Minor revision
[hadrian.git] / src / Settings / Packages / IntegerGmp.hs
index 1c8ed13..72a70ce 100644 (file)
@@ -1,19 +1,28 @@
-module Settings.Packages.IntegerGmp (integerGmpPackageArgs) where
+module Settings.Packages.IntegerGmp (integerGmpPackageArgs, gmpBuildPath) where
 
 import Base
-import Expression
-import GHC (integerGmp)
-import Predicates (builder, package)
+import GHC
+import Oracles.Config.Setting
+import Predicate
+import Settings.Paths
 
+-- TODO: move build artefacts to buildRootPath, see #113
 -- TODO: Is this needed?
 -- ifeq "$(GMP_PREFER_FRAMEWORK)" "YES"
 -- libraries/integer-gmp_CONFIGURE_OPTS += --with-gmp-framework-preferred
 -- endif
 integerGmpPackageArgs :: Args
-integerGmpPackageArgs = package integerGmp ?
-    builder GhcCabal ? mconcat
-        [ arg "--configure-option=--with-intree-gmp"
-        , appendSub "--configure-option=CFLAGS" includeGmp
-        , appendSub "--gcc-options"             includeGmp ]
-  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]
+              ]
+            ]