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