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