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