-# If we are going to use dynamic libraries instead of .o files for ghci,
-# we will need to always retain CAFs in the compiler.
-# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
-# function which sets the keepCAFs flag for the RTS before any Haskell
-# code is run.
-ifeq "$(GhcBuildDylibs)" "YES"
-else
-EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c
-endif
-
-# Enable readline if either:
-# - we're building stage 1 and $(GhcHasReadline)="YES"
-# - we're building stage 2/3, and we have built the readline package
-#
-# But we don't enable readline on Windows, because readline is fairly
-# broken there.
-#
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-ifeq "$(stage)" "1"
-ifeq "$(GhcHasReadline)" "YES"
-SRC_HC_OPTS += -package readline -DUSE_READLINE
-PKG_DEPENDS += readline
-endif
-else
--include $(FPTOOLS_TOP)/libraries/readline/config.mk
-# readline's config.mk sets PACKAGE, which we don't want here
-PACKAGE=
-ifeq "$(READLINE_BUILD_PACKAGE)" "yes"
-SRC_HC_OPTS += -package readline -DUSE_READLINE
-PKG_DEPENDS += readline
-endif
-endif # stage=1
-endif # not windows
-
-else
-
-# No interpreter, so exclude Template Haskell modules
-EXCLUDED_SRCS += deSugar/DsMeta.hs typecheck/TcSplice.lhs hsSyn/Convert.lhs
-
-endif # bootstrapped with interpreter
-
-# -----------------------------------------------
-# mkdependC stuff
-#
-# Big Fudge to get around inherent problem that Makefile setup
-# has got with 'mkdependC'.
-#
-SRC_MKDEPENDC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
-
-# XXX not really correct, hschooks.c actually gets include files like
-# RtsFlags.c from the installed GHC, but we can't tell mkdependC about that.
-SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
-
-# -----------------------------------------------------------------------------
-# Haskell compilations
-
-SRC_HC_OPTS += \
- -cpp -fglasgow-exts -fno-generics -Rghc-timing \
- -I. -Iparser
-
-# Omitted: -I$(GHC_INCLUDE_DIR)
-# We should have -I$(GHC_INCLUDE_DIR) in SRC_HC_OPTS,
-# to avoid the use of an explicit path in GHC source files
-# (include "../includes/config.h"
-# But alas GHC 4.08 (and others for all I know) uses this very
-# same include path when compiling the .hc files it generates.
-# Disaster! Then the hc file sees the GHC 5.02 (or whatever)
-# include files. For the moment we've reverted to using
-# an explicit path in the .hs sources
-#
-# For the benefit of <5.00 compilers, do include GHC_INCLUDE_DIR
-# when generating dependencies. (=> it gets passed onto mkdependHS,
-# which needs it).
-SRC_MKDEPENDHS_OPTS += -I$(GHC_INCLUDE_DIR)
-
-# We need System.Posix (or Posix when ghc < 6.2)
-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-ifeq "$(bootstrapped)" "YES"
-SRC_HC_OPTS += -package Win32
-PKG_DEPENDS += Win32
-endif
-else
-ifeq "$(bootstrapped) $(ghc_ge_601)" "NO NO"
-SRC_HC_OPTS += -package posix
-else
-SRC_HC_OPTS += -package unix
-PKG_DEPENDS += unix
-endif
-endif
-
-# We use the Cabal package in stages 2/3 only; in stage 1 we're using
-# the libcompat library which provides the Cabal modules.
-ifneq "$(stage)" "1"
-SRC_HC_OPTS += -package Cabal
-PKG_DEPENDS += Cabal
-endif
-
-# We use Text.Regex which is in regex-compat with GHC 6.6+
-ifeq "$(bootstrapped)" "YES"
-SRC_HC_OPTS += -package regex-compat
-PKG_DEPENDS += regex-compat
-else
-ifeq "$(ghc_ge_605)" "YES"
-SRC_HC_OPTS += -package regex-compat
-endif
-endif
-
-ifeq "$(ghc_ge_603)" "YES"
-# Ignore lang, to avoid potential clash with the Generics module if
-# lang happens to be a dependency of some exposed package in the local
-# GHC installation (eg. wxHaskell did this around 6.4).
-SRC_HC_OPTS += -ignore-package lang
-endif
-
-SRC_CC_OPTS += -Iparser -I. -O
-SRC_HC_OPTS += -recomp $(GhcHcOpts) $(GhcStage$(stage)HcOpts)
-SRC_HC_OPTS += -H16M
-
-ifeq "$(BootingFromHc)" "YES"
-SRC_CC_OPTS += -D__GLASGOW_HASKELL__=$(ProjectVersionInt)
-endif
-
-# Special flags for particular modules
-# The standard suffix rule for compiling a Haskell file
-# adds these flags to the command line
-
-# There used to be a -no-recomp flag on PrimOp, but why?
-# It's an expensive module to recompile!
-prelude/PrimOp_HC_OPTS = -H80m
-
-
-main/ParsePkgConf_HC_OPTS += -fno-warn-incomplete-patterns
-parser/Parser_HC_OPTS += -fno-warn-incomplete-patterns
-
-ifeq "$(ghc_ge_603)" "NO"
-# Use -fvia-C since the NCG can't handle the narrow16Int# (and intToInt16#?)
-# primops on all platforms.
-parser/Parser_HC_OPTS += -fvia-C
-# because the NCG can't handle the 64-bit math in here
-prelude/PrelRules_HC_OPTS += -fvia-C
-# ByteCodeItbls uses primops that the NCG doesn't support.
-ghci/ByteCodeItbls_HC_OPTS += -fvia-C
-ghci/ByteCodeLink_HC_OPTS += -fvia-C -monly-3-regs
-endif
-
-# Careful optimisation of the parser: we don't want to throw everything
-# at it, because that takes too long and doesn't buy much, but we do want
-# to inline certain key external functions, so we instruct GHC not to
-# throw away inlinings as it would normally do in -Onot mode:
-parser/Parser_HC_OPTS += -Onot -fno-ignore-interface-pragmas
-
-ifeq "$(HOSTPLATFORM)" "hppa1.1-hp-hpux9"
-rename/RnMonad_HC_OPTS = -O2 -O2-for-C
-endif
-
-utils/Digraph_HC_OPTS = -fglasgow-exts
-
-basicTypes/SrcLoc_HC_OPTS = -funbox-strict-fields
-
-# We always optimise some low-level modules, otherwise performance of
-# a non-optimised compiler is severely affected.
-main/BinIface_HC_OPTS += -O
-utils/Binary_HC_OPTS += -O -funbox-strict-fields
-utils/FastMutInt_HC_OPTS += -O
-utils/Encoding_HC_OPTS += -O
-utils/StringBuffer_HC_OPTS += -O -funbox-strict-fields
-utils/FastString_HC_OPTS += -O -funbox-strict-fields
-
-# ---- Profiling ----
-#simplCore/Simplify_HC_OPTS = -auto-all
-#simplCore/SimplEnv_HC_OPTS = -auto-all
-#simplCore/SimplUtils_HC_OPTS = -auto-all
-
-# CSE interacts badly with top-level IORefs (reportedly in DriverState and
-# DriverMkDepend), causing some of them to be commoned up. We have a fix for
-# this in 5.00+, but earlier versions of the compiler will need CSE turned off.
-# To be on the safe side, we disable CSE in *all* modules with top-level IORefs.
-ghci/InteractiveUI_HC_OPTS = -fno-cse
-main/CmdLineOpts_HC_OPTS = -fno-cse
-main/DriverMkDepend_HC_OPTS = -fno-cse
-main/DriverPipeline_HC_OPTS = -fno-cse
-main/Finder_HC_OPTS = -fno-cse
-main/SysTools_HC_OPTS = -fno-cse
-main/StaticFlags_HC_OPTS = -fno-cse
-
-# The #include is vital for the via-C route, else the C
-# compiler doesn't realise that the stcall foreign imports are indeed
-# stdcall, and doesn't generate the Foo@8 name for them
-ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-main/SysTools_HC_OPTS += '-\#include <windows.h>' '-\#include <process.h>'
-endif
-
-parser/Lexer_HC_OPTS += -funbox-strict-fields
-
-# ghc_strlen percolates through so many modules that it is easier to get its
-# prototype via a global option instead of a myriad of per-file OPTIONS
-SRC_HC_OPTS += '-\#include "cutils.h"'
-
-# ----------------------------------------------------------------------------
-# Generate supporting stuff for prelude/PrimOp.lhs
-# from prelude/primops.txt
-
-PRIMOP_BITS=primop-data-decl.hs-incl \
- primop-tag.hs-incl \
- primop-list.hs-incl \
- primop-has-side-effects.hs-incl \
- primop-out-of-line.hs-incl \
- primop-commutable.hs-incl \
- primop-needs-wrapper.hs-incl \
- primop-can-fail.hs-incl \
- primop-strictness.hs-incl \
- primop-primop-info.hs-incl
-
-CLEAN_FILES += prelude/primops.txt
-CLEAN_FILES += $(PRIMOP_BITS)
-
-SRC_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
-SRC_CPP_OPTS += ${GhcCppOpts}
-
-ifneq "$(BootingFromHc)" "YES"
-prelude/PrimOp.lhs $(odir)/prelude/PrimOp.o: $(PRIMOP_BITS)
-endif
-
-ifneq "$(BootingFromHc)" "YES"
-depend :: $(PRIMOP_BITS)
-endif
-
-# This is an ugly hack: we need stage1/$(PLATFORM_H) built before we
-# preprocess primops.txt.pp, but we don't want to just add that
-# dependency because we don't want $(PLATFORM_H) built during normal
-# operations, because we don't have have dependencies from the .hs
-# sources on it, and we don't want those dependencies because that
-# would cause everything to be rebuilt every time the Makefile
-# changed. So here we add the required dependency only when making
-# boot or depend:
-ifneq "$(findstring boot, $(MAKECMDGOALS))$(findstring depend, $(MAKECMDGOALS))" ""
-prelude/primops.txt.pp : stage1/$(PLATFORM_H)
-endif
-
-primop-data-decl.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --data-decl < $< > $@
-primop-tag.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --primop-tag < $< > $@
-primop-list.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --primop-list < $< > $@
-primop-has-side-effects.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --has-side-effects < $< > $@
-primop-out-of-line.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --out-of-line < $< > $@
-primop-commutable.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --commutable < $< > $@
-primop-needs-wrapper.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --needs-wrapper < $< > $@
-primop-can-fail.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --can-fail < $< > $@
-primop-strictness.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --strictness < $< > $@
-primop-primop-info.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --primop-primop-info < $< > $@
-
-# Usages aren't used any more; but the generator
-# can still generate them if we want them back
-primop-usage.hs-incl: prelude/primops.txt
- $(GENPRIMOP) --usage < $< > $@
-
-
-#-----------------------------------------------------------------------------
-# Linking
-
-# Include libghccompat in stage1 only. In stage2 onwards, all these
-# libraries will be available from the main libraries.
-
-ifeq "$(stage)" "1"
-include $(GHC_COMPAT_DIR)/compat.mk
-endif
-
-SRC_LD_OPTS += -no-link-chk
-
-# -----------------------------------------------------------------------------
-# create ghc-inplace, a convenient way to run ghc from the build tree...
-
-all :: $(odir)/ghc-inplace ghc-inplace
-
-$(odir)/ghc-inplace : $(GHC_PROG)
- @$(RM) $@
- echo '#!/bin/sh' >>$@
- echo exec $(GHC_COMPILER_DIR_ABS)/$(GHC_PROG) '-B$(subst \,\\,$(FPTOOLS_TOP_ABS_PLATFORM))' '"$$@"' >>$@
- chmod 755 $@
-
-ghc-inplace : stage1/ghc-inplace
- $(RM) -f $@ && $(LN_S) $< $@
-
-ifeq "$(stage)" "1"
-CLEAN_FILES += ghc-inplace
-endif
-
-CLEAN_FILES += $(odir)/ghc-inplace
-
-#-----------------------------------------------------------------------------
-# install
-
-# We don't want ghc treated as an ordinary executable,
-# but put it together with the libraries.
-# Also don't want any interface files installed
-
-DESTDIR = $(INSTALL_LIBRARY_DIR_GHC)
-
-ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-INSTALL_LIBEXECS += $(GHC_PROG)
-else
-INSTALL_PROGS += $(GHC_PROG)
-endif
-
-# ----------------------------------------------------------------------------
-# profiling.
-
-# rename/RnBinds_HC_OPTS += -auto-all
-# rename/RnEnv_HC_OPTS += -auto-all
-# rename/RnExpr_HC_OPTS += -auto-all
-# rename/RnHiFiles_HC_OPTS += -auto-all
-# rename/RnHsSyn_HC_OPTS += -auto-all
-# rename/Rename_HC_OPTS += -auto-all
-# rename/RnIfaces_HC_OPTS += -auto-all
-# rename/RnNames_HC_OPTS += -auto-all
-# rename/RnSource_HC_OPTS += -auto-all
-# rename/RnTypes_HC_OPTS += -auto-all
-#
-# typecheck/Inst_HC_OPTS += -auto-all
-# typecheck/TcBinds_HC_OPTS += -auto-all
-# typecheck/TcClassDcl_HC_OPTS += -auto-all
-# typecheck/TcDefaults_HC_OPTS += -auto-all
-# typecheck/TcDeriv_HC_OPTS += -auto-all
-# typecheck/TcEnv_HC_OPTS += -auto-all
-# typecheck/TcExpr_HC_OPTS += -auto-all
-# typecheck/TcForeign_HC_OPTS += -auto-all
-# typecheck/TcGenDeriv_HC_OPTS += -auto-all
-# typecheck/TcHsSyn_HC_OPTS += -auto-all
-# typecheck/TcIfaceSig_HC_OPTS += -auto-all
-# typecheck/TcInstDcls_HC_OPTS += -auto-all
-# typecheck/TcMatches_HC_OPTS += -auto-all
-# typecheck/TcMonoType_HC_OPTS += -auto-all
-# typecheck/TcMType_HC_OPTS += -auto-all
-# typecheck/TcPat_HC_OPTS += -auto-all
-# typecheck/TcRnDriver_HC_OPTS += -auto-all
-# #typecheck/TcRnMonad_HC_OPTS += -auto-all
-# #typecheck/TcRnTypes_HC_OPTS += -auto-all
-# typecheck/TcRules_HC_OPTS += -auto-all
-# typecheck/TcSimplify_HC_OPTS += -auto-all
-# typecheck/TcSplice_HC_OPTS += -auto-all
-# typecheck/TcTyClsDecls_HC_OPTS += -auto-all
-# typecheck/TcTyDecls_HC_OPTS += -auto-all
-# typecheck/TcType_HC_OPTS += -auto-all
-# typecheck/TcUnify_HC_OPTS += -auto-all
-
-coreSyn/CorePrep_HC_OPTS += -auto-all
-# parser/Parser_HC_OPTS += -fasm
-
-#-----------------------------------------------------------------------------
-# Building the GHC package
-
-# The GHC package is made from the stage 2 build. Fortunately the
-# package build system framework more or less does the right thing for
-# us here.
-
-ifeq "$(stage)" "2"
-PACKAGE = ghc
-HIERARCHICAL_LIB = NO
-VERSION = $(ProjectVersion)
-PKG_DEPENDS += base haskell98
-PACKAGE_CPP_OPTS += -DPKG_DEPENDS='$(PKG_DEPENDS)'
-
-# Omit Main from the library, the client will want to plug their own Main in
-LIBOBJS = $(filter-out $(odir)/main/Main.o $(odir)/parser/hschooks.o, $(OBJS))
-
-# disable splitting: it won't really help with GHC, and the specialised
-# build system for compiler/ isn't set up to handle it.
-SplitObjs = NO
-
-# the package build system likes to set WAYS=$(GhcLibWays), but we don't
-# really want to build the whole of GHC multiple ways... if you do,
-# set GhcCompilerWays instead.
-GhcLibWays = $(GhcCompilerWays)
-
-# override $(GhcLibHcOpts): we want GhcStage2HcOpts to take precedence
-GhcLibHcOpts =
-
-# override default definition of HS_IFACES so we can add $(odir)
-HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_OBJS)))
-
-# Haddock can't handle recursive modules currently, so we disable it for now.
-NO_HADDOCK_DOCS = YES
-
-# Don't build the GHC binary as normal, because we need to link it
-# against the GHC package. The GHC binary itself is built by
-# compiling Main.o separately and linking it with -package ghc. This is
-# done using a separate Makefile:
-
-all :: $(GHC_PROG)
-
-$(GHC_PROG) : libHS$(PACKAGE)$(_way).a main/Main.hs
- $(MAKE) -f Makefile.ghcbin $(MFLAGS) HS_PROG=$(GHC_PROG) $@
-
-docs runtests $(BOOT_TARGET) TAGS clean distclean mostlyclean maintainer-clean $(INSTALL_TARGET) $(INSTALL_DOCS_TARGET) html chm HxS ps dvi txt::
- $(MAKE) -f Makefile.ghcbin $(MFLAGS) $@
-endif
-
-#-----------------------------------------------------------------------------
-# clean
-
-MAINTAINER_CLEAN_FILES += parser/Parser.info main/ParsePkgConf.info
-
-#-----------------------------------------------------------------------------
-# Include target-rule boilerplate
-
-# Don't use the default MKDEPENDHS stuff... we'll do our own, below
-MKDEPENDHS_SRCS =
-MKDEPENDC_SRCS =
-
-# Make doesn't work this out for itself, it seems
-parser/Parser.y : parser/Parser.y.pp
-EXTRA_SRCS += parser/Parser.y
-
-
-#-----------------------------------------------------------------------------
-# Source files for tags file generation
-#
-# We want to excluded derived sources, because they won't be in the source
-# tree, which is where we are going to move the TAGS file to.a
-
-TAGS_HS_SRCS = parser/Parser.y.pp $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
-
-
-include $(TOP)/mk/target.mk
-
-# -----------------------------------------------------------------------------
-# Explicit dependencies
-
-# Some .hs files #include other source files, but since ghc -M doesn't spit out
-# these dependencies we have to include them manually.
-
-# We don't add dependencies on HsVersions.h, ghcautoconf.h, or ghc_boot_platform.h,
-# because then modifying one of these files would force recompilation of everything,
-# which is probably not what you want. However, it does mean you have to be
-# careful to recompile stuff you need if you reconfigure or change HsVersions.h.
-
-$(odir)/codeGen/Bitmap.hs : ../includes/MachDeps.h
-$(odir)/codeGen/CgCallConv.hs : ../includes/StgFun.h
-$(odir)/codeGen/CgProf.hs : ../includes/MachDeps.h
-$(odir)/codeGen/CgProf.hs : ../includes/Constants.h
-$(odir)/codeGen/CgProf.hs : ../includes/DerivedConstants.h
-$(odir)/codeGen/CgTicky.hs : ../includes/DerivedConstants.h
-$(odir)/codeGen/ClosureInfo.lhs : ../includes/MachDeps.h
-$(odir)/codeGen/SMRep.lhs : ../includes/MachDeps.h
-$(odir)/codeGen/SMRep.lhs : ../includes/ClosureTypes.h
-$(odir)/ghci/ByteCodeAsm.lhs : ../includes/Bytecodes.h
-$(odir)/ghci/ByteCodeFFI.lhs : nativeGen/NCG.h
-$(odir)/ghci/ByteCodeInstr.lhs : ../includes/MachDeps.h
-$(odir)/ghci/ByteCodeItbls.lhs : ../includes/ClosureTypes.h
-$(odir)/ghci/ByteCodeItbls.lhs : nativeGen/NCG.h
-$(odir)/main/Constants.lhs : ../includes/MachRegs.h
-$(odir)/main/Constants.lhs : ../includes/Constants.h
-$(odir)/main/Constants.lhs : ../includes/MachDeps.h
-$(odir)/main/Constants.lhs : ../includes/DerivedConstants.h
-$(odir)/main/Constants.lhs : ../includes/GHCConstants.h
-$(odir)/nativeGen/AsmCodeGen.lhs : nativeGen/NCG.h
-$(odir)/nativeGen/MachCodeGen.hs : nativeGen/NCG.h
-$(odir)/nativeGen/MachCodeGen.hs : ../includes/MachDeps.h
-$(odir)/nativeGen/MachInstrs.hs : nativeGen/NCG.h
-$(odir)/nativeGen/MachRegs.lhs : nativeGen/NCG.h
-$(odir)/nativeGen/MachRegs.lhs : ../includes/MachRegs.h
-$(odir)/nativeGen/PositionIndependentCode.hs : nativeGen/NCG.h
-$(odir)/nativeGen/PprMach.hs : nativeGen/NCG.h
-$(odir)/nativeGen/RegAllocInfo.hs : nativeGen/NCG.h
-$(odir)/typecheck/TcForeign.lhs : nativeGen/NCG.h
-$(odir)/utils/Binary.hs : ../includes/MachDeps.h
-$(odir)/utils/FastMutInt.lhs : ../includes/MachDeps.h
-
-# -----------------------------------------------------------------------------
-# Dependencies
-
-MKDEPENDHS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
-
-MKDEPENDHS=$(HC)
-
-# Must do this *after* including target.mk, because $(HS_SRCS) isn't set yet.
-depend :: $(STAGE_PLATFORM_H) $(HS_SRCS) $(C_SRCS)
- touch .depend-BASE
-ifneq "$(BootingFromHc)" "YES"
- $(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)
-endif
- $(MKDEPENDC) -f .depend-BASE $(MKDEPENDC_OPTS) $(foreach way,$(WAYS),-s $(way)) -- $(CC_OPTS) -- $(C_SRCS)
- $(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)
-# The binmode stuff tells perl not to add stupid ^M's to the output
-#
-# The /lib/compat replacement is to workaround a bug in the
-# -optdep--exclude-module flag in GHC 6.4. It is not required for any
-# other version of GHC, but doesn't do any harm.