[project @ 2003-01-10 10:55:24 by simonmar]
[ghc-hetmet.git] / ghc / compiler / Makefile
1 # -----------------------------------------------------------------------------
2 # Main ghc/compiler Makefile
3
4 # Targets:
5 #
6 #       all     builds stage1 compiler
7 #
8 #       boot stage=N   generate build dirs and dependencies for stage N.
9 #                      NB. Must be done before 'make stageN'.
10 #                      NB. Cannot 'make boot stage=2' until stage1 has
11 #                          been built (similarly for stage3).
12 #
13 #       stage1  (or stage=1) builds stage1 compiler
14 #       stage2  (or stage=2) builds stage2 compiler
15 #       stage3  (or stage=3) builds stage3 compiler
16 #
17
18 TOP = ..
19
20 # Use GHC for compiling C bits (NB. must be before boilerplate include)
21 #
22 ifneq "$(BootingFromHc)" "YES"
23 UseGhcForCc = YES
24 endif
25
26 include $(TOP)/mk/boilerplate.mk
27
28 #-----------------------------------------------------------------------------
29 # Counting source code lines
30
31 USER_SRCS = $(filter-out $(DERIVED_SRCS),$(SRCS))
32 count :
33         ./count_lines $(USER_SRCS)
34
35 #-----------------------------------------------------------------------------
36 # Building ghc different ways (default is just `normal' sequential)
37
38 WAYS=$(GhcCompilerWays)
39
40 # -----------------------------------------------------------------------------
41 # Bootstrapping
42
43 # The stage1/stage2/stage3 business is quite delicate.  Here's how it works:
44
45 #  - the variable $(stage) holds the current stage number.  To build a 
46 #    particular stage, you say 'make stage=N' where N is 1, 2, or 3.
47 #    N defaults to 1.
48 #
49 #  - for stage N, object files and .hi files are placed inside 
50 #    the directory stageN, in subdirectories as per the sources.
51 #
52 #  - .hi-boot files are *linked* into the stageN tree, because in GHC 5.05+
53 #    the .hi-boot file must reside in the same place as the .hi file.
54 #
55 #  - we use explicit -o and -ohi options to direct the output from C & 
56 #    Haskell compilations.
57 #
58 #  - we generate a different .depend file for each build.  They need to be
59 #    different, because each stage might include different files: stage1
60 #    might not include GHCi, for example.  For each stage, a normal .depend
61 #    file is generated, and then post-processed to add the correct stageN/
62 #    prefix to each object and .hi filename.  The resulting .depend file
63 #    is named .depend-$(stage).  See the end of this Makefile for details.
64 #
65 #  - normal implicit rules don't work any more, because they're of the form
66 #
67 #        %.o : %.hs 
68 #
69 #    whereas we really need 
70 #
71 #        stageN/%.o : %.hs
72 #
73 #    so suffix.mk now defines the appropriate suffix rules when
74 #    $(odir) is set to a non-empty value.  Here we set $(odir) to
75 #    stage1, stage2, or stage3.
76 #
77 #  There are other plausible designs that might work, but each has different
78 #  problems:
79 #
80 #  - using -odir and -hidir: GHC <= 4.08 doesn't support -hidir, and
81 #    anyway -odir puts all the objects in one directory (strips off the
82 #    subdirectory part), which eventually forces us to use VPATH to find
83 #    the sources.  I have a really bad feeling about VPATH.
84 #
85 #  - invoke make in the stageN subdirectory.  This probably requires VPATH
86 #    too.
87 #
88 #  - create a link tree.  The problem with requiring link trees is that 
89 #    Windows doesn't support symbolic links.
90
91 boot ::
92         $(MKDIRHIER) stage$(stage)
93         for i in $(ALL_DIRS); do \
94             $(MKDIRHIER) stage$(stage)/$$i; \
95         done
96 # On Windows, we can't use symbolic links for the -hi-boot files
97 # because GHC itself is a Mingw program and does not understand
98 # symbolic links.  So we have to copy the files instead of link them.
99 # That means that if you modify a .hi-boot file in Windows, you
100 # have to to say 'make boot' again.
101 #
102 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
103 #     whereas 'cp foo baz' treats the two paths independently.
104 #     Hence the "../.." in the ln command line
105 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
106         for i in */*hi-boot*; do \
107             cp -f $$i stage$(stage)/$$i; \
108         done
109 else
110         for i in */*hi-boot*; do \
111             $(LN_S) -f ../../$$i stage$(stage)/$$i; \
112         done
113 endif
114
115 ifeq "$(stage)" ""
116 stage=1
117 endif
118
119 ifeq "$(stage)" "1"
120 HC=$(GHC)
121 endif
122
123 ifeq "$(stage)" "2"
124 HC=$(GHC_STAGE1)
125 endif
126
127 ifeq "$(stage)" "3"
128 HC=$(GHC_STAGE2)
129 endif
130
131 stage1 ::
132         $(MAKE) stage=1
133
134 stage2 ::
135         $(MAKE) stage=2
136
137 stage3 ::
138         $(MAKE) stage=3
139
140 odir=stage$(stage)
141
142 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
143
144 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
145 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
146
147 CLEAN_FILES += $(odir)/*/*.hi
148
149 ifeq "$(stage)" "1"
150 mostlyclean clean distclean maintainer-clean ::
151         $(MAKE) $@ stage=2
152         $(MAKE) $@ stage=3
153 endif
154
155 # -----------------------------------------------------------------------------
156 #               Set HS_PROG
157
158 # Note: there have been reports of people running up against the ARG_MAX limit
159 # when linking ghc with all its constituent object files. The likely source of 
160 # the problem is that the environment is a bit too big, so a workaround could
161 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
162 # equivalent of `env' if it doesn't exist locally).
163 #
164 ifneq "$(way)" "dll"
165 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
166 HS_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
167 else
168 HS_PROG=$(odir)/ghc$(_way)
169 endif
170 else
171 HS_PROG=$(odir)/ghc-$(ProjectVersion)
172 endif
173
174 # -----------------------------------------------------------------------------
175 # Create compiler configuration
176 #
177 # The 'echo' commands simply spit the values of various make variables
178 # into Config.hs, whence they can be compiled and used by GHC itself
179
180 CONFIG_HS       = main/Config.hs
181 boot :: $(CONFIG_HS)
182
183 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
184         @$(RM) -f $(CONFIG_HS)
185         @echo -n "Creating $(CONFIG_HS) ... "
186         @echo "module Config where" >>$(CONFIG_HS)
187         @echo "cProjectName          = \"$(ProjectName)\"" >> $(CONFIG_HS)
188         @echo "cProjectVersion       = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
189         @echo "cProjectVersionInt    = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
190         @echo "cProjectPatchLevel    = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
191         @echo "cBooterVersion        = \"$(GhcVersion)\"" >> $(CONFIG_HS)
192         @echo "cHscIfaceFileVersion  = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
193         @echo "cHOSTPLATFORM         = \"$(HOSTPLATFORM)\"" >> $(CONFIG_HS)
194         @echo "cTARGETPLATFORM       = \"$(TARGETPLATFORM)\"" >> $(CONFIG_HS)
195         @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
196         @echo "cGhcUnregisterised    = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
197         @echo "cLeadingUnderscore    = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
198         @echo "cRAWCPP_FLAGS         = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
199         @echo "cGCC                  = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
200         @echo "cMKDLL                = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
201         @echo "cPROJECT_DIR          = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
202         @echo "cGHC_DRIVER_DIR_REL   = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
203         @echo "cGHC_TOUCHY_PGM       = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
204         @echo "cGHC_TOUCHY_DIR_REL   = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
205         @echo "cGHC_UNLIT_PGM        = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
206         @echo "cGHC_UNLIT_DIR_REL    = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
207         @echo "cGHC_MANGLER_PGM      = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
208         @echo "cGHC_MANGLER_DIR_REL  = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
209         @echo "cGHC_SPLIT_PGM        = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
210         @echo "cGHC_SPLIT_DIR_REL    = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
211         @echo "cGHC_SYSMAN_PGM       = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
212         @echo "cGHC_SYSMAN_DIR_REL   = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
213         @echo "cGHC_CP               = \"$(GHC_CP)\"" >> $(CONFIG_HS)
214         @echo "cGHC_PERL             = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
215 ifeq ($(GhcWithIlx),YES)
216         @echo "cILX2IL               = \"$(ILX2IL)\"" >> $(CONFIG_HS)
217         @echo "cILASM                = \"$(ILASM)\"" >> $(CONFIG_HS)
218 endif
219         @echo "cEnableWin32DLLs      = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
220         @echo "cCONTEXT_DIFF         = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
221         @echo "cHaveLibGmp           = \"$(HaveLibGmp)\"" >> $(CONFIG_HS)
222         @echo "cUSER_WAY_NAMES       = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
223         @echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
224         @echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
225         @echo done.
226
227 CLEAN_FILES += $(CONFIG_HS)
228
229 # -----------------------------------------------------------------------------
230 # Set SRCS etc.
231 #
232 # First figure out ALL_DIRS, the source sub-directories
233
234 ALL_DIRS = \
235   utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
236   specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \
237   profiling parser usageSP cprAnalysis compMan ndpFlatten
238
239 # Make sure we include Config.hs even if it doesn't exist yet...
240 ALL_SRCS += $(CONFIG_HS)
241
242 # HsGeneric.hs is not used just now
243 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
244
245 ifeq ($(GhcWithNativeCodeGen),YES)
246 ALL_DIRS += nativeGen
247 else
248 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
249 endif
250
251 ifeq ($(GhcWithIlx),YES)
252 ALL_DIRS += ilxGen
253 SRC_HC_OPTS += -DILX
254 endif
255
256 ifeq ($(GhcWithJavaGen),YES)
257 ALL_DIRS += javaGen
258 SRC_HC_OPTS += -DJAVA
259 endif
260
261 ifeq "$(BootingFromHc)" "YES"
262 # HC files are always from a self-booted compiler
263 bootstrapped = YES
264 compiling_with_4xx=NO
265 else
266 ifneq "$(findstring $(stage), 2 3)" ""
267 bootstrapped = YES
268 compiling_with_4xx = NO
269 else
270 bootstrapped = $(shell if (test $(GhcCanonVersion) -ge $(ProjectVersionInt) -a $(GhcPatchLevel) -ge $(ProjectPatchLevel)); then echo YES; else echo NO; fi)
271 compiling_with_4xx = $(shell if (test $(GhcCanonVersion) -lt 500); then echo YES; else echo NO; fi)
272 endif
273 endif
274
275 # Only include GHCi if we're bootstrapping with at least version 411
276 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
277 # Yes, include the interepreter, readline, and Template Haskell extensions
278 SRC_HC_OPTS += -DGHCI -package haskell-src
279 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
280 SRC_HC_OPTS += -package unix
281 ifeq "$(GhcLibsWithReadline)" "YES"
282 SRC_HC_OPTS += -package readline 
283 endif
284 endif
285 ALL_DIRS += ghci
286 else
287 # No interpreter, so exclude Template Haskell modules
288 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
289 endif 
290
291 # There are some C files to include in HS_PROG, so add these to HS_OBJS
292 HS_OBJS  += $(C_OBJS)
293
294 # -----------------------------------------------
295 # mkdependC stuff
296 #
297 # Big Fudge to get around inherent problem that Makefile setup
298 # has got with 'mkdependC'.
299
300 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
301
302 # XXX not really correct, hschooks.c actually gets include files like
303 # RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
304 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
305
306 # -----------------------------------------------------------------------------
307 #               Haskell compilations
308
309 SRC_HC_OPTS += \
310   -cpp -fglasgow-exts -Rghc-timing \
311   -I. -IcodeGen -InativeGen -Iparser
312
313 # Omitted:      -I$(GHC_INCLUDE_DIR)
314 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS, 
315 # to avoid the use of an explicit path in GHC source files
316 #       (include "../includes/config.h"
317 # But alas GHC 4.08 (and others for all I know) uses this very
318 # same include path when compiling the .hc files it generates.
319 # Disaster!  Then the hc file sees the GHC 5.02 (or whatever)
320 # include files.   For the moment we've reverted to using
321 # an explicit path in the .hs sources
322 #
323 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
324 # when generating dependencies. (=> it gets passed onto mkdependHS,
325 # which needs it).
326 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
327
328 # When bootstrapped, we don't make use of *any* packages
329 # (except possibly readline if GHCi is enabled, see above)
330 ifneq "$(bootstrapped)" "YES"
331 ifneq "$(mingw32_HOST_OS)" "1"
332 SRC_HC_OPTS += -package concurrent -package posix -package util
333 else
334 SRC_HC_OPTS += -package concurrent -package util
335 endif
336 endif
337
338 SRC_CC_OPTS += -Iparser -I. -O
339 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
340 SRC_HC_OPTS += -H16M
341
342 ifeq "$(BootingFromHc)" "YES"
343 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
344 endif
345
346 #       Special flags for particular modules
347 #       The standard suffix rule for compiling a Haskell file
348 #       adds these flags to the command line
349
350 # not sure if this is required --SDM
351 main/Main_HC_OPTS               = -fvia-C
352
353 prelude/PrimOp_HC_OPTS          = -no-recomp -H80m
354
355 # because the NCG can't handle the 64-bit math in here
356 prelude/PrelRules_HC_OPTS       = -fvia-C
357
358 main/ParsePkgConf_HC_OPTS       += -fno-warn-incomplete-patterns
359 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
360 # primops on all platforms.
361 parser/Parser_HC_OPTS           += -Onot -fno-warn-incomplete-patterns -fvia-C
362
363 # The latest GHC version doesn't have a -K option yet, and it doesn't
364 # seem to be necessary anymore for the modules below.
365 ifeq "$(compiling_with_4xx)" "YES"
366 parser/Parser_HC_OPTS           += -K2m
367 endif
368
369 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
370 rename/RnMonad_HC_OPTS          =  -O2 -O2-for-C
371 endif
372
373 utils/StringBuffer_HC_OPTS      = -fvia-C -fno-prune-tydecls
374 utils/Digraph_HC_OPTS           = -fglasgow-exts 
375
376 ifeq "$(bootstrapped)" "YES"
377 utils/Binary_HC_OPTS            = -funbox-strict-fields
378 endif
379
380 # 4.08.2's NCG can't cope with Binary
381 ifeq "$(compiling_with_4xx)" "YES"
382 utils/Binary_HC_OPTS            += -fvia-C
383 endif
384
385 # ByteCodeItbls uses primops that the NCG doesn't support yet.
386 ghci/ByteCodeItbls_HC_OPTS      = -fvia-C
387 ghci/ByteCodeLink_HC_OPTS       = -fvia-C -monly-3-regs
388
389 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
390 # DriverMkDepend), causing some of them to be commoned up.  We have a fix for
391 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
392 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
393 compMan/CompManager_HC_OPTS     = -fno-cse
394 ghci/InteractiveUI_HC_OPTS      = -fno-cse
395 main/CmdLineOpts_HC_OPTS        = -fno-cse
396 main/DriverFlags_HC_OPTS        = -fno-cse
397 main/DriverMkDepend_HC_OPTS     = -fno-cse
398 main/DriverPipeline_HC_OPTS     = -fno-cse
399 main/DriverState_HC_OPTS        = -fno-cse
400 main/DriverUtil_HC_OPTS         = -fno-cse
401 main/Finder_HC_OPTS             = -fno-cse
402 main/SysTools_HC_OPTS           = -fno-cse
403
404 # The #include is vital for the via-C route, else the C
405 # compiler doesn't realise that the stcall foreign imports are indeed
406 # stdcall, and doesn't generate the Foo@8 name for them
407 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
408 main/SysTools_HC_OPTS           += '-\#include <windows.h>' '-\#include <process.h>'
409 endif
410
411 # ghc_strlen percolates through so many modules that it is easier to get its
412 # prototype via a global option instead of a myriad of per-file OPTIONS
413 SRC_HC_OPTS += '-\#include "hschooks.h"'
414
415 # ----------------------------------------------------------------------------
416 #               Generate supporting stuff for prelude/PrimOp.lhs 
417 #               from prelude/primops.txt
418
419 GENPOC=$(TOP)/utils/genprimopcode/genprimopcode
420
421 PRIMOP_BITS=primop-data-decl.hs-incl \
422             primop-tag.hs-incl  \
423             primop-list.hs-incl  \
424             primop-has-side-effects.hs-incl  \
425             primop-out-of-line.hs-incl  \
426             primop-commutable.hs-incl  \
427             primop-needs-wrapper.hs-incl  \
428             primop-can-fail.hs-incl  \
429             primop-strictness.hs-incl  \
430             primop-usage.hs-incl  \
431             primop-primop-info.hs-incl
432
433 CLEAN_FILES += prelude/primops.txt
434 CLEAN_FILES += $(PRIMOP_BITS)
435
436 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR) -traditional
437 SRC_CPP_OPTS += ${GhcCppOpts}
438
439 ifneq "$(BootingFromHc)" "YES"
440 prelude/PrimOp.lhs prelude/PrimOp.o: $(PRIMOP_BITS)
441 endif
442
443 ifneq "$(BootingFromHc)" "YES"
444 depend :: $(PRIMOP_BITS)
445 endif
446
447 primop-data-decl.hs-incl: prelude/primops.txt
448         $(GENPOC) --data-decl          < $< > $@
449 primop-tag.hs-incl: prelude/primops.txt
450         $(GENPOC) --primop-tag         < $< > $@
451 primop-list.hs-incl: prelude/primops.txt
452         $(GENPOC) --primop-list        < $< > $@
453 primop-has-side-effects.hs-incl: prelude/primops.txt
454         $(GENPOC) --has-side-effects   < $< > $@
455 primop-out-of-line.hs-incl: prelude/primops.txt
456         $(GENPOC) --out-of-line        < $< > $@
457 primop-commutable.hs-incl: prelude/primops.txt
458         $(GENPOC) --commutable         < $< > $@
459 primop-needs-wrapper.hs-incl: prelude/primops.txt
460         $(GENPOC) --needs-wrapper      < $< > $@
461 primop-can-fail.hs-incl: prelude/primops.txt
462         $(GENPOC) --can-fail           < $< > $@
463 primop-strictness.hs-incl: prelude/primops.txt
464         $(GENPOC) --strictness         < $< > $@
465 primop-usage.hs-incl: prelude/primops.txt
466         $(GENPOC) --usage              < $< > $@
467 primop-primop-info.hs-incl: prelude/primops.txt
468         $(GENPOC) --primop-primop-info < $< > $@
469
470
471
472 # ----------------------------------------------------------------------------
473 #               Parsers/lexers
474
475 SRC_HAPPY_OPTS += +RTS -K2m -H16m -RTS  $(GHC_HAPPY_OPTS)
476
477 #-----------------------------------------------------------------------------
478 #               Linking
479
480 SRC_LD_OPTS += -no-link-chk 
481
482 # -----------------------------------------------------------------------------
483 # create ghc-inplace, a convenient way to run ghc from the build tree...
484
485 all :: $(odir)/ghc-inplace ghc-inplace
486
487 $(odir)/ghc-inplace : $(HS_PROG)
488         @$(RM) $@
489         echo '#!/bin/sh' >>$@
490         echo exec $(FPTOOLS_TOP_ABS)/ghc/compiler/$(HS_PROG) '-B$(subst \,\\,$(FPTOOLS_TOP_ABS_PLATFORM))' '"$$@"' >>$@
491         chmod 755 $@
492
493 ghc-inplace : stage1/ghc-inplace
494         $(LN_S) -f $< $@
495
496 CLEAN_FILES += $(odir)/ghc-inplace ghc-inplace
497
498 #-----------------------------------------------------------------------------
499 #               install
500
501 # We don't want ghc treated as an ordinary executable,
502 # but put it together with the libraries.
503 # Also don't want any interface files installed
504
505 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
506
507 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
508 INSTALL_LIBEXECS += $(HS_PROG)
509 else
510 INSTALL_PROGS += $(HS_PROG)
511 endif
512
513 # ----------------------------------------------------------------------------
514 # profiling.
515
516 # rename/Rename_HC_OPTS += -auto-all
517 # rename/RnEnv_HC_OPTS += -auto-all
518 # rename/RnHiFiles_HC_OPTS += -auto-all
519 # rename/RnIfaces_HC_OPTS += -auto-all
520 # rename/RnSource_HC_OPTS += -auto-all
521 # rename/RnBinds_HC_OPTS += -auto-all
522 # rename/RnExpr_HC_OPTS += -auto-all
523 # rename/RnHsSyn_HC_OPTS += -auto-all
524 # rename/RnNames_HC_OPTS += -auto-all
525 # rename/RnTypes_HC_OPTS += -auto-all
526
527 #-----------------------------------------------------------------------------
528 #               clean
529
530 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
531
532 #-----------------------------------------------------------------------------
533 #               Include target-rule boilerplate
534
535 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
536 MKDEPENDHS_SRCS =
537 MKDEPENDC_SRCS =
538
539 include $(TOP)/mk/target.mk
540
541 # -----------------------------------------------------------------------------
542 # Dependencies
543
544 MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
545
546 MKDEPENDHS=$(HC)
547
548 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
549 depend :: $(HS_SRCS) $(C_SRCS)
550         $(MKDEPENDHS) -M -optdep-f -optdep.depend-BASE $(foreach way,$(WAYS),-optdep-s -optdep$(way)) $(foreach obj,$(MKDEPENDHS_OBJ_SUFFICES),-osuf $(obj)) $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(MKDEPENDHS_HC_OPTS)) $(HS_SRCS)
551         $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS) 
552         $(PERL) -pe 'binmode(stdin); binmode(stdout); s@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g' <.depend-BASE >.depend-$(stage)
553 # The binmode stuff tells perl not to add stupid ^M's to the output
554
555 -include .depend-$(stage)