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