libxml2: Refactor and fix library propagation

This commit is contained in:
William A. Kennington III 2015-04-28 15:35:41 -07:00
parent faa9354de7
commit 287ec76b8f
2 changed files with 44 additions and 30 deletions

View File

@ -1,49 +1,63 @@
{ stdenv, fetchurl, zlib, xz, python ? null, pythonSupport ? true, findXMLCatalogs }: { stdenv, fetchurl, findXMLCatalogs
assert pythonSupport -> python != null; # Optional Dependencies
, icu ? null, python ? null, readline ? null, zlib ? null, xz ? null
}:
#TODO: share most stuff between python and non-python builds, perhaps via multiple-output #TODO: share most stuff between python and non-python builds, perhaps via multiple-output
let let
version = "2.9.2"; mkFlag = trueStr: falseStr: cond: name: val:
in if cond == null then null else
"--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
mkEnable = mkFlag "enable-" "disable-";
mkWith = mkFlag "with-" "without-";
mkOther = mkFlag "" "" true;
stdenv.mkDerivation (rec { shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
optIcu = shouldUsePkg icu;
optPython = shouldUsePkg python;
optReadline = shouldUsePkg readline;
optZlib = shouldUsePkg zlib;
optXz = shouldUsePkg xz;
sitePackages = if optPython == null then null else
"\${out}/lib/${python.libPrefix}/site-packages";
in
stdenv.mkDerivation rec {
name = "libxml2-${version}"; name = "libxml2-${version}";
version = "2.9.2";
src = fetchurl { src = fetchurl {
url = "http://xmlsoft.org/sources/${name}.tar.gz"; url = "http://xmlsoft.org/sources/${name}.tar.gz";
sha256 = "1g6mf03xcabmk5ing1lwqmasr803616gb2xhn7pll10x2l5w6y2i"; sha256 = "1g6mf03xcabmk5ing1lwqmasr803616gb2xhn7pll10x2l5w6y2i";
}; };
buildInputs = stdenv.lib.optional pythonSupport python buildInputs = [ optIcu optPython optReadline optZlib optXz ];
# Libxml2 has an optional dependency on liblzma. However, on impure propagatedBuildInputs = [ findXMLCatalogs ];
# platforms, it may end up using that from /usr/lib, and thus lack a
# RUNPATH for that, leading to undefined references for its users.
++ (stdenv.lib.optional stdenv.isFreeBSD xz);
propagatedBuildInputs = [ zlib findXMLCatalogs ]; configureFlags = [
(mkWith (optIcu != null) "icu" optIcu)
passthru = { inherit pythonSupport version; }; (mkWith (optPython != null) "python" optPython)
(mkWith (optPython != null) "python-install-dir" sitePackages)
(mkWith (optReadline != null) "readline" optReadline)
(mkWith (optZlib != null) "zlib" optZlib)
(mkWith (optXz != null) "lzma" optXz)
];
enableParallelBuilding = true; enableParallelBuilding = true;
meta = { meta = with stdenv.lib; {
homepage = http://xmlsoft.org/; homepage = http://xmlsoft.org/;
description = "An XML parsing library for C"; description = "An XML parsing library for C";
license = "bsd"; license = licenses.mit;
platforms = stdenv.lib.platforms.unix; platforms = platforms.unix;
maintainers = [ stdenv.lib.maintainers.eelco ]; maintainers = with maintainers; [ eelco wkennington ];
}; };
} // stdenv.lib.optionalAttrs pythonSupport { passthru = {
configureFlags = "--with-python=${python}"; inherit version;
pythonSupport = python != null;
# this is a pair of ugly hacks to make python stuff install into the right place };
preInstall = ''substituteInPlace python/libxml2mod.la --replace "${python}" "$out"''; }
installFlags = ''pythondir="$(out)/lib/${python.libPrefix}/site-packages"'';
} // stdenv.lib.optionalAttrs (!pythonSupport) {
configureFlags = "--with-python=no"; # otherwise build impurity bites us
})

View File

@ -6996,11 +6996,11 @@ let
libxmi = callPackage ../development/libraries/libxmi { }; libxmi = callPackage ../development/libraries/libxmi { };
libxml2 = callPackage ../development/libraries/libxml2 { libxml2 = callPackage ../development/libraries/libxml2 {
pythonSupport = false; python = null;
}; };
libxml2Python = lowPrio (libxml2.override { libxml2Python = lowPrio (libxml2.override {
pythonSupport = true; inherit python;
}); });
libxmlxx = callPackage ../development/libraries/libxmlxx { }; libxmlxx = callPackage ../development/libraries/libxmlxx { };