Commit 5271a058 authored by Ian Lynagh's avatar Ian Lynagh

Use the upstream hsc2hs repo

parent f0d822f4
......@@ -2,7 +2,7 @@
use strict;
my @top_dirs = ("nofib", "testsuite");
my @top_dirs = ("nofib", "testsuite", "utils/hsc2hs");
# Figure out where to get the other repositories from,
# based on where this GHC repo came from.
......@@ -10,6 +10,7 @@ my $defaultrepo = `cat _darcs/prefs/defaultrepo`;
chomp $defaultrepo;
my $defaultrepo_base;
my $defaultrepo_lib;
my $hsc2hs_repo_loc;
if ($defaultrepo =~ /^...*:/) {
# HTTP or SSH
......@@ -18,12 +19,14 @@ if ($defaultrepo =~ /^...*:/) {
$defaultrepo_base = $defaultrepo;
$defaultrepo_base =~ s#/[^/]+/?$##;
$defaultrepo_lib = "$defaultrepo_base/packages";
$hsc2hs_repo_loc = $defaultrepo_base;
}
elsif ($defaultrepo =~ /^(\.\.)?\//) {
# Local filesystem, either absolute or relative path
# (assumes a checked-out tree):
$defaultrepo_base = $defaultrepo;
$defaultrepo_lib = "$defaultrepo/libraries";
$hsc2hs_repo_loc = "$defaultrepo_base/utils";
}
else {
die "Couldn't work out defaultrepo";
......@@ -116,6 +119,10 @@ sub darcsget {
darcsgetpackage($nofib, $r_flags, $defaultrepo_base, "nofib");
darcsgetpackage($testsuite, $r_flags, $defaultrepo_base, "testsuite");
chdir "utils";
darcsgetpackage(1 , $r_flags, $hsc2hs_repo_loc, "hsc2hs");
chdir "..";
chdir "libraries";
my @packages;
......
The Glasgow Haskell Compiler License
Copyright 2002, The University Court of the University of Glasgow.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither name of the University nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY COURT OF THE UNIVERSITY OF
GLASGOW AND THE CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
UNIVERSITY COURT OF THE UNIVERSITY OF GLASGOW OR THE CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
This diff is collapsed.
TOP=../..
ENABLE_SHELL_WRAPPERS = YES
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/cabal.mk
ifeq "" "${MKDIR}"
MKDIR:=$(shell pwd)
#MKDIR:=$(PWD)
else
MKDIR:=$(patsubst %/$(notdir ${MKDIR}),%, ${MKDIR})
endif
include ${MKDIR}/Makefile.inc
include Makefile.inc
OBJDIR = ${BUILDDIR}/obj/hsc2hs
TARGET = ${DST}/hsc2hs$(EXE)
SRCS = Main.hs
FROMC = ../libraries/base/System/Console/GetOpt.$C \
../libraries/base/Data/List.$C \
../libraries/base/System/Cmd.$C
ifeq "$(findstring ghc, ${HC})" "ghc"
HFLAGS = $(shell $(LOCAL)fixghc $(GHCSYM) -package base -package lang )
export HFLAGS
endif
ifeq "$(findstring hbc, ${HC})" "hbc"
HFLAGS =
export HFLAGS
endif
ifeq "$(findstring nhc98, ${HC})" "nhc98"
HFLAGS = -package base +CTS -H4M -CTS
export HFLAGS
endif
all: $(TARGET)
install: $(TARGET)
cfiles: cleanC $(SRCS)
$(HMAKE) -hc=$(LOCAL)nhc98 -package base -C Main.hs
clean:
-rm -f *.hi *.o $(OBJDIR)/*.o
cleanC: clean
-rm -f *.hc *.c
realclean: clean cleanC
-rm -f $(OBJDIR)/Main$(EXE)
$(TARGET): $(OBJDIR) $(SRCS)
$(HMAKE) -hc=$(HC) Main -d$(OBJDIR) -DBUILD_NHC \
$(shell echo "${BUILDOPTS}") $(HFLAGS) $(CYGFLAG)
mv $(OBJDIR)/Main$(EXE) $(TARGET)
$(STRIP) $(TARGET)
$(OBJDIR):
mkdir -p $(OBJDIR)
fromC: $(OBJDIR)
cp $(FROMC) .
$(LOCAL)nhc98 -cpp -o $(TARGET) -d$(OBJDIR) *.$C
$(STRIP) $(TARGET)
Name: hsc2hs
Version: 0.67
Copyright: 2000, Marcin Kowalczyk
Build-Depends: base, directory, process
License: BSD3
License-File: LICENSE
Author: Marcin Kowalczyk <qrczak@knm.org.pl>
Maintainer: cvs-fptools@haskell.org
Synopsis: A preprocessor that helps with writing Haskell bindings to C code
Description:
The hsc2hs program can be used to automate some parts of the
process of writing Haskell bindings to C code. It reads an
almost-Haskell source file with embedded special constructs, and
outputs a real Haskell file with these constructs processed, based
on information taken from some C headers. The extra constructs
provide Haskell counterparts of C types, values of C constants,
including sizes of C types, and access to fields of C structs.
.
For more details, see
http://www.haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html
Category: Development
Data-Files: template-hsc.h
build-type: Simple
cabal-version: >=1.2
Flag base3
Description: Choose the new smaller, split-up base package.
Executable hsc2hs
Main-Is: Main.hs
-- needed for ReadP (used by Data.Version)
Hugs-Options: -98
Extensions: CPP, ForeignFunctionInterface
if flag(base3)
Build-Depends: base >= 3 && < 4,
directory >= 1 && < 1.1,
process >= 1 && < 1.1
else
Build-Depends: base < 3
Build-Depends: haskell98, Cabal
tflag="--template=$HSC2HS_DIR/template-hsc.h"
$HSC2HS_BINDIR/$HS_PROG $tflag $HSC2HS_EXTRA "$@"
tflag="--template=$datadir/template-hsc.h"
for arg do
case "$arg" in
-c*) HSC2HS_EXTRA=;;
--cc=*) HSC2HS_EXTRA=;;
-t*) tflag=;;
--template=*) tflag=;;
--) break;;
esac
done
exec $executablename $tflag $HSC2HS_EXTRA ${1+"$@"}
#if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409
#include <Rts.h>
#endif
#include <HsFFI.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
#ifndef offsetof
#define offsetof(t, f) ((size_t) &((t *)0)->f)
#endif
#if __NHC__
#define hsc_line(line, file) \
printf ("# %d \"%s\"\n", line, file);
#else
#define hsc_line(line, file) \
printf ("{-# LINE %d \"%s\" #-}\n", line, file);
#endif
#define hsc_const(x) \
if ((x) < 0) \
printf ("%ld", (long)(x)); \
else \
printf ("%lu", (unsigned long)(x));
#define hsc_const_str(x) \
{ \
const char *s = (x); \
printf ("\""); \
while (*s != '\0') \
{ \
if (*s == '"' || *s == '\\') \
printf ("\\%c", *s); \
else if (*s >= 0x20 && *s <= 0x7E) \
printf ("%c", *s); \
else \
printf ("\\%d%s", \
(unsigned char) *s, \
s[1] >= '0' && s[1] <= '9' ? "\\&" : ""); \
++s; \
} \
printf ("\""); \
}
#define hsc_type(t) \
if ((t)(int)(t)1.4 == (t)1.4) \
printf ("%s%d", \
(t)(-1) < (t)0 ? "Int" : "Word", \
sizeof (t) * 8); \
else \
printf ("%s", \
sizeof (t) > sizeof (double) ? "LDouble" : \
sizeof (t) == sizeof (double) ? "Double" : \
"Float");
#define hsc_peek(t, f) \
printf ("(\\hsc_ptr -> peekByteOff hsc_ptr %ld)", (long) offsetof (t, f));
#define hsc_poke(t, f) \
printf ("(\\hsc_ptr -> pokeByteOff hsc_ptr %ld)", (long) offsetof (t, f));
#define hsc_ptr(t, f) \
printf ("(\\hsc_ptr -> hsc_ptr `plusPtr` %ld)", (long) offsetof (t, f));
#define hsc_offset(t, f) \
printf("(%ld)", (long) offsetof (t, f));
#define hsc_size(t) \
printf("(%ld)", (long) sizeof(t));
#define hsc_enum(t, f, print_name, x) \
print_name; \
printf (" :: %s\n", #t); \
print_name; \
printf (" = %s ", #f); \
if ((x) < 0) \
printf ("(%ld)\n", (long)(x)); \
else \
printf ("%lu\n", (unsigned long)(x));
#define hsc_haskellize(x) \
{ \
const char *s = (x); \
int upper = 0; \
if (*s != '\0') \
{ \
putchar (tolower (*s)); \
++s; \
while (*s != '\0') \
{ \
if (*s == '_') \
upper = 1; \
else \
{ \
putchar (upper ? toupper (*s) : tolower (*s)); \
upper = 0; \
} \
++s; \
} \
} \
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment