Refactor imports.
[hadrian.git] / src / Oracles / Flag.hs
1 module Oracles.Flag (
2 Flag (..), flag,
3 crossCompiling, gccIsClang, gccLt46,
4 platformSupportsSharedLibs, ghcWithSMP, ghcWithNativeCodeGen
5 ) where
6
7 import Oracles.Base
8 import Oracles.Setting
9
10 data Flag = GccIsClang
11 | GccLt46
12 | CrossCompiling
13 | SupportsPackageKey
14 | SolarisBrokenShld
15 | SplitObjectsBroken
16 | GhcUnregisterised
17
18 flag :: Flag -> Action Bool
19 flag f = do
20 key <- return $ case f of
21 GccIsClang -> "gcc-is-clang"
22 GccLt46 -> "gcc-lt-46"
23 CrossCompiling -> "cross-compiling"
24 SupportsPackageKey -> "supports-package-key"
25 SolarisBrokenShld -> "solaris-broken-shld"
26 SplitObjectsBroken -> "split-objects-broken"
27 GhcUnregisterised -> "ghc-unregisterised"
28 value <- askConfigWithDefault key . putError
29 $ "\nFlag '" ++ key ++ "' not set in configuration files."
30 unless (value == "YES" || value == "NO") . putError
31 $ "\nFlag '" ++ key ++ "' is set to '" ++ value
32 ++ "' instead of 'YES' or 'NO'."
33 return $ value == "YES"
34
35 crossCompiling :: Action Bool
36 crossCompiling = flag CrossCompiling
37
38 gccIsClang :: Action Bool
39 gccIsClang = flag GccIsClang
40
41 gccLt46 :: Action Bool
42 gccLt46 = flag GccLt46
43
44 platformSupportsSharedLibs :: Action Bool
45 platformSupportsSharedLibs = do
46 badPlatform <- targetPlatforms [ "powerpc-unknown-linux"
47 , "x86_64-unknown-mingw32"
48 , "i386-unknown-mingw32" ]
49 solaris <- targetPlatform "i386-unknown-solaris2"
50 solarisBroken <- flag SolarisBrokenShld
51 return $ not (badPlatform || solaris && solarisBroken)
52
53 ghcWithSMP :: Action Bool
54 ghcWithSMP = do
55 goodArch <- targetArchs ["i386", "x86_64", "sparc", "powerpc", "arm"]
56 ghcUnreg <- flag GhcUnregisterised
57 return $ goodArch && not ghcUnreg
58
59 ghcWithNativeCodeGen :: Action Bool
60 ghcWithNativeCodeGen = do
61 goodArch <- targetArchs ["i386", "x86_64", "sparc", "powerpc"]
62 badOs <- targetOss ["ios", "aix"]
63 ghcUnreg <- flag GhcUnregisterised
64 return $ goodArch && not badOs && not ghcUnreg