Minor revision
[hadrian.git] / src / Settings / Packages / IntegerGmp.hs
index c679bf3..72a70ce 100644 (file)
@@ -1,9 +1,10 @@
-module Settings.Packages.IntegerGmp (integerGmpPackageArgs) where
+module Settings.Packages.IntegerGmp (integerGmpPackageArgs, gmpBuildPath) where
 
 import Base
-import Expression
-import GHC (integerGmp)
-import Predicates (builder, builderGcc, package)
+import GHC
+import Oracles.Config.Setting
+import Predicate
+import Settings.Paths
 
 -- TODO: move build artefacts to buildRootPath, see #113
 -- TODO: Is this needed?
@@ -11,13 +12,17 @@ import Predicates (builder, builderGcc, package)
 -- libraries/integer-gmp_CONFIGURE_OPTS += --with-gmp-framework-preferred
 -- endif
 integerGmpPackageArgs :: Args
-integerGmpPackageArgs = package integerGmp ?
-    mconcat
-        [ builder GhcCabal ? mconcat
-            [ arg "--configure-option=--with-intree-gmp"
-            , appendSub "--configure-option=CFLAGS" includeGmp
-            , appendSub "--gcc-options"             includeGmp ]
-        , builderGcc ? ( arg $ "-I" ++ pkgPath integerGmp -/- "gmp" )
-        ]
-  where
-    includeGmp = ["-I" ++ pkgPath integerGmp -/- "gmp"]
+integerGmpPackageArgs = package integerGmp ? do
+    let includeGmp = "-I" ++ gmpBuildPath -/- "include"
+    gmpIncludeDir <- getSetting GmpIncludeDir
+    gmpLibDir     <- getSetting GmpLibDir
+
+    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]
+              ]
+            ]