Commit 66f18bec authored by Moritz Angermann's avatar Moritz Angermann
Browse files

Generate includes/ghcversion.h

This should be the final commit to fix #39.
parent 43b6cc39
......@@ -46,6 +46,7 @@ executable ghc-shake
, Rules.Generators.GhcAutoconfH
, Rules.Generators.GhcBootPlatformH
, Rules.Generators.GhcPlatformH
, Rules.Generators.GhcVersionH
, Rules.Generators.VersionHs
, Rules.Install
, Rules.Library
......
......@@ -9,6 +9,7 @@ import Rules.Generators.ConfigHs
import Rules.Generators.GhcAutoconfH
import Rules.Generators.GhcBootPlatformH
import Rules.Generators.GhcPlatformH
import Rules.Generators.GhcVersionH
import Rules.Generators.VersionHs
import Oracles.ModuleFiles
import Rules.Actions
......@@ -107,6 +108,7 @@ generateRules :: Rules ()
generateRules = do
"includes/ghcautoconf.h" <~ generateGhcAutoconfH
"includes/ghcplatform.h" <~ generateGhcPlatformH
"includes/ghcversion.h" <~ generateGhcVersionH
where
file <~ gen = file %> \out -> generate out emptyTarget gen
......
module Rules.Generators.GhcVersionH (generateGhcVersionH) where
import Expression
import Oracles
generateGhcVersionH :: Expr String
generateGhcVersionH = do
version <- getSetting ProjectVersionInt
patchLevel1 <- getSetting ProjectPatchLevel1
patchLevel2 <- getSetting ProjectPatchLevel2
return . unlines $
[ "#ifndef __GHCVERSION_H__"
, "#define __GHCVERSION_H__"
, ""
, "#ifndef __GLASGOW_HASKELL__"
, "# define __GLASGOW_HASKELL__ " ++ version
, "#endif"
, ""]
++
[ "#define __GLASGOW_HASKELL_PATCHLEVEL1__ " ++ patchLevel1 | patchLevel1 /= "" ]
++
[ "#define __GLASGOW_HASKELL_PATCHLEVEL2__ " ++ patchLevel2 | patchLevel2 /= "" ]
++
[ ""
, "#define MIN_VERSION_GLASGOW_HASKELL(ma,mi,pl1,pl2) (\\"
, " ((ma)*100+(mi)) < __GLASGOW_HASKELL__ || \\"
, " ((ma)*100+(mi)) == __GLASGOW_HASKELL__ \\"
, " && (pl1) < __GLASGOW_HASKELL_PATCHLEVEL1__ || \\"
, " ((ma)*100+(mi)) == __GLASGOW_HASKELL__ \\"
, " && (pl1) == __GLASGOW_HASKELL_PATCHLEVEL1__ \\"
, " && (pl2) <= __GLASGOW_HASKELL_PATCHLEVEL2__ )"
, ""
, "#endif /* __GHCVERSION_H__ */" ]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment