Implement buildPackageDependencies rule.
[hadrian.git] / src / Settings / GccM.hs
1 module Settings.GccM (gccMArgs) where
2
3 import Util
4 import Builder
5 import Package
6 import Expression
7 import Oracles.PackageData
8 import Settings.Util
9 import Settings.TargetDirectory
10
11 -- TODO: handle custom $1_$2_MKDEPENDC_OPTS and
12 gccMArgs :: Args
13 gccMArgs = do
14 stage <- getStage
15 builder (GccM stage) ? do
16 pkg <- getPackage
17 files <- getFiles
18 ccArgs <- getPkgDataList CcArgs
19 let file = head files
20 path = targetPath stage pkg -/- "build"
21 mconcat
22 [ arg "-E"
23 , arg "-MM"
24 , append ccArgs -- TODO: remove? any other flags?
25 , includeGccArgs
26 , arg "-MF"
27 , arg $ path -/- takeFileName file <.> "deps"
28 , arg "-x"
29 , arg "c"
30 , arg file ]
31
32 includeGccArgs :: Args
33 includeGccArgs = do
34 stage <- getStage
35 pkg <- getPackage
36 incDirs <- getPkgDataList IncludeDirs
37 depIncDirs <- getPkgDataList DepIncludeDirs
38 let path = pkgPath pkg
39 mconcat
40 [ arg $ "-I" ++ targetPath stage pkg -/- "build/autogen"
41 , append . map (\dir -> "-I" ++ path -/- dir) $ incDirs ++ depIncDirs ]