diff --git a/configure.ac b/configure.ac index 964e1497134c2d94744c99b1782ea9a227b36f95..1fa892e73353e93593cdbe2290b9e967125c1246 100644 --- a/configure.ac +++ b/configure.ac @@ -68,21 +68,6 @@ FP_PROG_SORT dnl ---------------------------------------------------------- FP_SETUP_PROJECT_VERSION -dnl Don't use AC_DEFINE because it will make C-style comments invalid for -dnl Haskell. - -> rts/include/ghcversion.h - -cat rts/ghcversion.h.top >> rts/include/ghcversion.h - -echo "#define __GLASGOW_HASKELL__ ${ProjectVersionInt}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_FULL_VERSION__ \"${ProjectVersion}\"" >> rts/include/ghcversion.h -echo >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_PATCHLEVEL1__ ${ProjectPatchLevel1}" >> rts/include/ghcversion.h -echo "#define __GLASGOW_HASKELL_PATCHLEVEL2__ ${ProjectPatchLevel2}" >> rts/include/ghcversion.h - -cat rts/ghcversion.h.bottom >> rts/include/ghcversion.h - # Hmmm, we fix the RPM release number to 1 here... Is this convenient? AC_SUBST([release], [1]) @@ -103,8 +88,6 @@ AC_PREREQ([2.69]) AC_CONFIG_HEADER(mk/config.h) # This one is manually maintained. AC_CONFIG_HEADER(compiler/ghc-llvm-version.h) -dnl manually outputted above, for reasons described there. -dnl AC_CONFIG_HEADER(rts/include/ghcversion.h) # No, semi-sadly, we don't do `--srcdir'... if test x"$srcdir" != 'x.' ; then diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index 6a6875c22eeaf720f46a7a191b22e5053f97a612..b5c56f8010a6849f49ecf9366a1b563973272050 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -323,6 +323,12 @@ templateRules = do templateRule "utils/ghc-pkg/ghc-pkg.cabal" $ projectVersion templateRule "libraries/template-haskell/template-haskell.cabal" $ projectVersion templateRule "libraries/prologue.txt" $ packageVersions + templateRule "rts/include/ghcversion.h" $ mconcat + [ interpolateSetting "ProjectVersionInt" ProjectVersionInt + , interpolateSetting "ProjectVersion" ProjectVersion + , interpolateSetting "ProjectPatchLevel1" ProjectPatchLevel1 + , interpolateSetting "ProjectPatchLevel2" ProjectPatchLevel2 + ] templateRule "docs/index.html" $ packageVersions templateRule "docs/users_guide/ghc_config.py" $ mconcat [ projectVersion diff --git a/hadrian/src/Settings/Builders/Cabal.hs b/hadrian/src/Settings/Builders/Cabal.hs index 5cde8697cc1c6fdd3bb9929dfdfe826e29652aa7..3e83bb563423173d80ddbc04fd1a263030642d82 100644 --- a/hadrian/src/Settings/Builders/Cabal.hs +++ b/hadrian/src/Settings/Builders/Cabal.hs @@ -166,9 +166,14 @@ configureStageArgs = do let cFlags = getStagedCCFlags linkFlags = prgFlags . ccLinkProgram . tgtCCompilerLink <$> getStagedTarget mconcat [ configureArgs cFlags linkFlags - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] +ghcVersionH :: Args +ghcVersionH = notStage0 ? do + let h = "rts/include/ghcversion.h" + expr $ need [h] + arg $ "--ghc-option=-ghcversion-file=" <> h configureArgs :: Args -> Args -> Args configureArgs cFlags' ldFlags' = do @@ -199,7 +204,7 @@ configureArgs cFlags' ldFlags' = do -- ROMES:TODO: how is the Host set to TargetPlatformFull? That would be the target , conf "--host" $ arg =<< getSetting TargetPlatformFull , conf "--with-cc" $ arg =<< getBuilderPath . (Cc CompileC) =<< getStage - , notStage0 ? arg "--ghc-option=-ghcversion-file=rts/include/ghcversion.h" + , ghcVersionH ] bootPackageConstraints :: Args diff --git a/rts/ghcversion.h.top b/rts/ghcversion.h.top deleted file mode 100644 index 788dba3f408553a3b8d83e366796ec1fbe667166..0000000000000000000000000000000000000000 --- a/rts/ghcversion.h.top +++ /dev/null @@ -1,3 +0,0 @@ -#if !defined(__GHCVERSION_H__) -#define __GHCVERSION_H__ - diff --git a/rts/ghcversion.h.bottom b/rts/include/ghcversion.h.in similarity index 58% rename from rts/ghcversion.h.bottom rename to rts/include/ghcversion.h.in index b9a8fc29c6c21b60f825bdea1510598a5e753841..dc700a4fbbf9d2b2ecb6c8640aa6af309d66116c 100644 --- a/rts/ghcversion.h.bottom +++ b/rts/include/ghcversion.h.in @@ -1,3 +1,11 @@ +#if !defined(__GHCVERSION_H__) +#define __GHCVERSION_H__ + +#define __GLASGOW_HASKELL__ @ProjectVersionInt@ +#define __GLASGOW_HASKELL_FULL_VERSION__ "@ProjectVersion@" + +#define __GLASGOW_HASKELL_PATCHLEVEL1__ @ProjectPatchLevel1@ +#define __GLASGOW_HASKELL_PATCHLEVEL2__ @ProjectPatchLevel2@ #define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) ( \ ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \