1 # -----------------------------------------------------------------------------
2 # $Id: bootstrap.mk,v 1.34 2005/05/10 10:29:49 simonmar Exp $
4 # Makefile rules for booting from .hc files without a driver.
6 # When booting from .hc files without a compiler installed, we don't have
7 # the benefit of the GHC driver to add all the magic options required to
8 # compile the .hc files, so we have to duplicate that functionality here.
9 # The result is unfortunately ugly, but we don't have another choice.
14 include $(TOP)/mk/version.mk
15 include $(TOP)/mk/paths.mk
20 include $(TOP)/mk/suffix.mk
22 # -----------------------------------------------------------------------------
23 # Set the platform-specific options to send to the C compiler. These should
24 # match the list in machdepCCOpts in ghc/compiler/DriverFlags.hs.
28 PLATFORM_HC_BOOT_CC_OPTS =
30 ifeq "$(i386_TARGET_ARCH)" "1"
31 PLATFORM_CC_OPTS += -DDONT_WANT_WIN32_DLL_SUPPORT
32 PLATFORM_HC_BOOT_CC_OPTS += -fno-defer-pop -fomit-frame-pointer
35 ifeq "$(hppa_TARGET_ARCH)" "1"
36 PLATFORM_CC_OPTS += -static -D_HPUX_SOURCE
39 ifeq "$(powerpc_TARGET_ARCH)" "1"
40 PLATFORM_CC_OPTS += -static
41 PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
44 ifeq "$(rs6000_TARGET_ARCH)" "1"
45 PLATFORM_CC_OPTS += -static
46 PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
49 ifeq "$(mingw32_TARGET_OS)" "1"
50 PLATFORM_CC_OPTS += -mno-cygwin
53 ifeq "$(alpha_TARGET_ARCH)" "1"
54 PLATFORM_CC_OPTS += -static -w
55 PLATFORM_HC_BOOT_CC_OPTS += -mieee
58 ifeq "$(sparc_TARGET_ARCH)" "1"
59 PLATFORM_HC_BOOT_CC_OPTS += -w
62 ifeq "$(BootingFromUnregisterisedHc)" "YES"
63 PLATFORM_HC_BOOT_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
66 PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
68 HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS) $(CC_OPTS)
70 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
72 # C code compiled with UseGhcForCc=YES assumes the existence of certain CPP
73 # symbols defined by GHC (eg. __GLASGOW_HASKELL__), so we better make sure
74 # they're defined. We can't test $(UseGhcForCc) here though - it isn't defined
75 # yet, so we use lazy expansion.
76 SRC_CC_OPTS += $(if $(findstring YES,$(UseGhcForCc)), $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS))
78 ifeq "$(GhcWithInterpreter)" "YES"
79 SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/libraries/readline/include
82 # -----------------------------------------------------------------------------
83 # Linking: we have to give all the libraries explicitly.
85 ifeq "$(LeadingUnderscore)" "YES"
91 ifeq "$(HaveLibGmp)" "NO"
92 DASH_L_GHC_RTS_GMP_DIR=-L$(FPTOOLS_TOP_ABS)/ghc/rts/gmp
96 -L$(FPTOOLS_TOP_ABS)/ghc/rts \
97 $(DASH_L_GHC_RTS_GMP_DIR) \
98 -L$(FPTOOLS_TOP_ABS)/libraries/base \
99 -L$(FPTOOLS_TOP_ABS)/libraries/base/cbits \
100 -L$(FPTOOLS_TOP_ABS)/libraries/haskell98 \
101 -L$(FPTOOLS_TOP_ABS)/libraries/parsec \
102 -L$(FPTOOLS_TOP_ABS)/libraries/Cabal
104 ifeq "$(GhcWithInterpreter)" "YES"
106 -L$(FPTOOLS_TOP_ABS)/libraries/template-haskell \
107 -L$(FPTOOLS_TOP_ABS)/libraries/readline \
108 -L$(FPTOOLS_TOP_ABS)/libraries/unix \
109 -L$(FPTOOLS_TOP_ABS)/libraries/unix/cbits
113 -u "$(UNDERSCORE)GHCziBase_Izh_static_info" \
114 -u "$(UNDERSCORE)GHCziBase_Czh_static_info" \
115 -u "$(UNDERSCORE)GHCziFloat_Fzh_static_info" \
116 -u "$(UNDERSCORE)GHCziFloat_Dzh_static_info" \
117 -u "$(UNDERSCORE)GHCziPtr_Ptr_static_info" \
118 -u "$(UNDERSCORE)GHCziWord_Wzh_static_info" \
119 -u "$(UNDERSCORE)GHCziInt_I8zh_static_info" \
120 -u "$(UNDERSCORE)GHCziInt_I16zh_static_info" \
121 -u "$(UNDERSCORE)GHCziInt_I32zh_static_info" \
122 -u "$(UNDERSCORE)GHCziInt_I64zh_static_info" \
123 -u "$(UNDERSCORE)GHCziWord_W8zh_static_info" \
124 -u "$(UNDERSCORE)GHCziWord_W16zh_static_info" \
125 -u "$(UNDERSCORE)GHCziWord_W32zh_static_info" \
126 -u "$(UNDERSCORE)GHCziWord_W64zh_static_info" \
127 -u "$(UNDERSCORE)GHCziStable_StablePtr_static_info" \
128 -u "$(UNDERSCORE)GHCziBase_Izh_con_info" \
129 -u "$(UNDERSCORE)GHCziBase_Czh_con_info" \
130 -u "$(UNDERSCORE)GHCziFloat_Fzh_con_info" \
131 -u "$(UNDERSCORE)GHCziFloat_Dzh_con_info" \
132 -u "$(UNDERSCORE)GHCziPtr_Ptr_con_info" \
133 -u "$(UNDERSCORE)GHCziStable_StablePtr_con_info" \
134 -u "$(UNDERSCORE)GHCziBase_False_closure" \
135 -u "$(UNDERSCORE)GHCziBase_True_closure" \
136 -u "$(UNDERSCORE)GHCziPack_unpackCString_closure" \
137 -u "$(UNDERSCORE)GHCziIOBase_stackOverflow_closure" \
138 -u "$(UNDERSCORE)GHCziIOBase_heapOverflow_closure" \
139 -u "$(UNDERSCORE)GHCziIOBase_NonTermination_closure" \
140 -u "$(UNDERSCORE)GHCziIOBase_BlockedOnDeadMVar_closure" \
141 -u "$(UNDERSCORE)GHCziIOBase_Deadlock_closure" \
142 -u "$(UNDERSCORE)GHCziWeak_runFinalizzerBatch_closure" \
143 -u "$(UNDERSCORE)__stginit_Prelude"
148 ifeq "$(GhcWithInterpreter)" "YES"
149 HC_BOOT_LIBS += -lHSreadline -lHStemplate-haskell -lHSunix -lHSunix_cbits
152 HC_BOOT_LIBS += -lHSCabal -lHShaskell98 -lHSbase -lHSbase_cbits -lHSparsec -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
154 ifeq "$(GhcLibsWithReadline)" "YES"
155 HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))
158 ifeq "$(HaveLibDL)" "YES"