Commit f1dffa02 authored by sewardj's avatar sewardj
Browse files

[project @ 2001-01-17 15:23:39 by sewardj]

Bye bye STG Hugs!
parent 1eee6c55
module Dh_Demo where
wurble :: Int -> IO ()
wurble x = putStr ( "Hello Erik && Daan, today's magic number is: "
++ show x
++ show (take 100 (repeat 123.456))
++ "\n")
EXPORTS
DH_GetProcAddress@12
DH_LoadLibrary@4
# --------------------------------------------------------------------------- #
# $Id: Makefile,v 1.37 2000/05/26 10:14:33 sewardj Exp $ #
# --------------------------------------------------------------------------- #
TOP = ..
include $(TOP)/mk/boilerplate.mk
SUBDIRS = lib
# --------------------------------------------------------------------- #
# interpreter and relevant .a/.so files #
# --------------------------------------------------------------------- #
ifneq "$(TARGETPLATFORM)" "i386-unknown-cygwin32"
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
## UNIX
LIB_BFD=-lbfd -liberty
DYN_EXT=.so
LIB_DL=-ldl
M_NO_CYGWIN=
else
## mingw32
LIB_BFD=
DYN_EXT=.dll
LIB_DL=
M_NO_CYGWIN=-mno-cygwin
endif
else
## cygwin32
LIB_BFD=-lbfd -liberty
DYN_EXT=.dll
LIB_DL=
M_NO_CYGWIN=
endif
ifeq "$(HaveLibGmp)$" "YES"
LIB_GMP=-lgmp
else
LIB_GMP=../rts/gmp/libgmp.a
endif
YACC = bison -y
%.c: %.y
-$(YACC) $<
mv y.tab.c $@
rm -f input.o
HS_SRCS =
Y_SRCS = parser.y
C_SRCS = link.c type.c static.c storage.c derive.c input.c compiler.c subst.c \
translate.c codegen.c lift.c free.c stgSubst.c output.c \
hugs.c dynamic.c stg.c sainteger.c object.c interface.c
SRC_CC_OPTS = -I$(GHC_INTERPRETER_DIR) -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR) -D__HUGS__ -DCOMPILING_RTS -DNO_REGS -Wall -Wstrict-prototypes -Wno-unused -DDEBUG -Winline $(M_NO_CYGWIN) -g -O
GHC_LIBS_NEEDED = $(GHC_RUNTIME_DIR)/libHSrts.a
all :: parser.c $(GHC_LIBS_NEEDED) nHandle$(DYN_EXT) hugs
### EXTREMELY hacky
hugs: $(C_OBJS) ../rts/Sanity.o ../rts/Assembler.o ../rts/Disassembler.o \
../rts/Evaluator.o ../rts/ForeignCall.o ../rts/GC.o ../rts/Printer.o \
../rts/StgCRun.o ../rts/PrimOps.o ../rts/Prelude.o ../rts/Storage.o \
../rts/Schedule.o ../rts/libHSrts.a
$(CC) -o $@ $(CC_OPTS) $^ $(GHC_LIBS_NEEDED) \
$(LIB_BFD) $(LibsReadline) $(LIB_DL) \
$(LIB_GMP) -lm
foobar:
rm -f ../rts/libHSrts.a ../rts/libHSrts_u.a
rm -f ../rts/StgCRun.o ../rts/StgCRun.u_o
make all
nHandle$(DYN_EXT): nHandle.c
ifeq "$(DYN_EXT)" ".dll"
gcc -mno-cygwin -O -Wall -o nHandle.o -c nHandle.c
dllwrap -mno-cygwin --target=i386-mingw32 -o nHandle.dll \
-def nHandle.def nHandle.o
else
gcc -O -Wall -shared -fPIC -o nHandle.so nHandle.c
endif
$(GHC_RUNTIME_DIR)/libHSrts.a:
(cd $(GHC_RUNTIME_DIR) ; make clean ; make EXTRA_CC_OPTS=-I$(GHC_INTERPRETER_DIR))
cleanish:
/bin/rm *.o
rtsclean:
(cd $(GHC_RUNTIME_DIR) ; make clean)
binaries:
tar cvzf stghugs.tar.gz hugs$(exeext) nHandle$(DYN_EXT) lib/*lhs lib/Prelude.hs
snapshot:
/bin/rm -f snapshot.tar
tar cvf snapshot.tar Makefile *.[chy] \
../rts/Assembler.c ../rts/Evaluator.c ../rts/Disassembler.c \
../rts/ForeignCall.c ../rts/Printer.c ../rts/QueueTemplate.h \
../includes/options.h ../includes/Assembler.h nHandle.c \
../includes/Assembler.h ../rts/Bytecodes.h ../includes/ClosureMacros.h \
lib/*.hs runnofib runallnofib
# --------------------------------------------------------------------- #
# Testing #
# --------------------------------------------------------------------- #
check :: all
./test/runtests test/static/*.hs
./test/runtests test/typechecker/*.hs
./test/runtests test/runtime/*.hs
./test/runtests test/std/*.hs
./test/runtests test/exts/*.hs
checkrun: all
./test/runtests test/runtime/*.hs
./test/runtests test/std/*.hs
./test/runtests test/exts/*.hs
# --------------------------------------------------------------------- #
# Cleanery & misc #
# --------------------------------------------------------------------- #
CLEAN_FILES += hugs nHandle.dll
CLEAN_FILES += $(TOP)/ghc/rts/libHSrts.a $(TOP)/ghc/rts/*.o
CLEAN_FILES += parser.c
INSTALL_LIBEXECS = hugs
depend :: parser.c $(LOOPS) $(SRCS_UGNHS)
include $(TOP)/mk/target.mk
# --------------------------------------------------------------------------- #
# $Id: Makefile-DietHEP,v 1.2 2000/05/26 10:14:34 sewardj Exp $ #
# --------------------------------------------------------------------------- #
TOP = ..
include $(TOP)/mk/boilerplate.mk
SUBDIRS = lib
# --------------------------------------------------------------------- #
# interpreter and relevant .a/.so files #
# --------------------------------------------------------------------- #
ifneq "$(TARGETPLATFORM)" "i386-unknown-cygwin32"
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
## UNIX
LIB_BFD=-lbfd -liberty
DYN_EXT=.so
LIB_DL=-ldl
M_NO_CYGWIN=
else
## mingw32
LIB_BFD=
DYN_EXT=.dll
LIB_DL=
M_NO_CYGWIN=-mno-cygwin
endif
else
## cygwin32
LIB_BFD=-lbfd -liberty
DYN_EXT=.dll
LIB_DL=
M_NO_CYGWIN=
endif
YACC = bison -y
%.c: %.y
-$(YACC) $<
mv y.tab.c $@
rm -f input.o
HS_SRCS =
Y_SRCS = parser.y
C_SRCS = link.c type.c static.c storage.c derive.c input.c compiler.c subst.c \
translate.c codegen.c lift.c free.c stgSubst.c output.c \
hugs.c dynamic.c stg.c sainteger.c object.c interface.c
SRC_CC_OPTS = -I$(GHC_INTERPRETER_DIR) -I$(GHC_INCLUDE_DIR) -I$(GHC_RUNTIME_DIR) -D__HUGS__ -DCOMPILING_RTS -DNO_REGS -Wall -Wstrict-prototypes -Wno-unused -DDEBUG -Winline -g -DDIET_HEP -DBUILDING_DLL
GHC_LIBS_NEEDED = $(GHC_RUNTIME_DIR)/libHSrts.a \
$(GHC_RUNTIME_DIR)/gmp/libgmp.a
all :: parser.c $(GHC_LIBS_NEEDED) nHandle$(DYN_EXT) dh_demo.exe
dhtarfile: DietHEP.dll
rm -f DietHEP.h
ln -s ../includes/DietHEP.h .
tar cvf dhtarfile.tar --dereference DietHEP.h DietHEP.dll DietHEP_dll.a \
Dh_Demo.hs dh_demo.c dh_demo.exe \
lib library nHandle.dll Makefile-DietHEP
rm -f DietHEP.h
bzip2 -v dhtarfile.tar
dh_demo.exe: DietHEP.dll dh_demo.c
gcc -Wall -g -o dh_demo.exe dh_demo.c -L./ -lDietHEP
### EXTREMELY hacky
DietHEP.dll: $(C_OBJS) $(GHC_LIBS_NEEDED)
dllwrap -o DietHEP.dll --def DietHEP.def --implib libDietHEP.a \
$(OBJS) $(GHC_LIBS_NEEDED)
foobar:
rm -f ../rts/libHSrts.a ../rts/libHSrts_u.a
rm -f ../rts/StgCRun.o ../rts/StgCRun.u_o
make all
nHandle$(DYN_EXT): nHandle.c
ifeq "$(DYN_EXT)" ".dll"
gcc -mno-cygwin -O -Wall -o nHandle.o -c nHandle.c
dllwrap -mno-cygwin --target=i386-mingw32 -o nHandle.dll \
-def nHandle.def nHandle.o
else
gcc -O -Wall -shared -fPIC -o nHandle.so nHandle.c
endif
$(GHC_RUNTIME_DIR)/libHSrts.a:
(cd $(GHC_RUNTIME_DIR) ; make clean ; make EXTRA_CC_OPTS=-I$(GHC_INTERPRETER_DIR))
cleanish:
/bin/rm *.o
rtsclean:
(cd $(GHC_RUNTIME_DIR) ; make clean)
binaries:
tar cvzf stghugs.tar.gz hugs$(exeext) nHandle$(DYN_EXT) lib/*lhs lib/Prelude.hs
snapshot:
/bin/rm -f snapshot.tar
tar cvf snapshot.tar Makefile *.[chy] \
../rts/Assembler.c ../rts/Evaluator.c ../rts/Disassembler.c \
../rts/ForeignCall.c ../rts/Printer.c ../rts/QueueTemplate.h \
../includes/options.h ../includes/Assembler.h nHandle.c \
../includes/Assembler.h ../rts/Bytecodes.h ../includes/ClosureMacros.h \
lib/*.hs runnofib runallnofib
# --------------------------------------------------------------------- #
# Testing #
# --------------------------------------------------------------------- #
check :: all
./test/runtests test/static/*.hs
./test/runtests test/typechecker/*.hs
./test/runtests test/runtime/*.hs
./test/runtests test/std/*.hs
./test/runtests test/exts/*.hs
checkrun: all
./test/runtests test/runtime/*.hs
./test/runtests test/std/*.hs
./test/runtests test/exts/*.hs
# --------------------------------------------------------------------- #
# Cleanery & misc #
# --------------------------------------------------------------------- #
CLEAN_FILES += hugs nHandle.dll DietHEP.dll
CLEAN_FILES += $(TOP)/ghc/rts/libHSrts.a $(TOP)/ghc/rts/*.o
CLEAN_FILES += parser.c
INSTALL_LIBEXECS = hugs
depend :: parser.c $(LOOPS) $(SRCS_UGNHS)
include $(TOP)/mk/target.mk
Configure the rts with --target=i386-unknown-mingw32 (I think).
Build it with this:
make EXTRA_HC_OPTS=-optc-DHAVE_WIN32_DLL_SUPPORT
I think that will work.
These insns are for building Hugs on mingw32. We don't want no
cygwin no more :)
You need to have a fptools/mk/build.mk which looks like this in
order to build Hugs which has a hope of working in combined mode.
WithGhcHc=ghc-4.06 # or whatever; version not v. important
GhcLibWays=u # essential
GhcHcOpts=-DDEBUG -fasm-x86 # -fasm-x86 is optional
GhcRtsHcOpts=-optc-DDEBUG -optc-D__HUGS__ -unreg -optc-g
GhcRtsCcOpts=-optc-DDEBUG -optc-g -optc-D__HUGS__
SplitObjs=NO # essential
Then you need to configure like this:
cd ghc
autoconf
cd ..
autoconf
./configure --host=i386-unknown-mingw32 --enable-win32-dlls
Then
make boot
Then
cd ghc/rts/gmp/mpn/generic
for f in *.c *.h ; do echo $f ; rm -f ../$f ; cp $f ../$f ; done
# because mingw32 doesn't understand the symlinks that GMP makes
# during make boot
cd ../../..
make
cd ../utils
make boot
make
cd ../interpreter
make
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include <stdio.h>
#include <assert.h>
#include <windows.h>
//#include "../includes/DietHEP.h"
typedef enum { dh_stdcall, dh_ccall } DH_CALLCONV;
typedef int DH_MODULE;
typedef char* DH_LPCSTR;
__declspec(dllimport)
extern __stdcall
DH_MODULE DH_LoadLibrary ( DH_LPCSTR modname );
__declspec(dllimport)
extern __stdcall
void* DH_GetProcAddress ( DH_CALLCONV cconv,
DH_MODULE hModule,
DH_LPCSTR lpProcName );
int main ( int argc, char** argv )
{
{
DH_MODULE hModule;
void(*proc)(int);
hModule = DH_LoadLibrary("Dh_Demo"); /* note no .hs */
assert(hModule != 0);
proc = DH_GetProcAddress ( dh_ccall, hModule, "wurble" );
assert(proc);
proc(44);
proc(45);
proc(46);
}
return 0;
}
This diff is collapsed.
/* --------------------------------------------------------------------------
* Error handling support functions
*
* The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the
* Yale Haskell Group, and the Oregon Graduate Institute of Science and
* Technology, 1994-1999, All rights reserved. It is distributed as
* free software under the license in the file "License", which is
* included in the distribution.
*
* $RCSfile: errors.h,v $
* $Revision: 1.9 $
* $Date: 2000/03/24 14:32:03 $
* ------------------------------------------------------------------------*/
extern Void internal ( String) HUGS_noreturn;
extern Void fatal ( String) HUGS_noreturn;
#define Hilite() doNothing()
#define Lolite() doNothing()
#define errorStream stdout
#define ERRMSG(l) Hilite(); errHead(l); FPrintf(errorStream,
#define EEND ); Lolite(); errFail()
#define EEND_NO_LONGJMP ); Lolite(); errFail_no_longjmp()
#define ETHEN );
#define ERRTEXT Hilite(); FPrintf(errorStream,
#define ERREXPR(e) Hilite(); printExp(errorStream,e); Lolite()
#define ERRTYPE(e) Hilite(); printType(errorStream,e); Lolite()
#define ERRCONTEXT(qs) Hilite(); printContext(errorStream,qs); Lolite()
#define ERRPRED(pi) Hilite(); printPred(errorStream,pi); Lolite()
#define ERRKIND(k) Hilite(); printKind(errorStream,k); Lolite()
#define ERRKINDS(ks) Hilite(); printKinds(errorStream,ks); Lolite()
#define ERRFD(fd) Hilite(); printFD(errorStream,fd); Lolite()
extern Void errHead ( Int ); /* in main.c */
extern Void errFail ( Void ) HUGS_noreturn;
extern Void errFail_no_longjmp ( Void );
extern Void errAbort ( Void );
extern Cell errAssert ( Int );
extern Void printExp ( FILE *,Cell ); /* in output.c */
extern Void printType ( FILE *,Cell );
extern Void printContext ( FILE *,List );
extern Void printPred ( FILE *,Cell );
extern Void printKind ( FILE *,Kind );
extern Void printKinds ( FILE *,Kinds );
extern Void printFD ( FILE *,Pair );
/*-------------------------------------------------------------------------*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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