[project @ 2001-09-23 21:29:35 by ken]
[ghc-hetmet.git] / mk / bootstrap.mk
index abfd2e5..03b4eb1 100644 (file)
@@ -1,14 +1,18 @@
 # -----------------------------------------------------------------------------
-# $Id: bootstrap.mk,v 1.3 2001/03/27 09:38:26 simonmar Exp $
+# $Id: bootstrap.mk,v 1.15 2001/09/23 21:29:35 ken Exp $
 #
 # Makefile rules for booting from .hc files without a driver.
 #
+# When booting from .hc files without a compiler installed, we don't have
+# the benefit of the GHC driver to add all the magic options required to
+# compile the .hc files, so we have to duplicate that functionality here.
+# The result is unfortunately ugly, but we don't have another choice.
 
 TOP_SAVED := $(TOP)
 TOP:=$(TOP)/ghc
 
-include $(FPTOOLS_TOP_ABS)/ghc/mk/version.mk
-include $(FPTOOLS_TOP_ABS)/ghc/mk/paths.mk
+include $(TOP)/mk/version.mk
+include $(TOP)/mk/paths.mk
 
 # Reset TOP
 TOP:=$(TOP_SAVED)
@@ -37,16 +41,25 @@ endif
 
 ifeq "$(rs6000_TARGET_ARCH)" "1"
 PLATFORM_CC_OPTS += -static
-PLATFORM_HC_BOOT_CC_OPTS += -static -finhibit-size-directive
+PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
 endif
 
 ifeq "$(mingw32_TARGET_OS)" "1"
 PLATFORM_CC_OPTS += -mno-cygwin
 endif
 
+ifeq "$(alpha_TARGET_ARCH)" "1"
+PLATFORM_CC_OPTS += -static -w
+PLATFORM_HC_BOOT_CC_OPTS +=
+endif
+
+ifeq "$(sparc_TARGET_ARCH)" "1"
+PLATFORM_HC_BOOT_CC_OPTS += -w
+endif
+
 PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) 
 
-HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) -D__GLASGOW_HASKELL__=411 $(CC_OPTS)
+HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS) $(CC_OPTS)
 
 SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/ghc/includes -I$(FPTOOLS_TOP_ABS)/ghc/lib/std/cbits -I$(FPTOOLS_TOP_ABS)/hslibs/lang/cbits -I$(FPTOOLS_TOP_ABS)/hslibs/posix/cbits -I$(FPTOOLS_TOP_ABS)/hslibs/util/cbits -I$(FPTOOLS_TOP_ABS)/hslibs/text/cbits -I$(FPTOOLS_TOP_ABS)/hslibs/hssource/cbits
 
@@ -55,6 +68,7 @@ SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/ghc/includes -I$(FPTOOLS_TOP_ABS)/ghc/lib/st
 
 HC_BOOT_LD_OPTS =                              \
    -L$(FPTOOLS_TOP_ABS)/ghc/rts                        \
+   -L$(FPTOOLS_TOP_ABS)/ghc/rts/gmp            \
    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std            \
    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std/cbits      \
    -L$(FPTOOLS_TOP_ABS)/hslibs/lang            \
@@ -66,6 +80,7 @@ HC_BOOT_LD_OPTS =                             \
    -L$(FPTOOLS_TOP_ABS)/hslibs/util            \
    -L$(FPTOOLS_TOP_ABS)/hslibs/util/cbits      \
    -L$(FPTOOLS_TOP_ABS)/hslibs/text            \
+   -L$(FPTOOLS_TOP_ABS)/hslibs/text/cbits      \
    -u "PrelBase_Izh_static_info"               \
    -u "PrelBase_Czh_static_info"               \
    -u "PrelFloat_Fzh_static_info"              \
@@ -95,14 +110,14 @@ HC_BOOT_LD_OPTS =                          \
    -u "PrelIOBase_NonTermination_closure"      \
    -u "PrelIOBase_BlockedOnDeadMVar_closure"   \
    -u "PrelWeak_runFinalizzerBatch_closure"    \
-   -u "__init_Prelude"                         \
+   -u "__stginit_Prelude"                      \
    -u "PrelMain_mainIO_closure"                        \
-   -u "__init_PrelMain"
+   -u "__stginit_PrelMain"
 
-HC_BOOT_LIBS = -lHStext -lHSutil -lHSposix -lHSposix_cbits -lHSconcurrent -lHSlang -lHSlang_cbits -lHSstd -lHSstd_cbits -lHSrts -lgmp $(EXTRA_HC_BOOT_LIBS)
+HC_BOOT_LIBS = -lHStext -lHStext_cbits -lHSutil -lHSposix -lHSposix_cbits -lHSconcurrent -lHSlang -lHSlang_cbits -lHSstd -lHSstd_cbits -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
 
 ifeq "$(GhcLibsWithReadline)" "YES"
-HC_BOOT_LIBS += $(LibsReadline)
+HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))
 endif
 
 ifeq "$(HaveLibDL)" "YES"
@@ -112,6 +127,17 @@ endif
 # -----------------------------------------------------------------------------
 # suffix rules for building a .o from a .hc file.
 
+ifeq "$(BootingFromUnregisterisedHc)" "YES"
+
+# without mangling
+
+%.o : %.hc
+       $(CC) -x c $< -o $@ -c -O $(HC_BOOT_CC_OPTS) -I.  `echo $(patsubst -monly-%-regs, -DSTOLEN_X86_REGS=%, $(filter -monly-%-regs, $($*_HC_OPTS))) | sed 's/^$$/-DSTOLEN_X86_REGS=4/'`
+
+else
+
+# with mangling
+
 %.raw_s : %.hc
        $(CC) -x c $< -o $@ -S -O $(HC_BOOT_CC_OPTS) -I.  `echo $(patsubst -monly-%-regs, -DSTOLEN_X86_REGS=%, $(filter -monly-%-regs, $($*_HC_OPTS))) | sed 's/^$$/-DSTOLEN_X86_REGS=4/'`
 
@@ -120,3 +146,5 @@ endif
 
 %.o : %.s
        $(CC) -c -o $@ $<
+
+endif