1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.69 2000/01/25 10:15:55 simonmar 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).
23 # -----------------------------------------------------------------------------
24 # Compilation history for Patrick
26 # Make the sources first, because that's what the compilation history needs
27 $(HS_PROG) :: $(HS_SRCS)
30 # -----------------------------------------------------------------------------
31 # Set SRCS, LOOPS, HCS, OBJS
33 # First figure out DIRS, the source sub-directories
34 # Then derive SRCS by looking in them
38 utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
39 specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
40 profiling parser usageSP cprAnalysis
43 ifeq ($(GhcWithNativeCodeGen),YES)
46 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
50 HS_SRCS = $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
52 ifneq "$(GhcWithHscBuiltViaC)" "YES"
53 HS_SRCS += rename/ParseIface.hs parser/Parser.hs
56 HCS = $(patsubst %.lhs, %.hc, $(patsubst %.hs, %.hc, $(HS_SRCS)))
58 # ParseIface.hs ain't part of HS_SRCS when this is on..
59 ifeq "$(GhcWithHscBuiltViaC)" "YES"
60 HCS += rename/ParseIface.hc parser/Parser.hc
64 $(patsubst %.hc, %.o, $(HCS)) \
65 parser/ctypes.o parser/hschooks.o
68 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
71 # Add misc .c helper code (used by the frontend.)
73 C_SRCS += parser/ctypes.c parser/hschooks.c
76 # Big Fudge to get around inherent problem that Makefile setup
77 # has got with 'mkdependC'.
79 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
81 # stuff you get for free in a source distribution
83 # SRC_DIST_FILES += rename/ParseIface.hs rename/Parser.hs
85 # -----------------------------------------------------------------------------
86 # Haskell compilations
89 # Compiler to use for building hsc, use the build tree
90 # driver when booting.
92 ifneq "$(GhcWithHscBuiltViaC)" "YES"
98 # magic from GNU make manual to convert a list of values
99 # into a colon-separated list
101 space:= $(empty) $(empty)
104 -cpp -fglasgow-exts -Rghc-timing \
105 -I. -IcodeGen -InativeGen -Iparser \
106 -i$(subst $(space),:,$(DIRS))
108 SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
110 SRC_HC_OPTS += -recomp $(GhcHcOpts)
112 # Special flags for particular modules
113 # The standard suffix rule for compiling a Haskell file
114 # adds these flags to the command line
117 absCSyn/PprAbsC_HC_OPTS = -H10m
119 basicTypes/IdInfo_HC_OPTS = -K2m
120 codeGen/CgCase_HC_OPTS = -fno-prune-tydecls
121 hsSyn/HsExpr_HC_OPTS = -K2m
122 main/Main_HC_OPTS = -fvia-C
123 main/Constants_HC_OPTS = -DHscIfaceFileVersion=$(HscIfaceFileVersion)
125 ifneq "$(GhcWithHscBuiltViaC)" "YES"
126 ifeq "$(GhcReportCompiles)" "YES"
127 main/Main_HC_OPTS += -syslib misc -DREPORT_TO_MOTHERLODE
131 main/CmdLineOpts_HC_OPTS = -fvia-C -K6m
132 nativeGen/PprMach_HC_OPTS = -K2m
133 nativeGen/MachMisc_HC_OPTS = -K2m -fvia-C
134 nativeGen/MachCode_HC_OPTS = -H10m
136 # Avoids Bug in 3.02, it seems
137 usageSP/UsageSPInf_HC_OPTS = -Onot
139 prelude/PrimOp_HC_OPTS = -H12m -K3m
140 parser/Lex_HC_OPTS = -K2m -H16m -fvia-C
142 rename/ParseIface_HC_OPTS += -Onot -H45m -K2m -fno-warn-incomplete-patterns
143 rename/ParseIface_HAPPY_OPTS += -g
145 parser/Parser_HC_OPTS += -Onot -H80m -optCrts-M80m -K2m -fno-warn-incomplete-patterns
146 parser/Parser_HAPPY_OPTS += -g
148 ifeq "$(TARGETPLATFORM)" "hppa1.1-hp-hpux9"
149 rename/RnMonad_HC_OPTS = -fvia-C -O2 -O2-for-C
152 rename/RnEnv_HC_OPTS = -fvia-C
153 rename/RnSource_HC_OPTS = -H12m
154 rename/RnIfaces_HC_OPTS = -H8m -fvia-C
155 rename/RnExpr_HC_OPTS = -H10m
156 rename/RnNames_HC_OPTS = -H12m
157 rename/RnMonad_HC_OPTS = -fvia-C
158 specialise/Specialise_HC_OPTS = -Onot -H12m
159 simplCore/Simplify_HC_OPTS = -H15m
160 typecheck/TcGenDeriv_HC_OPTS = -H10m
163 specialise/Specialise_HC_OPTS += -fno-prune-tydecls
164 hsSyn/HsBasic_HC_OPTS += -fno-prune-tydecls
165 simplCore/SimplMonad_HC_OPTS += -fno-prune-tydecls
166 absCSyn/AbsCSyn_HC_OPTS += -fno-prune-tydecls
167 absCSyn/AbsCUtils_HC_OPTS += -fno-prune-tydecls
168 codeGen/CgBindery_HC_OPTS += -fno-prune-tydecls
169 codeGen/CgLetNoEscape_HC_OPTS += -fno-prune-tydecls
170 codeGen/CgExpr_HC_OPTS += -fno-prune-tydecls
171 nativeGen/AbsCStixGen_HC_OPTS += -fno-prune-tydecls
174 typecheck/TcHsSyn_HC_OPTS = -H15m
178 typecheck/TcExpr_HC_OPTS = -H15m
179 typecheck/TcBinds_HC_OPTS = -H10m
181 typecheck/TcEnv_HC_OPTS = -H10m
182 utils/Argv_HC_OPTS = -fvia-C
183 utils/SST_HC_OPTS = -fvia-C
184 utils/FastString_HC_OPTS = -fvia-C
185 utils/StringBuffer_HC_OPTS = -fvia-C -fno-prune-tydecls
186 utils/Digraph_HC_OPTS = -fglasgow-exts -fvia-C
187 utils/DirUtils_HC_OPTS = -fvia-C
189 ifeq "$(alpha_HOST_ARCH)" "1"
190 # "stbu" bug in alpha native code generator...
191 basicTypes/Unique_HC_OPTS = -fvia-C
194 # flags for PrimPacked:
197 # because it contains a 'ccall strlen', which gets inlined by
198 # gcc, causing a lack of registers.
200 # -optC-funfolding-interface-threshold10
201 # To stop the definition of 'strLength', which calls strlen, getting
202 # into the interface file and spreading the -monly-3-regs virus.
203 # We need -optC here because the driver before 3.02 didn't understand
204 # the -funfolding flags.
206 utils/PrimPacked_HC_OPTS = -fvia-C -monly-3-regs -optC-funfolding-interface-threshold10
208 # Strictness analyser misbehaving in 2.10, fails to terminate on
209 # UpdAnal.lhs due to weird recursive datatype. Bug was exposed by a
210 # separate bugfix to the fixpoint finder.
211 simplStg/UpdAnal_HC_OPTS = -fno-strictness
213 # ----------------------------------------------------------------------------
216 SRC_C_OPTS += -O -I. -IcodeGen
219 # ----------------------------------------------------------------------------
222 parser/hschooks.o : parser/hschooks.c
224 $(HC) -c -o $@ $(HC_OPTS) parser/hschooks.c
227 # Interface-file parser uses Happy
228 SRC_HAPPY_OPTS += +RTS -K2m -H16m -RTS
230 rename/ParseIface.hs : rename/ParseIface.y
231 @$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
232 $(HAPPY) $(HAPPY_OPTS) -g rename/ParseIface.y
233 @chmod 444 rename/ParseIface.hs
235 parser/Parser.hs : parser/Parser.y
236 @$(RM) parser/Parser.hs parser/ParseIface.hinfo
237 $(HAPPY) $(HAPPY_OPTS) -g parser/Parser.y
238 @chmod 444 parser/Parser.hs
240 #-----------------------------------------------------------------------------
243 SRC_LD_OPTS += -no-link-chk
245 ifneq "$(GhcWithHscBuiltViaC)" "YES"
246 ifeq "$(GhcReportCompiles)" "YES"
247 SRC_LD_OPTS += -syslib misc -syslib exts
251 #-----------------------------------------------------------------------------
254 # We don't want hsc treated as an ordinary executable,
255 # but put it together with the libraries.
256 # Also don't want any interface files intstalled
258 INSTALL_LIBEXECS += hsc
260 #-----------------------------------------------------------------------------
264 # Before doing `make depend', need to build all derived Haskell source files
268 ifneq "$(GhcWithHscBuiltViaC)" "YES"
269 depend :: rename/ParseIface.hs
272 #-----------------------------------------------------------------------------
275 CLEAN_FILES += $(wildcard */*.$(way_)o */*.$(way_)hi)
277 # Extra tidy, remove the .hc files (if you've got them).
278 MAINTAINER_CLEAN_FILES += $(wildcard */*.hc) \
279 parser/Parser.hs rename/ParseIface.hs
282 #-----------------------------------------------------------------------------
285 SRC_HSTAGS_OPTS += -fglasgow-exts -cpp
286 TAGS_HS_SRCS=$(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
287 TAGS_C_SRCS=$(strip $(foreach f,$(foreach dir,$(DIRS),$(wildcard $(dir)/*.c)),$(shell if [ -w $(f) ]; then echo $(f); else echo ''; fi)))
289 #-----------------------------------------------------------------------------
290 # Include target-rule boilerplate
292 include $(TOP)/mk/target.mk
294 parser/%.o : parser/%.c