[project @ 2001-03-26 16:58:09 by simonmar]
[ghc-hetmet.git] / mk / bootstrap.mk
1 # -----------------------------------------------------------------------------
2 # $Id: bootstrap.mk,v 1.2 2001/03/26 16:58:09 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) $(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/text             \
63    -u "PrelBase_Izh_static_info"                \
64    -u "PrelBase_Czh_static_info"                \
65    -u "PrelFloat_Fzh_static_info"               \
66    -u "PrelFloat_Dzh_static_info"               \
67    -u "PrelPtr_Ptr_static_info"                 \
68    -u "PrelWord_Wzh_static_info"                \
69    -u "PrelInt_I8zh_static_info"                \
70    -u "PrelInt_I16zh_static_info"               \
71    -u "PrelInt_I32zh_static_info"               \
72    -u "PrelInt_I64zh_static_info"               \
73    -u "PrelWord_W8zh_static_info"               \
74    -u "PrelWord_W16zh_static_info"              \
75    -u "PrelWord_W32zh_static_info"              \
76    -u "PrelWord_W64zh_static_info"              \
77    -u "PrelStable_StablePtr_static_info"        \
78    -u "PrelBase_Izh_con_info"                   \
79    -u "PrelBase_Czh_con_info"                   \
80    -u "PrelFloat_Fzh_con_info"                  \
81    -u "PrelFloat_Dzh_con_info"                  \
82    -u "PrelPtr_Ptr_con_info"                    \
83    -u "PrelStable_StablePtr_con_info"           \
84    -u "PrelBase_False_closure"                  \
85    -u "PrelBase_True_closure"                   \
86    -u "PrelPack_unpackCString_closure"          \
87    -u "PrelIOBase_stackOverflow_closure"        \
88    -u "PrelIOBase_heapOverflow_closure"         \
89    -u "PrelIOBase_NonTermination_closure"       \
90    -u "PrelIOBase_BlockedOnDeadMVar_closure"    \
91    -u "PrelWeak_runFinalizzerBatch_closure"     \
92    -u "__init_Prelude"                          \
93    -u "PrelMain_mainIO_closure"                 \
94    -u "__init_PrelMain"
95
96 HC_BOOT_LIBS = -lHStext -lHSlang -lHSstd -lHSstd_cbits -lHSrts -lgmp $(EXTRA_HC_BOOT_LIBS)
97
98 # -----------------------------------------------------------------------------
99 # suffix rules for building a .o from a .hc file.
100
101 %.raw_s : %.hc
102         $(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/'`
103
104 %.s : %.raw_s
105         $(GHC_MANGLER) $< $@ $(patsubst -monly-%-regs, %, $(filter -monly-%-regs, $($*_HC_OPTS)))
106
107 %.o : %.s
108         $(CC) -c -o $@ $<