1 # -----------------------------------------------------------------------------
2 # Main compiler Makefile
6 # all builds stage1 compiler
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).
13 # stage1 (or stage=1) builds stage1 compiler
14 # stage2 (or stage=2) builds stage2 compiler
15 # stage3 (or stage=3) builds stage3 compiler
20 # Use GHC for compiling C bits (NB. must be before boilerplate include)
24 # We don't want to compile stage1 in multiple ways
25 ifeq "$(findstring $(stage), 2 3)" ""
29 include $(TOP)/mk/boilerplate.mk
31 ifeq "$(GhcThreaded)$(GhcProfiled)" "YESYES"
32 $(error Cannot make GHC both threaded and profiled)
36 #-----------------------------------------------------------------------------
37 # Counting source code lines
39 USER_SRCS = $(filter-out $(DERIVED_SRCS),$(SRCS))
41 ./count_lines $(USER_SRCS)
43 # -----------------------------------------------------------------------------
46 # The stage1/stage2/stage3 business is quite delicate. Here's how it works:
48 # - the variable $(stage) holds the current stage number. To build a
49 # particular stage, you say 'make stage=N' where N is 1, 2, or 3.
52 # - for stage N, object files and .hi files are placed inside
53 # the directory stageN, in subdirectories as per the sources.
55 # - .hi-boot files are *linked* into the stageN tree, because in GHC 5.05+
56 # the .hi-boot file must reside in the same place as the .hi file.
58 # - we use explicit -o and -ohi options to direct the output from C &
59 # Haskell compilations.
61 # - we generate a different .depend file for each build. They need to be
62 # different, because each stage might include different files: stage1
63 # might not include GHCi, for example. For each stage, a normal .depend
64 # file is generated, and then post-processed to add the correct stageN/
65 # prefix to each object and .hi filename. The resulting .depend file
66 # is named .depend-$(stage). See the end of this Makefile for details.
68 # - normal implicit rules don't work any more, because they're of the form
72 # whereas we really need
76 # so suffix.mk now defines the appropriate suffix rules when
77 # $(odir) is set to a non-empty value. Here we set $(odir) to
78 # stage1, stage2, or stage3.
80 # There are other plausible designs that might work, but each has different
83 # - using -odir and -hidir: GHC <= 4.08 doesn't support -hidir, and
84 # anyway -odir puts all the objects in one directory (strips off the
85 # subdirectory part), which eventually forces us to use VPATH to find
86 # the sources. I have a really bad feeling about VPATH.
88 # - invoke make in the stageN subdirectory. This probably requires VPATH
91 # - create a link tree. The problem with requiring link trees is that
92 # Windows doesn't support symbolic links.
98 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
110 $(MKDIRHIER) stage$(stage)
111 for i in $(ALL_DIRS); do \
112 $(MKDIRHIER) stage$(stage)/$$i; \
115 ifeq "$(stage) $(ghc_ge_603)" "1 YES"
118 ifneq "$(findstring $(stage), 2 3)" ""
126 # On Windows, we can't use symbolic links for the -hi-boot files
127 # because GHC itself is a Mingw program and does not understand
128 # symbolic links. So we have to copy the files instead of link them.
129 # That means that if you modify a .hi-boot file in Windows, you
130 # have to to say 'make boot' again.
132 # PS: 'ln -s foo baz' takes 'foo' relative to the path to 'baz'
133 # whereas 'cp foo baz' treats the two paths independently.
134 # Hence the "../.." in the ln command line
135 ifeq "$(UsingHsBoot)" "NO"
136 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
137 for i in */*hi-boot*; do \
138 cp -u -f $$i stage$(stage)/$$i; \
141 for i in */*hi-boot*; do \
142 ($(RM) -f stage$(stage)/$$i \
143 && $(LN_S) ../../$$i stage$(stage)/$$i) || true ; \
171 SRC_HC_OPTS += $(patsubst %, -i$(odir)/%, $(ALL_DIRS))
173 SRC_HC_OPTS += -Wall -fno-warn-name-shadowing
174 # Turn off orphan warnings, but only if the flag exists (i.e. not if we
175 # are building stage 1 and using GHC < 6.3).
176 ifneq "$(stage) $(ghc_ge_603)" "1 NO"
177 SRC_HC_OPTS += -fno-warn-orphans
180 HS_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(HS_SRCS))))
181 C_OBJS = $(patsubst %, $(odir)/%, $(addsuffix .$(way_)o,$(basename $(C_SRCS))))
183 # Our standard cleaning rules don't know that we're doing our output
184 # into $(odir), so we have to augment CLEAN_FILES appropriateliy.
186 CLEAN_FILES += $(odir)/*/*.$(way_)hi $(odir)/*/*.$(way_)hi-boot $(odir)/*/*.$(way_)o-boot
188 ifeq "$(UsingHsBoot)" "YES"
189 CLEAN_FILES += $(odir)/*/*.hi-boot $(odir)/*/*.o-boot
193 mostlyclean clean distclean maintainer-clean ::
198 # -----------------------------------------------------------------------------
201 # Note: there have been reports of people running up against the ARG_MAX limit
202 # when linking ghc with all its constituent object files. The likely source of
203 # the problem is that the environment is a bit too big, so a workaround could
204 # be to do `env PATH=$(PATH) make ghc' to minimise the environment. (or the
205 # equivalent of `env' if it doesn't exist locally).
207 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
208 GHC_PROG=$(odir)/ghc$(_way)-$(ProjectVersion)
210 GHC_PROG=$(odir)/ghc$(_way)
214 HS_PROG = $(GHC_PROG)
217 # -----------------------------------------------------------------------------
218 # Create compiler configuration
220 # The 'echo' commands simply spit the values of various make variables
221 # into Config.hs, whence they can be compiled and used by GHC itself
223 CONFIG_HS = main/Config.hs
226 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk
227 @$(RM) -f $(CONFIG_HS)
228 @echo "Creating $(CONFIG_HS) ... "
229 @echo "{-# OPTIONS -w #-}" >>$(CONFIG_HS)
230 @echo "module Config where" >>$(CONFIG_HS)
231 @echo "cProjectName = \"$(ProjectName)\"" >> $(CONFIG_HS)
232 @echo "cProjectVersion = \"$(ProjectVersion)\"" >> $(CONFIG_HS)
233 @echo "cProjectVersionInt = \"$(ProjectVersionInt)\"" >> $(CONFIG_HS)
234 @echo "cProjectPatchLevel = \"$(ProjectPatchLevel)\"" >> $(CONFIG_HS)
235 @echo "cBooterVersion = \"$(GhcVersion)\"" >> $(CONFIG_HS)
236 @echo "cStage = STAGE" >> $(CONFIG_HS)
237 @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS)
238 @echo "cSplitObjs = \"$(SplitObjs)\"" >> $(CONFIG_HS)
239 @echo "cGhcWithInterpreter = \"$(GhcWithInterpreter)\"" >> $(CONFIG_HS)
240 @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS)
241 @echo "cGhcWithSMP = \"$(GhcWithSMP)\"" >> $(CONFIG_HS)
242 @echo "cGhcRTSWays = \"$(GhcRTSWays)\"" >> $(CONFIG_HS)
243 @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS)
244 @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $(CONFIG_HS)
245 @echo "cLeadingUnderscore = \"$(LeadingUnderscore)\"" >> $(CONFIG_HS)
246 @echo "cRAWCPP_FLAGS = \"$(RAWCPP_FLAGS)\"" >> $(CONFIG_HS)
247 @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
248 @echo "cMKDLL = \"$(BLD_DLL)\"" >> $(CONFIG_HS)
249 @echo "cLdIsGNULd = \"$(LdIsGNULd)\"" >> $(CONFIG_HS)
250 @echo "cLD_X = \"$(LD_X)\"" >> $(CONFIG_HS)
251 @echo "cPROJECT_DIR = \"$(PROJECT_DIR)\"" >> $(CONFIG_HS)
252 @echo "cGHC_DRIVER_DIR_REL = \"$(GHC_DRIVER_DIR_REL)\"" >> $(CONFIG_HS)
253 @echo "cGHC_TOUCHY_PGM = \"$(GHC_TOUCHY_PGM)\"" >> $(CONFIG_HS)
254 @echo "cGHC_TOUCHY_DIR_REL = \"$(GHC_TOUCHY_DIR_REL)\"" >> $(CONFIG_HS)
255 @echo "cGHC_UNLIT_PGM = \"$(GHC_UNLIT_PGM)\"" >> $(CONFIG_HS)
256 @echo "cGHC_UNLIT_DIR_REL = \"$(GHC_UNLIT_DIR_REL)\"" >> $(CONFIG_HS)
257 @echo "cGHC_MANGLER_PGM = \"$(GHC_MANGLER_PGM)\"" >> $(CONFIG_HS)
258 @echo "cGHC_MANGLER_DIR_REL = \"$(GHC_MANGLER_DIR_REL)\"" >> $(CONFIG_HS)
259 @echo "cGHC_SPLIT_PGM = \"$(GHC_SPLIT_PGM)\"" >> $(CONFIG_HS)
260 @echo "cGHC_SPLIT_DIR_REL = \"$(GHC_SPLIT_DIR_REL)\"" >> $(CONFIG_HS)
261 @echo "cGHC_SYSMAN_PGM = \"$(GHC_SYSMAN)\"" >> $(CONFIG_HS)
262 @echo "cGHC_SYSMAN_DIR_REL = \"$(GHC_SYSMAN_DIR)\"" >> $(CONFIG_HS)
263 @echo "cGHC_CP = \"$(GHC_CP)\"" >> $(CONFIG_HS)
264 @echo "cGHC_PERL = \"$(GHC_PERL)\"" >> $(CONFIG_HS)
265 ifeq ($(GhcWithIlx),YES)
266 @echo "cILX2IL = \"$(ILX2IL)\"" >> $(CONFIG_HS)
267 @echo "cILASM = \"$(ILASM)\"" >> $(CONFIG_HS)
269 @echo "cEnableWin32DLLs = \"$(EnableWin32DLLs)\"" >> $(CONFIG_HS)
270 @echo "cCONTEXT_DIFF = \"$(CONTEXT_DIFF)\"" >> $(CONFIG_HS)
271 @echo "cUSER_WAY_NAMES = \"$(USER_WAY_NAMES)\"" >> $(CONFIG_HS)
272 @echo "cUSER_WAY_OPTS = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
273 @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
274 ifeq "$(RelocatableBuild)" "YES"
275 @echo "cRelocatableBuild = True" >> $(CONFIG_HS)
277 @echo "cRelocatableBuild = False" >> $(CONFIG_HS)
281 CLEAN_FILES += $(CONFIG_HS)
283 # -----------------------------------------------------------------------------
284 # Create platform includes
286 # Here we generate a little header file containing CPP symbols that GHC
287 # uses to determine which platform it is building on/for. The platforms
288 # can differ between stage1 and stage2 if we're cross-compiling, so we
289 # need one of these header files per stage.
291 PLATFORM_H = ghc_boot_platform.h
293 stage1/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk
294 @echo "Creating $@..."
296 @echo "#ifndef __PLATFORM_H__" >$@
297 @echo "#define __PLATFORM_H__" >>$@
299 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
300 @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
301 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
303 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
304 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
305 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
307 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
308 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
309 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
310 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
311 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
312 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
314 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
315 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
316 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
317 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
318 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
319 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
320 ifeq "$(HostOS_CPP)" "irix"
321 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
322 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
323 @echo "#endif " >> $@
326 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
327 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
328 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
329 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
330 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
331 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
333 @echo "#endif /* __PLATFORM_H__ */" >> $@
336 # For stage2 and above, the BUILD platform is the HOST of stage1, and
337 # the HOST platform is the TARGET of stage1. The TARGET remains the same
338 # (stage1 is the cross-compiler, not stage2).
339 stage2/$(PLATFORM_H) : stage_dirs $(FPTOOLS_TOP)/mk/config.mk
340 @echo "Creating $@..."
342 @echo "#ifndef __PLATFORM_H__" >$@
343 @echo "#define __PLATFORM_H__" >>$@
345 @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
346 @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
347 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
349 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
350 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
351 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
353 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
354 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
355 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
356 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
357 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
358 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
360 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
361 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
362 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
363 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
364 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
365 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
366 ifeq "$(HostOS_CPP)" "irix"
367 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS " >> $@
368 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
369 @echo "#endif " >> $@
372 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
373 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
374 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
375 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
376 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
377 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
379 @echo "#endif /* __PLATFORM_H__ */" >> $@
382 stage3/$(PLATFORM_H) : stage_dirs stage2/$(PLATFORM_H)
383 $(CP) stage2/$(PLATFORM_H) stage3/$(PLATFORM_H)
385 STAGE_PLATFORM_H = stage$(stage)/$(PLATFORM_H)
387 boot :: $(STAGE_PLATFORM_H)
389 SRC_HC_OPTS += -Istage$(stage)
391 # -----------------------------------------------------------------------------
394 # First figure out ALL_DIRS, the source sub-directories
397 utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \
398 vectorise specialise simplCore stranal stgSyn simplStg codeGen main \
399 profiling parser cprAnalysis ndpFlatten iface cmm
401 # Make sure we include Config.hs even if it doesn't exist yet...
402 ALL_SRCS += $(CONFIG_HS)
404 # HsGeneric.hs is not used just now
405 EXCLUDED_SRCS += hsSyn/HsGeneric.hs
407 ifeq ($(GhcWithNativeCodeGen),YES)
408 ALL_DIRS += nativeGen
410 SRC_HC_OPTS += -DOMIT_NATIVE_CODEGEN
413 ifeq ($(GhcWithIlx),YES)
418 ifeq ($(GhcWithJavaGen),YES)
420 SRC_HC_OPTS += -DJAVA
423 ifeq "$(BootingFromHc)" "YES"
424 # HC files are always from a self-booted compiler
427 ifneq "$(findstring $(stage), 2 3)" ""
434 # -----------------------------------------------------------------------------
435 # Building a compiler with interpreter support
437 # The interpreter, GHCi interface, Template Haskell and Hpc are only
438 # enabled when we are bootstrapping with the same version of GHC, and
439 # the interpreter is supported on this platform.
441 ifeq "$(bootstrapped)" "YES"
442 SRC_HC_OPTS += -package hpc -package bytestring
443 PKG_DEPENDS += hpc bytestring
446 ifeq "$(GhcWithInterpreter) $(bootstrapped)" "YES YES"
448 # Yes, include the interepreter and Template Haskell extensions
449 SRC_HC_OPTS += -DGHCI -package template-haskell
450 PKG_DEPENDS += template-haskell
452 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
454 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
455 SRC_HC_OPTS += -DGHCI_TABLES_NEXT_TO_CODE
458 ifeq "$(GhcThreaded)" "YES"
459 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
460 SRC_LD_OPTS += -threaded
462 ifeq "$(GhcProfiled)" "YES"
465 ifeq "$(GhcDebugged)" "YES"
466 SRC_LD_OPTS += -debug
471 # If we are going to use dynamic libraries instead of .o files for ghci,
472 # we will need to always retain CAFs in the compiler.
473 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
474 # function which sets the keepCAFs flag for the RTS before any Haskell
476 ifeq "$(GhcBuildDylibs)" "YES"
478 EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c
481 # Enable readline if either:
482 # - we're building stage 1 and $(GhcHasReadline)="YES"
483 # - we're building stage 2/3, and we have built the readline package
485 # But we don't enable readline on Windows, because readline is fairly
488 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
490 ifeq "$(GhcHasReadline)" "YES"
491 SRC_HC_OPTS += -package readline -DUSE_READLINE
492 PKG_DEPENDS += readline
495 ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/readline/unbuildable)" ""
496 SRC_HC_OPTS += -package readline -DUSE_READLINE
497 PKG_DEPENDS += readline
504 # No interpreter, so exclude Template Haskell modules
505 EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
507 endif # bootstrapped with interpreter
509 # -----------------------------------------------
512 # Big Fudge to get around inherent problem that Makefile setup
513 # has got with 'mkdependC'.
515 SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
517 # XXX not really correct, hschooks.c actually gets include files like
518 # RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
519 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
521 # -----------------------------------------------------------------------------
522 # Haskell compilations
525 -cpp -fglasgow-exts -fno-generics -Rghc-timing \
528 # Omitted: -I$(GHC_INCLUDE_DIR)
529 # We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS,
530 # to avoid the use of an explicit path in GHC source files
531 # (include "../includes/config.h"
532 # But alas GHC 4.08 (and others for all I know) uses this very
533 # same include path when compiling the .hc files it generates.
534 # Disaster! Then the hc file sees the GHC 5.02 (or whatever)
535 # include files. For the moment we've reverted to using
536 # an explicit path in the .hs sources
538 # For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
539 # when generating dependencies. (=> it gets passed onto mkdependHS,
541 SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
543 # We need System.Posix (or Posix when ghc < 6.2)
544 ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
545 ifeq "$(bootstrapped)" "YES"
546 SRC_HC_OPTS += -package Win32
550 ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
551 SRC_HC_OPTS += -package posix
553 SRC_HC_OPTS += -package unix
558 # We use the Cabal package in stages 2/3 only; in stage 1 we're using
559 # the libcompat library which provides the Cabal modules.
561 SRC_HC_OPTS += -package Cabal
565 ifeq "$(ghc_ge_603)" "YES"
566 # Ignore lang, to avoid potential clash with the Generics module if
567 # lang happens to be a dependency of some exposed package in the local
568 # GHC installation (eg. wxHaskell did this around 6.4).
569 SRC_HC_OPTS += -ignore-package lang
572 SRC_CC_OPTS += -Iparser -I. -O
573 SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
576 ifeq "$(BootingFromHc)" "YES"
577 SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
580 # Special flags for particular modules
581 # The standard suffix rule for compiling a Haskell file
582 # adds these flags to the command line
584 # There used to be a -no-recomp flag on PrimOp, but why?
585 # It's an expensive module to recompile!
586 prelude/PrimOp_HC_OPTS = -H80m
589 main/ParsePkgConf_HC_OPTS += -fno-warn-incomplete-patterns
590 parser/Parser_HC_OPTS += -fno-warn-incomplete-patterns
592 ifeq "$(ghc_ge_603)" "NO"
593 # Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
594 # primops on all platforms.
595 parser/Parser_HC_OPTS += -fvia-C
596 # because the NCG can't handle the 64-bit math in here
597 prelude/PrelRules_HC_OPTS += -fvia-C
598 # ByteCodeItbls uses primops that the NCG doesn't support.
599 ghci/ByteCodeItbls_HC_OPTS += -fvia-C
600 ghci/ByteCodeLink_HC_OPTS += -fvia-C -monly-3-regs
603 # Careful optimisation of the parser: we don't want to throw everything
604 # at it, because that takes too long and doesn't buy much, but we do want
605 # to inline certain key external functions, so we instruct GHC not to
606 # throw away inlinings as it would normally do in -Onot mode:
607 parser/Parser_HC_OPTS += -Onot -fno-ignore-interface-pragmas
609 ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
610 rename/RnMonad_HC_OPTS = -O2 -O2-for-C
613 utils/Digraph_HC_OPTS = -fglasgow-exts
615 basicTypes/SrcLoc_HC_OPTS = -funbox-strict-fields
617 # We always optimise some low-level modules, otherwise performance of
618 # a non-optimised compiler is severely affected.
619 main/BinIface_HC_OPTS += -O
620 utils/Binary_HC_OPTS += -O -funbox-strict-fields
621 utils/FastMutInt_HC_OPTS += -O
622 utils/Encoding_HC_OPTS += -O
623 utils/StringBuffer_HC_OPTS += -O -funbox-strict-fields
624 utils/FastString_HC_OPTS += -O -funbox-strict-fields
626 # ---- Profiling ----
627 #simplCore/Simplify_HC_OPTS = -auto-all
628 #simplCore/SimplEnv_HC_OPTS = -auto-all
629 #simplCore/SimplUtils_HC_OPTS = -auto-all
631 # CSE interacts badly with top-level IORefs (reportedly in DriverState and
632 # DriverMkDepend), causing some of them to be commoned up. We have a fix for
633 # this in 5.00+, but earlier versions of the compiler will need CSE turned off.
634 # To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
635 ghci/InteractiveUI_HC_OPTS = -fno-cse
636 main/CmdLineOpts_HC_OPTS = -fno-cse
637 main/DriverMkDepend_HC_OPTS = -fno-cse
638 main/DriverPipeline_HC_OPTS = -fno-cse
639 main/Finder_HC_OPTS = -fno-cse
640 main/SysTools_HC_OPTS = -fno-cse
641 main/StaticFlags_HC_OPTS = -fno-cse
643 # The #include is vital for the via-C route, else the C
644 # compiler doesn't realise that the stcall foreign imports are indeed
645 # stdcall, and doesn't generate the Foo@8 name for them
646 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
647 main/SysTools_HC_OPTS += '-\#include <windows.h>' '-\#include <process.h>'
650 parser/Lexer_HC_OPTS += -funbox-strict-fields
652 # ghc_strlen percolates through so many modules that it is easier to get its
653 # prototype via a global option instead of a myriad of per-file OPTIONS
654 SRC_HC_OPTS += '-\#include "cutils.h"'
656 # ----------------------------------------------------------------------------
657 # Generate supporting stuff for prelude/PrimOp.lhs
658 # from prelude/primops.txt
660 PRIMOP_BITS=primop-data-decl.hs-incl \
662 primop-list.hs-incl \
663 primop-has-side-effects.hs-incl \
664 primop-out-of-line.hs-incl \
665 primop-commutable.hs-incl \
666 primop-needs-wrapper.hs-incl \
667 primop-can-fail.hs-incl \
668 primop-strictness.hs-incl \
669 primop-primop-info.hs-incl
671 CLEAN_FILES += prelude/primops.txt
672 CLEAN_FILES += $(PRIMOP_BITS)
674 SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
675 SRC_CPP_OPTS += ${GhcCppOpts}
677 ifneq "$(BootingFromHc)" "YES"
678 prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
681 ifneq "$(BootingFromHc)" "YES"
682 depend :: $(PRIMOP_BITS)
685 # This is an ugly hack: we need stage1/$(PLATFORM_H) built before we
686 # preprocess primops.txt.pp, but we don't want to just add that
687 # dependency because we don't want $(PLATFORM_H) built during normal
688 # operations, because we don't have have dependencies from the .hs
689 # sources on it, and we don't want those dependencies because that
690 # would cause everything to be rebuilt every time the Makefile
691 # changed. So here we add the required dependency only when making
693 ifneq "$(findstring boot, $(MAKECMDGOALS))$(findstring depend, $(MAKECMDGOALS))" ""
694 prelude/primops.txt.pp : stage1/$(PLATFORM_H)
697 primop-data-decl.hs-incl: prelude/primops.txt
698 $(GENPRIMOP) --data-decl < $< > $@
699 primop-tag.hs-incl: prelude/primops.txt
700 $(GENPRIMOP) --primop-tag < $< > $@
701 primop-list.hs-incl: prelude/primops.txt
702 $(GENPRIMOP) --primop-list < $< > $@
703 primop-has-side-effects.hs-incl: prelude/primops.txt
704 $(GENPRIMOP) --has-side-effects < $< > $@
705 primop-out-of-line.hs-incl: prelude/primops.txt
706 $(GENPRIMOP) --out-of-line < $< > $@
707 primop-commutable.hs-incl: prelude/primops.txt
708 $(GENPRIMOP) --commutable < $< > $@
709 primop-needs-wrapper.hs-incl: prelude/primops.txt
710 $(GENPRIMOP) --needs-wrapper < $< > $@
711 primop-can-fail.hs-incl: prelude/primops.txt
712 $(GENPRIMOP) --can-fail < $< > $@
713 primop-strictness.hs-incl: prelude/primops.txt
714 $(GENPRIMOP) --strictness < $< > $@
715 primop-primop-info.hs-incl: prelude/primops.txt
716 $(GENPRIMOP) --primop-primop-info < $< > $@
718 # Usages aren't used any more; but the generator
719 # can still generate them if we want them back
720 primop-usage.hs-incl: prelude/primops.txt
721 $(GENPRIMOP) --usage < $< > $@
724 #-----------------------------------------------------------------------------
727 # Include libghccompat in stage1 only. In stage2 onwards, all these
728 # libraries will be available from the main libraries.
731 include $(GHC_COMPAT_DIR)/compat.mk
734 SRC_LD_OPTS += -no-link-chk
736 # -----------------------------------------------------------------------------
737 # create ghc-inplace, a convenient way to run ghc from the build tree...
738 # See comments in $(FPTOOLS_TOP)/utils/ghc-pkg/Makefile for why we use
739 # a real binary here rather than a shell script.
741 INPLACE_SRC = $(odir)/ghc-inplace.c
742 INPLACE_PROG = $(odir)/ghc-inplace$(_way)$(exeext)
743 EXCLUDED_C_SRCS += ghc-inplace.c
745 CLEAN_FILES += $(INPLACE_SRC)
747 GHC_PATH=$(FPTOOLS_TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)$(exeext)
749 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
750 INPLACE_EXTRA_FLAGS = -optc-DWINDOWS
753 $(INPLACE_PROG): ghc-inplace.c
754 $(SED) -e "s@GHC_PATH@$(GHC_PATH)@g" -e "s@TOP_ABS@$(FPTOOLS_TOP_ABS)@g" < $< > $(INPLACE_SRC)
755 $(HC) -cpp $(INPLACE_EXTRA_FLAGS) $(INPLACE_SRC) -o $@
757 all :: $(INPLACE_PROG)
759 CLEAN_FILES += $(INPLACE_PROG)
762 ghc-inplace : $(INPLACE_PROG)
763 $(RM) -f $@ && $(LN_S) $< $@
767 CLEAN_FILES += ghc-inplace
770 #-----------------------------------------------------------------------------
773 # We don't want ghc treated as an ordinary executable,
774 # but put it together with the libraries.
775 # Also don't want any interface files installed
777 DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
779 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
780 INSTALL_LIBEXECS += $(GHC_PROG)
782 INSTALL_PROGS += $(GHC_PROG)
785 # ----------------------------------------------------------------------------
788 # rename/RnBinds_HC_OPTS += -auto-all
789 # rename/RnEnv_HC_OPTS += -auto-all
790 # rename/RnExpr_HC_OPTS += -auto-all
791 # rename/RnHiFiles_HC_OPTS += -auto-all
792 # rename/RnHsSyn_HC_OPTS += -auto-all
793 # rename/Rename_HC_OPTS += -auto-all
794 # rename/RnIfaces_HC_OPTS += -auto-all
795 # rename/RnNames_HC_OPTS += -auto-all
796 # rename/RnSource_HC_OPTS += -auto-all
797 # rename/RnTypes_HC_OPTS += -auto-all
799 # typecheck/Inst_HC_OPTS += -auto-all
800 # typecheck/TcBinds_HC_OPTS += -auto-all
801 # typecheck/TcClassDcl_HC_OPTS += -auto-all
802 # typecheck/TcDefaults_HC_OPTS += -auto-all
803 # typecheck/TcDeriv_HC_OPTS += -auto-all
804 # typecheck/TcEnv_HC_OPTS += -auto-all
805 # typecheck/TcExpr_HC_OPTS += -auto-all
806 # typecheck/TcForeign_HC_OPTS += -auto-all
807 # typecheck/TcGenDeriv_HC_OPTS += -auto-all
808 # typecheck/TcHsSyn_HC_OPTS += -auto-all
809 # typecheck/TcIfaceSig_HC_OPTS += -auto-all
810 # typecheck/TcInstDcls_HC_OPTS += -auto-all
811 # typecheck/TcMatches_HC_OPTS += -auto-all
812 # typecheck/TcMonoType_HC_OPTS += -auto-all
813 # typecheck/TcMType_HC_OPTS += -auto-all
814 # typecheck/TcPat_HC_OPTS += -auto-all
815 # typecheck/TcRnDriver_HC_OPTS += -auto-all
816 # #typecheck/TcRnMonad_HC_OPTS += -auto-all
817 # #typecheck/TcRnTypes_HC_OPTS += -auto-all
818 # typecheck/TcRules_HC_OPTS += -auto-all
819 # typecheck/TcSimplify_HC_OPTS += -auto-all
820 # typecheck/TcSplice_HC_OPTS += -auto-all
821 # typecheck/TcTyClsDecls_HC_OPTS += -auto-all
822 # typecheck/TcTyDecls_HC_OPTS += -auto-all
823 # typecheck/TcType_HC_OPTS += -auto-all
824 # typecheck/TcUnify_HC_OPTS += -auto-all
826 # coreSyn/CorePrep_HC_OPTS += -auto-all
827 # parser/Parser_HC_OPTS += -fasm
829 #-----------------------------------------------------------------------------
830 # Building the GHC package
832 # The GHC package is made from the stage 2 build and later.
833 # Fortunately the package build system framework more or less does the
834 # right thing for us here.
836 ifneq "$(findstring $(stage), 2 3)" ""
837 BUILD_GHC_PACKAGE=YES
840 ifeq "$(BUILD_GHC_PACKAGE)" "YES"
842 HIERARCHICAL_LIB = NO
843 VERSION = $(ProjectVersion)
844 PKG_DEPENDS += base haskell98
845 LIB_LD_OPTS += $(foreach pkg,$(PKG_DEPENDS),-package $(pkg))
846 # We have to expand each package dependency with its version, which we
847 # can do by calling "ghc-pkg list $pkg --simple-output".
848 PACKAGE_CPP_OPTS += -DPKG_DEPENDS='$(foreach pkg,$(PKG_DEPENDS),$(shell $(GHC_PKG_INPLACE) latest --global $(pkg)))'
849 PACKAGE_CPP_OPTS += -DSTAGE='"$(stage)"'
851 # Omit Main from the library, the client will want to plug their own Main in
852 LIBOBJS = $(filter-out $(odir)/main/Main.$(way_)o $(odir)/parser/hschooks.$(way_)o, $(OBJS))
854 # disable splitting: it won't really help with GHC, and the specialised
855 # build system for compiler/ isn't set up to handle it.
858 # the package build system likes to set WAYS=$(GhcLibWays), but we don't
859 # really want to build the whole of GHC multiple ways... if you do,
860 # set GhcCompilerWays instead.
861 GhcLibWays = $(GhcCompilerWays)
863 # override $(GhcLibHcOpts): we want GhcStage2HcOpts to take precedence
866 ifeq "$(DOING_BIN_DIST)" "YES"
867 # This is derived from the sources when we are in a source tree, but we
868 # don't have any sources in a bindist, so we have to shortcut it
869 HS_IFACES := $(wildcard stage$(stage)/*/*.hi)
871 # override default definition of HS_IFACES so we can add $(odir)
872 HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_OBJS)))
875 # Haddock can't handle recursive modules currently, so we disable it for now.
876 override HADDOCK_DOCS = NO
878 # Tell package.mk not to set $(HC)
881 # The stage 2 GHC binary itself is built by compiling main/Main.hs
882 # (the same as used in stage 1) against the GHC package.
884 # This is done by compiling Main.hs separately and linking it with
885 # -package ghc. This is done using a separate Makefile, Makefile.ghcbin
886 # Why? See comments in Makefile.ghcbin
888 # The stage 2 and stage 3 package.conf.in files are different, because they
889 # point to either the stage2/ or stage3/ dirs in import-dirs. Hence before
890 # linking the ghc binary we must install the correct version of the package
891 # configuration. Yeuch... maybe one day this will all be done more cleanly.
892 STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
894 # Propagate standard targets to Makefile.ghcbin
895 docs runtests $(BOOT_TARGET) TAGS clean distclean mostlyclean maintainer-clean $(INSTALL_TARGET) $(INSTALL_DOCS_TARGET) html chm HxS ps dvi txt::
896 $(MAKE) -f Makefile.ghcbin $(MFLAGS) $@
899 #-----------------------------------------------------------------------------
902 MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
904 #-----------------------------------------------------------------------------
905 # Include target-rule boilerplate
907 # Don't use the default MKDEPENDHS stuff... we'll do our own, below
911 # Make doesn't work this out for itself, it seems
912 parser/Parser.y : parser/Parser.y.pp
913 EXTRA_SRCS += parser/Parser.y
916 #-----------------------------------------------------------------------------
917 # Source files for tags file generation
919 # We want to excluded derived sources, because they won't be in the source
920 # tree, which is where we are going to move the TAGS file to.a
922 TAGS_HS_SRCS = parser/Parser.y.pp $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
924 WRONG_GHCTAGS_HS_SRCS = $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
925 # above is wrong because of the following problem:
926 # module `main:DataCon' is defined in multiple files: basicTypes/DataCon.lhs
927 # basicTypes/DataCon.lhs-boot
929 GHCTAGS_HS_SRCS = $(HS_SRCS)
930 GHCTAGS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
931 GHCTAGS_HC_OPTS += -DSTAGE='"$(stage)"'
933 #------------------------------------------------------------
938 ghctags :: $(GHCTAGS_HS_SRCS) $(TAGS_C_SRCS)
939 @if [ "$(stage)" != 2 ]; then echo "Must use 'make stage=2 ghctags'"; exit 1; fi
942 @echo SOURCES ARE "$(GHCTAGS_HS_SRCS)"
943 : ifneq "$(GHCTAGS_HS_SRCS)" ""
944 @echo TIME TO ROCK AND ROLL
945 # $(GHCTAGS_INPLACE) -- $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(MKDEPENDHS_HC_OPTS)) -- $(GHCTAGS_HS_SRCS)
946 $(GHCTAGS_INPLACE) -- $(GHCTAGS_HC_OPTS) -- $(GHCTAGS_HS_SRCS)
948 ifneq "$(TAGS_C_SRCS)" ""
949 etags -a $(TAGS_C_SRCS)
951 @( DEREFFED=`ls -l Makefile | sed -e 's/.*-> \(.*\)/\1/g'` && $(RM) `dirname $$DEREFFED`/TAGS && $(CP) TAGS `dirname $$DEREFFED` ) 2>/dev/null || echo TAGS file generated, perhaps copy over to source tree?
953 include $(TOP)/mk/target.mk
955 ifeq "$(BUILD_GHC_PACKAGE)" "YES"
959 $(odir)/main/Config.$(way_)o: SRC_HC_OPTS+=-DSTAGE=$(DQ)$(stage)$(DQ)
961 ifneq "$(findstring $(stage), 2 3)" ""
962 $(warning LIBRARY is $(LIBRARY))
964 ifneq "$(DOING_BIN_DIST)" "YES"
965 $(GHC_PROG) : $(LIBRARY) main/Main.hs
966 $(RM) package.conf.inplace
967 $(RM) $(STAMP_PKG_CONF)
968 $(MAKE) way="" $(STAMP_PKG_CONF)
969 $(MAKE) -f Makefile.ghcbin $(MFLAGS) HS_PROG=$(GHC_PROG) $@
974 #-----------------------------------------------------------------------------
978 $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler
979 $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler/stage$(stage)
980 echo "stage=$(stage)" > $(BIN_DIST_DIR)/compiler/Makefile
981 cat Makefile >> $(BIN_DIST_DIR)/compiler/Makefile
982 $(INSTALL_DATA) package.conf.in $(BIN_DIST_DIR)/compiler/
983 set -e; for d in stage$(stage)/*/; do $(INSTALL_DIR) $(BIN_DIST_DIR)/compiler/$$d; done
984 set -e; for f in $(HS_IFACES); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
985 ifneq "$(INSTALL_LIBS)" ""
986 set -e; for f in $(INSTALL_LIBS); do $(INSTALL_DATA) $$f $(BIN_DIST_DIR)/compiler/$$f; done
988 ifneq "$(INSTALL_PROGS)" ""
989 set -e; for f in $(INSTALL_PROGS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
991 ifneq "$(INSTALL_LIBEXECS)" ""
992 set -e; for f in $(INSTALL_LIBEXECS); do $(INSTALL_PROGRAM) $$f $(BIN_DIST_DIR)/compiler/$$f; done
995 # -----------------------------------------------------------------------------
996 # Explicit dependencies
998 # Some .hs files #include other source files, but since ghc -M doesn't spit out
999 # these dependencies we have to include them manually.
1001 # We don't add dependencies on HsVersions.h, ghcautoconf.h, or ghc_boot_platform.h,
1002 # because then modifying one of these files would force recompilation of everything,
1003 # which is probably not what you want. However, it does mean you have to be
1004 # careful to recompile stuff you need if you reconfigure or change HsVersions.h.
1006 # Aargh, these don't work properly anyway, because GHC's recompilation checker
1007 # just reports "compilation NOT required". Do we have to add -no-recomp for each
1008 # of these .hs files? I haven't done anything about this yet.
1010 $(odir)/codeGen/Bitmap.$(way_)o : ../includes/MachDeps.h
1011 $(odir)/codeGen/CgCallConv.$(way_)o : ../includes/StgFun.h
1012 $(odir)/codeGen/CgProf.$(way_)o : ../includes/MachDeps.h
1013 $(odir)/codeGen/CgProf.$(way_)o : ../includes/Constants.h
1014 $(odir)/codeGen/CgProf.$(way_)o : ../includes/DerivedConstants.h
1015 $(odir)/codeGen/CgTicky.$(way_)o : ../includes/DerivedConstants.h
1016 $(odir)/codeGen/ClosureInfo.$(way_)o : ../includes/MachDeps.h
1017 $(odir)/codeGen/SMRep.$(way_)o : ../includes/MachDeps.h
1018 $(odir)/codeGen/SMRep.$(way_)o : ../includes/ClosureTypes.h
1019 $(odir)/ghci/ByteCodeAsm.$(way_)o : ../includes/Bytecodes.h
1020 $(odir)/ghci/ByteCodeFFI.$(way_)o : nativeGen/NCG.h
1021 $(odir)/ghci/ByteCodeInstr.$(way_)o : ../includes/MachDeps.h
1022 $(odir)/ghci/ByteCodeItbls.$(way_)o : ../includes/ClosureTypes.h
1023 $(odir)/ghci/ByteCodeItbls.$(way_)o : nativeGen/NCG.h
1024 $(odir)/main/Constants.$(way_)o : ../includes/MachRegs.h
1025 $(odir)/main/Constants.$(way_)o : ../includes/Constants.h
1026 $(odir)/main/Constants.$(way_)o : ../includes/MachDeps.h
1027 $(odir)/main/Constants.$(way_)o : ../includes/DerivedConstants.h
1028 $(odir)/main/Constants.$(way_)o : ../includes/GHCConstants.h
1029 $(odir)/nativeGen/AsmCodeGen.$(way_)o : nativeGen/NCG.h
1030 $(odir)/nativeGen/MachCodeGen.$(way_)o : nativeGen/NCG.h
1031 $(odir)/nativeGen/MachCodeGen.$(way_)o : ../includes/MachDeps.h
1032 $(odir)/nativeGen/MachInstrs.$(way_)o : nativeGen/NCG.h
1033 $(odir)/nativeGen/MachRegs.$(way_)o : nativeGen/NCG.h
1034 $(odir)/nativeGen/MachRegs.$(way_)o : ../includes/MachRegs.h
1035 $(odir)/nativeGen/PositionIndependentCode.$(way_)o : nativeGen/NCG.h
1036 $(odir)/nativeGen/PprMach.$(way_)o : nativeGen/NCG.h
1037 $(odir)/nativeGen/RegAllocInfo.$(way_)o : nativeGen/NCG.h
1038 $(odir)/typecheck/TcForeign.$(way_)o : nativeGen/NCG.h
1039 $(odir)/utils/Binary.$(way_)o : ../includes/MachDeps.h
1040 $(odir)/utils/FastMutInt.$(way_)o : ../includes/MachDeps.h
1042 # -----------------------------------------------------------------------------
1045 MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
1049 # Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
1050 depend :: $(STAGE_PLATFORM_H) $(HS_SRCS) $(C_SRCS)
1052 ifneq "$(BootingFromHc)" "YES"
1053 $(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)
1055 $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS)
1056 $(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)
1057 # The binmode stuff tells perl not to add stupid ^M's to the output
1059 # The /lib/compat replacement is to workaround a bug in the
1060 # -optdep--exclude-module flag in GHC 6.4. It is not required for any
1061 # other version of GHC, but doesn't do any harm.
1063 ifeq "$(MakefileDeps)" "YES"
1064 $(CONFIG_HS) : Makefile
1065 stage1/$(PLATFORM_H) : Makefile
1066 stage2/$(PLATFORM_H) : Makefile
1069 -include .depend-$(stage)