[project @ 2004-11-11 09:46:54 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 UseGhcForCc = YES
23
24 include $(TOP)/mk/boilerplate.mk
25
26 #-----------------------------------------------------------------------------
27 # Counting source code lines
28
29 USER_SRCS = $(filter-out $(DERIVED_SRCS),$(SRCS))
30 count :
31         ./count_lines $(USER_SRCS)
32
33 #-----------------------------------------------------------------------------
34 # Building ghc different ways (default is just `normal' sequential)
35
36 WAYS=$(GhcCompilerWays)
37
38 # -----------------------------------------------------------------------------
39 # Bootstrapping
40
41 # The stage1/stage2/stage3 business is quite delicate.  Here's how it works:
42
43 #  - the variable $(stage) holds the current stage number.  To build a 
44 #    particular stage, you say 'make stage=N' where N is 1, 2, or 3.
45 #    N defaults to 1.
46 #
47 #  - for stage N, object files and .hi files are placed inside 
48 #    the directory stageN, in subdirectories as per the sources.
49 #
50 #  - .hi-boot files are *linked* into the stageN tree, because in GHC 5.05+
51 #    the .hi-boot file must reside in the same place as the .hi file.
52 #
53 #  - we use explicit -o and -ohi options to direct the output from C & 
54 #    Haskell compilations.
55 #
56 #  - we generate a different .depend file for each build.  They need to be
57 #    different, because each stage might include different files: stage1
58 #    might not include GHCi, for example.  For each stage, a normal .depend
59 #    file is generated, and then post-processed to add the correct stageN/
60 #    prefix to each object and .hi filename.  The resulting .depend file
61 #    is named .depend-$(stage).  See the end of this Makefile for details.
62 #
63 #  - normal implicit rules don't work any more, because they're of the form
64 #
65 #        %.o : %.hs 
66 #
67 #    whereas we really need 
68 #
69 #        stageN/%.o : %.hs
70 #
71 #    so suffix.mk now defines the appropriate suffix rules when
72 #    $(odir) is set to a non-empty value.  Here we set $(odir) to
73 #    stage1, stage2, or stage3.
74 #
75 #  There are other plausible designs that might work, but each has different
76 #  problems:
77 #
78 #  - using -odir and -hidir: GHC <= 4.08 doesn't support -hidir, and
79 #    anyway -odir puts all the objects in one directory (strips off the
80 #    subdirectory part), which eventually forces us to use VPATH to find
81 #    the sources.  I have a really bad feeling about VPATH.
82 #
83 #  - invoke make in the stageN subdirectory.  This probably requires VPATH
84 #    too.
85 #
86 #  - create a link tree.  The problem with requiring link trees is that 
87 #    Windows doesn't support symbolic links.
88
89 boot ::
90         $(MKDIRHIER) stage$(stage)
91         for i in $(ALL_DIRS); do \
92             $(MKDIRHIER) stage$(stage)/$$i; \
93         done
94 # On Windows, we can't use symbolic links for the -hi-boot files
95 # because GHC itself is a Mingw program and does not understand
96 # symbolic links.  So we have to copy the files instead of link them.
97 # That means that if you modify a .hi-boot file in Windows, you
98 # have to to say 'make boot' again.
99 #
100 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
101 #     whereas 'cp foo baz' treats the two paths independently.
102 #     Hence the "../.." in the ln command line
103 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
104         for i in */*hi-boot*; do \
105             cp -u -f $$i stage$(stage)/$$i; \
106         done
107 else
108         for i in */*hi-boot*; do \
109             $(LN_S) -f ../../$$i stage$(stage)/$$i || true ; \
110         done
111 endif
112
113 ifeq "$(stage)" ""
114 stage=1
115 endif
116
117 ifeq "$(stage)" "1"
118 HC=$(GHC)
119 endif
120
121 ifeq "$(stage)" "2"
122 HC=$(GHC_STAGE1)
123 endif
124
125 ifeq "$(stage)" "3"
126 HC=$(GHC_STAGE2)
127 endif
128
129 stage1 ::
130         $(MAKE) stage=1
131
132 stage2 ::
133         $(MAKE) stage=2
134
135 stage3 ::
136         $(MAKE) stage=3
137
138 odir=stage$(stage)
139
140 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
141
142 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
143 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
144
145 CLEAN_FILES += $(odir)/*/*.hi
146
147 ifeq "$(stage)" "1"
148 mostlyclean clean distclean maintainer-clean ::
149         $(MAKE) $@ stage=2
150         $(MAKE) $@ stage=3
151 endif
152
153 # -----------------------------------------------------------------------------
154 #               Set HS_PROG
155
156 # Note: there have been reports of people running up against the ARG_MAX limit
157 # when linking ghc with all its constituent object files. The likely source of 
158 # the problem is that the environment is a bit too big, so a workaround could
159 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
160 # equivalent of `env' if it doesn't exist locally).
161 #
162 ifneq "$(BuildPackageGHC)" "YES"
163 ifneq "$(way)" "dll"
164 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
165 HS_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
166 else
167 HS_PROG=$(odir)/ghc$(_way)
168 endif
169 else
170 HS_PROG=$(odir)/ghc-$(ProjectVersion)
171 endif
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 "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 "cTARGETOS             = \"$(TargetOS_CPP)\"" >> $(CONFIG_HS)
196         @echo "cTARGETARCH           = \"$(TargetArch_CPP)\"" >> $(CONFIG_HS)
197         @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
198         @echo "cGhcUnregisterised    = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
199         @echo "cLeadingUnderscore    = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
200         @echo "cRAWCPP_FLAGS         = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
201         @echo "cGCC                  = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
202         @echo "cMKDLL                = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
203         @echo "cPROJECT_DIR          = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
204         @echo "cGHC_DRIVER_DIR_REL   = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
205         @echo "cGHC_TOUCHY_PGM       = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
206         @echo "cGHC_TOUCHY_DIR_REL   = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
207         @echo "cGHC_UNLIT_PGM        = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
208         @echo "cGHC_UNLIT_DIR_REL    = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
209         @echo "cGHC_MANGLER_PGM      = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
210         @echo "cGHC_MANGLER_DIR_REL  = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
211         @echo "cGHC_SPLIT_PGM        = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
212         @echo "cGHC_SPLIT_DIR_REL    = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
213         @echo "cGHC_SYSMAN_PGM       = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
214         @echo "cGHC_SYSMAN_DIR_REL   = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
215         @echo "cGHC_CP               = \"$(GHC_CP)\"" >> $(CONFIG_HS)
216         @echo "cGHC_PERL             = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
217 ifeq ($(GhcWithIlx),YES)
218         @echo "cILX2IL               = \"$(ILX2IL)\"" >> $(CONFIG_HS)
219         @echo "cILASM                = \"$(ILASM)\"" >> $(CONFIG_HS)
220 endif
221         @echo "cEnableWin32DLLs      = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
222         @echo "cCONTEXT_DIFF         = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
223         @echo "cUSER_WAY_NAMES       = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
224         @echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
225         @echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
226         @echo done.
227
228 CLEAN_FILES += $(CONFIG_HS)
229
230 # -----------------------------------------------------------------------------
231 # Set SRCS etc.
232 #
233 # First figure out ALL_DIRS, the source sub-directories
234
235 ALL_DIRS = \
236   utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
237   specialise simplCore stranal stgSyn simplStg codeGen main \
238   profiling parser cprAnalysis compMan ndpFlatten iface cmm
239
240 # Make sure we include Config.hs even if it doesn't exist yet...
241 ALL_SRCS += $(CONFIG_HS)
242
243 # HsGeneric.hs is not used just now
244 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
245
246 ifeq ($(GhcWithNativeCodeGen),YES)
247 ALL_DIRS += nativeGen
248 else
249 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
250 endif
251
252 ifeq ($(GhcWithIlx),YES)
253 ALL_DIRS += ilxGen
254 SRC_HC_OPTS += -DILX
255 endif
256
257 ifeq ($(GhcWithJavaGen),YES)
258 ALL_DIRS += javaGen
259 SRC_HC_OPTS += -DJAVA
260 endif
261
262 ifeq "$(BootingFromHc)" "YES"
263 # HC files are always from a self-booted compiler
264 bootstrapped = YES
265 compiling_with_4xx=NO
266 else
267 ifneq "$(findstring $(stage), 2 3)" ""
268 bootstrapped = YES
269 compiling_with_4xx = NO
270 else
271 bootstrapped = $(shell if (test $(GhcCanonVersion) -ge $(ProjectVersionInt) -a $(GhcPatchLevel) -ge $(ProjectPatchLevel)); then echo YES; else echo NO; fi)
272 compiling_with_4xx = $(shell if (test $(GhcCanonVersion) -lt 500); then echo YES; else echo NO; fi)
273 endif
274 endif
275
276 # -----------------------------------------------------------------------------
277 # Building a compiler with interpreter support
278 #
279 # The interpreter, GHCi interface, and Template Haskell are only
280 # enabled when we are bootstrapping with the same version of GHC, and
281 # the interpreter is supported on this platform.
282
283 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
284
285 # Yes, include the interepreter, readline, and Template Haskell extensions
286 SRC_HC_OPTS += -DGHCI -package template-haskell
287
288 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
289 SRC_HC_OPTS += -package unix
290 endif
291
292 ALL_DIRS += ghci
293
294 # Enable readline if either:
295 #   - we're building stage 1 and $(GhcHasReadline)="YES"
296 #   - we're building stage 2/3, and we have built the readline package
297 #
298 # But we don't enable readline on Windows, because readline is fairly
299 # broken there.
300 #
301 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
302 ifeq "$(stage)" "1"
303 ifeq "$(GhcHasReadline)" "YES"
304 SRC_HC_OPTS += -package readline -DUSE_READLINE
305 endif
306 else
307 ifeq "$(GhcLibsWithReadline)" "YES"
308 SRC_HC_OPTS += -package readline -DUSE_READLINE
309 endif
310 endif # stage=1
311 endif # not windows
312
313 else
314
315 # No interpreter, so exclude Template Haskell modules
316 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
317
318 endif # bootstrapped with interpreter
319
320 # -----------------------------------------------
321 # mkdependC stuff
322 #
323 # Big Fudge to get around inherent problem that Makefile setup
324 # has got with 'mkdependC'.
325
326 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
327
328 # XXX not really correct, hschooks.c actually gets include files like
329 # RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
330 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
331
332 # -----------------------------------------------------------------------------
333 #               Haskell compilations
334
335 SRC_HC_OPTS += \
336   -cpp -fglasgow-exts -fno-generics -Rghc-timing \
337   -I. -IcodeGen -InativeGen -Iparser
338
339 # Omitted:      -I$(GHC_INCLUDE_DIR)
340 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS, 
341 # to avoid the use of an explicit path in GHC source files
342 #       (include "../includes/config.h"
343 # But alas GHC 4.08 (and others for all I know) uses this very
344 # same include path when compiling the .hc files it generates.
345 # Disaster!  Then the hc file sees the GHC 5.02 (or whatever)
346 # include files.   For the moment we've reverted to using
347 # an explicit path in the .hs sources
348 #
349 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
350 # when generating dependencies. (=> it gets passed onto mkdependHS,
351 # which needs it).
352 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
353
354 # When bootstrapped, we don't make use of *any* packages
355 # (except possibly readline if GHCi is enabled, see above)
356 ifneq "$(bootstrapped)" "YES"
357 ifneq "$(mingw32_HOST_OS)" "1"
358 SRC_HC_OPTS += -package concurrent -package posix -package util
359 else
360 SRC_HC_OPTS += -package concurrent -package util
361 endif
362 endif
363
364 SRC_CC_OPTS += -Iparser -I. -O
365 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
366 SRC_HC_OPTS += -H16M
367
368 ifeq "$(BootingFromHc)" "YES"
369 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
370 endif
371
372 #       Special flags for particular modules
373 #       The standard suffix rule for compiling a Haskell file
374 #       adds these flags to the command line
375
376 # There used to be a -no-recomp flag on PrimOp, but why?
377 # It's an expensive module to recompile!
378 prelude/PrimOp_HC_OPTS          = -H80m
379
380 # because the NCG can't handle the 64-bit math in here
381 prelude/PrelRules_HC_OPTS       = -fvia-C
382
383 main/ParsePkgConf_HC_OPTS       += -fno-warn-incomplete-patterns
384 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
385 # primops on all platforms.
386 parser/Parser_HC_OPTS           += -fno-warn-incomplete-patterns -fvia-C
387
388 # Careful optimisation of the parser: we don't want to throw everything
389 # at it, because that takes too long and doesn't buy much, but we do want
390 # to inline certain key external functions, so we instruct GHC not to
391 # throw away inlinings as it would normally do in -Onot mode:
392 parser/Parser_HC_OPTS           += -Onot -fno-ignore-interface-pragmas
393
394 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
395 rename/RnMonad_HC_OPTS          =  -O2 -O2-for-C
396 endif
397
398 utils/Digraph_HC_OPTS           = -fglasgow-exts 
399
400 basicTypes/SrcLoc_HC_OPTS       = -funbox-strict-fields
401
402 ifeq "$(bootstrapped)" "YES"
403 utils/Binary_HC_OPTS            = -funbox-strict-fields
404 endif
405
406 # 4.08.2's NCG can't cope with Binary
407 ifeq "$(compiling_with_4xx)" "YES"
408 utils/Binary_HC_OPTS            += -fvia-C
409 endif
410
411 # ByteCodeItbls uses primops that the NCG doesn't support yet.
412 ghci/ByteCodeItbls_HC_OPTS      += -fvia-C
413 ghci/ByteCodeLink_HC_OPTS       += -fvia-C -monly-3-regs
414
415 # BinIface and Binary take ages to both compile and run if you don's use -O
416 main/BinIface_HC_OPTS           += -O
417 utils/Binary_HC_OPTS            += -O
418 utils/FastMutInt_HC_OPTS        += -O
419
420
421 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
422 # DriverMkDepend), causing some of them to be commoned up.  We have a fix for
423 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
424 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
425 compMan/CompManager_HC_OPTS     = -fno-cse
426 ghci/InteractiveUI_HC_OPTS      = -fno-cse
427 main/CmdLineOpts_HC_OPTS        = -fno-cse
428 main/DriverFlags_HC_OPTS        = -fno-cse
429 main/DriverMkDepend_HC_OPTS     = -fno-cse
430 main/DriverPipeline_HC_OPTS     = -fno-cse
431 main/DriverState_HC_OPTS        = -fno-cse
432 main/DriverUtil_HC_OPTS         = -fno-cse
433 main/Finder_HC_OPTS             = -fno-cse
434 main/SysTools_HC_OPTS           = -fno-cse
435
436 # The #include is vital for the via-C route, else the C
437 # compiler doesn't realise that the stcall foreign imports are indeed
438 # stdcall, and doesn't generate the Foo@8 name for them
439 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
440 main/SysTools_HC_OPTS           += '-\#include <windows.h>' '-\#include <process.h>'
441 endif
442
443 parser/Lexer_HC_OPTS += -funbox-strict-fields
444
445 # ghc_strlen percolates through so many modules that it is easier to get its
446 # prototype via a global option instead of a myriad of per-file OPTIONS
447 SRC_HC_OPTS += '-\#include "hschooks.h"'
448
449 # ----------------------------------------------------------------------------
450 #               Generate supporting stuff for prelude/PrimOp.lhs 
451 #               from prelude/primops.txt
452
453 GENPOC=$(TOP)/utils/genprimopcode/genprimopcode
454
455 PRIMOP_BITS=primop-data-decl.hs-incl \
456             primop-tag.hs-incl  \
457             primop-list.hs-incl  \
458             primop-has-side-effects.hs-incl  \
459             primop-out-of-line.hs-incl  \
460             primop-commutable.hs-incl  \
461             primop-needs-wrapper.hs-incl  \
462             primop-can-fail.hs-incl  \
463             primop-strictness.hs-incl  \
464             primop-primop-info.hs-incl
465
466 CLEAN_FILES += prelude/primops.txt
467 CLEAN_FILES += $(PRIMOP_BITS)
468
469 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
470 SRC_CPP_OPTS += ${GhcCppOpts}
471
472 ifneq "$(BootingFromHc)" "YES"
473 prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
474 endif
475
476 ifneq "$(BootingFromHc)" "YES"
477 depend :: $(PRIMOP_BITS)
478 endif
479
480 primop-data-decl.hs-incl: prelude/primops.txt
481         $(GENPOC) --data-decl          < $< > $@
482 primop-tag.hs-incl: prelude/primops.txt
483         $(GENPOC) --primop-tag         < $< > $@
484 primop-list.hs-incl: prelude/primops.txt
485         $(GENPOC) --primop-list        < $< > $@
486 primop-has-side-effects.hs-incl: prelude/primops.txt
487         $(GENPOC) --has-side-effects   < $< > $@
488 primop-out-of-line.hs-incl: prelude/primops.txt
489         $(GENPOC) --out-of-line        < $< > $@
490 primop-commutable.hs-incl: prelude/primops.txt
491         $(GENPOC) --commutable         < $< > $@
492 primop-needs-wrapper.hs-incl: prelude/primops.txt
493         $(GENPOC) --needs-wrapper      < $< > $@
494 primop-can-fail.hs-incl: prelude/primops.txt
495         $(GENPOC) --can-fail           < $< > $@
496 primop-strictness.hs-incl: prelude/primops.txt
497         $(GENPOC) --strictness         < $< > $@
498 primop-primop-info.hs-incl: prelude/primops.txt
499         $(GENPOC) --primop-primop-info < $< > $@
500
501 # Usages aren't used any more; but the generator 
502 # can still generate them if we want them back
503 primop-usage.hs-incl: prelude/primops.txt
504         $(GENPOC) --usage              < $< > $@
505
506
507 #-----------------------------------------------------------------------------
508 #               Linking
509
510 # Include libghccompat in stage1.  In stage2 onwards, all these libraries
511 # will be available from the main libraries.
512 ifeq "$(stage)" "1"
513 SRC_HC_OPTS += -i$(GHC_LIB_COMPAT_DIR)
514 SRC_LD_OPTS += -L$(GHC_LIB_COMPAT_DIR) -lghccompat
515 SRC_MKDEPENDHS_OPTS += -optdep--exclude-module=Compat.RawSystem
516 endif
517
518 SRC_LD_OPTS += -no-link-chk 
519
520 # -----------------------------------------------------------------------------
521 # create ghc-inplace, a convenient way to run ghc from the build tree...
522
523 all :: $(odir)/ghc-inplace ghc-inplace
524
525 $(odir)/ghc-inplace : $(HS_PROG)
526         @$(RM) $@
527         echo '#!/bin/sh' >>$@
528         echo exec $(FPTOOLS_TOP_ABS)/ghc/compiler/$(HS_PROG) '-B$(subst \,\\,$(FPTOOLS_TOP_ABS_PLATFORM))' '"$$@"' >>$@
529         chmod 755 $@
530
531 ghc-inplace : stage1/ghc-inplace
532         $(LN_S) -f $< $@
533
534 CLEAN_FILES += $(odir)/ghc-inplace ghc-inplace
535
536 #-----------------------------------------------------------------------------
537 #               install
538
539 # We don't want ghc treated as an ordinary executable,
540 # but put it together with the libraries.
541 # Also don't want any interface files installed
542
543 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
544
545 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
546 INSTALL_LIBEXECS += $(HS_PROG)
547 else
548 INSTALL_PROGS += $(HS_PROG)
549 endif
550
551 # ----------------------------------------------------------------------------
552 # profiling.
553
554 # rename/RnBinds_HC_OPTS += -auto-all
555 # rename/RnEnv_HC_OPTS += -auto-all
556 # rename/RnExpr_HC_OPTS += -auto-all
557 # rename/RnHiFiles_HC_OPTS += -auto-all
558 # rename/RnHsSyn_HC_OPTS += -auto-all
559 # rename/Rename_HC_OPTS += -auto-all
560 # rename/RnIfaces_HC_OPTS += -auto-all
561 # rename/RnNames_HC_OPTS += -auto-all
562 # rename/RnSource_HC_OPTS += -auto-all
563 # rename/RnTypes_HC_OPTS += -auto-all
564
565 # typecheck/Inst_HC_OPTS += -auto-all
566 # typecheck/TcBinds_HC_OPTS += -auto-all
567 # typecheck/TcClassDcl_HC_OPTS += -auto-all
568 # typecheck/TcDefaults_HC_OPTS += -auto-all
569 # typecheck/TcDeriv_HC_OPTS += -auto-all
570 # typecheck/TcEnv_HC_OPTS += -auto-all
571 # typecheck/TcExpr_HC_OPTS += -auto-all
572 # typecheck/TcForeign_HC_OPTS += -auto-all
573 # typecheck/TcGenDeriv_HC_OPTS += -auto-all
574 # typecheck/TcHsSyn_HC_OPTS += -auto-all
575 # typecheck/TcIfaceSig_HC_OPTS += -auto-all
576 # typecheck/TcInstDcls_HC_OPTS += -auto-all
577 # typecheck/TcMatches_HC_OPTS += -auto-all
578 # typecheck/TcMonoType_HC_OPTS += -auto-all
579 # typecheck/TcMType_HC_OPTS += -auto-all
580 # typecheck/TcPat_HC_OPTS += -auto-all
581 # typecheck/TcRnDriver_HC_OPTS += -auto-all
582 # #typecheck/TcRnMonad_HC_OPTS += -auto-all
583 # #typecheck/TcRnTypes_HC_OPTS += -auto-all
584 # typecheck/TcRules_HC_OPTS += -auto-all
585 # typecheck/TcSimplify_HC_OPTS += -auto-all
586 # typecheck/TcSplice_HC_OPTS += -auto-all
587 # typecheck/TcTyClsDecls_HC_OPTS += -auto-all
588 # typecheck/TcTyDecls_HC_OPTS += -auto-all
589 # typecheck/TcType_HC_OPTS += -auto-all
590 # typecheck/TcUnify_HC_OPTS += -auto-all
591
592 coreSyn/CorePrep_HC_OPTS += -auto-all
593
594 #-----------------------------------------------------------------------------
595 # Building GHC package
596
597 ifeq "$(BuildPackageGHC)" "YES"
598
599 PACKAGE = ghc
600 STANDALONE_PACKAGE = YES
601 PACKAGE_DEPS =
602
603 endif
604
605 #-----------------------------------------------------------------------------
606 #               clean
607
608 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
609
610 #-----------------------------------------------------------------------------
611 #               Include target-rule boilerplate
612
613 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
614 MKDEPENDHS_SRCS =
615 MKDEPENDC_SRCS =
616
617 # Make doesn't work this out for itself, it seems
618 parser/Parser.y : parser/Parser.y.pp
619 EXTRA_SRCS += parser/Parser.y
620
621
622 #-----------------------------------------------------------------------------
623 #               Source files for tags file generation
624 #
625 # We want to excluded derived sources, because they won't be in the source
626 # tree, which is where we are going to move the TAGS file to.a
627
628 TAGS_HS_SRCS = parser/Parser.y.pp $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
629
630
631 include $(TOP)/mk/target.mk
632
633 # -----------------------------------------------------------------------------
634 # Dependencies
635
636 MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
637
638 MKDEPENDHS=$(HC)
639
640 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
641 depend :: $(HS_SRCS) $(C_SRCS)
642         touch .depend-BASE
643 ifneq "$(BootingFromHc)" "YES"
644         $(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)
645 endif
646         $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS) 
647         $(PERL) -pe 'binmode(stdin); binmode(stdout); s@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g' <.depend-BASE >.depend-$(stage)
648 # The binmode stuff tells perl not to add stupid ^M's to the output
649
650 -include .depend-$(stage)