[project @ 2000-07-07 09:37:39 by simonmar]
[ghc-hetmet.git] / ghc / compiler / Makefile
1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.82 2000/07/07 09:37:39 simonmar Exp $
3
4 TOP = ..
5 include $(TOP)/mk/boilerplate.mk
6
7 #-----------------------------------------------------------------------------
8 # Building hsc different ways (default is just `normal' sequential)
9 WAYS=$(GhcCompilerWays)
10
11 # -----------------------------------------------------------------------------
12 #               Set HS_PROG, LIBRARY
13
14 # Note: there have been reports of people running up against the ARG_MAX limit
15 # when linking hsc with all its constituent object files. The likely source of 
16 # the problem is that the environment is a bit too big, so a workaround could
17 # be to do ` env PATH=$(PATH) make hsc 'to minimise the environment. (or the
18 # equivalent of `env' if it doesn't exist locally).
19 #
20 HS_PROG=hsc$(_way)
21
22
23 # -----------------------------------------------------------------------------
24 #               Compilation history for Patrick
25
26 # Make the sources first, because that's what the compilation history needs
27 $(HS_PROG) :: $(HS_SRCS)
28
29
30 # -----------------------------------------------------------------------------
31 #               Set SRCS, LOOPS, HCS, OBJS
32 #
33 # First figure out DIRS, the source sub-directories
34 # Then derive SRCS by looking in them
35 #
36
37 DIRS = \
38   utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
39   specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
40   profiling parser usageSP cprAnalysis javaGen
41
42
43 ifeq ($(GhcWithNativeCodeGen),YES)
44 DIRS += nativeGen
45 else
46 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
47 ifeq ($(GhcWithIlx),YES)
48 DIRS += ilxGen
49 SRC_HC_OPTS += -DILX
50 endif
51 endif
52
53
54 HS_SRCS = $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
55
56 ifneq "$(GhcWithHscBuiltViaC)" "YES"
57 HS_SRCS += rename/ParseIface.hs parser/Parser.hs
58 endif
59
60 HCS      = $(patsubst %.lhs, %.hc, $(patsubst %.hs, %.hc, $(HS_SRCS)))
61
62 # ParseIface.hs ain't part of HS_SRCS when this is on..
63 ifeq "$(GhcWithHscBuiltViaC)" "YES"
64 HCS      += rename/ParseIface.hc parser/Parser.hc
65 endif
66
67 HS_OBJS  = \
68   $(patsubst %.hc, %.o, $(HCS)) \
69   parser/hschooks.o
70
71
72 DESTDIR       = $(INSTALL_LIBRARY_DIR_GHC)
73
74 #
75 # Add misc .c helper code (used by the frontend.)
76 #
77 C_SRCS += parser/hschooks.c
78
79 #
80 # Big Fudge to get around inherent problem that Makefile setup
81 # has got with 'mkdependC'.
82
83 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
84
85 # stuff you get for free in a source distribution
86
87 # SRC_DIST_FILES += rename/ParseIface.hs rename/Parser.hs
88
89 # -----------------------------------------------------------------------------
90 #               Haskell compilations
91
92 #
93 # Compiler to use for building hsc, use the build tree
94 # driver when booting.
95 #
96 ifneq "$(GhcWithHscBuiltViaC)" "YES"
97 HC=$(WithGhcHc)
98 else
99 HC=$(GHC_INPLACE)
100 endif
101
102 # magic from GNU make manual to convert a list of values
103 # into a colon-separated list
104 empty:=
105 space:= $(empty) $(empty)
106
107 SRC_HC_OPTS += \
108   -cpp -fglasgow-exts -Rghc-timing \
109   -I. -IcodeGen -InativeGen -Iparser \
110   -i$(subst $(space),:,$(DIRS))
111
112 SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
113
114 SRC_HC_OPTS += -recomp $(GhcHcOpts)
115
116 #       Special flags for particular modules
117 #       The standard suffix rule for compiling a Haskell file
118 #       adds these flags to the command line
119
120 # Was 6m with 2.10
121 absCSyn/PprAbsC_HC_OPTS         = -H10m
122
123 basicTypes/IdInfo_HC_OPTS       = -K2m
124 codeGen/CgCase_HC_OPTS          = -fno-prune-tydecls
125 hsSyn/HsExpr_HC_OPTS            = -K2m
126 main/Main_HC_OPTS               = 
127 main/Constants_HC_OPTS          = -DHscIfaceFileVersion=$(HscIfaceFileVersion)
128
129 ifneq "$(GhcWithHscBuiltViaC)" "YES"
130 ifeq "$(GhcReportCompiles)" "YES"
131 main/Main_HC_OPTS               += -syslib misc -DREPORT_TO_MOTHERLODE
132 endif
133 endif
134
135 main/CmdLineOpts_HC_OPTS        =  -K6m
136 nativeGen/PprMach_HC_OPTS       = -K2m
137 nativeGen/MachMisc_HC_OPTS      = -K2m 
138 nativeGen/MachCode_HC_OPTS      = -H10m
139
140 # Avoids Bug in 3.02, it seems
141 usageSP/UsageSPInf_HC_OPTS      = -Onot
142
143 prelude/PrimOp_HC_OPTS          = -H12m -K3m
144 prelude/PrelRules_HC_OPTS       = -fvia-C
145
146 parser/Lex_HC_OPTS              = -fvia-C -K2m -H16m 
147 parser/Ctype_HC_OPTS            = -K2m -fvia-C
148
149 rename/ParseIface_HC_OPTS       += -Onot -H45m -K2m -fno-warn-incomplete-patterns
150 rename/ParseIface_HAPPY_OPTS    += -g
151
152 parser/Parser_HC_OPTS           += -Onot -H80m -optCrts-M80m -K2m -fno-warn-incomplete-patterns
153 parser/Parser_HAPPY_OPTS        += -g
154
155 ifeq "$(TARGETPLATFORM)" "hppa1.1-hp-hpux9"
156 rename/RnMonad_HC_OPTS          =  -O2 -O2-for-C
157 endif
158
159 rename/RnEnv_HC_OPTS            = 
160 rename/RnSource_HC_OPTS         = -H12m
161 rename/RnIfaces_HC_OPTS         = -H8m 
162 rename/RnExpr_HC_OPTS           = -H10m
163 rename/RnNames_HC_OPTS          = -H12m
164 rename/RnMonad_HC_OPTS          = 
165 specialise/Specialise_HC_OPTS   = -Onot -H12m
166 simplCore/Simplify_HC_OPTS      = -H15m 
167 simplCore/OccurAnal_HC_OPTS     = -H10m
168 typecheck/TcGenDeriv_HC_OPTS    = -H10m
169
170 # tmp, -- SDM
171 specialise/Specialise_HC_OPTS   += -fno-prune-tydecls
172 hsSyn/HsBasic_HC_OPTS           += -fno-prune-tydecls
173 simplCore/SimplMonad_HC_OPTS    += -fno-prune-tydecls
174 absCSyn/AbsCSyn_HC_OPTS         += -fno-prune-tydecls
175 absCSyn/AbsCUtils_HC_OPTS       += -fno-prune-tydecls
176 codeGen/CgBindery_HC_OPTS       += -fno-prune-tydecls
177 codeGen/CgLetNoEscape_HC_OPTS   += -fno-prune-tydecls
178 codeGen/CgExpr_HC_OPTS          += -fno-prune-tydecls
179 nativeGen/AbsCStixGen_HC_OPTS   += -fno-prune-tydecls
180
181 # Was 10m for 2.10
182 typecheck/TcHsSyn_HC_OPTS       = -H15m 
183
184
185 # Was 10m for 2.10
186 typecheck/TcExpr_HC_OPTS        = -H15m
187 typecheck/TcBinds_HC_OPTS       = -H10m
188
189 typecheck/TcEnv_HC_OPTS         = -H10m
190 utils/Argv_HC_OPTS              = -fvia-C
191 utils/SST_HC_OPTS               = 
192 utils/StringBuffer_HC_OPTS      = -fvia-C -fno-prune-tydecls
193 utils/Digraph_HC_OPTS           = -fglasgow-exts 
194 utils/DirUtils_HC_OPTS          = 
195
196 # temporary, due to bug in NCG  (SDM, 1/6/2000)
197 utils/FastString_HC_OPTS        = -fvia-C
198
199 ifeq "$(alpha_HOST_ARCH)" "1"
200 # "stbu" bug in alpha native code generator...
201 basicTypes/Unique_HC_OPTS       = 
202 endif
203
204 # flags for PrimPacked:
205 #
206 # -monly-3-regs 
207 #       because it contains a 'ccall strlen', which gets inlined by
208 #       gcc, causing a lack of registers.
209 #
210 # -optC-funfolding-interface-threshold7
211 #       To stop the definition of 'strLength', which calls strlen, getting
212 #       into the interface file and spreading the -monly-3-regs virus.
213 #       We need -optC here because the driver before 3.02 didn't understand
214 #       the -funfolding flags.
215
216 utils/PrimPacked_HC_OPTS        = -fvia-C -monly-3-regs -optC-funfolding-interface-threshold7
217
218 # Strictness analyser misbehaving in 2.10, fails to terminate on
219 # UpdAnal.lhs due to weird recursive datatype.  Bug was exposed by a
220 # separate bugfix to the fixpoint finder.
221 simplStg/UpdAnal_HC_OPTS        = -fno-strictness
222
223 # ----------------------------------------------------------------------------
224 #               C compilations
225
226 SRC_C_OPTS     += -O -I. -IcodeGen
227
228
229 # ----------------------------------------------------------------------------
230 #               Parsers/lexers
231
232 parser/hschooks.o : parser/hschooks.c
233         @$(RM) $@
234         $(HC) -c -o $@ $(HC_OPTS) parser/hschooks.c
235
236
237 # Interface-file parser uses Happy
238 SRC_HAPPY_OPTS += +RTS -K2m -H16m -RTS
239
240 rename/ParseIface.hs : rename/ParseIface.y
241         @$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
242         $(HAPPY) $(HAPPY_OPTS) -g rename/ParseIface.y
243         @chmod 444 rename/ParseIface.hs
244
245 parser/Parser.hs : parser/Parser.y
246         @$(RM) parser/Parser.hs parser/ParseIface.hinfo
247         $(HAPPY) $(HAPPY_OPTS) -g parser/Parser.y
248         @chmod 444 parser/Parser.hs
249
250 #-----------------------------------------------------------------------------
251 #               Linking
252
253 SRC_LD_OPTS += -no-link-chk
254
255 ifneq "$(GhcWithHscBuiltViaC)" "YES"
256 ifeq "$(GhcReportCompiles)" "YES"
257 SRC_LD_OPTS += -syslib misc -syslib exts
258 endif
259 endif
260
261 #-----------------------------------------------------------------------------
262 #               install
263
264 # We don't want hsc treated as an ordinary executable,
265 # but put it together with the libraries.
266 # Also don't want any interface files intstalled
267
268 INSTALL_LIBEXECS += hsc
269
270 #-----------------------------------------------------------------------------
271 #               depend
272
273 #
274 # Before doing `make depend', need to build all derived Haskell source files
275 #
276 depend :: $(LOOPS)
277
278 ifneq "$(GhcWithHscBuiltViaC)" "YES"
279 depend :: rename/ParseIface.hs
280 endif
281
282 #-----------------------------------------------------------------------------
283 #               clean
284
285 CLEAN_FILES += $(wildcard */*.$(way_)o */*.$(way_)hi)
286
287 # Extra tidy, remove the .hc files (if you've got them).
288 MAINTAINER_CLEAN_FILES += $(wildcard */*.hc) \
289         parser/Parser.hs rename/ParseIface.hs
290
291
292 #-----------------------------------------------------------------------------
293 #               TAGS setup
294
295 SRC_HSTAGS_OPTS += -fglasgow-exts -cpp
296 TAGS_HS_SRCS=$(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
297 TAGS_C_SRCS=$(strip $(foreach f,$(foreach dir,$(DIRS),$(wildcard $(dir)/*.c)),$(shell if [ -w $(f) ]; then echo $(f); else echo ''; fi)))
298
299 #-----------------------------------------------------------------------------
300 #               Include target-rule boilerplate
301
302 include $(TOP)/mk/target.mk
303
304 parser/%.o : parser/%.c
305