summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hadrian/src/Rules/Generate.hs57
-rw-r--r--hadrian/src/Rules/Lint.hs3
-rw-r--r--rts/configure.ac25
-rw-r--r--rts/ghcplatform.h.bottom2
-rw-r--r--rts/ghcplatform.h.top.in23
-rw-r--r--rts/rts.cabal.in2
6 files changed, 54 insertions, 58 deletions
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index b156c9dfdf..c72002eb56 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -146,10 +146,10 @@ generatePackageCode context@(Context stage pkg _ _) = do
when (pkg == rts) $ do
root -/- "**" -/- dir -/- "cmm/AutoApply.cmm" %> \file ->
build $ target context GenApply [] [file]
- let go gen file = generate file (semiEmptyTarget stage) gen
root -/- "**" -/- dir -/- "include/ghcautoconf.h" %> \_ ->
need . pure =<< pkgSetupConfigFile context
- root -/- "**" -/- dir -/- "include/ghcplatform.h" %> go generateGhcPlatformH
+ root -/- "**" -/- dir -/- "include/ghcplatform.h" %> \_ ->
+ need . pure =<< pkgSetupConfigFile context
root -/- "**" -/- dir -/- "include/DerivedConstants.h" %> genPlatformConstantsHeader context
root -/- "**" -/- dir -/- "include/rts/EventLogConstants.h" %> genEventTypes "--event-types-defines"
root -/- "**" -/- dir -/- "include/rts/EventTypes.h" %> genEventTypes "--event-types-array"
@@ -320,59 +320,6 @@ ghcWrapper stage = do
else [])
++ [ "$@" ]
--- | Given a 'String' replace characters '.' and '-' by underscores ('_') so that
--- the resulting 'String' is a valid C preprocessor identifier.
-cppify :: String -> String
-cppify = replaceEq '-' '_' . replaceEq '.' '_'
-
--- | Generate @ghcplatform.h@ header.
-generateGhcPlatformH :: Expr String
-generateGhcPlatformH = do
- trackGenerateHs
- stage <- getStage
- let chooseSetting x y = getSetting $ case stage of { Stage0 {} -> x; _ -> y }
- buildPlatform <- chooseSetting BuildPlatform HostPlatform
- buildArch <- chooseSetting BuildArch HostArch
- buildOs <- chooseSetting BuildOs HostOs
- buildVendor <- chooseSetting BuildVendor HostVendor
- hostPlatform <- chooseSetting HostPlatform TargetPlatform
- hostArch <- chooseSetting HostArch TargetArch
- hostOs <- chooseSetting HostOs TargetOs
- hostVendor <- chooseSetting HostVendor TargetVendor
- ghcUnreg <- getFlag GhcUnregisterised
- return . unlines $
- [ "#if !defined(__GHCPLATFORM_H__)"
- , "#define __GHCPLATFORM_H__"
- , ""
- , "#define BuildPlatform_TYPE " ++ cppify buildPlatform
- , "#define HostPlatform_TYPE " ++ cppify hostPlatform
- , ""
- , "#define " ++ cppify buildPlatform ++ "_BUILD 1"
- , "#define " ++ cppify hostPlatform ++ "_HOST 1"
- , ""
- , "#define " ++ buildArch ++ "_BUILD_ARCH 1"
- , "#define " ++ hostArch ++ "_HOST_ARCH 1"
- , "#define BUILD_ARCH " ++ show buildArch
- , "#define HOST_ARCH " ++ show hostArch
- , ""
- , "#define " ++ buildOs ++ "_BUILD_OS 1"
- , "#define " ++ hostOs ++ "_HOST_OS 1"
- , "#define BUILD_OS " ++ show buildOs
- , "#define HOST_OS " ++ show hostOs
- , ""
- , "#define " ++ buildVendor ++ "_BUILD_VENDOR 1"
- , "#define " ++ hostVendor ++ "_HOST_VENDOR 1"
- , "#define BUILD_VENDOR " ++ show buildVendor
- , "#define HOST_VENDOR " ++ show hostVendor
- , ""
- ]
- ++
- [ "#define UnregisterisedCompiler 1" | ghcUnreg ]
- ++
- [ ""
- , "#endif /* __GHCPLATFORM_H__ */"
- ]
-
-- See Note [tooldir: How GHC finds mingw on Windows]
generateSettings :: Expr String
generateSettings = do
diff --git a/hadrian/src/Rules/Lint.hs b/hadrian/src/Rules/Lint.hs
index 0928ec02eb..2a145d30b3 100644
--- a/hadrian/src/Rules/Lint.hs
+++ b/hadrian/src/Rules/Lint.hs
@@ -20,6 +20,8 @@ lintRules = do
cmd_ (Cwd "libraries/base") "./configure"
"rts" -/- "include" -/- "ghcautoconf.h" %> \_ ->
cmd_ (Cwd "rts") "./configure"
+ "rts" -/- "include" -/- "ghcplatform.h" %> \_ ->
+ cmd_ (Cwd "rts") "./configure"
lint :: Action () -> Action ()
lint lintAction = do
@@ -66,7 +68,6 @@ base = do
let includeDirs =
[ "rts/include"
, "libraries/base/include"
- , stage1RtsInc
]
runHLint includeDirs [] "libraries/base"
diff --git a/rts/configure.ac b/rts/configure.ac
index 21e6f57602..be8ecb7cb3 100644
--- a/rts/configure.ac
+++ b/rts/configure.ac
@@ -22,6 +22,8 @@ dnl #define SIZEOF_CHAR 0
dnl recently.
AC_PREREQ([2.69])
+AC_CONFIG_FILES([ghcplatform.h.top])
+
AC_CONFIG_HEADERS([ghcautoconf.h.autoconf])
AC_ARG_ENABLE(asserts-all-ways,
@@ -85,6 +87,10 @@ FP_CC_LLVM_BACKEND
AS_IF([test x"$CcLlvmBackend" = x"YES"],
[AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end])])
+GHC_CONVERT_PLATFORM_PARTS([build], [Build])
+FPTOOLS_SET_PLATFORM_VARS([build],[Build])
+FPTOOLS_SET_HASKELL_PLATFORM_VARS([Build])
+
GHC_CONVERT_PLATFORM_PARTS([host], [Host])
FPTOOLS_SET_PLATFORM_VARS([host], [Host])
FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
@@ -357,11 +363,28 @@ dnl --------------------------------------------------------------
AC_OUTPUT
dnl ######################################################################
-dnl Generate ghcautoconf.h
+dnl Generate ghcplatform.h
dnl ######################################################################
[
mkdir -p include
+
+touch include/ghcplatform.h
+> include/ghcplatform.h
+
+cat ghcplatform.h.top >> include/ghcplatform.h
+]
+AS_IF([test x"${Unregisterised}" = x"YES"],
+ [echo "#define UnregisterisedCompiler 1" >> include/ghcplatform.h])
+[
+cat $srcdir/ghcplatform.h.bottom >> include/ghcplatform.h
+]
+
+dnl ######################################################################
+dnl Generate ghcautoconf.h
+dnl ######################################################################
+
+[
touch include/ghcautoconf.h
> include/ghcautoconf.h
diff --git a/rts/ghcplatform.h.bottom b/rts/ghcplatform.h.bottom
new file mode 100644
index 0000000000..77c4b77653
--- /dev/null
+++ b/rts/ghcplatform.h.bottom
@@ -0,0 +1,2 @@
+
+#endif /* __GHCPLATFORM_H__ */
diff --git a/rts/ghcplatform.h.top.in b/rts/ghcplatform.h.top.in
new file mode 100644
index 0000000000..ebb1961a1f
--- /dev/null
+++ b/rts/ghcplatform.h.top.in
@@ -0,0 +1,23 @@
+#if !defined(__GHCPLATFORM_H__)
+#define __GHCPLATFORM_H__
+
+#define BuildPlatform_TYPE @BuildPlatform_CPP@
+#define HostPlatform_TYPE @HostPlatform_CPP@
+
+#define @BuildPlatform_CPP@_BUILD 1
+#define @HostPlatform_CPP@_HOST 1
+
+#define @BuildArch_CPP@_BUILD_ARCH 1
+#define @HostArch_CPP@_HOST_ARCH 1
+#define BUILD_ARCH "@BuildArch_CPP@"
+#define HOST_ARCH "@HostArch_CPP@"
+
+#define @BuildOS_CPP@_BUILD_OS 1
+#define @HostOS_CPP@_HOST_OS 1
+#define BUILD_OS "@BuildOS_CPP@"
+#define HOST_OS "@HostOS_CPP@"
+
+#define @BuildVendor_CPP@_BUILD_VENDOR 1
+#define @HostVendor_CPP@_HOST_VENDOR 1
+#define BUILD_VENDOR "@BuildVendor_CPP@"
+#define HOST_VENDOR "@HostVendor_CPP@"
diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in
index 98ca808917..d9bfa8657c 100644
--- a/rts/rts.cabal.in
+++ b/rts/rts.cabal.in
@@ -224,7 +224,7 @@ library
include-dirs: include
includes: Rts.h
- autogen-includes: ghcautoconf.h
+ autogen-includes: ghcautoconf.h ghcplatform.h
install-includes: Cmm.h HsFFI.h MachDeps.h Rts.h RtsAPI.h Stg.h
ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
-- ^ from include