Add hardwire-lib-paths option and make it default for inplace invocations
[ghc-hetmet.git] / compiler / Makefile
1 # -----------------------------------------------------------------------------
2 # Main 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 ifeq "$(stage)" ""
90 stage=1
91 endif
92
93 .DUMMY: stage_dir
94 stage_dirs :
95         $(MKDIRHIER) stage$(stage)
96         for i in $(ALL_DIRS); do \
97             $(MKDIRHIER) stage$(stage)/$$i; \
98         done
99
100 ifeq "$(stage) $(ghc_ge_603)" "1 YES"
101 UsingHsBoot = YES
102 else
103 ifneq "$(findstring $(stage), 2 3)" ""
104 UsingHsBoot = YES
105 else
106 UsingHsBoot = NO
107 endif
108 endif
109
110 boot :: stage_dirs
111 # On Windows, we can't use symbolic links for the -hi-boot files
112 # because GHC itself is a Mingw program and does not understand
113 # symbolic links.  So we have to copy the files instead of link them.
114 # That means that if you modify a .hi-boot file in Windows, you
115 # have to to say 'make boot' again.
116 #
117 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
118 #     whereas 'cp foo baz' treats the two paths independently.
119 #     Hence the "../.." in the ln command line
120 ifeq "$(UsingHsBoot)" "NO"
121 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
122         for i in */*hi-boot*; do \
123             cp -u -f $$i stage$(stage)/$$i; \
124         done
125 else
126         for i in */*hi-boot*; do \
127             ($(RM) -f stage$(stage)/$$i \
128                && $(LN_S) ../../$$i stage$(stage)/$$i) || true ; \
129         done
130 endif
131 endif
132
133 ifeq "$(stage)" "1"
134 HC=$(GHC)
135 endif
136
137 ifeq "$(stage)" "2"
138 HC=$(GHC_STAGE1)
139 endif
140
141 ifeq "$(stage)" "3"
142 HC=$(GHC_STAGE2)
143 endif
144
145 stage1 ::
146         $(MAKE) stage=1
147
148 stage2 ::
149         $(MAKE) stage=2
150
151 stage3 ::
152         $(MAKE) stage=3
153
154 odir=stage$(stage)
155
156 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
157
158 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
159 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
160
161 # Our standard cleaning rules don't know that we're doing our output
162 # into $(odir), so we have to augment CLEAN_FILES appropriateliy.
163
164 CLEAN_FILES += $(odir)/*/*.hi $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
165
166 ifeq "$(UsingHsBoot)" "YES"
167 CLEAN_FILES += $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
168 endif
169
170 ifeq "$(stage)" "1"
171 mostlyclean clean distclean maintainer-clean ::
172         $(MAKE) $@ stage=2
173         $(MAKE) $@ stage=3
174 endif
175
176 # -----------------------------------------------------------------------------
177 #               Set HS_PROG
178
179 # Note: there have been reports of people running up against the ARG_MAX limit
180 # when linking ghc with all its constituent object files. The likely source of 
181 # the problem is that the environment is a bit too big, so a workaround could
182 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
183 # equivalent of `env' if it doesn't exist locally).
184 #
185 ifneq "$(way)" "dll"
186 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
187 GHC_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
188 else
189 GHC_PROG=$(odir)/ghc$(_way)
190 endif
191 else
192 GHC_PROG=$(odir)/ghc-$(ProjectVersion)
193 endif
194
195 ifeq "$(stage)" "1"
196 HS_PROG = $(GHC_PROG)
197 endif
198
199 # -----------------------------------------------------------------------------
200 # Create compiler configuration
201 #
202 # The 'echo' commands simply spit the values of various make variables
203 # into Config.hs, whence they can be compiled and used by GHC itself
204
205 CONFIG_HS       = main/Config.hs
206 boot :: $(CONFIG_HS)
207
208 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
209         @$(RM) -f $(CONFIG_HS)
210         @echo "Creating $(CONFIG_HS) ... "
211         @echo "module Config where" >>$(CONFIG_HS)
212         @echo "cProjectName          = \"$(ProjectName)\"" >> $(CONFIG_HS)
213         @echo "cProjectVersion       = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
214         @echo "cProjectVersionInt    = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
215         @echo "cProjectPatchLevel    = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
216         @echo "cBooterVersion        = \"$(GhcVersion)\"" >> $(CONFIG_HS)
217         @echo "cStage                = STAGE" >> $(CONFIG_HS)
218         @echo "cHscIfaceFileVersion  = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
219         @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
220         @echo "cGhcUnregisterised    = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
221         @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $(CONFIG_HS)
222         @echo "cLeadingUnderscore    = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
223         @echo "cRAWCPP_FLAGS         = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
224         @echo "cGCC                  = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
225         @echo "cMKDLL                = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
226         @echo "cLdIsGNULd            = \"$(LdIsGNULd)\"" >> $(CONFIG_HS)
227         @echo "cLD_X                 = \"$(LD_X)\"" >> $(CONFIG_HS)
228         @echo "cPROJECT_DIR          = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
229         @echo "cGHC_DRIVER_DIR_REL   = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
230         @echo "cGHC_TOUCHY_PGM       = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
231         @echo "cGHC_TOUCHY_DIR_REL   = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
232         @echo "cGHC_UNLIT_PGM        = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
233         @echo "cGHC_UNLIT_DIR_REL    = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
234         @echo "cGHC_MANGLER_PGM      = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
235         @echo "cGHC_MANGLER_DIR_REL  = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
236         @echo "cGHC_SPLIT_PGM        = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
237         @echo "cGHC_SPLIT_DIR_REL    = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
238         @echo "cGHC_SYSMAN_PGM       = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
239         @echo "cGHC_SYSMAN_DIR_REL   = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
240         @echo "cGHC_CP               = \"$(GHC_CP)\"" >> $(CONFIG_HS)
241         @echo "cGHC_PERL             = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
242 ifeq ($(GhcWithIlx),YES)
243         @echo "cILX2IL               = \"$(ILX2IL)\"" >> $(CONFIG_HS)
244         @echo "cILASM                = \"$(ILASM)\"" >> $(CONFIG_HS)
245 endif
246         @echo "cEnableWin32DLLs      = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
247         @echo "cCONTEXT_DIFF         = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
248         @echo "cUSER_WAY_NAMES       = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
249         @echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
250         @echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
251         @echo done.
252
253 CLEAN_FILES += $(CONFIG_HS)
254
255 # -----------------------------------------------------------------------------
256 # Create platform includes
257
258 # Here we generate a little header file containing CPP symbols that GHC
259 # uses to determine which platform it is building on/for.  The platforms
260 # can differ between stage1 and stage2 if we're cross-compiling, so we
261 # need one of these header files per stage.
262
263 PLATFORM_H = ghc_boot_platform.h
264
265 stage1/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk Makefile
266         @echo "Creating $@..."
267         @$(RM) $@
268         @echo "#ifndef __PLATFORM_H__"  >$@
269         @echo "#define __PLATFORM_H__" >>$@
270         @echo >> $@
271         @echo "#define BuildPlatform_NAME  \"$(BUILDPLATFORM)\"" >> $@
272         @echo "#define HostPlatform_NAME   \"$(HOSTPLATFORM)\"" >> $@
273         @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
274         @echo >> $@
275         @echo "#define $(BuildPlatform_CPP)_BUILD       1" >> $@
276         @echo "#define $(HostPlatform_CPP)_HOST         1" >> $@
277         @echo "#define $(TargetPlatform_CPP)_TARGET     1" >> $@
278         @echo >> $@
279         @echo "#define $(BuildArch_CPP)_BUILD_ARCH      1" >> $@
280         @echo "#define $(HostArch_CPP)_HOST_ARCH        1" >> $@
281         @echo "#define $(TargetArch_CPP)_TARGET_ARCH    1" >> $@
282         @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
283         @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
284         @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
285         @echo >> $@
286         @echo "#define $(BuildOS_CPP)_BUILD_OS          1" >> $@
287         @echo "#define $(HostOS_CPP)_HOST_OS            1" >> $@
288         @echo "#define $(TargetOS_CPP)_TARGET_OS        1" >> $@  
289         @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
290         @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
291         @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
292 ifeq "$(HostOS_CPP)" "irix"
293         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
294         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
295         @echo "#endif                                    " >> $@  
296 endif
297         @echo >> $@
298         @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR  1" >> $@
299         @echo "#define $(HostVendor_CPP)_HOST_VENDOR    1" >> $@
300         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
301         @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
302         @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
303         @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
304         @echo >> $@
305         @echo "#endif /* __PLATFORM_H__ */"          >> $@
306         @echo "Done."
307
308 # For stage2 and above, the BUILD platform is the HOST of stage1, and
309 # the HOST platform is the TARGET of stage1.  The TARGET remains the same
310 # (stage1 is the cross-compiler, not stage2).
311 stage2/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk Makefile
312         @echo "Creating $@..."
313         @$(RM) $@
314         @echo "#ifndef __PLATFORM_H__"  >$@
315         @echo "#define __PLATFORM_H__" >>$@
316         @echo >> $@
317         @echo "#define BuildPlatform_NAME  \"$(HOSTPLATFORM)\"" >> $@
318         @echo "#define HostPlatform_NAME   \"$(TARGETPLATFORM)\"" >> $@
319         @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
320         @echo >> $@
321         @echo "#define $(HostPlatform_CPP)_BUILD        1" >> $@
322         @echo "#define $(TargetPlatform_CPP)_HOST               1" >> $@
323         @echo "#define $(TargetPlatform_CPP)_TARGET     1" >> $@
324         @echo >> $@
325         @echo "#define $(HostArch_CPP)_BUILD_ARCH       1" >> $@
326         @echo "#define $(TargetArch_CPP)_HOST_ARCH      1" >> $@
327         @echo "#define $(TargetArch_CPP)_TARGET_ARCH    1" >> $@
328         @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
329         @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
330         @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
331         @echo >> $@
332         @echo "#define $(HostOS_CPP)_BUILD_OS           1" >> $@
333         @echo "#define $(TargetOS_CPP)_HOST_OS          1" >> $@
334         @echo "#define $(TargetOS_CPP)_TARGET_OS        1" >> $@  
335         @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
336         @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
337         @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
338 ifeq "$(HostOS_CPP)" "irix"
339         @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS           " >> $@  
340         @echo "#define $(IRIX_MAJOR)_TARGET_OS          1" >> $@  
341         @echo "#endif                                    " >> $@  
342 endif
343         @echo >> $@
344         @echo "#define $(HostVendor_CPP)_BUILD_VENDOR   1" >> $@
345         @echo "#define $(TargetVendor_CPP)_HOST_VENDOR  1" >> $@
346         @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
347         @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
348         @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
349         @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
350         @echo >> $@
351         @echo "#endif /* __PLATFORM_H__ */"          >> $@
352         @echo "Done."
353
354 stage3/$(PLATFORM_H) : stage_dirs stage2/$(PLATFORM_H)
355         $(CP) stage2/$(PLATFORM_H) stage3/$(PLATFORM_H)
356
357 STAGE_PLATFORM_H = stage$(stage)/$(PLATFORM_H)
358
359 boot :: $(STAGE_PLATFORM_H)
360
361 SRC_HC_OPTS += -Istage$(stage)
362
363 # -----------------------------------------------------------------------------
364 # Set SRCS etc.
365 #
366 # First figure out ALL_DIRS, the source sub-directories
367
368 ALL_DIRS = \
369   utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
370   vectorise specialise simplCore stranal stgSyn simplStg codeGen main \
371   profiling parser cprAnalysis ndpFlatten iface cmm
372
373 # Make sure we include Config.hs even if it doesn't exist yet...
374 ALL_SRCS += $(CONFIG_HS)
375
376 # HsGeneric.hs is not used just now
377 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
378
379 ifeq ($(GhcWithNativeCodeGen),YES)
380 ALL_DIRS += nativeGen
381 else
382 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
383 endif
384
385 ifeq ($(GhcWithIlx),YES)
386 ALL_DIRS += ilxGen
387 SRC_HC_OPTS += -DILX
388 endif
389
390 ifeq ($(GhcWithJavaGen),YES)
391 ALL_DIRS += javaGen
392 SRC_HC_OPTS += -DJAVA
393 endif
394
395 ifeq "$(BootingFromHc)" "YES"
396 # HC files are always from a self-booted compiler
397 bootstrapped = YES
398 else
399 ifneq "$(findstring $(stage), 2 3)" ""
400 bootstrapped = YES
401 else
402 bootstrapped = NO
403 endif
404 endif
405
406 # -----------------------------------------------------------------------------
407 # Building a compiler with interpreter support
408 #
409 # The interpreter, GHCi interface, Template Haskell and Hpc are only
410 # enabled when we are bootstrapping with the same version of GHC, and
411 # the interpreter is supported on this platform.
412
413 ifeq "$(bootstrapped)" "YES"
414 SRC_HC_OPTS += -package hpc
415 PKG_DEPENDS += hpc
416 endif
417
418 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
419
420 # Yes, include the interepreter, readline, and Template Haskell extensions
421 SRC_HC_OPTS += -DGHCI -package template-haskell
422 PKG_DEPENDS += template-haskell
423
424 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
425 # or not?
426 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
427 SRC_HC_OPTS += -DGHCI_TABLES_NEXT_TO_CODE
428 endif
429
430 ifneq "$(GhcNotThreaded)" "YES"
431 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
432 SRC_HC_OPTS += -threaded
433 endif
434
435 ALL_DIRS += ghci
436
437 # If we are going to use dynamic libraries instead of .o files for ghci,
438 # we will need to always retain CAFs in the compiler.
439 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
440 # function which sets the keepCAFs flag for the RTS before any Haskell
441 # code is run.
442 ifeq "$(GhcBuildDylibs)" "YES"
443 else
444 EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c
445 endif
446
447 # Enable readline if either:
448 #   - we're building stage 1 and $(GhcHasReadline)="YES"
449 #   - we're building stage 2/3, and we have built the readline package
450 #
451 # But we don't enable readline on Windows, because readline is fairly
452 # broken there.
453 #
454 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
455 ifeq "$(stage)" "1"
456 ifeq "$(GhcHasReadline)" "YES"
457 SRC_HC_OPTS += -package readline -DUSE_READLINE
458 PKG_DEPENDS += readline
459 endif
460 else
461 -include $(FPTOOLS_TOP)/libraries/readline/config.mk
462 # readline's config.mk sets PACKAGE, which we don't want here
463 PACKAGE=
464 ifeq "$(READLINE_BUILD_PACKAGE)" "yes"
465 SRC_HC_OPTS += -package readline -DUSE_READLINE
466 PKG_DEPENDS += readline
467 endif
468 endif # stage=1
469 endif # not windows
470
471 else
472
473 # No interpreter, so exclude Template Haskell modules
474 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
475
476 endif # bootstrapped with interpreter
477
478 # -----------------------------------------------
479 # mkdependC stuff
480 #
481 # Big Fudge to get around inherent problem that Makefile setup
482 # has got with 'mkdependC'.
483
484 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
485
486 # XXX not really correct, hschooks.c actually gets include files like
487 # RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
488 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
489
490 # -----------------------------------------------------------------------------
491 #               Haskell compilations
492
493 SRC_HC_OPTS += \
494   -cpp -fglasgow-exts -fno-generics -Rghc-timing \
495   -I. -Iparser
496
497 # Omitted:      -I$(GHC_INCLUDE_DIR)
498 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS, 
499 # to avoid the use of an explicit path in GHC source files
500 #       (include "../includes/config.h"
501 # But alas GHC 4.08 (and others for all I know) uses this very
502 # same include path when compiling the .hc files it generates.
503 # Disaster!  Then the hc file sees the GHC 5.02 (or whatever)
504 # include files.   For the moment we've reverted to using
505 # an explicit path in the .hs sources
506 #
507 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
508 # when generating dependencies. (=> it gets passed onto mkdependHS,
509 # which needs it).
510 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
511
512 # We need System.Posix (or Posix when ghc < 6.2)
513 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
514 ifeq "$(bootstrapped)" "YES"
515 SRC_HC_OPTS += -package Win32
516 PKG_DEPENDS += Win32
517 endif
518 else
519 ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
520 SRC_HC_OPTS += -package posix
521 else
522 SRC_HC_OPTS += -package unix
523 PKG_DEPENDS += unix
524 endif
525 endif
526
527 # We use the Cabal package in stages 2/3 only; in stage 1 we're using
528 # the libcompat library which provides the Cabal modules.
529 ifneq "$(stage)" "1"
530 SRC_HC_OPTS += -package Cabal
531 PKG_DEPENDS += Cabal
532 endif
533
534 ifeq "$(ghc_ge_603)" "YES"
535 # Ignore lang, to avoid potential clash with the Generics module if
536 # lang happens to be a dependency of some exposed package in the local
537 # GHC installation (eg. wxHaskell did this around 6.4).
538 SRC_HC_OPTS += -ignore-package lang
539 endif
540
541 SRC_CC_OPTS += -Iparser -I. -O
542 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
543 SRC_HC_OPTS += -H16M
544
545 ifeq "$(BootingFromHc)" "YES"
546 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
547 endif
548
549 #       Special flags for particular modules
550 #       The standard suffix rule for compiling a Haskell file
551 #       adds these flags to the command line
552
553 # There used to be a -no-recomp flag on PrimOp, but why?
554 # It's an expensive module to recompile!
555 prelude/PrimOp_HC_OPTS          = -H80m
556
557
558 main/ParsePkgConf_HC_OPTS       += -fno-warn-incomplete-patterns
559 parser/Parser_HC_OPTS           += -fno-warn-incomplete-patterns
560
561 ifeq "$(ghc_ge_603)" "NO"
562 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
563 # primops on all platforms.
564 parser/Parser_HC_OPTS           += -fvia-C
565 # because the NCG can't handle the 64-bit math in here
566 prelude/PrelRules_HC_OPTS       += -fvia-C
567 # ByteCodeItbls uses primops that the NCG doesn't support.
568 ghci/ByteCodeItbls_HC_OPTS      += -fvia-C
569 ghci/ByteCodeLink_HC_OPTS       += -fvia-C -monly-3-regs
570 endif
571
572 # Careful optimisation of the parser: we don't want to throw everything
573 # at it, because that takes too long and doesn't buy much, but we do want
574 # to inline certain key external functions, so we instruct GHC not to
575 # throw away inlinings as it would normally do in -Onot mode:
576 parser/Parser_HC_OPTS           += -Onot -fno-ignore-interface-pragmas
577
578 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
579 rename/RnMonad_HC_OPTS          =  -O2 -O2-for-C
580 endif
581
582 utils/Digraph_HC_OPTS           = -fglasgow-exts 
583
584 basicTypes/SrcLoc_HC_OPTS       = -funbox-strict-fields
585
586 # We always optimise some low-level modules, otherwise performance of
587 # a non-optimised compiler is severely affected.
588 main/BinIface_HC_OPTS           += -O
589 utils/Binary_HC_OPTS            += -O -funbox-strict-fields
590 utils/FastMutInt_HC_OPTS        += -O
591 utils/Encoding_HC_OPTS          += -O
592 utils/StringBuffer_HC_OPTS      += -O -funbox-strict-fields
593 utils/FastString_HC_OPTS        += -O -funbox-strict-fields
594
595 # ---- Profiling ----
596 #simplCore/Simplify_HC_OPTS = -auto-all
597 #simplCore/SimplEnv_HC_OPTS = -auto-all
598 #simplCore/SimplUtils_HC_OPTS = -auto-all
599
600 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
601 # DriverMkDepend), causing some of them to be commoned up.  We have a fix for
602 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
603 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
604 ghci/InteractiveUI_HC_OPTS      = -fno-cse
605 main/CmdLineOpts_HC_OPTS        = -fno-cse
606 main/DriverMkDepend_HC_OPTS     = -fno-cse
607 main/DriverPipeline_HC_OPTS     = -fno-cse
608 main/Finder_HC_OPTS             = -fno-cse
609 main/SysTools_HC_OPTS           = -fno-cse
610 main/StaticFlags_HC_OPTS        = -fno-cse
611
612 # The #include is vital for the via-C route, else the C
613 # compiler doesn't realise that the stcall foreign imports are indeed
614 # stdcall, and doesn't generate the Foo@8 name for them
615 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
616 main/SysTools_HC_OPTS           += '-\#include <windows.h>' '-\#include <process.h>'
617 endif
618
619 parser/Lexer_HC_OPTS += -funbox-strict-fields
620
621 # ghc_strlen percolates through so many modules that it is easier to get its
622 # prototype via a global option instead of a myriad of per-file OPTIONS
623 SRC_HC_OPTS += '-\#include "cutils.h"'
624
625 # ----------------------------------------------------------------------------
626 #               Generate supporting stuff for prelude/PrimOp.lhs 
627 #               from prelude/primops.txt
628
629 PRIMOP_BITS=primop-data-decl.hs-incl \
630             primop-tag.hs-incl  \
631             primop-list.hs-incl  \
632             primop-has-side-effects.hs-incl  \
633             primop-out-of-line.hs-incl  \
634             primop-commutable.hs-incl  \
635             primop-needs-wrapper.hs-incl  \
636             primop-can-fail.hs-incl  \
637             primop-strictness.hs-incl  \
638             primop-primop-info.hs-incl
639
640 CLEAN_FILES += prelude/primops.txt
641 CLEAN_FILES += $(PRIMOP_BITS)
642
643 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
644 SRC_CPP_OPTS += ${GhcCppOpts}
645
646 ifneq "$(BootingFromHc)" "YES"
647 prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
648 endif
649
650 ifneq "$(BootingFromHc)" "YES"
651 depend :: $(PRIMOP_BITS)
652 endif
653
654 # This is an ugly hack: we need stage1/$(PLATFORM_H) built before we
655 # preprocess primops.txt.pp, but we don't want to just add that
656 # dependency because we don't want $(PLATFORM_H) built during normal
657 # operations, because we don't have have dependencies from the .hs
658 # sources on it, and we don't want those dependencies because that
659 # would cause everything to be rebuilt every time the Makefile
660 # changed.  So here we add the required dependency only when making
661 # boot or depend:
662 ifneq "$(findstring boot, $(MAKECMDGOALS))$(findstring depend, $(MAKECMDGOALS))" ""
663 prelude/primops.txt.pp : stage1/$(PLATFORM_H)
664 endif
665
666 primop-data-decl.hs-incl: prelude/primops.txt
667         $(GENPRIMOP) --data-decl          < $< > $@
668 primop-tag.hs-incl: prelude/primops.txt
669         $(GENPRIMOP) --primop-tag         < $< > $@
670 primop-list.hs-incl: prelude/primops.txt
671         $(GENPRIMOP) --primop-list        < $< > $@
672 primop-has-side-effects.hs-incl: prelude/primops.txt
673         $(GENPRIMOP) --has-side-effects   < $< > $@
674 primop-out-of-line.hs-incl: prelude/primops.txt
675         $(GENPRIMOP) --out-of-line        < $< > $@
676 primop-commutable.hs-incl: prelude/primops.txt
677         $(GENPRIMOP) --commutable         < $< > $@
678 primop-needs-wrapper.hs-incl: prelude/primops.txt
679         $(GENPRIMOP) --needs-wrapper      < $< > $@
680 primop-can-fail.hs-incl: prelude/primops.txt
681         $(GENPRIMOP) --can-fail           < $< > $@
682 primop-strictness.hs-incl: prelude/primops.txt
683         $(GENPRIMOP) --strictness         < $< > $@
684 primop-primop-info.hs-incl: prelude/primops.txt
685         $(GENPRIMOP) --primop-primop-info < $< > $@
686
687 # Usages aren't used any more; but the generator 
688 # can still generate them if we want them back
689 primop-usage.hs-incl: prelude/primops.txt
690         $(GENPRIMOP) --usage              < $< > $@
691
692
693 #-----------------------------------------------------------------------------
694 #               Linking
695
696 # Include libghccompat in stage1 only.  In stage2 onwards, all these
697 # libraries will be available from the main libraries.
698
699 ifeq "$(stage)" "1"
700 include $(GHC_COMPAT_DIR)/compat.mk
701 endif
702
703 SRC_LD_OPTS += -no-link-chk
704
705 # -----------------------------------------------------------------------------
706 # create ghc-inplace, a convenient way to run ghc from the build tree...
707 # See comments in $(FPTOOLS_TOP)/utils/ghc-pkg/Makefile for why we use
708 # a real binary here rather than a shell script.
709
710 INPLACE_HS   = $(odir)/ghc-inplace.hs
711 INPLACE_PROG = $(odir)/ghc-inplace$(exeext)
712 EXCLUDED_SRCS += $(INPLACE_HS)
713
714 # FPTOOLS_TOP_ABS platform uses backslashes, at least on Cygwin, but that
715 # will go wrong when we use it in a Haskell string below.
716 TOP_ABS=$(subst \\,/,$(FPTOOLS_TOP_ABS_PLATFORM))
717
718 ifeq "$(stage)" "1"
719 EnvImport = System.Environment
720 GetArgs = getArgs
721 else
722 EnvImport = GHC.Environment
723 GetArgs = getFullArgs
724 endif
725
726 $(INPLACE_HS): Makefile $(FPTOOLS_TOP)/mk/config.mk
727         echo "import System.Cmd; import $(EnvImport); import System.Exit" > $@
728         echo "main = do args <- $(GetArgs); rawSystem \"$(TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)\" (\"-B$(TOP_ABS)\":\"-fhardwire-lib-paths\":args) >>= exitWith" >> $@
729
730 $(INPLACE_PROG): $(INPLACE_HS)
731         $(HC) --make $< -o $@
732
733 all :: $(INPLACE_PROG)
734
735 CLEAN_FILES += $(INPLACE_HS) $(INPLACE_PROG)
736
737 ifeq "$(stage)" "1"
738 ghc-inplace : $(INPLACE_PROG)
739         $(RM) -f $@ && $(LN_S) $< $@
740
741 all :: ghc-inplace
742
743 CLEAN_FILES += ghc-inplace
744 endif
745
746 #-----------------------------------------------------------------------------
747 #               install
748
749 # We don't want ghc treated as an ordinary executable,
750 # but put it together with the libraries.
751 # Also don't want any interface files installed
752
753 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
754
755 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
756 INSTALL_LIBEXECS += $(GHC_PROG)
757 else
758 INSTALL_PROGS += $(GHC_PROG)
759 endif
760
761 # ----------------------------------------------------------------------------
762 # profiling.
763
764 # rename/RnBinds_HC_OPTS += -auto-all
765 # rename/RnEnv_HC_OPTS += -auto-all
766 # rename/RnExpr_HC_OPTS += -auto-all
767 # rename/RnHiFiles_HC_OPTS += -auto-all
768 # rename/RnHsSyn_HC_OPTS += -auto-all
769 # rename/Rename_HC_OPTS += -auto-all
770 # rename/RnIfaces_HC_OPTS += -auto-all
771 # rename/RnNames_HC_OPTS += -auto-all
772 # rename/RnSource_HC_OPTS += -auto-all
773 # rename/RnTypes_HC_OPTS += -auto-all
774
775 # typecheck/Inst_HC_OPTS += -auto-all
776 # typecheck/TcBinds_HC_OPTS += -auto-all
777 # typecheck/TcClassDcl_HC_OPTS += -auto-all
778 # typecheck/TcDefaults_HC_OPTS += -auto-all
779 # typecheck/TcDeriv_HC_OPTS += -auto-all
780 # typecheck/TcEnv_HC_OPTS += -auto-all
781 # typecheck/TcExpr_HC_OPTS += -auto-all
782 # typecheck/TcForeign_HC_OPTS += -auto-all
783 # typecheck/TcGenDeriv_HC_OPTS += -auto-all
784 # typecheck/TcHsSyn_HC_OPTS += -auto-all
785 # typecheck/TcIfaceSig_HC_OPTS += -auto-all
786 # typecheck/TcInstDcls_HC_OPTS += -auto-all
787 # typecheck/TcMatches_HC_OPTS += -auto-all
788 # typecheck/TcMonoType_HC_OPTS += -auto-all
789 # typecheck/TcMType_HC_OPTS += -auto-all
790 # typecheck/TcPat_HC_OPTS += -auto-all
791 # typecheck/TcRnDriver_HC_OPTS += -auto-all
792 # #typecheck/TcRnMonad_HC_OPTS += -auto-all
793 # #typecheck/TcRnTypes_HC_OPTS += -auto-all
794 # typecheck/TcRules_HC_OPTS += -auto-all
795 # typecheck/TcSimplify_HC_OPTS += -auto-all
796 # typecheck/TcSplice_HC_OPTS += -auto-all
797 # typecheck/TcTyClsDecls_HC_OPTS += -auto-all
798 # typecheck/TcTyDecls_HC_OPTS += -auto-all
799 # typecheck/TcType_HC_OPTS += -auto-all
800 # typecheck/TcUnify_HC_OPTS += -auto-all
801
802 coreSyn/CorePrep_HC_OPTS += -auto-all
803 # parser/Parser_HC_OPTS += -fasm
804
805 #-----------------------------------------------------------------------------
806 # Building the GHC package
807
808 # The GHC package is made from the stage 2 build and later.
809 # Fortunately the package build system framework more or less does the
810 # right thing for us here.
811
812 ifneq "$(findstring $(stage), 2 3)" ""
813 PACKAGE = ghc
814 HIERARCHICAL_LIB = NO
815 VERSION = $(ProjectVersion)
816 PKG_DEPENDS += base haskell98
817 PACKAGE_CPP_OPTS += -DPKG_DEPENDS='$(PKG_DEPENDS)'
818 PACKAGE_CPP_OPTS += -DSTAGE='"$(stage)"'
819
820 # Omit Main from the library, the client will want to plug their own Main in
821 LIBOBJS = $(filter-out $(odir)/main/Main.o $(odir)/parser/hschooks.o, $(OBJS))
822
823 # disable splitting: it won't really help with GHC, and the specialised
824 # build system for compiler/ isn't set up to handle it.
825 SplitObjs = NO
826
827 # the package build system likes to set WAYS=$(GhcLibWays), but we don't 
828 # really want to build the whole of GHC multiple ways... if you do,
829 # set GhcCompilerWays instead.
830 GhcLibWays = $(GhcCompilerWays)
831
832 # override $(GhcLibHcOpts): we want GhcStage2HcOpts to take precedence
833 GhcLibHcOpts =
834
835 # override default definition of HS_IFACES so we can add $(odir)
836 HS_IFACES   = $(addsuffix .$(way_)hi,$(basename $(HS_OBJS)))
837
838 # Haddock can't handle recursive modules currently, so we disable it for now.
839 HADDOCK_DOCS = NO
840
841 # Tell package.mk not to set $(HC)
842 NO_SET_HC = YES
843
844 # The stage 2 GHC binary itself is built by  compiling main/Main.hs 
845 # (the same as used in stage 1) against the GHC package.
846 #
847 # This is done by compiling Main.hs separately and linking it with 
848 # -package ghc.  This is done using a separate Makefile, Makefile.ghcbin
849 # Why? See comments in Makefile.ghcbin
850
851 all :: $(GHC_PROG)
852
853 # The stage 2 and stage 3 package.conf.in files are different, because they
854 # point to either the stage2/ or stage3/ dirs in import-dirs.  Hence before
855 # linking the ghc binary we must install the correct version of the package
856 # configuration.  Yeuch... maybe one day this will all be done more cleanly.
857 STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
858
859 ifeq "$(GhcBuildDylibs)" "YES"
860 ifeq "$(darwin_TARGET_OS)" "1"
861 GhcLibraryName=libHS$(PACKAGE)$(_way)_dyn.dylib
862 else
863 GhcLibraryName=libHS$(PACKAGE)$(_way)_dyn.so
864 endif
865 else
866 GhcLibraryName=libHS$(PACKAGE)$(_way).a
867 endif
868
869 ifneq "$(DOING_BIN_DIST)" "YES"
870 $(GHC_PROG) : $(GhcLibraryName) main/Main.hs
871         $(RM) package.conf.inplace
872         $(RM) $(STAMP_PKG_CONF)
873         $(MAKE) $(STAMP_PKG_CONF)
874         $(MAKE) -f Makefile.ghcbin $(MFLAGS) HS_PROG=$(GHC_PROG) $@
875 endif
876
877 # Propagate standard targets to Makefile.ghcbin
878 docs runtests $(BOOT_TARGET) TAGS clean distclean mostlyclean maintainer-clean $(INSTALL_TARGET) $(INSTALL_DOCS_TARGET) html chm HxS ps dvi txt::
879         $(MAKE) -f Makefile.ghcbin $(MFLAGS) $@
880 endif
881
882 #-----------------------------------------------------------------------------
883 #               clean
884
885 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
886
887 #-----------------------------------------------------------------------------
888 #               Include target-rule boilerplate
889
890 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
891 MKDEPENDHS_SRCS =
892 MKDEPENDC_SRCS =
893
894 # Make doesn't work this out for itself, it seems
895 parser/Parser.y : parser/Parser.y.pp
896 EXTRA_SRCS += parser/Parser.y
897
898
899 #-----------------------------------------------------------------------------
900 #               Source files for tags file generation
901 #
902 # We want to excluded derived sources, because they won't be in the source
903 # tree, which is where we are going to move the TAGS file to.a
904
905 TAGS_HS_SRCS = parser/Parser.y.pp $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
906
907 include $(TOP)/mk/target.mk
908
909 $(odir)/main/Config.$(way_)o: SRC_HC_OPTS+=-DSTAGE='"$(stage)"'
910
911 #-----------------------------------------------------------------------------
912 # binary-dist
913
914 ifeq "$(DOING_BIN_DIST)" "YES"
915 # This is derived from the sources when we are in a source tree, but we
916 # don't have any sources in a bindist, so we have to shortcut it
917 HS_IFACES := $(wildcard stage$(stage)/*/*.hi)
918 endif
919
920 binary-dist:
921         $(INSTALL_DIR)                         $(BIN_DIST_DIR)/compiler
922         $(INSTALL_DIR)                         $(BIN_DIST_DIR)/compiler/stage$(stage)
923         echo "stage=$(stage)"                > $(BIN_DIST_DIR)/compiler/Makefile
924         cat Makefile                        >> $(BIN_DIST_DIR)/compiler/Makefile
925         $(INSTALL_DATA)    package.conf.in     $(BIN_DIST_DIR)/compiler/
926         set -e; for d in stage$(stage)/*/; do $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler/$$d; done
927         set -e; for f in $(HS_IFACES); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
928 ifneq "$(INSTALL_LIBS)" ""
929         set -e; for f in $(INSTALL_LIBS); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
930 endif
931 ifneq "$(INSTALL_PROGS)" ""
932         set -e; for f in $(INSTALL_PROGS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
933 endif
934 ifneq "$(INSTALL_LIBEXECS)" ""
935         set -e; for f in $(INSTALL_LIBEXECS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
936 endif
937
938 # -----------------------------------------------------------------------------
939 # Explicit dependencies
940
941 # Some .hs files #include other source files, but since ghc -M doesn't spit out
942 # these dependencies we have to include them manually.
943
944 # We don't add dependencies on HsVersions.h, ghcautoconf.h, or ghc_boot_platform.h,
945 # because then modifying one of these files would force recompilation of everything,
946 # which is probably not what you want.  However, it does mean you have to be
947 # careful to recompile stuff you need if you reconfigure or change HsVersions.h.
948
949 # Aargh, these don't work properly anyway, because GHC's recompilation checker
950 # just reports "compilation NOT required".  Do we have to add -no-recomp for each
951 # of these .hs files?  I haven't done anything about this yet.
952
953 $(odir)/codeGen/Bitmap.$(way_)o         :  ../includes/MachDeps.h
954 $(odir)/codeGen/CgCallConv.$(way_)o     :  ../includes/StgFun.h
955 $(odir)/codeGen/CgProf.$(way_)o         :  ../includes/MachDeps.h
956 $(odir)/codeGen/CgProf.$(way_)o         :  ../includes/Constants.h
957 $(odir)/codeGen/CgProf.$(way_)o         :  ../includes/DerivedConstants.h
958 $(odir)/codeGen/CgTicky.$(way_)o        :  ../includes/DerivedConstants.h
959 $(odir)/codeGen/ClosureInfo.$(way_)o    :  ../includes/MachDeps.h
960 $(odir)/codeGen/SMRep.$(way_)o          :  ../includes/MachDeps.h
961 $(odir)/codeGen/SMRep.$(way_)o          :  ../includes/ClosureTypes.h
962 $(odir)/ghci/ByteCodeAsm.$(way_)o       :  ../includes/Bytecodes.h
963 $(odir)/ghci/ByteCodeFFI.$(way_)o       :  nativeGen/NCG.h
964 $(odir)/ghci/ByteCodeInstr.$(way_)o     :  ../includes/MachDeps.h
965 $(odir)/ghci/ByteCodeItbls.$(way_)o     :  ../includes/ClosureTypes.h
966 $(odir)/ghci/ByteCodeItbls.$(way_)o     :  nativeGen/NCG.h
967 $(odir)/main/Constants.$(way_)o         :  ../includes/MachRegs.h
968 $(odir)/main/Constants.$(way_)o         :  ../includes/Constants.h
969 $(odir)/main/Constants.$(way_)o         :  ../includes/MachDeps.h
970 $(odir)/main/Constants.$(way_)o         :  ../includes/DerivedConstants.h
971 $(odir)/main/Constants.$(way_)o         :  ../includes/GHCConstants.h
972 $(odir)/nativeGen/AsmCodeGen.$(way_)o   :  nativeGen/NCG.h
973 $(odir)/nativeGen/MachCodeGen.$(way_)o  :  nativeGen/NCG.h
974 $(odir)/nativeGen/MachCodeGen.$(way_)o  : ../includes/MachDeps.h
975 $(odir)/nativeGen/MachInstrs.$(way_)o   :  nativeGen/NCG.h
976 $(odir)/nativeGen/MachRegs.$(way_)o     :  nativeGen/NCG.h
977 $(odir)/nativeGen/MachRegs.$(way_)o     :  ../includes/MachRegs.h
978 $(odir)/nativeGen/PositionIndependentCode.$(way_)o :  nativeGen/NCG.h
979 $(odir)/nativeGen/PprMach.$(way_)o      :  nativeGen/NCG.h
980 $(odir)/nativeGen/RegAllocInfo.$(way_)o :  nativeGen/NCG.h
981 $(odir)/typecheck/TcForeign.$(way_)o    :  nativeGen/NCG.h
982 $(odir)/utils/Binary.$(way_)o           :  ../includes/MachDeps.h
983 $(odir)/utils/FastMutInt.$(way_)o       :  ../includes/MachDeps.h
984
985 # -----------------------------------------------------------------------------
986 # Dependencies
987
988 MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
989
990 MKDEPENDHS=$(HC)
991
992 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
993 depend :: $(STAGE_PLATFORM_H) $(HS_SRCS) $(C_SRCS)
994         touch .depend-BASE
995 ifneq "$(BootingFromHc)" "YES"
996         $(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)
997 endif
998         $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS) 
999         $(PERL) -pe 'binmode(stdin); binmode(stdout); s@^(\S*\.o)@stage$(stage)/$$1@g; s@(\S*\.hi)@stage$(stage)/$$1@g; s@^.*/compat.*$$@@g;' <.depend-BASE >.depend-$(stage)
1000 # The binmode stuff tells perl not to add stupid ^M's to the output
1001 #
1002 # The /lib/compat replacement is to workaround a bug in the
1003 # -optdep--exclude-module flag in GHC 6.4.  It is not required for any
1004 # other version of GHC, but doesn't do any harm.
1005
1006 -include .depend-$(stage)