-# ----------------------------------------------------------------------------- #
-# $Id: Makefile,v 1.8 1999/04/27 10:59:29 sewardj Exp $ #
-# ----------------------------------------------------------------------------- #
+# --------------------------------------------------------------------------- #
+# $Id: Makefile,v 1.37 2000/05/26 10:14:33 sewardj Exp $ #
+# --------------------------------------------------------------------------- #
-TOP = ../..
+TOP = ..
include $(TOP)/mk/boilerplate.mk
-
-GHC_DIR = $(TOP)/ghc
-RTS_DIR = $(TOP)/ghc/rts
+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 optimise.c output.c \
- hugs.c dynamic.c stg.c sainteger.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 = -O2 -g -I$(GHC_DIR)/interpreter -I$(GHC_DIR)/includes -I$(GHC_DIR)/rts -D__HUGS__ -DCOMPILING_RTS -Wall -Wstrict-prototypes -Wno-unused
+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 = $(TOP)/ghc/rts/libHSrts.a
+GHC_LIBS_NEEDED = $(GHC_RUNTIME_DIR)/libHSrts.a
-all :: parser.c $(GHC_LIBS_NEEDED) nHandle.so hugs
+all :: parser.c $(GHC_LIBS_NEEDED) nHandle$(DYN_EXT) hugs
### EXTREMELY hacky
-hugs: $(C_OBJS) ../rts/Sanity.o ../rts/Assembler.o ../rts/Disassembler.o \
+hugs: $(C_OBJS) ../rts/Sanity.o ../rts/Assembler.o ../rts/Disassembler.o \
../rts/Evaluator.o ../rts/ForeignCall.o ../rts/GC.o ../rts/Printer.o \
- nHandle.so
- $(CC) -o $@ -rdynamic $(CC_OPTS) $^ $(GHC_LIBS_NEEDED) -lbfd -liberty -ldl -lm
-
-nHandle.so:
- gcc -O -fPIC -shared -o nHandle.so nHandle.c
-
-$(TOP)/ghc/rts/libHSrts.a:
- (cd $(TOP)/ghc/rts ; make clean ; make EXTRA_CC_OPTS=-I$(GHC_DIR)/interpreter)
+ ../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] *-ORIG-* \
+ 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 \
# Cleanery & misc #
# --------------------------------------------------------------------- #
-CLEAN_FILES += hugs nHandle.so
+CLEAN_FILES += hugs nHandle.dll
CLEAN_FILES += $(TOP)/ghc/rts/libHSrts.a $(TOP)/ghc/rts/*.o
CLEAN_FILES += parser.c
INSTALL_LIBEXECS = hugs
-depend :: $(LOOPS) $(SRCS_UGNHS)
+depend :: parser.c $(LOOPS) $(SRCS_UGNHS)
include $(TOP)/mk/target.mk