-
-TOP = ..
-
-ifeq "$(stage)" ""
-stage=1
-endif
-
-include $(TOP)/mk/boilerplate.mk
-include $(TOP)/mk/cabal-flags.mk
-
-ifeq "$(GhcThreaded) $(GhcProfiled)" "YES YES"
-$(error Cannot make GHC both threaded and profiled)
-endif
-
-CONFIG_HS = main/Config.hs
-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
-
-boot:: boot.stage.$(stage)
-
-all:: build.stage.$(stage)
-
-doc:: doc.stage.$(stage)
-
-stage1 ::
- $(MAKE) stage=1
-
-stage2 ::
- $(MAKE) stage=2
-
-stage3 ::
- $(MAKE) stage=3
-
-ifeq "$(CLEAN_ALL_STAGES)" "YES"
-clean distclean::
- $(RM) -f prelude/primops.txt
- $(RM) -f $(PRIMOP_BITS)
- $(RM) -f $(CONFIG_HS)
- $(RM) -f parser/Parser.y
- $(RM) -rf stage1 stage2plus
- $(RM) -f $(STAGE3_PACKAGE_CONF)
-endif
-
-ifeq "$(CLEAN_ALL_STAGES)" "YES"
-clean distclean:: clean.stage.1 clean.stage.2 clean.stage.3
-else
-clean distclean:: clean.stage.$(stage)
-endif
-
-ifeq "$(CLEAN_ALL_STAGES)" "YES"
-distclean::
- $(RM) -f ghc.cabal
-endif
-
-clean.stage.%:
- -$(CABAL) clean --distpref dist-stage$*
- $(RM) -f Makefile-stage$*
-
-CONFIGURE_FLAGS_STAGE1 += --flags=stage1
-CONFIGURE_FLAGS_STAGE2 += --flags=-stage1
-
-ifeq "$(GhcWithNativeCodeGen)" "YES"
-CONFIGURE_FLAGS_STAGE1 += --flags=ncg
-CONFIGURE_FLAGS_STAGE2 += --flags=ncg
-endif
-
-ifeq "$(GhcWithInterpreter)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --flags=ghci
-
-ifeq "$(BuildSharedLibs)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --enable-shared
-# 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.
-CONFIGURE_FLAGS_STAGE2 += --flags=dynlibs
-endif
-
-ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
-# Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
-# or not?
-# XXX This should logically be a CPP option, but there doesn't seem to
-# be a flag for that
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
-endif
-
-# Should the debugger commands be enabled?
-ifeq "$(GhciWithDebugger)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DDEBUGGER
-endif
-
-# Enable editline if:
-# - we're building stage 2/3, and we have built the editline package
-#
-# But we don't enable editline on Windows, as Windows terminals have
-# editline-like support builtin.
-#
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/editline/unbuildable)" ""
-CONFIGURE_FLAGS_STAGE2 += --flags=editline
-endif
-endif
-endif
-
-ifeq "$(GhcWithNativeCodeGen)" "NO"
-# XXX This should logically be a CPP option, but there doesn't seem to
-# be a flag for that
-COMMON_CONFIGURE_FLAGS += --ghc-option=-DOMIT_NATIVE_CODEGEN
-endif
-
-ifeq "$(TargetOS_CPP)" "openbsd"
-COMMON_CONFIGURE_FLAGS += --ld-options=-E
-endif
-
-ifeq "$(GhcUnregisterised)" "NO"
-ifeq "$(HOSTPLATFORM)" "ia64-unknown-linux"
-# needed for generating proper relocation in large binaries: trac #856
-COMMON_CONFIGURE_FLAGS += --ld-option=-Wl,--relax
-endif
-endif
-
-# We need to turn on profiling either if we have been asked to
-# (GhcLibProfiled = YES) or if we want GHC itself to be compiled with
-# profiling enabled (GhcProfiled = YES).
-ifneq "$(GhcLibProfiled) $(GhcProfiled)" "NO NO"
-CONFIGURE_FLAGS_STAGE2 += --enable-library-profiling
-# And if we're profiling GHC then we want lots of SCCs.
-# We also don't want to waste time building the non-profiling library,
-# either normally or for ghci. Unfortunately this means that we have to
-# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't
-# exist.
-ifeq "$(GhcProfiled)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-auto-all
-CONFIGURE_FLAGS_STAGE2 += --disable-library-vanilla
-CONFIGURE_FLAGS_STAGE2 += --disable-library-for-ghci
-CONFIGURE_FLAGS_STAGE2 += --ghc-pkg-option=--force
-endif
-endif
-
-ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-# The #include is vital for the via-C route with older compilers, 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
-# As it's only important for older compilers we don't need to do anything
-# for stage2+.
-CONFIGURE_FLAGS_STAGE1 += --ghc-option='-\#include' \
- --ghc-option='"<windows.h>"' \
- --ghc-option='-\#include' \
- --ghc-option='"<process.h>"'
-endif
-
-# 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.
-# Again, this is only important for older compilers, so we don't do it in
-# stage 2+.
-CONFIGURE_FLAGS_STAGE1 += --ghc-options='-\#include "cutils.h"'
-
-CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
-CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS)
-CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS)
-
-boot.stage.%: $(PRIMOP_BITS) $(CONFIG_HS) parser/Parser.y
- test -f $(STAGE3_PACKAGE_CONF) || echo "[]" > $(STAGE3_PACKAGE_CONF)
- $(CABAL) configure --distpref dist-stage$* \
- $(CONFIGURE_FLAGS_STAGE$*) \
- $(INSTALL_DIRS_CONFIGURE_FLAGS) \
- $(COMMON_CONFIGURE_FLAGS) \
- --ghc-option=-DSTAGE=$*
- $(RM) -f Makefile-stage$*
- $(CABAL) makefile --distpref dist-stage$* -f Makefile-stage$*
-
-build.stage.%:
- $(MAKE) -f Makefile-stage$* stage=$*
- $(CABAL) register --distpref dist-stage$* --inplace
- $(MAKE) -C ../ghc stage=$*
-
-doc.stage.%:
- $(CABAL) haddock --distpref dist-stage$* \
- --haddock-option=--optghc=-DSTAGE=$* \
- --with-haddock=$(FPTOOLS_TOP_ABS)/utils/haddock/install-inplace/bin/haddock
-
-install:
- $(INSTALL_PACKAGE) install '$(GHC_PKG_INSTALL_PROG)' '$(DESTDIR)$(datadir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' --distpref dist-stage2
-
-# -----------------------------------------------------------------------------
-# Create compiler configuration