[project @ 2001-03-27 11:37:39 by simonmar]
[ghc-hetmet.git] / mk / bootstrap.mk
1 # -----------------------------------------------------------------------------
2 # $Id: bootstrap.mk,v 1.5 2001/03/27 11:37:39 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 # -----------------------------------------------------------------------------
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) -D__GLASGOW_HASKELL__=411 $(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/lib/std             \
63    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std/cbits       \
64    -L$(FPTOOLS_TOP_ABS)/hslibs/lang             \
65    -L$(FPTOOLS_TOP_ABS)/hslibs/lang/cbits       \
66    -L$(FPTOOLS_TOP_ABS)/hslibs/concurrent       \
67    -L$(FPTOOLS_TOP_ABS)/hslibs/concurrent/cbits \
68    -L$(FPTOOLS_TOP_ABS)/hslibs/posix            \
69    -L$(FPTOOLS_TOP_ABS)/hslibs/posix/cbits      \
70    -L$(FPTOOLS_TOP_ABS)/hslibs/util             \
71    -L$(FPTOOLS_TOP_ABS)/hslibs/util/cbits       \
72    -L$(FPTOOLS_TOP_ABS) hslibs/text             \
73    -u "PrelBase_Izh_static_info"                \
74    -u "PrelBase_Czh_static_info"                \
75    -u "PrelFloat_Fzh_static_info"               \
76    -u "PrelFloat_Dzh_static_info"               \
77    -u "PrelPtr_Ptr_static_info"                 \
78    -u "PrelWord_Wzh_static_info"                \
79    -u "PrelInt_I8zh_static_info"                \
80    -u "PrelInt_I16zh_static_info"               \
81    -u "PrelInt_I32zh_static_info"               \
82    -u "PrelInt_I64zh_static_info"               \
83    -u "PrelWord_W8zh_static_info"               \
84    -u "PrelWord_W16zh_static_info"              \
85    -u "PrelWord_W32zh_static_info"              \
86    -u "PrelWord_W64zh_static_info"              \
87    -u "PrelStable_StablePtr_static_info"        \
88    -u "PrelBase_Izh_con_info"                   \
89    -u "PrelBase_Czh_con_info"                   \
90    -u "PrelFloat_Fzh_con_info"                  \
91    -u "PrelFloat_Dzh_con_info"                  \
92    -u "PrelPtr_Ptr_con_info"                    \
93    -u "PrelStable_StablePtr_con_info"           \
94    -u "PrelBase_False_closure"                  \
95    -u "PrelBase_True_closure"                   \
96    -u "PrelPack_unpackCString_closure"          \
97    -u "PrelIOBase_stackOverflow_closure"        \
98    -u "PrelIOBase_heapOverflow_closure"         \
99    -u "PrelIOBase_NonTermination_closure"       \
100    -u "PrelIOBase_BlockedOnDeadMVar_closure"    \
101    -u "PrelWeak_runFinalizzerBatch_closure"     \
102    -u "__init_Prelude"                          \
103    -u "PrelMain_mainIO_closure"                 \
104    -u "__init_PrelMain"
105
106 HC_BOOT_LIBS = -lHStext -lHSutil -lHSposix -lHSposix_cbits -lHSconcurrent -lHSlang -lHSlang_cbits -lHSstd -lHSstd_cbits -lHSrts -lgmp $(EXTRA_HC_BOOT_LIBS)
107
108 ifeq "$(GhcLibsWithReadline)" "YES"
109 HC_BOOT_LIBS += $(LibsReadline)
110 endif
111
112 ifeq "$(HaveLibDL)" "YES"
113 HC_BOOT_LIBS += -ldl
114 endif
115
116 # -----------------------------------------------------------------------------
117 # suffix rules for building a .o from a .hc file.
118
119 %.raw_s : %.hc
120         $(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/'`
121
122 %.s : %.raw_s
123         $(GHC_MANGLER) $< $@ $(patsubst -monly-%-regs, %, $(filter -monly-%-regs, $($*_HC_OPTS)))
124
125 %.o : %.s
126         $(CC) -c -o $@ $<