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