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