From 5b9164b417bd96a629adb0998796e2f9d2d5d22f Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Thu, 17 Jul 2008 14:49:06 +0000 Subject: [PATCH] Remove some duplication --- compiler/Makefile | 51 +++++++++++++++++++++------------------------------ ghc/Makefile | 47 ++++++++++++++++------------------------------- mk/cabal-flags.mk | 26 ++++++++++++-------------- 3 files changed, 49 insertions(+), 75 deletions(-) diff --git a/compiler/Makefile b/compiler/Makefile index f32e020..3e2ae8d 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -40,7 +40,7 @@ PRIMOP_BITS = primop-data-decl.hs-incl \ primop-strictness.hs-incl \ primop-primop-info.hs-incl -all:: build.stage$(stage) +all:: build.stage.$(stage) stage1 :: $(MAKE) stage=1 @@ -61,6 +61,11 @@ clean distclean:: $(RM) -f $(CONFIG_HS) $(RM) -f parser/Parser.y +CONFIGURE_FLAGS_STAGE1 += --flags=stage1 +CONFIGURE_FLAGS_STAGE2 += --flags=-stage1 + +CONFIGURE_FLAGS_STAGE1 += --flags=-ghci + ifeq "$(GhcWithInterpreter)" "YES" CONFIGURE_FLAGS_STAGE2 += --flags=ghci @@ -118,20 +123,17 @@ 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 +COMMON_CONFIGURE_FLAGS += --ghc-option=-DOMIT_NATIVE_CODEGEN endif ifeq "$(TargetOS_CPP)" "openbsd" -CONFIGURE_FLAGS_STAGE1 += --ld-options="-Xlinker -E" -CONFIGURE_FLAGS_STAGE2 += --ld-options="-Xlinker -E" +COMMON_CONFIGURE_FLAGS += --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 +COMMON_CONFIGURE_FLAGS += --ld-option=-Wl,--relax endif endif @@ -153,32 +155,21 @@ endif # 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 +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) -build.stage2: $(PRIMOP_BITS) - $(CABAL) configure --distpref dist-stage2 \ - $(CONFIGURE_FLAGS_STAGE2) \ +build.stage.%: $(PRIMOP_BITS) + $(CABAL) configure --distpref dist-stage$* \ + $(CONFIGURE_FLAGS_STAGE$*) \ $(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 + --ghc-option=-DSTAGE=$* + $(RM) -f Makefile-stage$* + $(CABAL) makefile --distpref dist-stage$* -f Makefile-stage$* + $(MAKE) -f Makefile-stage$* stage=$* + $(CABAL) register --distpref dist-stage$* --inplace stage_dirs : $(MKDIRHIER) stage$(stage) diff --git a/ghc/Makefile b/ghc/Makefile index 4bd84b9..4bf9ac9 100644 --- a/ghc/Makefile +++ b/ghc/Makefile @@ -16,7 +16,7 @@ endif boot: @: -all:: build.stage$(stage) +all:: build.stage.$(stage) stage1 :: $(MAKE) stage=1 @@ -44,27 +44,7 @@ SET_DATA_SUBDIR = INPLACE_DATA_DIR = '$$prefix/data' endif -build.stage1: - $(CABAL) configure --distpref dist-stage1 \ - --flags=-ghci \ - $(SET_DATA_SUBDIR) \ - $(INSTALL_DIRS_CONFIGURE_FLAGS) \ - $(USE_BOOT_CONFIGURE_FLAGS) \ - $(COMMON_CONFIGURE_FLAGS) - $(CABAL) build --distpref dist-stage1 $(BUILD_FLAGS) - $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \ - $(FPTOOLS_TOP_ABS)/ghc/stage1-inplace \ - $(FPTOOLS_TOP_ABS)/ghc/stage1-inplace \ - '$$prefix/bin' \ - '$$prefix/lib' \ - '$$prefix/libexec' \ - '$$prefix/dynlib' \ - $(INPLACE_DATA_DIR) \ - '$$prefix/doc' \ - '$$prefix/html' \ - '$$prefix/haddock' \ - --distpref dist-stage1 \ - $(INSTALL_FLAGS) +CONFIGURE_FLAGS_STAGE1 += --flags=-ghci ifeq "$(GhcWithInterpreter)" "YES" CONFIGURE_FLAGS_STAGE2 += --flags=ghci @@ -83,21 +63,26 @@ ifeq "$(GhcThreaded)" "YES" CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded endif -# XXX In stage2 we should really use the inplace ghc-pkg +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) + +# XXX In stage2+ we should really use the inplace ghc-pkg # It works because installPackage doesn't actually use ghc-pkg, as there's # no library to register -build.stage2: - $(CABAL) configure --distpref dist-stage2 \ +build.stage.%: + $(CABAL) configure --distpref dist-stage$* \ $(SET_DATA_SUBDIR) \ - $(CONFIGURE_FLAGS_STAGE2) \ $(INSTALL_DIRS_CONFIGURE_FLAGS) \ - $(USE_STAGE1_CONFIGURE_FLAGS) \ + $(CONFIGURE_FLAGS_STAGE$*) \ $(COMMON_CONFIGURE_FLAGS) - $(CABAL) build --distpref dist-stage2 $(BUILD_FLAGS) + $(CABAL) build --distpref dist-stage$* $(BUILD_FLAGS) $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \ - $(FPTOOLS_TOP_ABS)/ghc/stage2-inplace \ - $(FPTOOLS_TOP_ABS)/ghc/stage2-inplace \ + $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \ + $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \ '$$prefix/bin' \ '$$prefix/lib' \ '$$prefix/libexec' \ @@ -106,7 +91,7 @@ build.stage2: '$$prefix/doc' \ '$$prefix/html' \ '$$prefix/haddock' \ - --distpref dist-stage2 \ + --distpref dist-stage$* \ $(INSTALL_FLAGS) # XXX fix: diff --git a/mk/cabal-flags.mk b/mk/cabal-flags.mk index d736679..c9663aa 100644 --- a/mk/cabal-flags.mk +++ b/mk/cabal-flags.mk @@ -63,25 +63,23 @@ INSTALL_DIRS_CONFIGURE_FLAGS = \ INPLACE_DIRS_CONFIGURE_FLAGS = \ --prefix=`$(TOP)/utils/pwd/pwd forwardslash`/install-inplace -USE_STAGE1_CONFIGURE_FLAGS = \ - --with-compiler=$(GHC_STAGE1) \ - --with-hc-pkg=$(FPTOOLS_TOP_ABS)/utils/ghc-pkg/ghc-pkg-inplace \ - $(addprefix --cc-option=,$(MACOSX_DEPLOYMENT_CC_OPTS)) \ - $(addprefix --ld-option=,$(MACOSX_DEPLOYMENT_LD_OPTS)) - USE_BOOT_CONFIGURE_FLAGS = \ --with-compiler=$(GHC) \ --with-hc-pkg=$(GHC_PKG) \ --package-db $(FPTOOLS_TOP_ABS)/libraries/bootstrapping.conf -# XXX -# --bindir='$$prefix/bin' \ -# --libdir='$$prefix/lib' \ -# --libexecdir='$$prefix/libexec' \ -# --datadir='$$prefix/data' \ -# --docdir='$$prefix/doc' \ -# --haddockdir='$$prefix/haddock' \ -# --htmldir='$$prefix/html' \ +USE_STAGE_CONFIGURE_FLAGS = \ + --with-hc-pkg=$(FPTOOLS_TOP_ABS)/utils/ghc-pkg/ghc-pkg-inplace \ + $(addprefix --cc-option=,$(MACOSX_DEPLOYMENT_CC_OPTS)) \ + $(addprefix --ld-option=,$(MACOSX_DEPLOYMENT_LD_OPTS)) + +USE_STAGE1_CONFIGURE_FLAGS = \ + --with-compiler=$(GHC_STAGE1) \ + $(USE_STAGE_CONFIGURE_FLAGS) + +USE_STAGE2_CONFIGURE_FLAGS = \ + --with-compiler=$(GHC_STAGE2) \ + $(USE_STAGE_CONFIGURE_FLAGS) BUILD_FLAGS = $(addprefix --ghc-option=,$(SRC_HC_OPTS)) -- 1.7.10.4