bootstrap.mk 5.32 KB
Newer Older
1
# -----------------------------------------------------------------------------
2
# $Id: bootstrap.mk,v 1.33 2005/01/27 13:00:14 simonmar Exp $
3
4
5
#
# Makefile rules for booting from .hc files without a driver.
#
6
7
8
9
# When booting from .hc files without a compiler installed, we don't have
# the benefit of the GHC driver to add all the magic options required to
# compile the .hc files, so we have to duplicate that functionality here.
# The result is unfortunately ugly, but we don't have another choice.
10
11
12
13

TOP_SAVED := $(TOP)
TOP:=$(TOP)/ghc

14
15
include $(TOP)/mk/version.mk
include $(TOP)/mk/paths.mk
16
17
18
19

# Reset TOP
TOP:=$(TOP_SAVED)

dons's avatar
dons committed
20
21
include $(TOP)/mk/suffix.mk

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# -----------------------------------------------------------------------------
# Set the platform-specific options to send to the C compiler.  These should
# match the list in machdepCCOpts in ghc/compiler/DriverFlags.hs.
#

PLATFORM_CC_OPTS =
PLATFORM_HC_BOOT_CC_OPTS =

ifeq "$(i386_TARGET_ARCH)" "1"
PLATFORM_CC_OPTS += -DDONT_WANT_WIN32_DLL_SUPPORT
PLATFORM_HC_BOOT_CC_OPTS += -fno-defer-pop -fomit-frame-pointer 
endif

ifeq "$(hppa_TARGET_ARCH)" "1"
PLATFORM_CC_OPTS += -static -D_HPUX_SOURCE
endif

ifeq "$(powerpc_TARGET_ARCH)" "1"
PLATFORM_CC_OPTS += -static
PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
endif

ifeq "$(rs6000_TARGET_ARCH)" "1"
PLATFORM_CC_OPTS += -static
ken's avatar
ken committed
46
PLATFORM_HC_BOOT_CC_OPTS += -finhibit-size-directive
47
48
49
50
51
52
endif

ifeq "$(mingw32_TARGET_OS)" "1"
PLATFORM_CC_OPTS += -mno-cygwin
endif

ken's avatar
ken committed
53
ifeq "$(alpha_TARGET_ARCH)" "1"
ken's avatar
ken committed
54
PLATFORM_CC_OPTS += -static -w
ken's avatar
ken committed
55
PLATFORM_HC_BOOT_CC_OPTS += -mieee
ken's avatar
ken committed
56
57
58
59
endif

ifeq "$(sparc_TARGET_ARCH)" "1"
PLATFORM_HC_BOOT_CC_OPTS += -w
ken's avatar
ken committed
60
61
endif

sof's avatar
sof committed
62
ifeq "$(BootingFromUnregisterisedHc)" "YES"
63
PLATFORM_HC_BOOT_CC_OPTS += -DNO_REGS -DUSE_MINIINTERPRETER
sof's avatar
sof committed
64
65
endif

66
67
PLATFORM_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt) 

68
HC_BOOT_CC_OPTS = $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS) $(CC_OPTS)
69

70
SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/ghc/includes -I$(FPTOOLS_TOP_ABS)/libraries/base/include -I$(FPTOOLS_TOP_ABS)/libraries/unix/include -I$(FPTOOLS_TOP_ABS)/libraries/parsec/include
71

72
73
74
75
76
77
# C code compiled with UseGhcForCc=YES assumes the existence of certain CPP
# symbols defined by GHC (eg. __GLASGOW_HASKELL__), so we better make sure
# they're defined.  We can't test $(UseGhcForCc) here though - it isn't defined
# yet, so we use lazy expansion.
SRC_CC_OPTS += $(if $(findstring YES,$(UseGhcForCc)), $(PLATFORM_HC_BOOT_CC_OPTS) $(PLATFORM_CC_OPTS))

78
79
80
81
ifeq "$(GhcWithInterpreter)" "YES"
SRC_CC_OPTS += -I$(FPTOOLS_TOP_ABS)/libraries/readline/include
endif

82
83
84
# -----------------------------------------------------------------------------
# Linking: we have to give all the libraries explicitly.

sof's avatar
sof committed
85
86
87
88
89
90
ifeq "$(LeadingUnderscore)" "YES"
UNDERSCORE=_
else
UNDERSCORE=
endif

sof's avatar
sof committed
91
92
93
ifeq "$(HaveLibGmp)" "NO"
DASH_L_GHC_RTS_GMP_DIR=-L$(FPTOOLS_TOP_ABS)/ghc/rts/gmp
endif
sof's avatar
sof committed
94

