-
-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
-
-all:: build.stage$(stage)
-
-stage1 ::
- $(MAKE) stage=1
-
-stage2 ::
- $(MAKE) stage=2
-
-stage3 ::
- $(MAKE) stage=3
-
-clean distclean::
- -$(CABAL) clean --distpref dist-stage1
- -$(CABAL) clean --distpref dist-stage2
- $(RM) -f Makefile-stage1
- $(RM) -f Makefile-stage2
- $(RM) -f prelude/primops.txt
- $(RM) -f $(PRIMOP_BITS)
- $(RM) -f $(CONFIG_HS)
- $(RM) -f parser/Parser.y
-
-ifeq "$(GhcWithInterpreter)" "YES"
-CONFIGURE_FLAGS_STAGE2 += --flags=ghci
-
-# 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"
-CONFIGURE_FLAGS_STAGE2 += --flags=dynlibs
-else
-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 either:
-# - we're building stage 1 and $(GhcHasEditline)="YES"
-# - 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.
-#
-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-CONFIGURE_FLAGS_STAGE1 += --flags=-editline
-CONFIGURE_FLAGS_STAGE2 += --flags=-editline
-else
-ifeq "$(GhcHasEditline)" "YES"
-CONFIGURE_FLAGS_STAGE1 += --flags=editline
-else
-CONFIGURE_FLAGS_STAGE1 += --flags=-editline
-endif
-ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/editline/unbuildable)" ""
-CONFIGURE_FLAGS_STAGE2 += --flags=editline
-else
-CONFIGURE_FLAGS_STAGE2 += --flags=-editline
-endif
-endif
-
-else
-CONFIGURE_FLAGS_STAGE2 += --flags=-ghci
-endif
-
-ifeq "$(GhcWithNativeCodeGen)" "NO"
-# XXX This should logically be a CPP option, but there doesn't seem to
-# be a flag for that
-CONFIGURE_FLAGS_STAGE1 += --ghc-option=-DOMIT_NATIVE_CODEGEN
-CONFIGURE_FLAGS_STAGE2 += --ghc-option=-DOMIT_NATIVE_CODEGEN
-endif
-
-ifeq "$(TargetOS_CPP)" "openbsd"
-CONFIGURE_FLAGS_STAGE1 += --ld-options="-Xlinker -E"
-CONFIGURE_FLAGS_STAGE2 += --ld-options="-Xlinker -E"
-endif
-
-ifeq "$(GhcUnregisterised)" "NO"
-ifeq "$(HOSTPLATFORM)" "ia64-unknown-linux"
-# needed for generating proper relocation in large binaries: trac #856
-CONFIGURE_FLAGS_STAGE1 += --ld-option=-Wl,--relax
-CONFIGURE_FLAGS_STAGE2 += --ld-option=-Wl,--relax
-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"'
-
-build.stage1: $(PRIMOP_BITS)
- $(CABAL) configure --distpref dist-stage1 \
- $(CONFIGURE_FLAGS_STAGE1) \
- $(INSTALL_DIRS_CONFIGURE_FLAGS) \
- $(USE_BOOT_CONFIGURE_FLAGS) \
- $(COMMON_CONFIGURE_FLAGS) \
- --flags=-ghci \
- --flags=stage1 \
- --ghc-option=-DSTAGE=1
- $(RM) -f Makefile-stage1
- $(CABAL) makefile --distpref dist-stage1 -f Makefile-stage1
- $(MAKE) -f Makefile-stage1 stage=1
- $(CABAL) register --distpref dist-stage1 --inplace
-
-build.stage2: $(PRIMOP_BITS)
- $(CABAL) configure --distpref dist-stage2 \
- $(CONFIGURE_FLAGS_STAGE2) \
- $(INSTALL_DIRS_CONFIGURE_FLAGS) \
- $(USE_STAGE1_CONFIGURE_FLAGS) \
- $(COMMON_CONFIGURE_FLAGS) \
- --flags=-stage1 \
- --ghc-option=-DSTAGE=2
- $(RM) -f Makefile-stage2
- $(CABAL) makefile --distpref dist-stage2 -f Makefile-stage2
- $(MAKE) -f Makefile-stage2 stage=2
- $(CABAL) register --distpref dist-stage2 --inplace
-
-stage_dirs :
- $(MKDIRHIER) stage$(stage)
-
-boot :: stage_dirs
-
-# -----------------------------------------------------------------------------
-# Create compiler configuration