diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2021-02-13 11:47:48 +0800 |
---|---|---|
committer | Moritz Angermann <moritz.angermann@gmail.com> | 2021-02-17 07:24:00 +0800 |
commit | 1cab640962376a9a7db8da1574937d963feb6e1f (patch) | |
tree | 992c321e6b76081f7629b28407db0fab11a8cc98 | |
parent | 8efc660d041cff413a53cb821bc952adb1852032 (diff) | |
download | haskell-1cab640962376a9a7db8da1574937d963feb6e1f.tar.gz |
[make] Allow to set the curses library for stage0
This may be necessary when building stage2 cross compiled
compilers.
-rw-r--r-- | aclocal.m4 | 9 | ||||
-rw-r--r-- | hadrian/cfg/system.config.in | 5 | ||||
-rw-r--r-- | hadrian/src/Context.hs | 8 | ||||
-rw-r--r-- | hadrian/src/Oracles/Setting.hs | 6 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/Cabal.hs | 2 | ||||
-rw-r--r-- | mk/config.mk.in | 1 | ||||
-rw-r--r-- | rules/build-package-data.mk | 10 |
7 files changed, 36 insertions, 5 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index 015d4d12e9..259db63dbf 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1909,6 +1909,15 @@ AC_DEFUN([FP_CURSES], AC_SUBST(CURSES_INCLUDE_DIRS) AC_SUBST(CURSES_LIB_DIRS) + + AC_ARG_WITH([curses-libraries-stage0], + [AC_HELP_STRING([--with-curses-libraries-stage0], + [directory containing build-platform curses libraries (for stage0 build)])], + [CURSES_LIB_DIRS_STAGE0=$withval], + [CURSES_LIB_DIRS_STAGE0=$CURSES_LIB_DIRS]) + + AC_SUBST(CURSES_LIB_DIRS_STAGE0) + ])# FP_CURSES # -------------------------------------------------------------- diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in index 46e564d4cb..4463548a87 100644 --- a/hadrian/cfg/system.config.in +++ b/hadrian/cfg/system.config.in @@ -171,7 +171,10 @@ target-arm-version = @ARM_ISA@ # Include and library directories: #================================= -curses-lib-dir = @CURSES_LIB_DIRS@ +curses-lib-dir-stage0 = @CURSES_LIB_DIRS_STAGE0@ +curses-lib-dir-stage1 = @CURSES_LIB_DIRS@ +curses-lib-dir-stage2 = @CURSES_LIB_DIRS@ +curses-lib-dir-stage3 = @CURSES_LIB_DIRS@ iconv-include-dir = @ICONV_INCLUDE_DIRS@ iconv-lib-dir = @ICONV_LIB_DIRS@ diff --git a/hadrian/src/Context.hs b/hadrian/src/Context.hs index 0676743ee5..2ead1378aa 100644 --- a/hadrian/src/Context.hs +++ b/hadrian/src/Context.hs @@ -3,7 +3,9 @@ module Context ( Context (..), vanillaContext, stageContext, -- * Expressions - getStage, getPackage, getWay, getStagedSettingList, getBuildPath, + getStage, getPackage, getWay, + getStagedSetting, getStagedSettingList, + getBuildPath, -- * Paths contextDir, buildPath, buildDir, pkgInplaceConfig, pkgSetupConfigFile, @@ -44,6 +46,10 @@ getWay = way <$> getContext getStagedSettingList :: (Stage -> SettingList) -> Args Context b getStagedSettingList f = getSettingList . f =<< getStage +-- | Get a configuration setting for the current stage. +getStagedSetting :: (Stage -> Setting) -> Expr Context b String +getStagedSetting f = getSetting . f =<< getStage + -- | Path to the directory containg the final artifact in a given 'Context'. libPath :: Context -> Action FilePath libPath Context {..} = buildRoot <&> (-/- (stageString stage -/- "lib")) diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs index 3731cdb94e..a8ac1ee69e 100644 --- a/hadrian/src/Oracles/Setting.hs +++ b/hadrian/src/Oracles/Setting.hs @@ -36,7 +36,6 @@ data Setting = BuildArch | BuildOs | BuildPlatform | BuildVendor - | CursesLibDir | DynamicExtension | FfiIncludeDir | FfiLibDir @@ -76,6 +75,8 @@ data Setting = BuildArch | TargetArchHaskell | TargetOsHaskell | TargetArmVersion + -- staged settings + | CursesLibDir Stage -- TODO: Reduce the variety of similar flags (e.g. CPP and non-CPP versions). -- | Each 'SettingList' comes from the file @hadrian/cfg/system.config@, @@ -132,7 +133,6 @@ setting key = lookupValueOrError configFile $ case key of BuildOs -> "build-os" BuildPlatform -> "build-platform" BuildVendor -> "build-vendor" - CursesLibDir -> "curses-lib-dir" DynamicExtension -> "dynamic-extension" FfiIncludeDir -> "ffi-include-dir" FfiLibDir -> "ffi-lib-dir" @@ -172,6 +172,8 @@ setting key = lookupValueOrError configFile $ case key of TargetVendor -> "target-vendor" TargetArchHaskell -> "target-arch-haskell" TargetOsHaskell -> "target-os-haskell" + -- Staged settings + CursesLibDir stage -> "curses-lib-dir-" ++ stageString stage -- | Look up the value of a 'SettingList' in @cfg/system.config@, tracking the -- result. diff --git a/hadrian/src/Settings/Builders/Cabal.hs b/hadrian/src/Settings/Builders/Cabal.hs index 85350d96e6..d291a13f1f 100644 --- a/hadrian/src/Settings/Builders/Cabal.hs +++ b/hadrian/src/Settings/Builders/Cabal.hs @@ -124,7 +124,7 @@ configureArgs = do , conf "--with-iconv-libraries" $ arg =<< getSetting IconvLibDir , conf "--with-gmp-includes" $ arg =<< getSetting GmpIncludeDir , conf "--with-gmp-libraries" $ arg =<< getSetting GmpLibDir - , conf "--with-curses-libraries" $ arg =<< getSetting CursesLibDir + , conf "--with-curses-libraries" $ arg =<< getStagedSetting CursesLibDir , flag CrossCompiling ? (conf "--host" $ arg =<< getSetting TargetPlatformFull) , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage , notStage0 ? (arg =<< ("--ghc-option=-ghcversion-file=" ++) <$> expr ((-/-) <$> topDirectory <*> ghcVersionH stage))] diff --git a/mk/config.mk.in b/mk/config.mk.in index 7a5993eedd..92d552fc35 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -911,6 +911,7 @@ GMP_PREFER_FRAMEWORK = @GMP_PREFER_FRAMEWORK@ GMP_FORCE_INTREE = @GMP_FORCE_INTREE@ CURSES_LIB_DIRS = @CURSES_LIB_DIRS@ +CURSES_LIB_DIRS_STAGE0 = @CURSES_LIB_DIRS_STAGE0@ # See Note [Disable -O2 in unregisterised mode] # Be careful: 'GhcUnregisterised' should be defined earlier in this file. diff --git a/rules/build-package-data.mk b/rules/build-package-data.mk index 1c5987e63d..364c2ef2e1 100644 --- a/rules/build-package-data.mk +++ b/rules/build-package-data.mk @@ -100,9 +100,19 @@ ifeq "$$(GMP_FORCE_INTREE)" "YES" $1_$2_CONFIGURE_OPTS += --configure-option=--with-intree-gmp endif +ifeq "$3" "0" +ifneq "$$(CURSES_LIB_DIRS_STAGE0)" "" +$1_$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="$$(CURSES_LIB_DIRS_STAGE0)" +else +ifneq "$$(CURSES_LIB_DIRS)" "" +$1_$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="$$(CURSES_LIB_DIRS)" +endif +endif +else ifneq "$$(CURSES_LIB_DIRS)" "" $1_$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="$$(CURSES_LIB_DIRS)" endif +endif ifeq "$$(CrossCompiling)" "YES" $1_$2_CONFIGURE_OPTS += --configure-option=--host=$(TargetPlatformFull) |