1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.92 2000/09/11 12:20:56 sewardj Exp $
5 include $(TOP)/mk/boilerplate.mk
7 #-----------------------------------------------------------------------------
8 # Building hsc different ways (default is just `normal' sequential)
9 WAYS=$(GhcCompilerWays)
11 # -----------------------------------------------------------------------------
12 # Set HS_PROG, LIBRARY
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).
27 # -----------------------------------------------------------------------------
28 # Compilation history for Patrick
30 # Make the sources first, because that's what the compilation history needs
31 $(HS_PROG) :: $(HS_SRCS)
34 # -----------------------------------------------------------------------------
35 # Set SRCS, LOOPS, HCS, OBJS
37 # First figure out DIRS, the source sub-directories
38 # Then derive SRCS by looking in them
42 utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
43 specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
44 profiling parser usageSP cprAnalysis javaGen
47 ifeq ($(GhcWithNativeCodeGen),YES)
50 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
51 ifeq ($(GhcWithIlx),YES)
58 HS_SRCS = $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
60 ifneq "$(GhcWithHscBuiltViaC)" "YES"
61 HS_SRCS += rename/ParseIface.hs parser/Parser.hs
64 HCS = $(patsubst %.lhs, %.hc, $(patsubst %.hs, %.hc, $(HS_SRCS)))
66 # ParseIface.hs ain't part of HS_SRCS when this is on..
67 ifeq "$(GhcWithHscBuiltViaC)" "YES"
68 HCS += rename/ParseIface.hc parser/Parser.hc
72 $(patsubst %.hc, %.o, $(HCS)) \
76 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
79 # Add misc .c helper code (used by the frontend.)
81 C_SRCS += parser/hschooks.c
84 # Big Fudge to get around inherent problem that Makefile setup
85 # has got with 'mkdependC'.
87 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
89 # stuff you get for free in a source distribution
91 # SRC_DIST_FILES += rename/ParseIface.hs rename/Parser.hs
93 # -----------------------------------------------------------------------------
94 # Haskell compilations
97 # Compiler to use for building hsc, use the build tree
98 # driver when booting.
100 ifneq "$(GhcWithHscBuiltViaC)" "YES"
106 # magic from GNU make manual to convert a list of values
107 # into a colon-separated list
109 space:= $(empty) $(empty)
112 -cpp -fglasgow-exts -Rghc-timing \
113 -I. -IcodeGen -InativeGen -Iparser \
114 -i$(subst $(space),:,$(DIRS))
116 SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
118 SRC_HC_OPTS += -recomp $(GhcHcOpts)
120 # Special flags for particular modules
121 # The standard suffix rule for compiling a Haskell file
122 # adds these flags to the command line
125 absCSyn/PprAbsC_HC_OPTS = -H10m
127 basicTypes/IdInfo_HC_OPTS = -K2m
128 codeGen/CgCase_HC_OPTS = -fno-prune-tydecls
129 hsSyn/HsExpr_HC_OPTS = -K2m
131 main/Constants_HC_OPTS = -DHscIfaceFileVersion=$(HscIfaceFileVersion)
133 ifneq "$(GhcWithHscBuiltViaC)" "YES"
134 ifeq "$(GhcReportCompiles)" "YES"
135 main/Main_HC_OPTS += -syslib misc -DREPORT_TO_MOTHERLODE
139 main/CmdLineOpts_HC_OPTS = -K6m
140 nativeGen/PprMach_HC_OPTS = -K2m
141 nativeGen/MachMisc_HC_OPTS = -K2m
142 nativeGen/MachCode_HC_OPTS = -H10m
144 # Avoids Bug in 3.02, it seems
145 usageSP/UsageSPInf_HC_OPTS = -Onot
147 prelude/PrimOp_HC_OPTS = -H12m -K3m
148 prelude/PrelRules_HC_OPTS = -fvia-C
150 parser/Lex_HC_OPTS = -fvia-C -K2m -H16m
151 parser/Ctype_HC_OPTS = -K2m -fvia-C
153 rename/ParseIface_HC_OPTS += -Onot -H45m -K2m -fno-warn-incomplete-patterns
155 parser/Parser_HC_OPTS += -Onot -H80m -optCrts-M80m -K2m -fno-warn-incomplete-patterns
157 ifeq "$(TARGETPLATFORM)" "hppa1.1-hp-hpux9"
158 rename/RnMonad_HC_OPTS = -O2 -O2-for-C
161 rename/RnEnv_HC_OPTS =
162 rename/RnSource_HC_OPTS = -H12m
163 rename/RnIfaces_HC_OPTS = -H8m
164 rename/RnExpr_HC_OPTS = -H10m
165 rename/RnNames_HC_OPTS = -H12m
166 rename/RnMonad_HC_OPTS =
167 specialise/Specialise_HC_OPTS = -Onot -H12m
168 simplCore/Simplify_HC_OPTS = -H15m
169 simplCore/OccurAnal_HC_OPTS = -H10m
170 typecheck/TcGenDeriv_HC_OPTS = -H10m
173 specialise/Specialise_HC_OPTS += -fno-prune-tydecls
174 hsSyn/HsBasic_HC_OPTS += -fno-prune-tydecls
175 simplCore/SimplMonad_HC_OPTS += -fno-prune-tydecls
176 absCSyn/AbsCSyn_HC_OPTS += -fno-prune-tydecls
177 absCSyn/AbsCUtils_HC_OPTS += -fno-prune-tydecls
178 codeGen/CgBindery_HC_OPTS += -fno-prune-tydecls
179 codeGen/CgLetNoEscape_HC_OPTS += -fno-prune-tydecls
180 codeGen/CgExpr_HC_OPTS += -fno-prune-tydecls
181 nativeGen/AbsCStixGen_HC_OPTS += -fno-prune-tydecls
184 typecheck/TcHsSyn_HC_OPTS = -H15m
188 typecheck/TcExpr_HC_OPTS = -H15m
189 typecheck/TcBinds_HC_OPTS = -H10m
191 typecheck/TcEnv_HC_OPTS = -H10m
192 utils/Argv_HC_OPTS = -fvia-C
194 utils/StringBuffer_HC_OPTS = -fvia-C -fno-prune-tydecls
195 utils/Digraph_HC_OPTS = -fglasgow-exts
196 utils/DirUtils_HC_OPTS =
198 # temporary, due to bug in NCG (SDM, 1/6/2000)
199 utils/FastString_HC_OPTS = -fvia-C
201 ifeq "$(alpha_HOST_ARCH)" "1"
202 # "stbu" bug in alpha native code generator...
203 basicTypes/Unique_HC_OPTS =
206 # flags for PrimPacked:
209 # because it contains a 'ccall strlen', which gets inlined by
210 # gcc, causing a lack of registers.
212 # -optC-funfolding-interface-threshold7
213 # To stop the definition of 'strLength', which calls strlen, getting
214 # into the interface file and spreading the -monly-3-regs virus.
215 # We need -optC here because the driver before 3.02 didn't understand
216 # the -funfolding flags.
218 utils/PrimPacked_HC_OPTS = -fvia-C -monly-3-regs -optC-funfolding-interface-threshold7
220 # Strictness analyser misbehaving in 2.10, fails to terminate on
221 # UpdAnal.lhs due to weird recursive datatype. Bug was exposed by a
222 # separate bugfix to the fixpoint finder.
223 simplStg/UpdAnal_HC_OPTS = -fno-strictness
225 stgSyn/StgInterp_HC_OPTS = -fvia-C
227 # ----------------------------------------------------------------------------
230 SRC_C_OPTS += -O -I. -IcodeGen
233 # ----------------------------------------------------------------------------
234 # Generate supporting stuff for prelude/PrimOp.lhs
235 # from prelude/primops.txt
237 GENPOC=$(TOP)/utils/genprimopcode/genprimopcode
239 PRIMOP_BITS=primop-data-decl.hs-incl \
241 primop-list.hs-incl \
242 primop-has-side-effects.hs-incl \
243 primop-out-of-line.hs-incl \
244 primop-commutable.hs-incl \
245 primop-needs-wrapper.hs-incl \
246 primop-can-fail.hs-incl \
247 primop-strictness.hs-incl \
248 primop-usage.hs-incl \
249 primop-primop-info.hs-incl
251 prelude/PrimOp.o: $(PRIMOP_BITS)
253 depend :: $(PRIMOP_BITS)
255 primop-data-decl.hs-incl: prelude/primops.txt
256 $(GENPOC) --data-decl < $< > $@
257 primop-tag.hs-incl: prelude/primops.txt
258 $(GENPOC) --primop-tag < $< > $@
259 primop-list.hs-incl: prelude/primops.txt
260 $(GENPOC) --primop-list < $< > $@
261 primop-has-side-effects.hs-incl: prelude/primops.txt
262 $(GENPOC) --has-side-effects < $< > $@
263 primop-out-of-line.hs-incl: prelude/primops.txt
264 $(GENPOC) --out-of-line < $< > $@
265 primop-commutable.hs-incl: prelude/primops.txt
266 $(GENPOC) --commutable < $< > $@
267 primop-needs-wrapper.hs-incl: prelude/primops.txt
268 $(GENPOC) --needs-wrapper < $< > $@
269 primop-can-fail.hs-incl: prelude/primops.txt
270 $(GENPOC) --can-fail < $< > $@
271 primop-strictness.hs-incl: prelude/primops.txt
272 $(GENPOC) --strictness < $< > $@
273 primop-usage.hs-incl: prelude/primops.txt
274 $(GENPOC) --usage < $< > $@
275 primop-primop-info.hs-incl: prelude/primops.txt
276 $(GENPOC) --primop-primop-info < $< > $@
280 # ----------------------------------------------------------------------------
283 parser/hschooks.o : parser/hschooks.c
285 $(HC) -c -o $@ $(HC_OPTS) parser/hschooks.c
288 # Interface-file parser uses Happy
289 SRC_HAPPY_OPTS += +RTS -K2m -H16m -RTS $(GHC_HAPPY_OPTS)
291 rename/ParseIface.hs : rename/ParseIface.y
292 @$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
293 $(HAPPY) $(HAPPY_OPTS) rename/ParseIface.y
294 @chmod 444 rename/ParseIface.hs
296 parser/Parser.hs : parser/Parser.y
297 @$(RM) parser/Parser.hs parser/ParseIface.hinfo
298 $(HAPPY) $(HAPPY_OPTS) parser/Parser.y
299 @chmod 444 parser/Parser.hs
301 #-----------------------------------------------------------------------------
304 SRC_LD_OPTS += -no-link-chk
306 ifneq "$(GhcWithHscBuiltViaC)" "YES"
307 ifeq "$(GhcReportCompiles)" "YES"
308 SRC_LD_OPTS += -syslib misc -syslib exts
312 #-----------------------------------------------------------------------------
315 # We don't want hsc treated as an ordinary executable,
316 # but put it together with the libraries.
317 # Also don't want any interface files intstalled
319 INSTALL_LIBEXECS += hsc
321 #-----------------------------------------------------------------------------
325 # Before doing `make depend', need to build all derived Haskell source files
329 ifneq "$(GhcWithHscBuiltViaC)" "YES"
330 depend :: rename/ParseIface.hs
333 #-----------------------------------------------------------------------------
336 CLEAN_FILES += $(wildcard */*.$(way_)o */*.$(way_)hi)
337 CLEAN_FILES += $(PRIMOP_BITS)
339 # Extra tidy, remove the .hc files (if you've got them).
340 MAINTAINER_CLEAN_FILES += $(wildcard */*.hc) \
341 parser/Parser.hs rename/ParseIface.hs
344 #-----------------------------------------------------------------------------
347 SRC_HSTAGS_OPTS += -fglasgow-exts -cpp
348 TAGS_HS_SRCS=$(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
349 TAGS_C_SRCS=$(strip $(foreach f,$(foreach dir,$(DIRS),$(wildcard $(dir)/*.c)),$(shell if [ -w $(f) ]; then echo $(f); else echo ''; fi)))
351 #-----------------------------------------------------------------------------
352 # Include target-rule boilerplate
354 include $(TOP)/mk/target.mk
356 parser/%.o : parser/%.c