93b953b8f86fb70b28ebd2a594294268eea12989
[hadrian.git] / src / Rules / Generators / GhcBootPlatformH.hs
1 module Rules.Generators.GhcBootPlatformH (generateGhcBootPlatformH) where
2
3 import Expression
4 import Oracles
5
6 generateGhcBootPlatformH :: Expr String
7 generateGhcBootPlatformH = do
8 lift $ need [sourcePath -/- "Rules/Generators/GhcBootPlatformH.hs"]
9 stage <- getStage
10 let cppify = replaceEq '-' '_' . replaceEq '.' '_'
11 chooseSetting x y = getSetting $ if stage == Stage0 then x else y
12 buildPlatform <- chooseSetting BuildPlatform HostPlatform
13 buildArch <- chooseSetting BuildArch HostArch
14 buildOs <- chooseSetting BuildOs HostOs
15 buildVendor <- chooseSetting BuildVendor HostVendor
16 hostPlatform <- chooseSetting HostPlatform TargetPlatform
17 hostArch <- chooseSetting HostArch TargetArch
18 hostOs <- chooseSetting HostOs TargetOs
19 hostVendor <- chooseSetting HostVendor TargetVendor
20 targetPlatform <- getSetting TargetPlatform
21 targetArch <- getSetting TargetArch
22 targetOs <- getSetting TargetOs
23 targetVendor <- getSetting TargetVendor
24 return $ unlines
25 [ "#ifndef __PLATFORM_H__"
26 , "#define __PLATFORM_H__"
27 , ""
28 , "#define BuildPlatform_NAME " ++ quote buildPlatform
29 , "#define HostPlatform_NAME " ++ quote hostPlatform
30 , "#define TargetPlatform_NAME " ++ quote targetPlatform
31 , ""
32 , "#define " ++ cppify buildPlatform ++ "_BUILD 1"
33 , "#define " ++ cppify hostPlatform ++ "_HOST 1"
34 , "#define " ++ cppify targetPlatform ++ "_TARGET 1"
35 , ""
36 , "#define " ++ buildArch ++ "_BUILD_ARCH 1"
37 , "#define " ++ hostArch ++ "_HOST_ARCH 1"
38 , "#define " ++ targetArch ++ "_TARGET_ARCH 1"
39 , "#define BUILD_ARCH " ++ quote buildArch
40 , "#define HOST_ARCH " ++ quote hostArch
41 , "#define TARGET_ARCH " ++ quote targetArch
42 , ""
43 , "#define " ++ buildOs ++ "_BUILD_OS 1"
44 , "#define " ++ hostOs ++ "_HOST_OS 1"
45 , "#define " ++ targetOs ++ "_TARGET_OS 1"
46 , "#define BUILD_OS " ++ quote buildOs
47 , "#define HOST_OS " ++ quote hostOs
48 , "#define TARGET_OS " ++ quote targetOs
49 , ""
50 , "#define " ++ buildVendor ++ "_BUILD_VENDOR 1"
51 , "#define " ++ hostVendor ++ "_HOST_VENDOR 1"
52 , "#define " ++ targetVendor ++ "_TARGET_VENDOR 1"
53 , "#define BUILD_VENDOR " ++ quote buildVendor
54 , "#define HOST_VENDOR " ++ quote hostVendor
55 , "#define TARGET_VENDOR " ++ quote targetVendor
56 , ""
57 , "#endif /* __PLATFORM_H__ */" ]