lol

build-support/cabal: add an option to enable shared library support

enableSharedLibraries configures Cabal to build of shared libraries. This
option requires that all dependencies of the package have been compiled
for use in shared libraries, too.

enableSharedExecutables configures Cabal to prefer shared libraries when
linking executables.

This patch partly fixes issue #1084.

+17 -1
+17 -1
pkgs/build-support/cabal/default.nix
··· 2 2 3 3 { stdenv, fetchurl, lib, pkgconfig, ghc, Cabal, jailbreakCabal, glibcLocales 4 4 , enableLibraryProfiling ? false 5 + , enableSharedLibraries ? false 6 + , enableSharedExecutables ? false 5 7 , enableCheckPhase ? true 6 8 }: 7 9 ··· 42 44 # if that is not desired (for applications), name can be set to 43 45 # fname. 44 46 name = if self.isLibrary then 45 - if enableLibraryProfiling then 47 + if enableLibraryProfiling && self.enableSharedLibraries then 48 + "haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-profiling-shared" 49 + else if enableLibraryProfiling && !self.enableSharedLibraries then 46 50 "haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-profiling" 51 + else if !enableLibraryProfiling && self.enableSharedLibraries then 52 + "haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}-shared" 47 53 else 48 54 "haskell-${self.pname}-ghc${ghc.ghc.version}-${self.version}" 49 55 else ··· 107 113 # and run any regression test suites the package might have 108 114 doCheck = enableCheckPhase; 109 115 116 + # pass the '--enable-shared' flag to cabal in the configure 117 + # stage to enable building shared libraries 118 + inherit enableSharedLibraries; 119 + 120 + # pass the '--enable-executable-dynamic' flag to cabal in 121 + # the configure stage to enable linking shared libraries 122 + inherit enableSharedExecutables; 123 + 110 124 extraConfigureFlags = [ 111 125 (stdenv.lib.enableFeature enableLibraryProfiling "library-profiling") 126 + (stdenv.lib.enableFeature self.enableSharedLibraries "shared") 127 + (stdenv.lib.enableFeature self.enableSharedExecutables "executable-dynamic") 112 128 (stdenv.lib.enableFeature self.enableSplitObjs "split-objs") 113 129 ] ++ stdenv.lib.optional (stdenv.lib.versionOlder "7" ghc.ghcVersion) (stdenv.lib.enableFeature self.doCheck "tests"); 114 130