Skip to content
Snippets Groups Projects
Commit 0295375a authored by John Ericson's avatar John Ericson Committed by Marge Bot
Browse files

Generate `ghcversion.h` from a `.in` file

Now that there are no conditional sections (see the previous commit), we
can just a do simple substitution rather than pasting it together line
by line.

Progress on #23966
parent b12df0bb
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
......@@ -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
......
#if !defined(__GHCVERSION_H__)
#define __GHCVERSION_H__
#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__ || \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment