-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?
-- 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]
+ ]
+ ]