cabal: add support for the enableStaticLibrary flag to enable/disable building of static libraries

Disabling static libraries is supported only in GHC 7.7 or later.
This commit is contained in:
Peter Simons 2013-12-06 12:52:18 +01:00
parent 36cb2af057
commit ea20904aef
2 changed files with 12 additions and 4 deletions

View File

@ -4,6 +4,7 @@
, enableLibraryProfiling ? false , enableLibraryProfiling ? false
, enableSharedLibraries ? false , enableSharedLibraries ? false
, enableSharedExecutables ? false , enableSharedExecutables ? false
, enableStaticLibraries ? true
, enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version , enableCheckPhase ? stdenv.lib.versionOlder "7.4" ghc.version
}: }:
@ -25,6 +26,9 @@ assert enableSharedExecutables -> versionOlder "7.4" ghc.version;
# Our GHC 6.10.x builds do not provide sharable versions of their core libraries. # Our GHC 6.10.x builds do not provide sharable versions of their core libraries.
assert enableSharedLibraries -> versionOlder "6.12" ghc.version; assert enableSharedLibraries -> versionOlder "6.12" ghc.version;
# Our GHC 6.10.x builds do not provide sharable versions of their core libraries.
assert !enableStaticLibraries -> versionOlder "7.7" ghc.version;
{ {
mkDerivation = mkDerivation =
args : # arguments for the individual package, can modify the defaults args : # arguments for the individual package, can modify the defaults
@ -128,6 +132,10 @@ assert enableSharedLibraries -> versionOlder "6.12" ghc.version;
# and run any regression test suites the package might have # and run any regression test suites the package might have
doCheck = enableCheckPhase; doCheck = enableCheckPhase;
# pass the '--enable-library-vanilla' flag to cabal in the
# configure stage to enable building shared libraries
inherit enableStaticLibraries;
# pass the '--enable-shared' flag to cabal in the configure # pass the '--enable-shared' flag to cabal in the configure
# stage to enable building shared libraries # stage to enable building shared libraries
inherit enableSharedLibraries; inherit enableSharedLibraries;
@ -140,6 +148,7 @@ assert enableSharedLibraries -> versionOlder "6.12" ghc.version;
(enableFeature self.enableSplitObjs "split-objs") (enableFeature self.enableSplitObjs "split-objs")
(enableFeature enableLibraryProfiling "library-profiling") (enableFeature enableLibraryProfiling "library-profiling")
(enableFeature self.enableSharedLibraries "shared") (enableFeature self.enableSharedLibraries "shared")
(optional (versionOlder "7" ghc.version) (enableFeature self.enableStaticLibraries "library-vanilla"))
(optional (versionOlder "7.4" ghc.version) (enableFeature self.enableSharedExecutables "executable-dynamic")) (optional (versionOlder "7.4" ghc.version) (enableFeature self.enableSharedExecutables "executable-dynamic"))
(optional (versionOlder "7" ghc.version) (enableFeature self.doCheck "tests")) (optional (versionOlder "7" ghc.version) (enableFeature self.doCheck "tests"))
]; ];

View File

@ -63,6 +63,7 @@
, enableSharedLibraries ? pkgs.stdenv.lib.versionOlder "7.7" ghc.version , enableSharedLibraries ? pkgs.stdenv.lib.versionOlder "7.7" ghc.version
, enableSharedExecutables ? pkgs.stdenv.lib.versionOlder "7.7" ghc.version , enableSharedExecutables ? pkgs.stdenv.lib.versionOlder "7.7" ghc.version
, enableCheckPhase ? pkgs.stdenv.lib.versionOlder "7.4" ghc.version , enableCheckPhase ? pkgs.stdenv.lib.versionOlder "7.4" ghc.version
, enableStaticLibraries ? true
}: }:
# We redefine callPackage to take into account the new scope. The optional # We redefine callPackage to take into account the new scope. The optional
@ -113,10 +114,8 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x
# packages. It isn't the Cabal library, which is spelled "Cabal". # packages. It isn't the Cabal library, which is spelled "Cabal".
cabal = callPackage ../build-support/cabal { cabal = callPackage ../build-support/cabal {
inherit enableLibraryProfiling; inherit enableLibraryProfiling enableCheckPhase
inherit enableSharedLibraries; enableStaticLibraries enableSharedLibraries enableSharedExecutables;
inherit enableSharedExecutables;
inherit enableCheckPhase;
glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null; glibcLocales = if pkgs.stdenv.isLinux then pkgs.glibcLocales else null;
}; };