95
HC_BOOT_LD_OPTS =				\
96
   -L$(FPTOOLS_TOP_ABS)/ghc/rts			\
sof's avatar
sof committed
97
   $(DASH_L_GHC_RTS_GMP_DIR)                    \
98
99
   -L$(FPTOOLS_TOP_ABS)/libraries/base		\
   -L$(FPTOOLS_TOP_ABS)/libraries/base/cbits	\
100
101
102
103
   -L$(FPTOOLS_TOP_ABS)/libraries/haskell98

ifeq "$(GhcWithInterpreter)" "YES"
HC_BOOT_LD_OPTS += \
104
   -L$(FPTOOLS_TOP_ABS)/libraries/template-haskell	\
105
   -L$(FPTOOLS_TOP_ABS)/libraries/readline	\
106
   -L$(FPTOOLS_TOP_ABS)/libraries/parsec        \
107
   -L$(FPTOOLS_TOP_ABS)/libraries/Cabal         \
108
109
110
111
112
   -L$(FPTOOLS_TOP_ABS)/libraries/unix          \
   -L$(FPTOOLS_TOP_ABS)/libraries/unix/cbits
endif

HC_BOOT_LD_OPTS += \
sof's avatar
sof committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
   -u "$(UNDERSCORE)GHCziBase_Izh_static_info" \
   -u "$(UNDERSCORE)GHCziBase_Czh_static_info" \
   -u "$(UNDERSCORE)GHCziFloat_Fzh_static_info" \
   -u "$(UNDERSCORE)GHCziFloat_Dzh_static_info" \
   -u "$(UNDERSCORE)GHCziPtr_Ptr_static_info" \
   -u "$(UNDERSCORE)GHCziWord_Wzh_static_info" \
   -u "$(UNDERSCORE)GHCziInt_I8zh_static_info" \
   -u "$(UNDERSCORE)GHCziInt_I16zh_static_info" \
   -u "$(UNDERSCORE)GHCziInt_I32zh_static_info" \
   -u "$(UNDERSCORE)GHCziInt_I64zh_static_info" \
   -u "$(UNDERSCORE)GHCziWord_W8zh_static_info" \
   -u "$(UNDERSCORE)GHCziWord_W16zh_static_info" \
   -u "$(UNDERSCORE)GHCziWord_W32zh_static_info" \
   -u "$(UNDERSCORE)GHCziWord_W64zh_static_info" \
   -u "$(UNDERSCORE)GHCziStable_StablePtr_static_info" \
   -u "$(UNDERSCORE)GHCziBase_Izh_con_info" \
   -u "$(UNDERSCORE)GHCziBase_Czh_con_info" \
   -u "$(UNDERSCORE)GHCziFloat_Fzh_con_info" \
   -u "$(UNDERSCORE)GHCziFloat_Dzh_con_info" \
   -u "$(UNDERSCORE)GHCziPtr_Ptr_con_info" \
   -u "$(UNDERSCORE)GHCziStable_StablePtr_con_info" \
   -u "$(UNDERSCORE)GHCziBase_False_closure" \
   -u "$(UNDERSCORE)GHCziBase_True_closure" \
   -u "$(UNDERSCORE)GHCziPack_unpackCString_closure" \
   -u "$(UNDERSCORE)GHCziIOBase_stackOverflow_closure" \
   -u "$(UNDERSCORE)GHCziIOBase_heapOverflow_closure" \
   -u "$(UNDERSCORE)GHCziIOBase_NonTermination_closure" \
   -u "$(UNDERSCORE)GHCziIOBase_BlockedOnDeadMVar_closure" \
   -u "$(UNDERSCORE)GHCziIOBase_Deadlock_closure" \
   -u "$(UNDERSCORE)GHCziWeak_runFinalizzerBatch_closure" \
   -u "$(UNDERSCORE)__stginit_Prelude"
144

145
146
147
148

HC_BOOT_LIBS =

ifeq "$(GhcWithInterpreter)" "YES"
149
HC_BOOT_LIBS += -lHSreadline -lHStemplate-haskell -lHSunix -lHSunix_cbits
150
151
endif

152
HC_BOOT_LIBS +=  -lHSCabal -lHShaskell98 -lHSbase -lHSbase_cbits -lHSparsec -lHSrts -lgmp -lm $(EXTRA_HC_BOOT_LIBS)
153
154

ifeq "$(GhcLibsWithReadline)" "YES"
155
HC_BOOT_LIBS += $(patsubst %, -l%, $(LibsReadline))
156
157
158
159
160
endif

ifeq "$(HaveLibDL)" "YES"
HC_BOOT_LIBS += -ldl
endif