1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.85 2000/07/21 08:45:05 rrt 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 # ----------------------------------------------------------------------------
228 SRC_C_OPTS += -O -I. -IcodeGen
231 # ----------------------------------------------------------------------------
234 parser/hschooks.o : parser/hschooks.c
236 $(HC) -c -o $@ $(HC_OPTS) parser/hschooks.c
239 # Interface-file parser uses Happy
240 SRC_HAPPY_OPTS += +RTS -K2m -H16m -RTS $(GHC_HAPPY_OPTS)
242 rename/ParseIface.hs : rename/ParseIface.y
243 @$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
244 $(HAPPY) $(HAPPY_OPTS) rename/ParseIface.y
245 @chmod 444 rename/ParseIface.hs
247 parser/Parser.hs : parser/Parser.y
248 @$(RM) parser/Parser.hs parser/ParseIface.hinfo
249 $(HAPPY) $(HAPPY_OPTS) parser/Parser.y
250 @chmod 444 parser/Parser.hs
252 #-----------------------------------------------------------------------------
255 SRC_LD_OPTS += -no-link-chk
257 ifneq "$(GhcWithHscBuiltViaC)" "YES"
258 ifeq "$(GhcReportCompiles)" "YES"
259 SRC_LD_OPTS += -syslib misc -syslib exts
263 #-----------------------------------------------------------------------------
266 # We don't want hsc treated as an ordinary executable,
267 # but put it together with the libraries.
268 # Also don't want any interface files intstalled
270 INSTALL_LIBEXECS += hsc
272 #-----------------------------------------------------------------------------
276 # Before doing `make depend', need to build all derived Haskell source files
280 ifneq "$(GhcWithHscBuiltViaC)" "YES"
281 depend :: rename/ParseIface.hs
284 #-----------------------------------------------------------------------------
287 CLEAN_FILES += $(wildcard */*.$(way_)o */*.$(way_)hi)
289 # Extra tidy, remove the .hc files (if you've got them).
290 MAINTAINER_CLEAN_FILES += $(wildcard */*.hc) \
291 parser/Parser.hs rename/ParseIface.hs
294 #-----------------------------------------------------------------------------
297 SRC_HSTAGS_OPTS += -fglasgow-exts -cpp
298 TAGS_HS_SRCS=$(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
299 TAGS_C_SRCS=$(strip $(foreach f,$(foreach dir,$(DIRS),$(wildcard $(dir)/*.c)),$(shell if [ -w $(f) ]; then echo $(f); else echo ''; fi)))
301 #-----------------------------------------------------------------------------
302 # Include target-rule boilerplate
304 include $(TOP)/mk/target.mk
306 parser/%.o : parser/%.c