-
-#-----------------------------------------------------------------------------
-# 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...
-# See comments in $(FPTOOLS_TOP)/utils/ghc-pkg/Makefile for why we use
-# a real binary here rather than a shell script.
-
-INPLACE_SRC = $(odir)/ghc-inplace.c
-INPLACE_PROG = $(odir)/ghc-inplace$(_way)$(exeext)
-INPLACE_EXTRA_FLAGS = -I$(TOP)/includes
-EXCLUDED_C_SRCS += ghc-inplace.c
-
-CLEAN_FILES += $(INPLACE_SRC)
-
-GHC_PATH=$(FPTOOLS_TOP_ABS)/$(GHC_COMPILER_DIR_REL)/$(GHC_PROG)$(exeext)
-
-$(INPLACE_PROG): ghc-inplace.c
- $(SED) -e "s@GHC_PATH@$(GHC_PATH)@g" -e "s@TOP_ABS@$(FPTOOLS_TOP_ABS)@g" < $< > $(INPLACE_SRC)
- $(HC) -cpp $(INPLACE_EXTRA_FLAGS) $(INPLACE_SRC) -o $@
-
-all :: $(INPLACE_PROG)
-
-CLEAN_FILES += $(INPLACE_PROG)
-
-ifeq "$(stage)" "1"
-ghc-inplace : $(INPLACE_PROG)
- $(RM) -f $@ && $(LN_S) $< $@
-
-all :: ghc-inplace
-
-CLEAN_FILES += ghc-inplace
-endif
-
-#-----------------------------------------------------------------------------
-# 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 and later.
-# Fortunately the package build system framework more or less does the
-# right thing for us here.
-
-ifneq "$(findstring $(stage), 2 3)" ""
-BUILD_GHC_PACKAGE=YES
-endif
-
-ifeq "$(BUILD_GHC_PACKAGE)" "YES"
-PACKAGE = ghc
-HIERARCHICAL_LIB = NO
-VERSION = $(ProjectVersion)
-PKG_DEPENDS += base haskell98
-LIB_LD_OPTS += $(foreach pkg,$(PKG_DEPENDS),-package $(pkg))
-# We have to expand each package dependency with its version, which we
-# can do by calling "ghc-pkg list $pkg --simple-output".
-PACKAGE_CPP_OPTS += -DPKG_DEPENDS='$(foreach pkg,$(PKG_DEPENDS),$(shell $(GHC_PKG_INPLACE) latest --global $(pkg)))'
-PACKAGE_CPP_OPTS += -DSTAGE='"$(stage)"'
-
-# Omit Main from the library, the client will want to plug their own Main in
-LIBOBJS = $(filter-out $(odir)/main/Main.$(way_)o $(odir)/parser/hschooks.$(way_)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 =
-
-ifeq "$(DOING_BIN_DIST)" "YES"
-# This is derived from the sources when we are in a source tree, but we
-# don't have any sources in a bindist, so we have to shortcut it
-HS_IFACES := $(wildcard stage$(stage)/*/*.hi)
-else
-# override default definition of HS_IFACES so we can add $(odir)
-HS_IFACES = $(addsuffix .$(way_)hi,$(basename $(HS_OBJS)))
-endif
-
-# Haddock can't handle recursive modules currently, so we disable it for now.
-override HADDOCK_DOCS = NO
-
-# Tell package.mk not to set $(HC)
-NO_SET_HC = YES
-
-# The stage 2 GHC binary itself is built by compiling main/Main.hs
-# (the same as used in stage 1) against the GHC package.
-#
-# This is done by compiling Main.hs separately and linking it with
-# -package ghc. This is done using a separate Makefile, Makefile.ghcbin
-# Why? See comments in Makefile.ghcbin
-
-# The stage 2 and stage 3 package.conf.in files are different, because they
-# point to either the stage2/ or stage3/ dirs in import-dirs. Hence before
-# linking the ghc binary we must install the correct version of the package
-# configuration. Yeuch... maybe one day this will all be done more cleanly.
-STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
-
-# Propagate standard targets to Makefile.ghcbin
-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)))
-
-WRONG_GHCTAGS_HS_SRCS = $(filter-out $(DERIVED_SRCS) main/Config.hs parser/Parser.y, $(sort $(SRCS)))
-# above is wrong because of the following problem:
-# module `main:DataCon' is defined in multiple files: basicTypes/DataCon.lhs
-# basicTypes/DataCon.lhs-boot
-
-GHCTAGS_HS_SRCS = $(HS_SRCS)
-GHCTAGS_HC_OPTS = $(patsubst -i$(odir)/%, -i%, $(HC_OPTS))
-GHCTAGS_HC_OPTS += -DSTAGE='"$(stage)"'
-
-#------------------------------------------------------------
-# Tags
-
-.PHONY: ghctags
-
-ghctags :: $(GHCTAGS_HS_SRCS) $(TAGS_C_SRCS)
- @if [ "$(stage)" != 2 ]; then echo "Must use 'make stage=2 ghctags'"; exit 1; fi
- @$(RM) TAGS
- @touch TAGS
- @echo SOURCES ARE "$(GHCTAGS_HS_SRCS)"
- : ifneq "$(GHCTAGS_HS_SRCS)" ""
- @echo TIME TO ROCK AND ROLL
- # $(GHCTAGS_INPLACE) -- $(MKDEPENDHS_OPTS) $(filter-out -split-objs, $(MKDEPENDHS_HC_OPTS)) -- $(GHCTAGS_HS_SRCS)
- $(GHCTAGS_INPLACE) -- $(GHCTAGS_HC_OPTS) -- $(GHCTAGS_HS_SRCS)
- : endif
-ifneq "$(TAGS_C_SRCS)" ""
- etags -a $(TAGS_C_SRCS)
-endif
- @( 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?
-
-include $(TOP)/mk/target.mk
-
-ifeq "$(BUILD_GHC_PACKAGE)" "YES"
-all :: $(GHC_PROG)
-endif
-
-$(odir)/main/Config.$(way_)o: SRC_HC_OPTS+=-DSTAGE=$(DQ)$(stage)$(DQ)
-
-ifneq "$(findstring $(stage), 2 3)" ""
-$(warning LIBRARY is $(LIBRARY))
-
-ifneq "$(DOING_BIN_DIST)" "YES"
-$(GHC_PROG) : $(LIBRARY) main/Main.hs
- $(RM) package.conf.inplace
- $(RM) $(STAMP_PKG_CONF)
- $(MAKE) way="" $(STAMP_PKG_CONF)
- $(MAKE) -f Makefile.ghcbin $(MFLAGS) HS_PROG=$(GHC_PROG) $@
-endif
-endif
-