b8846be6f48bb01598c405812696ee077d679d8c
[ghc.git] / src / Settings / Builders / DeriveConstants.hs
1 module Settings.Builders.DeriveConstants (deriveConstantsBuilderArgs) where
2
3 import Settings.Builders.Common
4
5 -- TODO: do we need to support `includes_CC_OPTS += -DDYNAMIC_BY_DEFAULT`?
6 deriveConstantsBuilderArgs :: Args
7 deriveConstantsBuilderArgs = builder DeriveConstants ? do
8 cFlags <- includeCcArgs
9 [outputFile, tempDir] <- getOutputs
10 mconcat
11 [ output "//DerivedConstants.h" ? arg "--gen-header"
12 , output "//GHCConstantsHaskellType.hs" ? arg "--gen-haskell-type"
13 , output "//platformConstants" ? arg "--gen-haskell-value"
14 , output "//GHCConstantsHaskellWrappers.hs" ? arg "--gen-haskell-wrappers"
15 , output "//GHCConstantsHaskellExports.hs" ? arg "--gen-haskell-exports"
16 , arg "-o", arg outputFile
17 , arg "--tmpdir", arg tempDir
18 , arg "--gcc-program", arg =<< getBuilderPath (Cc CompileC Stage1)
19 , pure $ concatMap (\a -> ["--gcc-flag", a]) cFlags
20 , arg "--nm-program", arg =<< getBuilderPath Nm
21 , isSpecified Objdump ? mconcat [ arg "--objdump-program"
22 , arg =<< getBuilderPath Objdump ]
23 , arg "--target-os", arg =<< getSetting TargetOs ]
24
25 includeCcArgs :: Args
26 includeCcArgs = do
27 root <- getBuildRoot
28 mconcat [ cArgs
29 , cWarnings
30 , getSettingList $ ConfCcArgs Stage1
31 , flag GhcUnregisterised ? arg "-DUSE_MINIINTERPRETER"
32 , arg "-Irts"
33 , arg "-Iincludes"
34 , arg $ "-I" ++ root -/- generatedDir
35 , notM ghcWithSMP ? arg "-DNOSMP"
36 , arg "-fcommon" ]