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