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