[project @ 2001-03-27 09:38:26 by simonmar]
[ghc-hetmet.git] / mk / bootstrap.mk
1 # -----------------------------------------------------------------------------
2 # $Id: bootstrap.mk,v 1.3 2001/03/27 09:38:26 simonmar Exp $
3 #
4 # Makefile rules for booting from .hc files without a driver.
5 #
6
7 TOP_SAVED := $(TOP)
8 TOP:=$(TOP)/ghc
9
10 include $(FPTOOLS_TOP_ABS)/ghc/mk/version.mk
11 include $(FPTOOLS_TOP_ABS)/ghc/mk/paths.mk
12
13 # Reset TOP
14 TOP:=$(TOP_SAVED)
15
16 # -----------------------------------------------------------------------------
17 # Set the platform-specific options to send to the C compiler.  These should
18 # match the list in machdepCCOpts in ghc/compiler/DriverFlags.hs.
19 #
20
21 PLATFORM_CC_OPTS =
22 PLATFORM_HC_BOOT_CC_OPTS =
23
24 ifeq "$(i386_TARGET_ARCH)" "1"
25 PLATFORM_CC_OPTS += -DDONT_WANT_WIN32_DLL_SUPPORT
26 PLATFORM_HC_BOOT_CC_OPTS += -fno-defer-pop -fomit-frame-pointer 
27 endif
28
29 ifeq "$(hppa_TARGET_ARCH)" "1"
30 PLATFORM_CC_OPTS += -static -D_HPUX_SOURCE
31 endif
32
33 ifeq "$(powerpc_TARGET_ARCH)" "1"
34 PLATFORM_CC_OPTS += -static
35 PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
36 endif
37
38 ifeq "$(rs6000_TARGET_ARCH)" "1"
39 PLATFORM_CC_OPTS += -static
40 PLATFORM_HC_BOOT_CC_OPTS += -static -finhibit-size-directive
41 endif
42
43 ifeq "$(mingw32_TARGET_OS)" "1"
44 PLATFORM_CC_OPTS += -mno-cygwin
45 endif
46
47 PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) 
48
49 HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) -D__GLASGOW_HASKELL__=411 $(CC_OPTS)
50
51 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
52
53 # -----------------------------------------------------------------------------
54 # Linking: we have to give all the libraries explicitly.
55
56 HC_BOOT_LD_OPTS =                               \
57    -L$(FPTOOLS_TOP_ABS)/ghc/rts                 \
58    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std             \
59    -L$(FPTOOLS_TOP_ABS)/ghc/lib/std/cbits       \
60    -L$(FPTOOLS_TOP_ABS)/hslibs/lang             \
61    -L$(FPTOOLS_TOP_ABS)/hslibs/lang/cbits       \
62    -L$(FPTOOLS_TOP_ABS)/hslibs/concurrent       \
63    -L$(FPTOOLS_TOP_ABS)/hslibs/concurrent/cbits \
64    -L$(FPTOOLS_TOP_ABS)/hslibs/posix            \
65    -L$(FPTOOLS_TOP_ABS)/hslibs/posix/cbits      \
66    -L$(FPTOOLS_TOP_ABS)/hslibs/util             \
67    -L$(FPTOOLS_TOP_ABS)/hslibs/util/cbits       \
68    -L$(FPTOOLS_TOP_ABS)/hslibs/text             \
69    -u "PrelBase_Izh_static_info"                \
70    -u "PrelBase_Czh_static_info"                \
71    -u "PrelFloat_Fzh_static_info"               \
72    -u "PrelFloat_Dzh_static_info"               \
73    -u "PrelPtr_Ptr_static_info"                 \
74    -u "PrelWord_Wzh_static_info"                \
75    -u "PrelInt_I8zh_static_info"                \
76    -u "PrelInt_I16zh_static_info"               \
77    -u "PrelInt_I32zh_static_info"               \
78    -u "PrelInt_I64zh_static_info"               \
79    -u "PrelWord_W8zh_static_info"               \
80    -u "PrelWord_W16zh_static_info"              \
81    -u "PrelWord_W32zh_static_info"              \
82    -u "PrelWord_W64zh_static_info"              \
83    -u "PrelStable_StablePtr_static_info"        \
84    -u "PrelBase_Izh_con_info"                   \
85    -u "PrelBase_Czh_con_info"                   \
86    -u "PrelFloat_Fzh_con_info"                  \
87    -u "PrelFloat_Dzh_con_info"                  \
88    -u "PrelPtr_Ptr_con_info"                    \
89    -u "PrelStable_StablePtr_con_info"           \
90    -u "PrelBase_False_closure"                  \
91    -u "PrelBase_True_closure"                   \
92    -u "PrelPack_unpackCString_closure"          \
93    -u "PrelIOBase_stackOverflow_closure"        \
94    -u "PrelIOBase_heapOverflow_closure"         \
95    -u "PrelIOBase_NonTermination_closure"       \
96    -u "PrelIOBase_BlockedOnDeadMVar_closure"    \
97    -u "PrelWeak_runFinalizzerBatch_closure"     \
98    -u "__init_Prelude"                          \
99    -u "PrelMain_mainIO_closure"                 \
100    -u "__init_PrelMain"
101
102 HC_BOOT_LIBS = -lHStext -lHSutil -lHSposix -lHSposix_cbits -lHSconcurrent -lHSlang -lHSlang_cbits -lHSstd -lHSstd_cbits -lHSrts -lgmp $(EXTRA_HC_BOOT_LIBS)
103
104 ifeq "$(GhcLibsWithReadline)" "YES"
105 HC_BOOT_LIBS += $(LibsReadline)
106 endif
107
108 ifeq "$(HaveLibDL)" "YES"
109 HC_BOOT_LIBS += -ldl
110 endif
111
112 # -----------------------------------------------------------------------------
113 # suffix rules for building a .o from a .hc file.
114
115 %.raw_s : %.hc
116         $(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/'`
117
118 %.s : %.raw_s
119         $(GHC_MANGLER) $< $@ $(patsubst -monly-%-regs, %, $(filter -monly-%-regs, $($*_HC_OPTS)))
120
121 %.o : %.s
122         $(CC) -c -o $@ $<