[project @ 2005-01-27 13:00:14 by simonmar]
[ghc-hetmet.git] / mk / bootstrap.mk
1 # -----------------------------------------------------------------------------
2 # $Id: bootstrap.mk,v 1.33 2005/01/27 13:00:14 simonmar Exp $
3 #
4 # Makefile rules for booting from .hc files without a driver.
5 #
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.
10
11 TOP_SAVED := $(TOP)
12 TOP:=$(TOP)/ghc
13
14 include $(TOP)/mk/version.mk
15 include $(TOP)/mk/paths.mk
16
17 # Reset TOP
18 TOP:=$(TOP_SAVED)
19
20 include $(TOP)/mk/suffix.mk
21
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.
25 #
26
27 PLATFORM_CC_OPTS =
28 PLATFORM_HC_BOOT_CC_OPTS =
29
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 
33 endif
34
35 ifeq "$(hppa_TARGET_ARCH)" "1"
36 PLATFORM_CC_OPTS += -static -D_HPUX_SOURCE
37 endif
38
39 ifeq "$(powerpc_TARGET_ARCH)" "1"
40 PLATFORM_CC_OPTS += -static
41 PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
42 endif
43
44 ifeq "$(rs6000_TARGET_ARCH)" "1"
45 PLATFORM_CC_OPTS += -static
46 PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
47 endif
48
49 ifeq "$(mingw32_TARGET_OS)" "1"
50 PLATFORM_CC_OPTS += -mno-cygwin
51 endif
52
53 ifeq "$(alpha_TARGET_ARCH)" "1"
54 PLATFORM_CC_OPTS += -static -w
55 PLATFORM_HC_BOOT_CC_OPTS += -mieee
56 endif
57
58 ifeq "$(sparc_TARGET_ARCH)" "1"
59 PLATFORM_HC_BOOT_CC_OPTS += -w
60 endif
61
62 ifeq "$(BootingFromUnregisterisedHc)" "YES"
63 PLATFORM_HC_BOOT_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
64 endif
65
66 PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) 
67
68 HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS) $(CC_OPTS)
69
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
71
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))
77
78 ifeq "$(GhcWithInterpreter)" "YES"
79 SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/libraries/readline/include
80 endif
81
82 # -----------------------------------------------------------------------------
83 # Linking: we have to give all the libraries explicitly.
84
85 ifeq "$(LeadingUnderscore)" "YES"
86 UNDERSCORE=_
87 else
88 UNDERSCORE=
89 endif
90
91 ifeq "$(HaveLibGmp)" "NO"
92 DASH_L_GHC_RTS_GMP_DIR=-L$(FPTOOLS_TOP_ABS)/ghc/rts/gmp
93 endif
94
95 HC_BOOT_LD_OPTS =                               \
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
102 ifeq "$(GhcWithInterpreter)" "YES"
103 HC_BOOT_LD_OPTS += \
104    -L$(FPTOOLS_TOP_ABS)/libraries/template-haskell      \
105    -L$(FPTOOLS_TOP_ABS)/libraries/readline      \
106    -L$(FPTOOLS_TOP_ABS)/libraries/parsec        \
107    -L$(FPTOOLS_TOP_ABS)/libraries/Cabal         \
108    -L$(FPTOOLS_TOP_ABS)/libraries/unix          \
109    -L$(FPTOOLS_TOP_ABS)/libraries/unix/cbits
110 endif
111
112 HC_BOOT_LD_OPTS += \
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"
144
145
146 HC_BOOT_LIBS =
147
148 ifeq "$(GhcWithInterpreter)" "YES"
149 HC_BOOT_LIBS += -lHSreadline -lHStemplate-haskell -lHSunix -lHSunix_cbits
150 endif
151
152 HC_BOOT_LIBS +=  -lHSCabal -lHShaskell98 -lHSbase -lHSbase_cbits -lHSparsec -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
153
154 ifeq "$(GhcLibsWithReadline)" "YES"
155 HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))
156 endif
157
158 ifeq "$(HaveLibDL)" "YES"
159 HC_BOOT_LIBS += -ldl
160 endif