diff options
author | Ian Lynagh <igloo@earth.li> | 2009-04-26 11:42:15 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2009-04-26 11:42:15 +0000 |
commit | 34cc75e1a62638f2833815746ebce0a9114dc26b (patch) | |
tree | ef21e8fd7af1356beea9cce7d6efb8a65374e24c /ghc | |
parent | 74e1368d4688ee16f6decdf2cd3ebe27506b26ba (diff) | |
download | haskell-34cc75e1a62638f2833815746ebce0a9114dc26b.tar.gz |
GHC new build system megapatch
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/Main.hs | 2 | ||||
-rw-r--r-- | ghc/Makefile | 161 | ||||
-rw-r--r-- | ghc/ghc-bin.cabal.in | 3 | ||||
-rw-r--r-- | ghc/ghc.mk | 127 | ||||
-rw-r--r-- | ghc/ghc.wrapper | 2 |
5 files changed, 141 insertions, 154 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index df90857fbb..bdf9e63e43 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -10,8 +10,6 @@ module Main (main) where -#include "HsVersions.h" - -- The official GHC API import qualified GHC import GHC ( DynFlags(..), HscTarget(..), diff --git a/ghc/Makefile b/ghc/Makefile index ed7d24b643..664df24c4a 100644 --- a/ghc/Makefile +++ b/ghc/Makefile @@ -1,155 +1,16 @@ +dir = ghc +TOP = .. +SPEC_TARGETS = 1 2 3 +include $(TOP)/mk/sub-makefile.mk -TOP=.. -include $(TOP)/mk/boilerplate.mk -include $(TOP)/mk/cabal-flags.mk +.PHONY: 1 2 3 -ifeq "$(stage)" "" -stage=1 -endif +1: + +$(TOPMAKE) stage=1 all_ghc_stage1 compiler_stage1_NO_BUILD_DEPS=YES -ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -INSTALL_FLAGS = -else -INSTALL_FLAGS = --enable-shell-wrappers -endif +2: + +$(TOPMAKE) stage=2 all_ghc_stage2 compiler_stage2_NO_BUILD_DEPS=YES -# Don't strip the inplace versions, we might need to debug them -INPLACE_INSTALL_FLAGS += --disable-executable-stripping - -boot:: boot.stage.$(stage) - -all:: build.stage.$(stage) - -rebuild :: - -$(CABAL) clean --distpref dist-stage$(stage) - $(RM) -rf stage$(stage)-inplace - $(MAKE) boot all - -stage1 :: - $(MAKE) stage=1 - -stage2 :: - $(MAKE) stage=2 - -stage3 :: - $(MAKE) stage=3 - - -ifeq "$(CLEAN_ALL_STAGES)" "YES" -clean distclean maintainer-clean:: clean.stage.1 clean.stage.2 clean.stage.3 -else -clean distclean maintainer-clean:: clean.stage.$(stage) -endif - -ifeq "$(CLEAN_ALL_STAGES)" "YES" -distclean maintainer-clean:: - $(RM) -f ghc-bin.cabal -endif - -clean.stage.%: - $(RM) -rf stage$*-inplace -# This is a bit naughty. We ought to use: -# -$(CABAL) clean --distpref dist-stage$* -# but that won't work if the Cabal file (a generated file) doesn't -# exist. So we do this instead: - $(RM) -rf dist-stage$* - -CONFIGURE_FLAGS_STAGE1 += --flags=-ghci - -ifeq "$(GhcWithInterpreter)" "YES" -CONFIGURE_FLAGS_STAGE2PLUS += --flags=ghci -else -CONFIGURE_FLAGS_STAGE2PLUS += --flags=-ghci -endif - -ifeq "$(GhcProfiled)" "YES" -CONFIGURE_FLAGS_STAGE2PLUS += --enable-executable-profiling -endif -ifeq "$(GhcDebugged)" "YES" -CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-debug -endif -ifeq "$(GhcThreaded)" "YES" -# Use threaded RTS with GHCi, so threads don't get blocked at the prompt. -CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-threaded -endif - -ifeq "$(BuildSharedLibs)" "YES" -CONFIGURE_FLAGS_STAGE2PLUS += --ghc-option=-dynamic -endif - -CONFIGURE_FLAGS_STAGE2 = $(CONFIGURE_FLAGS_STAGE2PLUS) -CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2PLUS) - -CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS) -CONFIGURE_FLAGS_STAGE2 += $(USE_STAGE1_CONFIGURE_FLAGS) -CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS) -CONFIGURE_FLAGS_STAGE3 += --package-db $(STAGE3_PACKAGE_CONF) - -CONFIGURE_FLAGS_STAGE1 += $(foreach flag, $(GhcStage1HcOpts), --ghc-option=$(flag)) -CONFIGURE_FLAGS_STAGE2 += $(foreach flag, $(GhcStage2HcOpts), --ghc-option=$(flag)) -CONFIGURE_FLAGS_STAGE3 += $(foreach flag, $(GhcStage3HcOpts), --ghc-option=$(flag)) - -BUILD_FLAGS += $(patsubst %, --ghc-option=%, $(SRC_HC_OPTS)) -# Allow EXTRA_HC_OPTS to be used from the command line to add options -# when building (e.g. -v) -BUILD_FLAGS += $(patsubst %, --ghc-option=%, $(EXTRA_HC_OPTS)) - -# 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 - -ifeq "$(stage)" "1" -ifeq "$(ghc_ge_609)" "NO" -# GHC 6.9+ can handle cross-package recompilation checking, but -# we don't rely on the bootstrapping compiler being able to do this. -TOUCH_MAIN = $(RM) dist-stage1/build/ghc/ghc-tmp/Main.o -endif -endif - -dist-stage1 dist-stage2 dist-stage3: dist-stage%: boot.stage.% - -boot.stage.%: - $(CABAL) configure --distpref dist-stage$* \ - $(INSTALL_DIRS_CONFIGURE_FLAGS) \ - $(CONFIGURE_FLAGS_STAGE$*) \ - $(COMMON_CONFIGURE_FLAGS) \ - --libsubdir=. \ - --datadir='$$libdir' \ - --datasubdir=. - -build.stage.%: dist-stage% - $(TOUCH_MAIN) - $(CABAL) build --distpref dist-stage$* $(BUILD_FLAGS) - $(INSTALL_PACKAGE) install '$(GHC_PKG_PROG)' 'XXX/package.conf' "" \ - $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \ - $(FPTOOLS_TOP_ABS)/ghc/stage$*-inplace \ - '$$prefix' \ - '$(INPLACE_DATA_DIR)' \ - '$$prefix/libexec' \ - '$$prefix/dynlib' \ - '$(INPLACE_DATA_DIR)' \ - '$$prefix/doc' \ - '$$prefix/html' \ - '$$prefix/haddock' \ - --distpref dist-stage$* \ - $(INPLACE_INSTALL_FLAGS) \ - $(INSTALL_FLAGS) - -# XXX For now we always install the stage 2 compiler -install: - $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \ - '$(prefix)' '$(bindir)' '$(libdir)' \ - '$(libexecdir)' '$(dynlibdir)' '$(datadir)' \ - '$(docdir)' '$(htmldir)' '$(haddockdir)' \ - --distpref dist-stage2 \ - $(INSTALL_FLAGS) - -html: - @: - -install-docs: - @: - -include $(TOP)/mk/bindist.mk -EXE_DIST_DIR = dist-stage2 +3: + +$(TOPMAKE) stage=3 all_ghc_stage3 compiler_stage3_NO_BUILD_DEPS=YES diff --git a/ghc/ghc-bin.cabal.in b/ghc/ghc-bin.cabal.in index 4e6d0081b1..3374edf62d 100644 --- a/ghc/ghc-bin.cabal.in +++ b/ghc/ghc-bin.cabal.in @@ -1,3 +1,6 @@ +-- WARNING: ghc-bin.cabal is automatically generated from ghc-bin.cabal.in by +-- ./configure. Make sure you are editing ghc-bin.cabal.in, not ghc-bin.cabal. + Name: ghc-bin Version: @ProjectVersion@ Copyright: XXX diff --git a/ghc/ghc.mk b/ghc/ghc.mk new file mode 100644 index 0000000000..7f9c630771 --- /dev/null +++ b/ghc/ghc.mk @@ -0,0 +1,127 @@ +# ToDo +ghc_USES_CABAL = NO +# ghc_PACKAGE = ghc-bin + +ghc_stage1_HC_OPTS = $(GhcStage1HcOpts) +ghc_stage2_HC_OPTS = $(GhcStage2HcOpts) +ghc_stage3_HC_OPTS = $(GhcStage3HcOpts) + +ifeq "$(GhcWithInterpreter)" "YES" +ghc_stage2_HC_OPTS += -DGHCI +ghc_stage3_HC_OPTS += -DGHCI +endif + +ifeq "$(GhcDebugged)" "YES" +ghc_HC_OPTS += -debug +endif + +ifeq "$(GhcThreaded)" "YES" +# Use threaded RTS with GHCi, so threads don't get blocked at the prompt. +ghc_HC_OPTS += -threaded +endif + +ifeq "$(BuildSharedLibs)" "YES" +ghc_HC_OPTS += -dynamic +endif + +# XXX ToDp +# ifeq "$(GhcProfiled)" "YES" + +ghc_stage1_MODULES = Main + +ghc_stage2_MODULES = $(ghc_stage1_MODULES) +ghc_stage3_MODULES = $(ghc_stage1_MODULES) + +ghc_stage1_PROG = ghc-stage1$(exeext) +ghc_stage2_PROG = ghc-stage2$(exeext) +ghc_stage3_PROG = ghc-stage3$(exeext) + +# ToDo: perhaps use ghc-cabal to configure ghc-bin +ghc_stage1_USE_BOOT_LIBS = YES +ghc_stage1_HC_OPTS += -package $(compiler_PACKAGE)-$(compiler_stage1_VERSION) +ghc_stage2_HC_OPTS += -package $(compiler_PACKAGE)-$(compiler_stage2_VERSION) +ghc_stage3_HC_OPTS += -package $(compiler_PACKAGE)-$(compiler_stage3_VERSION) + +ghc_stage1_HC_OPTS += -XCPP -XPatternGuards +ghc_stage2_HC_OPTS += -XCPP -XPatternGuards +ghc_stage3_HC_OPTS += -XCPP -XPatternGuards + +# In stage1 we might not benefit from cross-package dependencies and +# recompilation checking. We must force recompilation here, otherwise +# Main.o won't necessarily be rebuilt when the ghc package has changed: +ghc_stage1_HC_OPTS += -fforce-recomp + +# Further dependencies we need only in stage 1, due to no +# cross-package dependencies or recompilation checking. +ghc/stage1/build/Main.o : $(compiler_stage1_v_LIB) + +ghc_stage1_SHELL_WRAPPER = YES +ghc_stage2_SHELL_WRAPPER = YES +ghc_stage3_SHELL_WRAPPER = YES +ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper +ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper +ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper + +ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER = YES +ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion) + +# stage 1 is enabled unless $(stage) is set to something other than 1 +ifeq "$(filter-out 1,$(stage))" "" +$(eval $(call build-prog,ghc,stage1,0)) +endif + +# stage 2 is enabled unless $(stage) is set to something other than 2 +ifeq "$(filter-out 2,$(stage))" "" +$(eval $(call build-prog,ghc,stage2,1)) +endif + +# stage 3 has to be requested explicitly with stage=3 +ifeq "$(stage)" "3" +$(eval $(call build-prog,ghc,stage3,2)) +endif + +ifneq "$(BINDIST)" "YES" + +# ToDo: should we add these in the build-prog macro? +ghc/stage1/build/tmp/$(ghc_stage1_PROG) : $(compiler_stage1_v_LIB) +ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_v_LIB) +ghc/stage3/build/tmp/$(ghc_stage3_PROG) : $(compiler_stage3_v_LIB) + +all_ghc_stage1 : $(GHC_STAGE1) +all_ghc_stage2 : $(GHC_STAGE2) +all_ghc_stage3 : $(GHC_STAGE3) + +$(INPLACE_LIB)/extra-gcc-opts : extra-gcc-opts + $(CP) $< $@ + +# The GHC programs need to depend on all the helper programs they might call +$(GHC_STAGE1) : $(INPLACE_LIB)/extra-gcc-opts $(MANGLER) $(SPLIT) +$(GHC_STAGE2) : $(INPLACE_LIB)/extra-gcc-opts $(MANGLER) $(SPLIT) +$(GHC_STAGE3) : $(INPLACE_LIB)/extra-gcc-opts $(MANGLER) $(SPLIT) + +ifeq "$(Windows)" "YES" +$(GHC_STAGE1) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe +$(GHC_STAGE2) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe +$(GHC_STAGE3) : $(TOUCHY) $(INPLACE)/stamp-mingw $(INPLACE_LIB)/perl.exe +endif + +endif + +INSTALL_LIBS += extra-gcc-opts + +ifeq "$(Windows)" "NO" +install: install_ghc_link +.PNONY: install_ghc_link +install_ghc_link: + $(RM) -f $(DESTDIR)$(bindir)/ghc + $(LN_S) ghc-$(ProjectVersion) $(DESTDIR)$(bindir)/ghc +else +# On Windows we install the main binary as $(bindir)/ghc.exe +# To get ghc-<version>.exe we have a little C program in driver/ghc +install: install_ghc_post +.PHONY: install_ghc_post +install_ghc_post: install_bins + $(RM) -f $(DESTDIR)$(bindir)/ghc.exe + $(MV) -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/ghc.exe +endif + diff --git a/ghc/ghc.wrapper b/ghc/ghc.wrapper index 71eae84738..ce409ca488 100644 --- a/ghc/ghc.wrapper +++ b/ghc/ghc.wrapper @@ -1,3 +1 @@ -#!/bin/sh - exec $executablename -B$datadir -dynload wrapped ${1+"$@"} |