1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.42 1998/06/04 11:36:51 sof Exp $
5 include $(TOP)/mk/boilerplate.mk
7 #-----------------------------------------------------------------------------
8 # Building hsc different ways (default is just `normal' sequential)
9 WAYS=$(GhcCompilerWays)
11 #-----------------------------------------------------------------------------
14 ifeq ($(IncludeTestDirsInBuild),YES)
18 # -----------------------------------------------------------------------------
19 # Set HS_PROG, LIBRARY
20 # Setting HS_PROG and LIBRARY causes all targets in target.mk
21 # (included below) to kick in.
26 # Note: there have been reports of people running up against the ARG_MAX limit
27 # when linking hsc with all its constituent object files. The likely source of
28 # the problem is that the environment is a bit too big, so a workaround could
29 # be to do ` env PATH=$(PATH) make hsc 'to minimise the environment. (or the
30 # equivalent of `env' if it doesn't exist locally).
35 # -----------------------------------------------------------------------------
36 # Compilation history for Patrick
38 # Make the sources first, because that's what the compilation history needs
39 $(HS_PROG) :: $(HS_SRCS)
42 # -----------------------------------------------------------------------------
43 # Set SRCS, LOOPS, HCS, OBJS
45 # First figure out DIRS, the source sub-directories
46 # Then derive SRCS by looking in them
50 utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
51 specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
52 reader profiling parser
55 ifeq ($(GhcWithNativeCodeGen),YES)
58 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
62 HS_SRCS = $(SRCS_UGNHS) \
63 $(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs)) \
66 # NB: it's no good to include *.hs in the top-line wildcard, because the .hs files
67 # in parser/ may not have been created at that point.
69 HCS = $(patsubst %.lhs, %.hc, $(patsubst %.hs, %.hc, $(HS_SRCS)))
73 $(patsubst %.hc, %.o, $(HCS)) \
74 parser/hsclink.o parser/hschooks.o libhsp.a
77 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
79 SRCS_UGN = $(wildcard parser/*.ugn)
80 SRCS_UGNC = $(patsubst %.ugn, %.c, $(SRCS_UGN))
81 SRCS_UGNH = $(patsubst %.ugn, %.h, $(SRCS_UGN))
82 SRCS_UGNHS = $(patsubst parser/%.ugn, parser/U_%.hs, $(SRCS_UGN))
83 SRCS_UGN_OBJS = $(patsubst %.c, %.o, $(SRCS_UGNC))
86 # Add the generated C files to the C_SRCS, so as to let `depend'
87 # generate correct dependencies for them.
89 C_SRCS += $(SRCS_UGNC)
92 $(SRCS_UGN_OBJS) parser/hslexer.o parser/hsparser.tab.o \
93 parser/id.o parser/infix.o parser/syntax.o parser/type2context.o \
97 # stuff you get for free in a source distribution
99 SRC_DIST_FILES += rename/ParseIface.hs \
100 parser/U_tree.c parser/tree.h parser/tree.c \
101 parser/hsparser.tab.c parser/hsparser.tab.h \
104 # -----------------------------------------------------------------------------
105 # Haskell compilations
108 # Compiler to use for building hsc, use the build tree
109 # driver when booting.
111 ifneq "$(GhcWithHscBuiltViaC)" "YES"
114 HC=$(GHC_DRIVER_DIR)/ghc
117 # magic from GNU make manual to convert a list of values
118 # into a colon-separated list
120 space:= $(empty) $(empty)
123 -cpp -fglasgow-exts -Rghc-timing \
124 -I. -IcodeGen -InativeGen -Iparser \
125 -i$(subst $(space),:,$(DIRS))
127 SRC_CC_OPTS += -Iparser -I. -I$(TOP)/includes -O
129 SRC_HC_OPTS += -recomp $(GhcHcOpts)
131 # Special flags for particular modules
132 # The standard suffix rule for compiling a Haskell file
133 # adds these flags to the command line
136 absCSyn/PprAbsC_HC_OPTS = -H10m
138 basicTypes/IdInfo_HC_OPTS = -K2m
139 hsSyn/HsExpr_HC_OPTS = -K2m
140 main/Main_HC_OPTS = -fvia-C -DPROJECTVERSION=$(GhcProjectVersion)
141 main/MkIface_HC_OPTS = -DPROJECTVERSION=$(GhcProjectVersionInt)
142 main/CmdLineOpts_HC_OPTS = -fvia-C
143 nativeGen/PprMach_HC_OPTS = -K2m
144 nativeGen/MachMisc_HC_OPTS = -K2m -fvia-C
145 nativeGen/MachCode_HC_OPTS = -H10m
146 parser/UgenAll_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
147 parser/UgenUtil_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
148 parser/U_constr_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
149 parser/U_binding_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
150 parser/U_pbinding_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
151 parser/U_entidt_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
152 parser/U_list_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
153 parser/U_literal_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
154 parser/U_maybe_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
155 parser/U_either_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
156 parser/U_qid_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
157 parser/U_tree_HC_OPTS = -H12m -fvia-C '-\#include"hspincl.h"'
158 parser/U_ttype_HC_OPTS = -fvia-C '-\#include"hspincl.h"'
159 prelude/PrimOp_HC_OPTS = -H12m -K3m
160 reader/Lex_HC_OPTS = -K2m -H16m -fvia-C -DPROJECTVERSION=$(GhcProjectVersionInt)
162 # Heap was 6m with 2.10
163 reader/ReadPrefix_HC_OPTS = -fvia-C '-\#include"hspincl.h"' -H10m
165 rename/ParseIface_HC_OPTS += -Onot -H30m -fno-warn-incomplete-patterns
166 rename/ParseIface_HAPPY_OPTS += -g
168 ifeq "$(TARGETPLATFORM)" "hppa1.1-hp-hpux9"
169 rename/RnMonad_HC_OPTS = -fvia-C -O2 -O2-for-C
172 rename/RnEnv_HC_OPTS = -fvia-C
173 rename/RnSource_HC_OPTS = -H12m
174 rename/RnIfaces_HC_OPTS = -H8m -fvia-C
175 rename/RnExpr_HC_OPTS = -H10m
176 rename/RnNames_HC_OPTS = -H12m
177 rename/RnMonad_HC_OPTS = -fvia-C
178 specialise/Specialise_HC_OPTS = -Onot -H12m
179 typecheck/TcGenDeriv_HC_OPTS = -H10m
182 typecheck/TcHsSyn_HC_OPTS = -H15m
185 typecheck/TcExpr_HC_OPTS = -H15m
187 typecheck/TcEnv_HC_OPTS = -H10m
188 utils/Argv_HC_OPTS = -fvia-C
189 utils/SST_HC_OPTS = -fvia-C
190 utils/FastString_HC_OPTS = -fvia-C
191 utils/StringBuffer_HC_OPTS = -fvia-C -fno-prune-tydecls
192 utils/Digraph_HC_OPTS = -fglasgow-exts -fvia-C
193 utils/DirUtils_HC_OPTS = -fvia-C
195 # flags for PrimPacked:
198 # because it contains a 'ccall strlen', which gets inlined by
199 # gcc, causing a lack of registers.
201 # -optC-funfolding-interface-threshold10
202 # To stop the definition of 'strLength', which calls strlen, getting
203 # into the interface file and spreading the -monly-3-regs virus.
204 # We need -optC here because the driver before 3.02 didn't understand
205 # the -funfolding flags.
207 utils/PrimPacked_HC_OPTS = -fvia-C -monly-3-regs -optC-funfolding-interface-threshold10
209 # Strictness analyser misbehaving in 2.10, fails to terminate on
210 # UpdAnal.lhs due to weird recursive datatype. Bug was exposed by a
211 # separate bugfix to the fixpoint finder.
212 simplStg/UpdAnal_HC_OPTS = -fno-strictness
214 # ----------------------------------------------------------------------------
217 SRC_C_OPTS += -O -Iparser -I. -IcodeGen
220 # ----------------------------------------------------------------------------
223 # Main parser uses Yacc/Bison
224 SRC_YACC_OPTS += -d -v
225 # Suppress the generation of a default rule
229 # Want to keep the intermediate (included in src distribs).
231 .PRECIOUS: %.tab.c %.tab.h parser/hslexer.c
233 parser/hschooks.o : parser/hschooks.c
235 $(HC) -c -o $@ $(HCFLAGS) parser/hschooks.c
238 # Interface-file parser uses Happy
239 SRC_HAPPY_OPTS += +RTS -K2m -H10m -RTS
241 rename/ParseIface.hs : rename/ParseIface.y
242 @$(RM) rename/ParseIface.hs rename/ParseIface.hinfo
243 $(HAPPY) $(HAPPY_OPTS) -g rename/ParseIface.y
244 @chmod 444 rename/ParseIface.hs
246 #----------------------------------------------------------------------
248 # Building the stand-alone parser
252 hsp: parser/printtree.o parser/main.o libhsp.a
253 $(CC) -o $@ $(CC_OPTS) $^
257 #-----------------------------------------------------------------------------
260 SRC_LD_OPTS += -no-link-chk
262 #-----------------------------------------------------------------------------
265 # We don't want hsc treated as an ordinary executable,
266 # but put it together with the libraries.
267 # Also don't want any interface files intstalled
269 INSTALL_LIBEXECS += hsc hsp
271 #-----------------------------------------------------------------------------
275 # Before doing `make depend', need to build all derived Haskell source files
277 depend :: $(LOOPS) $(SRCS_UGNHS) rename/ParseIface.hs
279 #-----------------------------------------------------------------------------
282 CLEAN_FILES += $(wildcard */*.$(way_)o */*.$(way_)hi) \
283 $(SRCS_UGNC) $(SRCS_UGNH) \
285 parser/hslexer.c parser/hsparser.tab.h parser/hsparser.tab.c
287 # Extra tidy, remove the .hc files (if you've got them).
288 MAINTAINER_CLEAN_FILES += $(wildcard */*.hc)
291 #-----------------------------------------------------------------------------
294 SRC_HSTAGS_OPTS += -fglasgow-exts -cpp
295 TAGS_HS_SRCS=$(foreach dir,$(DIRS),$(wildcard $(dir)/*.lhs))
296 TAGS_C_SRCS=$(strip $(foreach f,$(foreach dir,$(DIRS),$(wildcard $(dir)/*.c)),$(shell if [ -w $(f) ]; then echo $(f); else echo ''; fi)))
298 #-----------------------------------------------------------------------------
299 # Include target-rule boilerplate
301 include $(TOP)/mk/target.mk
305 # Special extra dependencies for yukky ugen stuff
308 parser/%.o : parser/%.c $(SRCS_UGNH)
309 parser/hslexer.o : parser/hslexer.c parser/hsparser.tab.h
311 parser/hspincl.h : $(SRCS_UGNH)
312 parser/UgenAll.o : parser/hspincl.h
313 parser/UgenUtil.o : parser/hspincl.h
314 parser/U_constr.o : parser/hspincl.h
315 parser/U_binding.o : parser/hspincl.h
316 parser/U_pbinding.o : parser/hspincl.h
317 parser/U_entidt.o : parser/hspincl.h
318 parser/U_list.o : parser/hspincl.h
319 parser/U_literal.o : parser/hspincl.h
320 parser/U_maybe.o : parser/hspincl.h
321 parser/U_either.o : parser/hspincl.h
322 parser/U_qid.o : parser/hspincl.h
323 parser/U_tree.o : parser/hspincl.h
324 parser/U_ttype.o : parser/hspincl.h
325 parser/printtree.o : parser/hspincl.h
326 reader/ReadPrefix.o : parser/hspincl.h