Minor revision
[hadrian.git] / src / Settings / Packages / IntegerGmp.hs
index 8b100b3..72a70ce 100644 (file)
@@ -1,14 +1,10 @@
 module Settings.Packages.IntegerGmp (integerGmpPackageArgs, gmpBuildPath) where
 
 import Base
-import Expression
-import GHC (integerGmp)
-import Predicates (builder, builderGcc, package)
-import Settings.User
-
--- TODO: move elsewhere
-gmpBuildPath :: FilePath
-gmpBuildPath = buildRootPath -/- "stage0/gmp"
+import GHC
+import Oracles.Config.Setting
+import Predicate
+import Settings.Paths
 
 -- TODO: move build artefacts to buildRootPath, see #113
 -- TODO: Is this needed?
@@ -18,11 +14,15 @@ gmpBuildPath = buildRootPath -/- "stage0/gmp"
 integerGmpPackageArgs :: Args
 integerGmpPackageArgs = package integerGmp ? do
     let includeGmp = "-I" ++ gmpBuildPath -/- "include"
-    mconcat [ builder GhcCabal ? mconcat
-              [ arg "--configure-option=--with-intree-gmp"
-              , appendSub "--configure-option=CFLAGS" [includeGmp]
-              , appendSub "--gcc-options"             [includeGmp] ]
+    gmpIncludeDir <- getSetting GmpIncludeDir
+    gmpLibDir     <- getSetting GmpLibDir
 
-            , builderGcc ? arg includeGmp ]
-  where
+    mconcat [ builder Cc ? arg includeGmp
 
+            , builder GhcCabal ? mconcat
+              [ (null gmpIncludeDir && null gmpLibDir) ?
+                arg "--configure-option=--with-intree-gmp"
+              , appendSub "--configure-option=CFLAGS" [includeGmp]
+              , appendSub "--gcc-options"             [includeGmp]
+              ]
+            ]