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