[project @ 2001-07-24 04:45:59 by ken]
[ghc-hetmet.git] / mk / bootstrap.mk
1 # -----------------------------------------------------------------------------
2 # $Id: bootstrap.mk,v 1.13 2001/07/24 04:45:59 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 += -static -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 -Xlinker -noprefix_recognition
53 endif
54
55 PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) 
56
57 HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS) $(CC_OPTS)
58
59 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
60
61 # -----------------------------------------------------------------------------
62 # Linking: we have to give all the libraries explicitly.
63
64 HC_BOOT_LD_OPTS =                               \
65    -L$(FPTOOLS_TOP_ABS)/ghc/rts                 \
66    -L$(FPTOOLS_TOP_ABS)/ghc/rts/gmp             \
67    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std             \
68    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std/cbits       \
69    -L$(FPTOOLS_TOP_ABS)/hslibs/lang             \
70    -L$(FPTOOLS_TOP_ABS)/hslibs/lang/cbits       \
71    -L$(FPTOOLS_TOP_ABS)/hslibs/concurrent       \
72    -L$(FPTOOLS_TOP_ABS)/hslibs/concurrent/cbits \
73    -L$(FPTOOLS_TOP_ABS)/hslibs/posix            \
74    -L$(FPTOOLS_TOP_ABS)/hslibs/posix/cbits      \
75    -L$(FPTOOLS_TOP_ABS)/hslibs/util             \
76    -L$(FPTOOLS_TOP_ABS)/hslibs/util/cbits       \
77    -L$(FPTOOLS_TOP_ABS)/hslibs/text             \
78    -L$(FPTOOLS_TOP_ABS)/hslibs/text/cbits       \
79    -u "PrelBase_Izh_static_info"                \
80    -u "PrelBase_Czh_static_info"                \
81    -u "PrelFloat_Fzh_static_info"               \
82    -u "PrelFloat_Dzh_static_info"               \
83    -u "PrelPtr_Ptr_static_info"                 \
84    -u "PrelWord_Wzh_static_info"                \
85    -u "PrelInt_I8zh_static_info"                \
86    -u "PrelInt_I16zh_static_info"               \
87    -u "PrelInt_I32zh_static_info"               \
88    -u "PrelInt_I64zh_static_info"               \
89    -u "PrelWord_W8zh_static_info"               \
90    -u "PrelWord_W16zh_static_info"              \
91    -u "PrelWord_W32zh_static_info"              \
92    -u "PrelWord_W64zh_static_info"              \
93    -u "PrelStable_StablePtr_static_info"        \
94    -u "PrelBase_Izh_con_info"                   \
95    -u "PrelBase_Czh_con_info"                   \
96    -u "PrelFloat_Fzh_con_info"                  \
97    -u "PrelFloat_Dzh_con_info"                  \
98    -u "PrelPtr_Ptr_con_info"                    \
99    -u "PrelStable_StablePtr_con_info"           \
100    -u "PrelBase_False_closure"                  \
101    -u "PrelBase_True_closure"                   \
102    -u "PrelPack_unpackCString_closure"          \
103    -u "PrelIOBase_stackOverflow_closure"        \
104    -u "PrelIOBase_heapOverflow_closure"         \
105    -u "PrelIOBase_NonTermination_closure"       \
106    -u "PrelIOBase_BlockedOnDeadMVar_closure"    \
107    -u "PrelWeak_runFinalizzerBatch_closure"     \
108    -u "__init_Prelude"                          \
109    -u "PrelMain_mainIO_closure"                 \
110    -u "__init_PrelMain"
111
112 HC_BOOT_LIBS = -lHStext -lHStext_cbits -lHSutil -lHSposix -lHSposix_cbits -lHSconcurrent -lHSlang -lHSlang_cbits -lHSstd -lHSstd_cbits -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
113
114 ifeq "$(GhcLibsWithReadline)" "YES"
115 HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))
116 endif
117
118 ifeq "$(HaveLibDL)" "YES"
119 HC_BOOT_LIBS += -ldl
120 endif
121
122 # -----------------------------------------------------------------------------
123 # suffix rules for building a .o from a .hc file.
124
125 ifeq "$(BootingFromUnregisterisedHc)" "YES"
126
127 # without mangling
128
129 %.o : %.hc
130         $(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/'`
131
132 else
133
134 # with mangling
135
136 %.raw_s : %.hc
137         $(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/'`
138
139 %.s : %.raw_s
140         $(GHC_MANGLER) $< $@ $(patsubst -monly-%-regs, %, $(filter -monly-%-regs, $($*_HC_OPTS)))
141
142 %.o : %.s
143         $(CC) -c -o $@ $<
144
145 endif