1{ stdenv, fetchurl, zlib, xz, python ? null, pythonSupport ? true, findXMLCatalogs }:
2
3assert pythonSupport -> python != null;
4
5#TODO: share most stuff between python and non-python builds, perhaps via multiple-output
6
7stdenv.mkDerivation (rec {
8 name = "libxml2-${version}";
9 version = "2.9.3";
10
11 src = fetchurl {
12 url = "http://xmlsoft.org/sources/${name}.tar.gz";
13 sha256 = "0bd17g6znn2r98gzpjppsqjg33iraky4px923j3k8kdl8qgy7sad";
14 };
15
16 outputs = [ "out" "doc" ];
17
18 buildInputs = stdenv.lib.optional pythonSupport python
19 # Libxml2 has an optional dependency on liblzma. However, on impure
20 # platforms, it may end up using that from /usr/lib, and thus lack a
21 # RUNPATH for that, leading to undefined references for its users.
22 ++ stdenv.lib.optional stdenv.isFreeBSD xz;
23
24 propagatedBuildInputs = [ zlib findXMLCatalogs ];
25
26 passthru = { inherit pythonSupport version; };
27
28 enableParallelBuilding = true;
29
30 meta = {
31 homepage = http://xmlsoft.org/;
32 description = "An XML parsing library for C";
33 license = "bsd";
34 platforms = stdenv.lib.platforms.unix;
35 maintainers = [ stdenv.lib.maintainers.eelco ];
36 };
37
38} // stdenv.lib.optionalAttrs pythonSupport {
39 configureFlags = "--with-python=${python}";
40
41 # this is a pair of ugly hacks to make python stuff install into the right place
42 preInstall = ''substituteInPlace python/libxml2mod.la --replace "${python}" "$out"'';
43 installFlags = ''pythondir="$(out)/lib/${python.libPrefix}/site-packages"'';
44
45} // stdenv.lib.optionalAttrs (!pythonSupport) {
46 configureFlags = "--with-python=no"; # otherwise build impurity bites us
47})