3437a6c4da617e1a17d19725bc041effae26a9db
[hadrian.git] / src / Settings / Builders / Gcc.hs
1 module Settings.Builders.Gcc (gccArgs, gccMArgs) where
2
3 import Expression
4 import GHC
5 import Oracles
6 import Predicates (package, stagedBuilder)
7 import Settings
8
9 -- TODO: I had to define symbol __GLASGOW_HASKELL__ as otherwise directory.c is
10 -- effectively empty. I presume it was expected that GHC will be used for
11 -- compiling all C files, but I don't know why. It seems that directory.c is the
12 -- only file which requires special treatment when using GCC.
13 gccArgs :: Args
14 gccArgs = stagedBuilder Gcc ?
15 mconcat [ commonGccArgs
16 , package directory ? arg "-D__GLASGOW_HASKELL__"
17 , arg "-c", arg =<< getInput
18 , arg "-o", arg =<< getOutput ]
19
20 -- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
21 gccMArgs :: Args
22 gccMArgs = stagedBuilder GccM ? do
23 output <- getOutput
24 mconcat [ arg "-E"
25 , arg "-MM"
26 , commonGccArgs
27 , arg "-MF"
28 , arg output
29 , arg "-MT"
30 , arg $ dropExtension output -<.> "o"
31 , arg "-x"
32 , arg "c"
33 , arg =<< getInput ]
34
35 commonGccArgs :: Args
36 commonGccArgs = do
37 pkg <- getPackage
38 path <- getTargetPath
39 iDirs <- getPkgDataList IncludeDirs
40 dDirs <- getPkgDataList DepIncludeDirs
41 ccArgs <- getPkgDataList CcArgs
42 mconcat [ append ccArgs
43 , arg $ "-I" ++ path -/- "build/autogen"
44 , append [ "-I" ++ pkgPath pkg -/- dir | dir <- iDirs ++ dDirs ]]