Clean up code, add comments.
[hadrian.git] / src / Settings / Builders / Gcc.hs
1 module Settings.Builders.Gcc (gccArgs, gccMArgs) where
2
3 import Expression
4 import Oracles
5 import Predicates (stagedBuilder)
6 import Settings
7
8 gccArgs :: Args
9 gccArgs = stagedBuilder Gcc ? do
10 file <- getFile
11 src <- getSource
12 mconcat [ commonGccArgs
13 , arg "-c"
14 , arg src
15 , arg "-o"
16 , arg file ]
17
18 -- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
19 gccMArgs :: Args
20 gccMArgs = stagedBuilder GccM ? do
21 file <- getFile
22 src <- getSource
23 mconcat [ arg "-E"
24 , arg "-MM"
25 , commonGccArgs
26 , arg "-MF"
27 , arg file
28 , arg "-MT"
29 , arg $ dropExtension file -<.> "o"
30 , arg "-x"
31 , arg "c"
32 , arg src ]
33
34 commonGccArgs :: Args
35 commonGccArgs = do
36 pkg <- getPackage
37 path <- getTargetPath
38 iDirs <- getPkgDataList IncludeDirs
39 dDirs <- getPkgDataList DepIncludeDirs
40 ccArgs <- getPkgDataList CcArgs
41 mconcat [ append ccArgs
42 , arg $ "-I" ++ path -/- "build/autogen"
43 , append [ "-I" ++ pkgPath pkg -/- dir | dir <- iDirs ++ dDirs ]]