# -----------------------------------------------------------------------------
-# $Id: bootstrap.mk,v 1.25 2003/07/24 11:46:01 simonmar Exp $
+# $Id: bootstrap.mk,v 1.34 2005/05/10 10:29:49 simonmar Exp $
#
# Makefile rules for booting from .hc files without a driver.
#
# Reset TOP
TOP:=$(TOP_SAVED)
+include $(TOP)/mk/suffix.mk
+
# -----------------------------------------------------------------------------
# Set the platform-specific options to send to the C compiler. These should
# match the list in machdepCCOpts in ghc/compiler/DriverFlags.hs.
endif
ifeq "$(BootingFromUnregisterisedHc)" "YES"
-PLATFORM_HC_BOOT_CC_OPTS +=-DNO_REGS -DUSE_MINIINTERPRETER
+PLATFORM_HC_BOOT_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
endif
PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
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)/libraries/base/include -I$(FPTOOLS_TOP_ABS)/libraries/unix/include
+SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/ghc/includes -I$(FPTOOLS_TOP_ABS)/libraries/base/include -I$(FPTOOLS_TOP_ABS)/libraries/unix/include -I$(FPTOOLS_TOP_ABS)/libraries/parsec/include
+
+# C code compiled with UseGhcForCc=YES assumes the existence of certain CPP
+# symbols defined by GHC (eg. __GLASGOW_HASKELL__), so we better make sure
+# they're defined. We can't test $(UseGhcForCc) here though - it isn't defined
+# yet, so we use lazy expansion.
+SRC_CC_OPTS += $(if $(findstring YES,$(UseGhcForCc)), $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS))
+
+ifeq "$(GhcWithInterpreter)" "YES"
+SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/libraries/readline/include
+endif
# -----------------------------------------------------------------------------
# Linking: we have to give all the libraries explicitly.
-L$(FPTOOLS_TOP_ABS)/libraries/base \
-L$(FPTOOLS_TOP_ABS)/libraries/base/cbits \
-L$(FPTOOLS_TOP_ABS)/libraries/haskell98 \
+ -L$(FPTOOLS_TOP_ABS)/libraries/parsec \
+ -L$(FPTOOLS_TOP_ABS)/libraries/Cabal
+
+ifeq "$(GhcWithInterpreter)" "YES"
+HC_BOOT_LD_OPTS += \
+ -L$(FPTOOLS_TOP_ABS)/libraries/template-haskell \
+ -L$(FPTOOLS_TOP_ABS)/libraries/readline \
+ -L$(FPTOOLS_TOP_ABS)/libraries/unix \
+ -L$(FPTOOLS_TOP_ABS)/libraries/unix/cbits
+endif
+
+HC_BOOT_LD_OPTS += \
-u "$(UNDERSCORE)GHCziBase_Izh_static_info" \
-u "$(UNDERSCORE)GHCziBase_Czh_static_info" \
-u "$(UNDERSCORE)GHCziFloat_Fzh_static_info" \
-u "$(UNDERSCORE)GHCziWeak_runFinalizzerBatch_closure" \
-u "$(UNDERSCORE)__stginit_Prelude"
-HC_BOOT_LIBS = -lHShaskell98 -lHSbase -lHSbase_cbits -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
+
+HC_BOOT_LIBS =
+
+ifeq "$(GhcWithInterpreter)" "YES"
+HC_BOOT_LIBS += -lHSreadline -lHStemplate-haskell -lHSunix -lHSunix_cbits
+endif
+
+HC_BOOT_LIBS += -lHSCabal -lHShaskell98 -lHSbase -lHSbase_cbits -lHSparsec -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
ifeq "$(GhcLibsWithReadline)" "YES"
HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))