Add a GhcDebugged build setting, for whether GHC is linked with -debug
[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 ifeq "$(GhcThreaded)$(GhcProfiled)" "YESYES"
27 $(error Cannot make GHC both threaded and profiled)
28 endif
29
30 #-----------------------------------------------------------------------------
31 # Counting source code lines
32
33 USER_SRCS = $(filter-out $(DERIVED_SRCS),$(SRCS))
34 count :
35         ./count_lines $(USER_SRCS)
36
37 # -----------------------------------------------------------------------------
38 # Bootstrapping
39
40 # The stage1/stage2/stage3 business is quite delicate.  Here's how it works:
41
42 #  - the variable $(stage) holds the current stage number.  To build a 
43 #    particular stage, you say 'make stage=N' where N is 1, 2, or 3.
44 #    N defaults to 1.
45 #
46 #  - for stage N, object files and .hi files are placed inside 
47 #    the directory stageN, in subdirectories as per the sources.
48 #
49 #  - .hi-boot files are *linked* into the stageN tree, because in GHC 5.05+
50 #    the .hi-boot file must reside in the same place as the .hi file.
51 #
52 #  - we use explicit -o and -ohi options to direct the output from C & 
53 #    Haskell compilations.
54 #
55 #  - we generate a different .depend file for each build.  They need to be
56 #    different, because each stage might include different files: stage1
57 #    might not include GHCi, for example.  For each stage, a normal .depend
58 #    file is generated, and then post-processed to add the correct stageN/
59 #    prefix to each object and .hi filename.  The resulting .depend file
60 #    is named .depend-$(stage).  See the end of this Makefile for details.
61 #
62 #  - normal implicit rules don't work any more, because they're of the form
63 #
64 #        %.o : %.hs 
65 #
66 #    whereas we really need 
67 #
68 #        stageN/%.o : %.hs
69 #
70 #    so suffix.mk now defines the appropriate suffix rules when
71 #    $(odir) is set to a non-empty value.  Here we set $(odir) to
72 #    stage1, stage2, or stage3.
73 #
74 #  There are other plausible designs that might work, but each has different
75 #  problems:
76 #
77 #  - using -odir and -hidir: GHC <= 4.08 doesn't support -hidir, and
78 #    anyway -odir puts all the objects in one directory (strips off the
79 #    subdirectory part), which eventually forces us to use VPATH to find
80 #    the sources.  I have a really bad feeling about VPATH.
81 #
82 #  - invoke make in the stageN subdirectory.  This probably requires VPATH
83 #    too.
84 #
85 #  - create a link tree.  The problem with requiring link trees is that 
86 #    Windows doesn't support symbolic links.
87
88 ifeq "$(stage)" ""
89 stage=1
90 endif
91
92 .DUMMY: stage_dir
93 stage_dirs :
94         $(MKDIRHIER) stage$(stage)
95         for i in $(ALL_DIRS); do \
96             $(MKDIRHIER) stage$(stage)/$$i; \
97         done
98
99 ifeq "$(stage) $(ghc_ge_603)" "1 YES"
100 UsingHsBoot = YES
101 else
102 ifneq "$(findstring $(stage), 2 3)" ""
103 UsingHsBoot = YES
104 else
105 UsingHsBoot = NO
106 endif
107 endif
108
109 boot :: stage_dirs
110 # On Windows, we can't use symbolic links for the -hi-boot files
111 # because GHC itself is a Mingw program and does not understand
112 # symbolic links.  So we have to copy the files instead of link them.
113 # That means that if you modify a .hi-boot file in Windows, you
114 # have to to say 'make boot' again.
115 #
116 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
117 #     whereas 'cp foo baz' treats the two paths independently.
118 #     Hence the "../.." in the ln command line
119 ifeq "$(UsingHsBoot)" "NO"
120 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
121         for i in */*hi-boot*; do \
122             cp -u -f $$i stage$(stage)/$$i; \
123         done
124 else
125         for i in */*hi-boot*; do \
126             ($(RM) -f stage$(stage)/$$i \
127                && $(LN_S) ../../$$i stage$(stage)/$$i) || true ; \
128         done
129 endif
130 endif
131
132 ifeq "$(stage)" "1"
133 HC=$(GHC)
134 endif
135
136 ifeq "$(stage)" "2"
137 HC=$(GHC_STAGE1)
138 endif
139
140 ifeq "$(stage)" "3"
141 HC=$(GHC_STAGE2)
142 endif
143
144 stage1 ::
145         $(MAKE) stage=1
146
147 stage2 ::
148         $(MAKE) stage=2
149
150 stage3 ::
151         $(MAKE) stage=3
152
153 odir=stage$(stage)
154
155 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
156
157 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
158 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
159
160 # Our standard cleaning rules don't know that we're doing our output
161 # into $(odir), so we have to augment CLEAN_FILES appropriateliy.
162
163 CLEAN_FILES += $(odir)/*/*.hi $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
164
165 ifeq "$(UsingHsBoot)" "YES"
166 CLEAN_FILES += $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
167 endif
168
169 ifeq "$(stage)" "1"
170 mostlyclean clean distclean maintainer-clean ::
171         $(MAKE) $@ stage=2
172         $(MAKE) $@ stage=3
173 endif
174
175 # -----------------------------------------------------------------------------
176 #               Set HS_PROG
177
178 # Note: there have been reports of people running up against the ARG_MAX limit
179 # when linking ghc with all its constituent object files. The likely source of 
180 # the problem is that the environment is a bit too big, so a workaround could
181 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
182 # equivalent of `env' if it doesn't exist locally).
183 #
184 ifneq "$(way)" "dll"
185 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
186 GHC_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
187 else
188 GHC_PROG=$(odir)/ghc$(_way)
189 endif
190 else
191 GHC_PROG=$(odir)/ghc-$(ProjectVersion)
192 endif
193
194 ifeq "$(stage)" "1"
195 HS_PROG = $(GHC_PROG)
196 endif
197
198 # -----------------------------------------------------------------------------
199 # Create compiler configuration
200 #
201 # The 'echo' commands simply spit the values of various make variables
202 # into Config.hs, whence they can be compiled and used by GHC itself
203
204 CONFIG_HS       = main/Config.hs
205 boot :: $(CONFIG_HS)
206
207 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk
208         @$(RM) -f $(CONFIG_HS)
209         @echo "Creating $(CONFIG_HS) ... "
210         @echo "module Config where" >>$(CONFIG_HS)
211         @echo "cProjectName          = \"$(ProjectName)\"" >> $(CONFIG_HS)
212         @echo "cProjectVersion       = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
213         @echo "cProjectVersionInt    = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
214         @echo "cProjectPatchLevel    = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
215         @echo "cBooterVersion        = \"$(GhcVersion)\"" >> $(CONFIG_HS)
216         @echo "cStage                = STAGE" >> $(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
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
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   vectorise 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, Template Haskell and Hpc 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 "$(bootstrapped)" "YES"
413 SRC_HC_OPTS += -package hpc -package bytestring
414 PKG_DEPENDS += hpc bytestring
415 endif
416
417 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
418
419 # Yes, include the interepreter, readline, and Template Haskell extensions
420 SRC_HC_OPTS += -DGHCI -package template-haskell
421 PKG_DEPENDS += template-haskell
422
423 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
424 # or not?
425 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
426 SRC_HC_OPTS += -DGHCI_TABLES_NEXT_TO_CODE
427 endif
428
429 ifeq "$(GhcThreaded)" "YES"
430 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
431 SRC_LD_OPTS += -threaded
432 endif
433 ifeq "$(GhcProfiled)" "YES"
434 SRC_LD_OPTS += -prof
435 endif
436 ifeq "$(GhcDebugged)" "YES"
437 SRC_LD_OPTS += -debug
438 endif
439
440 ALL_DIRS += ghci
441
442 # If we are going to use dynamic libraries instead of .o files for ghci,
443 # we will need to always retain CAFs in the compiler.
444 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
445 # function which sets the keepCAFs flag for the RTS before any Haskell
446 # code is run.
447 ifeq "$(GhcBuildDylibs)" "YES"
448 else
449 EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c
450 endif
451
452 # Enable readline if either:
453 #   - we're building stage 1 and $(GhcHasReadline)="YES"
454 #   - we're building stage 2/3, and we have built the readline package
455 #
456 # But we don't enable readline on Windows, because readline is fairly
457 # broken there.
458 #
459 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
460 ifeq "$(stage)" "1"
461 ifeq "$(GhcHasReadline)" "YES"
462 SRC_HC_OPTS += -package readline -DUSE_READLINE
463 PKG_DEPENDS += readline
464 endif
465 else
466 -include $(FPTOOLS_TOP)/libraries/readline/config.mk
467 # readline's config.mk sets PACKAGE, which we don't want here
468 PACKAGE=
469 ifeq "$(READLINE_BUILD_PACKAGE)" "yes"
470 SRC_HC_OPTS += -package readline -DUSE_READLINE
471 PKG_DEPENDS += readline
472 endif
473 endif # stage=1
474 endif # not windows
475
476 else
477
478 # No interpreter, so exclude Template Haskell modules
479 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
480
481 endif # bootstrapped with interpreter
482
483 # -----------------------------------------------
484 # mkdependC stuff
485 #
486 # Big Fudge to get around inherent problem that Makefile setup
487 # has got with 'mkdependC'.
488
489 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
490
491 # XXX not really correct, hschooks.c actually gets include files like
492 # RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
493 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
494
495 # -----------------------------------------------------------------------------
496 #               Haskell compilations
497
498 SRC_HC_OPTS += \
499   -cpp -fglasgow-exts -fno-generics -Rghc-timing \
500   -I. -Iparser
501
502 # Omitted:      -I$(GHC_INCLUDE_DIR)
503 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS, 
504 # to avoid the use of an explicit path in GHC source files
505 #       (include "../includes/config.h"
506 # But alas GHC 4.08 (and others for all I know) uses this very
507 # same include path when compiling the .hc files it generates.
508 # Disaster!  Then the hc file sees the GHC 5.02 (or whatever)
509 # include files.   For the moment we've reverted to using
510 # an explicit path in the .hs sources
511 #
512 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
513 # when generating dependencies. (=> it gets passed onto mkdependHS,
514 # which needs it).
515 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
516
517 # We need System.Posix (or Posix when ghc < 6.2)
518 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
519 ifeq "$(bootstrapped)" "YES"
520 SRC_HC_OPTS += -package Win32
521 PKG_DEPENDS += Win32
522 endif
523 else
524 ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
525 SRC_HC_OPTS += -package posix
526 else
527 SRC_HC_OPTS += -package unix
528 PKG_DEPENDS += unix
529 endif
530 endif
531
532 # We use the Cabal package in stages 2/3 only; in stage 1 we're using
533 # the libcompat library which provides the Cabal modules.
534 ifneq "$(stage)" "1"
535 SRC_HC_OPTS += -package Cabal
536 PKG_DEPENDS += Cabal
537 endif
538
539 ifeq "$(ghc_ge_603)" "YES"
540 # Ignore lang, to avoid potential clash with the Generics module if
541 # lang happens to be a dependency of some exposed package in the local
542 # GHC installation (eg. wxHaskell did this around 6.4).
543 SRC_HC_OPTS += -ignore-package lang
544 endif
545
546 SRC_CC_OPTS += -Iparser -I. -O
547 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
548 SRC_HC_OPTS += -H16M
549
550 ifeq "$(BootingFromHc)" "YES"
551 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
552 endif
553
554 #       Special flags for particular modules
555 #       The standard suffix rule for compiling a Haskell file
556 #       adds these flags to the command line
557
558 # There used to be a -no-recomp flag on PrimOp, but why?
559 # It's an expensive module to recompile!
560 prelude/PrimOp_HC_OPTS          = -H80m
561
562
563 main/ParsePkgConf_HC_OPTS       += -fno-warn-incomplete-patterns
564 parser/Parser_HC_OPTS           += -fno-warn-incomplete-patterns
565
566 ifeq "$(ghc_ge_603)" "NO"
567 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
568 # primops on all platforms.
569 parser/Parser_HC_OPTS           += -fvia-C
570 # because the NCG can't handle the 64-bit math in here
571 prelude/PrelRules_HC_OPTS       += -fvia-C
572 # ByteCodeItbls uses primops that the NCG doesn't support.
573 ghci/ByteCodeItbls_HC_OPTS      += -fvia-C
574 ghci/ByteCodeLink_HC_OPTS       += -fvia-C -monly-3-regs
575 endif
576
577 # Careful optimisation of the parser: we don't want to throw everything
578 # at it, because that takes too long and doesn't buy much, but we do want
579 # to inline certain key external functions, so we instruct GHC not to
580 # throw away inlinings as it would normally do in -Onot mode:
581 parser/Parser_HC_OPTS           += -Onot -fno-ignore-interface-pragmas
582
583 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
584 rename/RnMonad_HC_OPTS          =  -O2 -O2-for-C
585 endif
586
587 utils/Digraph_HC_OPTS           = -fglasgow-exts 
588
589 basicTypes/SrcLoc_HC_OPTS       = -funbox-strict-fields
590
591 # We always optimise some low-level modules, otherwise performance of
592 # a non-optimised compiler is severely affected.
593 main/BinIface_HC_OPTS           += -O
594 utils/Binary_HC_OPTS            += -O -funbox-strict-fields
595 utils/FastMutInt_HC_OPTS        += -O
596 utils/Encoding_HC_OPTS          += -O
597 utils/StringBuffer_HC_OPTS      += -O -funbox-strict-fields
598 utils/FastString_HC_OPTS        += -O -funbox-strict-fields
599
600 # ---- Profiling ----
601 #simplCore/Simplify_HC_OPTS = -auto-all
602 #simplCore/SimplEnv_HC_OPTS = -auto-all
603 #simplCore/SimplUtils_HC_OPTS = -auto-all
604
605 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
606 # DriverMkDepend), causing some of them to be commoned up.  We have a fix for
607 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
608 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
609 ghci/InteractiveUI_HC_OPTS      = -fno-cse
610 main/CmdLineOpts_HC_OPTS        = -fno-cse
611 main/DriverMkDepend_HC_OPTS     = -fno-cse
612 main/DriverPipeline_HC_OPTS     = -fno-cse
613 main/Finder_HC_OPTS             = -fno-cse
614 main/SysTools_HC_OPTS           = -fno-cse
615 main/StaticFlags_HC_OPTS        = -fno-cse
616
617 # The #include is vital for the via-C route, else the C
618 # compiler doesn't realise that the stcall foreign imports are indeed
619 # stdcall, and doesn't generate the Foo@8 name for them
620 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
621 main/SysTools_HC_OPTS           += '-\#include <windows.h>' '-\#include <process.h>'
622 endif
623
624 parser/Lexer_HC_OPTS += -funbox-strict-fields
625
626 # ghc_strlen percolates through so many modules that it is easier to get its
627 # prototype via a global option instead of a myriad of per-file OPTIONS
628 SRC_HC_OPTS += '-\#include "cutils.h"'
629
630 # ----------------------------------------------------------------------------
631 #               Generate supporting stuff for prelude/PrimOp.lhs 
632 #               from prelude/primops.txt
633
634 PRIMOP_BITS=primop-data-decl.hs-incl \
635             primop-tag.hs-incl  \
636             primop-list.hs-incl  \
637             primop-has-side-effects.hs-incl  \
638             primop-out-of-line.hs-incl  \
639             primop-commutable.hs-incl  \
640             primop-needs-wrapper.hs-incl  \
641             primop-can-fail.hs-incl  \
642             primop-strictness.hs-incl  \
643             primop-primop-info.hs-incl
644
645 CLEAN_FILES += prelude/primops.txt
646 CLEAN_FILES += $(PRIMOP_BITS)
647
648 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
649 SRC_CPP_OPTS += ${GhcCppOpts}
650
651 ifneq "$(BootingFromHc)" "YES"
652 prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
653 endif
654
655 ifneq "$(BootingFromHc)" "YES"
656 depend :: $(PRIMOP_BITS)
657 endif
658
659 # This is an ugly hack: we need stage1/$(PLATFORM_H) built before we
660 # preprocess primops.txt.pp, but we don't want to just add that
661 # dependency because we don't want $(PLATFORM_H) built during normal
662 # operations, because we don't have have dependencies from the .hs
663 # sources on it, and we don't want those dependencies because that
664 # would cause everything to be rebuilt every time the Makefile
665 # changed.  So here we add the required dependency only when making
666 # boot or depend:
667 ifneq "$(findstring boot, $(MAKECMDGOALS))$(findstring depend, $(MAKECMDGOALS))" ""
668 prelude/primops.txt.pp : stage1/$(PLATFORM_H)
669 endif
670
671 primop-data-decl.hs-incl: prelude/primops.txt
672         $(GENPRIMOP) --data-decl          < $< > $@
673 primop-tag.hs-incl: prelude/primops.txt
674         $(GENPRIMOP) --primop-tag         < $< > $@
675 primop-list.hs-incl: prelude/primops.txt
676         $(GENPRIMOP) --primop-list        < $< > $@
677 primop-has-side-effects.hs-incl: prelude/primops.txt
678         $(GENPRIMOP) --has-side-effects   < $< > $@
679 primop-out-of-line.hs-incl: prelude/primops.txt
680         $(GENPRIMOP) --out-of-line        < $< > $@
681 primop-commutable.hs-incl: prelude/primops.txt
682         $(GENPRIMOP) --commutable         < $< > $@
683 primop-needs-wrapper.hs-incl: prelude/primops.txt
684         $(GENPRIMOP) --needs-wrapper      < $< > $@
685 primop-can-fail.hs-incl: prelude/primops.txt
686         $(GENPRIMOP) --can-fail           < $< > $@
687 primop-strictness.hs-incl: prelude/primops.txt
688         $(GENPRIMOP) --strictness         < $< > $@
689 primop-primop-info.hs-incl: prelude/primops.txt
690         $(GENPRIMOP) --primop-primop-info < $< > $@
691
692 # Usages aren't used any more; but the generator 
693 # can still generate them if we want them back
694 primop-usage.hs-incl: prelude/primops.txt
695         $(GENPRIMOP) --usage              < $< > $@
696
697
698 #-----------------------------------------------------------------------------
699 #               Linking
700
701 # Include libghccompat in stage1 only.  In stage2 onwards, all these
702 # libraries will be available from the main libraries.
703
704 ifeq "$(stage)" "1"
705 include $(GHC_COMPAT_DIR)/compat.mk
706 endif
707
708 SRC_LD_OPTS += -no-link-chk
709
710 # -----------------------------------------------------------------------------
711 # create ghc-inplace, a convenient way to run ghc from the build tree...
712 # See comments in $(FPTOOLS_TOP)/utils/ghc-pkg/Makefile for why we use
713 # a real binary here rather than a shell script.
714
715 INPLACE_PROG = $(odir)/ghc-inplace$(exeext)
716 EXCLUDED_C_SRCS += ghc-inplace.c
717
718 # FPTOOLS_TOP_ABS platform uses backslashes, at least on Cygwin, but that
719 # will go wrong when we use it in a Haskell string below.
720 TOP_ABS=$(subst \\,/,$(FPTOOLS_TOP_ABS_PLATFORM))
721
722 GHC_PATH=$(TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)
723
724 $(INPLACE_PROG): ghc-inplace.c
725         $(HC) -cpp -optc-DGHC_PATH=\"$(GHC_PATH)\" -optc-DTOP_ABS=\"$(TOP_ABS)\" $< -o $@
726
727 all :: $(INPLACE_PROG)
728
729 CLEAN_FILES += $(INPLACE_PROG)
730
731 ifeq "$(stage)" "1"
732 ghc-inplace : $(INPLACE_PROG)
733         $(RM) -f $@ && $(LN_S) $< $@
734
735 all :: ghc-inplace
736
737 CLEAN_FILES += ghc-inplace
738 endif
739
740 #-----------------------------------------------------------------------------
741 #               install
742
743 # We don't want ghc treated as an ordinary executable,
744 # but put it together with the libraries.
745 # Also don't want any interface files installed
746
747 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
748
749 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
750 INSTALL_LIBEXECS += $(GHC_PROG)
751 else
752 INSTALL_PROGS += $(GHC_PROG)
753 endif
754
755 # ----------------------------------------------------------------------------
756 # profiling.
757
758 # rename/RnBinds_HC_OPTS += -auto-all
759 # rename/RnEnv_HC_OPTS += -auto-all
760 # rename/RnExpr_HC_OPTS += -auto-all
761 # rename/RnHiFiles_HC_OPTS += -auto-all
762 # rename/RnHsSyn_HC_OPTS += -auto-all
763 # rename/Rename_HC_OPTS += -auto-all
764 # rename/RnIfaces_HC_OPTS += -auto-all
765 # rename/RnNames_HC_OPTS += -auto-all
766 # rename/RnSource_HC_OPTS += -auto-all
767 # rename/RnTypes_HC_OPTS += -auto-all
768
769 # typecheck/Inst_HC_OPTS += -auto-all
770 # typecheck/TcBinds_HC_OPTS += -auto-all
771 # typecheck/TcClassDcl_HC_OPTS += -auto-all
772 # typecheck/TcDefaults_HC_OPTS += -auto-all
773 # typecheck/TcDeriv_HC_OPTS += -auto-all
774 # typecheck/TcEnv_HC_OPTS += -auto-all
775 # typecheck/TcExpr_HC_OPTS += -auto-all
776 # typecheck/TcForeign_HC_OPTS += -auto-all
777 # typecheck/TcGenDeriv_HC_OPTS += -auto-all
778 # typecheck/TcHsSyn_HC_OPTS += -auto-all
779 # typecheck/TcIfaceSig_HC_OPTS += -auto-all
780 # typecheck/TcInstDcls_HC_OPTS += -auto-all
781 # typecheck/TcMatches_HC_OPTS += -auto-all
782 # typecheck/TcMonoType_HC_OPTS += -auto-all
783 # typecheck/TcMType_HC_OPTS += -auto-all
784 # typecheck/TcPat_HC_OPTS += -auto-all
785 # typecheck/TcRnDriver_HC_OPTS += -auto-all
786 # #typecheck/TcRnMonad_HC_OPTS += -auto-all
787 # #typecheck/TcRnTypes_HC_OPTS += -auto-all
788 # typecheck/TcRules_HC_OPTS += -auto-all
789 # typecheck/TcSimplify_HC_OPTS += -auto-all
790 # typecheck/TcSplice_HC_OPTS += -auto-all
791 # typecheck/TcTyClsDecls_HC_OPTS += -auto-all
792 # typecheck/TcTyDecls_HC_OPTS += -auto-all
793 # typecheck/TcType_HC_OPTS += -auto-all
794 # typecheck/TcUnify_HC_OPTS += -auto-all
795
796 coreSyn/CorePrep_HC_OPTS += -auto-all
797 # parser/Parser_HC_OPTS += -fasm
798
799 #-----------------------------------------------------------------------------
800 # Building the GHC package
801
802 # The GHC package is made from the stage 2 build and later.
803 # Fortunately the package build system framework more or less does the
804 # right thing for us here.
805
806 ifneq "$(findstring $(stage), 2 3)" ""
807 BUILD_GHC_PACKAGE=YES
808 endif
809
810 ifeq "$(BUILD_GHC_PACKAGE)" "YES"
811 PACKAGE = ghc
812 HIERARCHICAL_LIB = NO
813 VERSION = $(ProjectVersion)
814 PKG_DEPENDS += base haskell98
815 PACKAGE_CPP_OPTS += -DPKG_DEPENDS='$(PKG_DEPENDS)'
816 PACKAGE_CPP_OPTS += -DSTAGE='"$(stage)"'
817
818 # Omit Main from the library, the client will want to plug their own Main in
819 LIBOBJS = $(filter-out $(odir)/main/Main.o   $(odir)/parser/hschooks.o     \
820                        $(odir)/main/Main.p_o $(odir)/parser/hschooks.p_o,  \
821                        $(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 # The stage 2 and stage 3 package.conf.in files are different, because they
852 # point to either the stage2/ or stage3/ dirs in import-dirs.  Hence before
853 # linking the ghc binary we must install the correct version of the package
854 # configuration.  Yeuch... maybe one day this will all be done more cleanly.
855 STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
856
857 ifeq "$(GhcBuildDylibs)" "YES"
858 ifeq "$(darwin_TARGET_OS)" "1"
859 GhcLibraryName=libHS$(PACKAGE)$(_way)_dyn.dylib
860 else
861 GhcLibraryName=libHS$(PACKAGE)$(_way)_dyn.so
862 endif
863 else
864 GhcLibraryName=libHS$(PACKAGE)$(_way).a
865 endif
866
867 ifneq "$(DOING_BIN_DIST)" "YES"
868 $(GHC_PROG) : $(GhcLibraryName) main/Main.hs
869         $(RM) package.conf.inplace
870         $(RM) $(STAMP_PKG_CONF)
871         $(MAKE) $(STAMP_PKG_CONF)
872         $(MAKE) -f Makefile.ghcbin $(MFLAGS) HS_PROG=$(GHC_PROG) $@
873 endif
874
875 # Propagate standard targets to Makefile.ghcbin
876 docs runtests $(BOOT_TARGET) TAGS clean distclean mostlyclean maintainer-clean $(INSTALL_TARGET) $(INSTALL_DOCS_TARGET) html chm HxS ps dvi txt::
877         $(MAKE) -f Makefile.ghcbin $(MFLAGS) $@
878 endif
879
880 #-----------------------------------------------------------------------------
881 #               clean
882
883 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
884
885 #-----------------------------------------------------------------------------
886 #               Include target-rule boilerplate
887
888 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
889 MKDEPENDHS_SRCS =
890 MKDEPENDC_SRCS =
891
892 # Make doesn't work this out for itself, it seems
893 parser/Parser.y : parser/Parser.y.pp
894 EXTRA_SRCS += parser/Parser.y
895
896
897 #-----------------------------------------------------------------------------
898 #               Source files for tags file generation
899 #
900 # We want to excluded derived sources, because they won't be in the source
901 # tree, which is where we are going to move the TAGS file to.a
902
903 TAGS_HS_SRCS = parser/Parser.y.pp $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
904
905 include $(TOP)/mk/target.mk
906
907 ifeq "$(BUILD_GHC_PACKAGE)" "YES"
908 ifeq "$(way)" ""
909 all :: $(GHC_PROG)
910 endif
911 endif
912
913 $(odir)/main/Config.$(way_)o: SRC_HC_OPTS+=-DSTAGE='"$(stage)"'
914
915 #-----------------------------------------------------------------------------
916 # binary-dist
917
918 ifeq "$(DOING_BIN_DIST)" "YES"
919 # This is derived from the sources when we are in a source tree, but we
920 # don't have any sources in a bindist, so we have to shortcut it
921 HS_IFACES := $(wildcard stage$(stage)/*/*.hi)
922 endif
923
924 binary-dist:
925         $(INSTALL_DIR)                         $(BIN_DIST_DIR)/compiler
926         $(INSTALL_DIR)                         $(BIN_DIST_DIR)/compiler/stage$(stage)
927         echo "stage=$(stage)"                > $(BIN_DIST_DIR)/compiler/Makefile
928         cat Makefile                        >> $(BIN_DIST_DIR)/compiler/Makefile
929         $(INSTALL_DATA)    package.conf.in     $(BIN_DIST_DIR)/compiler/
930         set -e; for d in stage$(stage)/*/; do $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler/$$d; done
931         set -e; for f in $(HS_IFACES); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
932 ifneq "$(INSTALL_LIBS)" ""
933         set -e; for f in $(INSTALL_LIBS); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
934 endif
935 ifneq "$(INSTALL_PROGS)" ""
936         set -e; for f in $(INSTALL_PROGS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
937 endif
938 ifneq "$(INSTALL_LIBEXECS)" ""
939         set -e; for f in $(INSTALL_LIBEXECS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
940 endif
941
942 # -----------------------------------------------------------------------------
943 # Explicit dependencies
944
945 # Some .hs files #include other source files, but since ghc -M doesn't spit out
946 # these dependencies we have to include them manually.
947
948 # We don't add dependencies on HsVersions.h, ghcautoconf.h, or ghc_boot_platform.h,
949 # because then modifying one of these files would force recompilation of everything,
950 # which is probably not what you want.  However, it does mean you have to be
951 # careful to recompile stuff you need if you reconfigure or change HsVersions.h.
952
953 # Aargh, these don't work properly anyway, because GHC's recompilation checker
954 # just reports "compilation NOT required".  Do we have to add -no-recomp for each
955 # of these .hs files?  I haven't done anything about this yet.
956
957 $(odir)/codeGen/Bitmap.$(way_)o         :  ../includes/MachDeps.h
958 $(odir)/codeGen/CgCallConv.$(way_)o     :  ../includes/StgFun.h
959 $(odir)/codeGen/CgProf.$(way_)o         :  ../includes/MachDeps.h
960 $(odir)/codeGen/CgProf.$(way_)o         :  ../includes/Constants.h
961 $(odir)/codeGen/CgProf.$(way_)o         :  ../includes/DerivedConstants.h
962 $(odir)/codeGen/CgTicky.$(way_)o        :  ../includes/DerivedConstants.h
963 $(odir)/codeGen/ClosureInfo.$(way_)o    :  ../includes/MachDeps.h
964 $(odir)/codeGen/SMRep.$(way_)o          :  ../includes/MachDeps.h
965 $(odir)/codeGen/SMRep.$(way_)o          :  ../includes/ClosureTypes.h
966 $(odir)/ghci/ByteCodeAsm.$(way_)o       :  ../includes/Bytecodes.h
967 $(odir)/ghci/ByteCodeFFI.$(way_)o       :  nativeGen/NCG.h
968 $(odir)/ghci/ByteCodeInstr.$(way_)o     :  ../includes/MachDeps.h
969 $(odir)/ghci/ByteCodeItbls.$(way_)o     :  ../includes/ClosureTypes.h
970 $(odir)/ghci/ByteCodeItbls.$(way_)o     :  nativeGen/NCG.h
971 $(odir)/main/Constants.$(way_)o         :  ../includes/MachRegs.h
972 $(odir)/main/Constants.$(way_)o         :  ../includes/Constants.h
973 $(odir)/main/Constants.$(way_)o         :  ../includes/MachDeps.h
974 $(odir)/main/Constants.$(way_)o         :  ../includes/DerivedConstants.h
975 $(odir)/main/Constants.$(way_)o         :  ../includes/GHCConstants.h
976 $(odir)/nativeGen/AsmCodeGen.$(way_)o   :  nativeGen/NCG.h
977 $(odir)/nativeGen/MachCodeGen.$(way_)o  :  nativeGen/NCG.h
978 $(odir)/nativeGen/MachCodeGen.$(way_)o  : ../includes/MachDeps.h
979 $(odir)/nativeGen/MachInstrs.$(way_)o   :  nativeGen/NCG.h
980 $(odir)/nativeGen/MachRegs.$(way_)o     :  nativeGen/NCG.h
981 $(odir)/nativeGen/MachRegs.$(way_)o     :  ../includes/MachRegs.h
982 $(odir)/nativeGen/PositionIndependentCode.$(way_)o :  nativeGen/NCG.h
983 $(odir)/nativeGen/PprMach.$(way_)o      :  nativeGen/NCG.h
984 $(odir)/nativeGen/RegAllocInfo.$(way_)o :  nativeGen/NCG.h
985 $(odir)/typecheck/TcForeign.$(way_)o    :  nativeGen/NCG.h
986 $(odir)/utils/Binary.$(way_)o           :  ../includes/MachDeps.h
987 $(odir)/utils/FastMutInt.$(way_)o       :  ../includes/MachDeps.h
988
989 # -----------------------------------------------------------------------------
990 # Dependencies
991
992 MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
993
994 MKDEPENDHS=$(HC)
995
996 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
997 depend :: $(STAGE_PLATFORM_H) $(HS_SRCS) $(C_SRCS)
998         touch .depend-BASE
999 ifneq "$(BootingFromHc)" "YES"
1000         $(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)
1001 endif
1002         $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS) 
1003         $(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)
1004 # The binmode stuff tells perl not to add stupid ^M's to the output
1005 #
1006 # The /lib/compat replacement is to workaround a bug in the
1007 # -optdep--exclude-module flag in GHC 6.4.  It is not required for any
1008 # other version of GHC, but doesn't do any harm.
1009
1010 ifeq "$(MakefileDeps)" "YES"
1011 $(CONFIG_HS) : Makefile
1012 stage1/$(PLATFORM_H) : Makefile
1013 stage2/$(PLATFORM_H) : Makefile
1014 endif
1015
1016 -include .depend-$(stage)