[project @ 2001-09-04 18:29:20 by ken]
[ghc-hetmet.git] / mk / bootstrap.mk
1 # -----------------------------------------------------------------------------
2 # $Id: bootstrap.mk,v 1.14 2001/09/04 18:29:22 ken 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 # -----------------------------------------------------------------------------
21 # Set the platform-specific options to send to the C compiler.  These should
22 # match the list in machdepCCOpts in ghc/compiler/DriverFlags.hs.
23 #
24
25 PLATFORM_CC_OPTS =
26 PLATFORM_HC_BOOT_CC_OPTS =
27
28 ifeq "$(i386_TARGET_ARCH)" "1"
29 PLATFORM_CC_OPTS += -DDONT_WANT_WIN32_DLL_SUPPORT
30 PLATFORM_HC_BOOT_CC_OPTS += -fno-defer-pop -fomit-frame-pointer 
31 endif
32
33 ifeq "$(hppa_TARGET_ARCH)" "1"
34 PLATFORM_CC_OPTS += -static -D_HPUX_SOURCE
35 endif
36
37 ifeq "$(powerpc_TARGET_ARCH)" "1"
38 PLATFORM_CC_OPTS += -static
39 PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
40 endif
41
42 ifeq "$(rs6000_TARGET_ARCH)" "1"
43 PLATFORM_CC_OPTS += -static
44 PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
45 endif
46
47 ifeq "$(mingw32_TARGET_OS)" "1"
48 PLATFORM_CC_OPTS += -mno-cygwin
49 endif
50
51 ifeq "$(alpha_TARGET_ARCH)" "1"
52 PLATFORM_CC_OPTS += -static
53 PLATFORM_HC_BOOT_CC_OPTS += -w
54 endif
55
56 ifeq "$(sparc_TARGET_ARCH)" "1"
57 PLATFORM_HC_BOOT_CC_OPTS += -w
58 endif
59
60 PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) 
61
62 HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS) $(CC_OPTS)
63
64 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
65
66 # -----------------------------------------------------------------------------
67 # Linking: we have to give all the libraries explicitly.
68
69 HC_BOOT_LD_OPTS =                               \
70    -L$(FPTOOLS_TOP_ABS)/ghc/rts                 \
71    -L$(FPTOOLS_TOP_ABS)/ghc/rts/gmp             \
72    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std             \
73    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std/cbits       \
74    -L$(FPTOOLS_TOP_ABS)/hslibs/lang             \
75    -L$(FPTOOLS_TOP_ABS)/hslibs/lang/cbits       \
76    -L$(FPTOOLS_TOP_ABS)/hslibs/concurrent       \
77    -L$(FPTOOLS_TOP_ABS)/hslibs/concurrent/cbits \
78    -L$(FPTOOLS_TOP_ABS)/hslibs/posix            \
79    -L$(FPTOOLS_TOP_ABS)/hslibs/posix/cbits      \
80    -L$(FPTOOLS_TOP_ABS)/hslibs/util             \
81    -L$(FPTOOLS_TOP_ABS)/hslibs/util/cbits       \
82    -L$(FPTOOLS_TOP_ABS)/hslibs/text             \
83    -L$(FPTOOLS_TOP_ABS)/hslibs/text/cbits       \
84    -u "PrelBase_Izh_static_info"                \
85    -u "PrelBase_Czh_static_info"                \
86    -u "PrelFloat_Fzh_static_info"               \
87    -u "PrelFloat_Dzh_static_info"               \
88    -u "PrelPtr_Ptr_static_info"                 \
89    -u "PrelWord_Wzh_static_info"                \
90    -u "PrelInt_I8zh_static_info"                \
91    -u "PrelInt_I16zh_static_info"               \
92    -u "PrelInt_I32zh_static_info"               \
93    -u "PrelInt_I64zh_static_info"               \
94    -u "PrelWord_W8zh_static_info"               \
95    -u "PrelWord_W16zh_static_info"              \
96    -u "PrelWord_W32zh_static_info"              \
97    -u "PrelWord_W64zh_static_info"              \
98    -u "PrelStable_StablePtr_static_info"        \
99    -u "PrelBase_Izh_con_info"                   \
100    -u "PrelBase_Czh_con_info"                   \
101    -u "PrelFloat_Fzh_con_info"                  \
102    -u "PrelFloat_Dzh_con_info"                  \
103    -u "PrelPtr_Ptr_con_info"                    \
104    -u "PrelStable_StablePtr_con_info"           \
105    -u "PrelBase_False_closure"                  \
106    -u "PrelBase_True_closure"                   \
107    -u "PrelPack_unpackCString_closure"          \
108    -u "PrelIOBase_stackOverflow_closure"        \
109    -u "PrelIOBase_heapOverflow_closure"         \
110    -u "PrelIOBase_NonTermination_closure"       \
111    -u "PrelIOBase_BlockedOnDeadMVar_closure"    \
112    -u "PrelWeak_runFinalizzerBatch_closure"     \
113    -u "__stginit_Prelude"                       \
114    -u "PrelMain_mainIO_closure"                 \
115    -u "__stginit_PrelMain"
116
117 HC_BOOT_LIBS = -lHStext -lHStext_cbits -lHSutil -lHSposix -lHSposix_cbits -lHSconcurrent -lHSlang -lHSlang_cbits -lHSstd -lHSstd_cbits -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
118
119 ifeq "$(GhcLibsWithReadline)" "YES"
120 HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))
121 endif
122
123 ifeq "$(HaveLibDL)" "YES"
124 HC_BOOT_LIBS += -ldl
125 endif
126
127 # -----------------------------------------------------------------------------
128 # suffix rules for building a .o from a .hc file.
129
130 ifeq "$(BootingFromUnregisterisedHc)" "YES"
131
132 # without mangling
133
134 %.o : %.hc
135         $(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/'`
136
137 else
138
139 # with mangling
140
141 %.raw_s : %.hc
142         $(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/'`
143
144 %.s : %.raw_s
145         $(GHC_MANGLER) $< $@ $(patsubst -monly-%-regs, %, $(filter -monly-%-regs, $($*_HC_OPTS)))
146
147 %.o : %.s
148         $(CC) -c -o $@ $<
149
150 endif