summary refs log tree commit diff
path: root/pkgs/development/libraries/libxml2/default.nix
blob: 0d70a6502feb42286871a9e2cb17dd85fee07cf9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ stdenv, fetchurl, findXMLCatalogs

# 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

let
  mkFlag = trueStr: falseStr: cond: name: val:
    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;

  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}";
  version = "2.9.2";

  src = fetchurl {
    url = "http://xmlsoft.org/sources/${name}.tar.gz";
    sha256 = "1g6mf03xcabmk5ing1lwqmasr803616gb2xhn7pll10x2l5w6y2i";
  };

  buildInputs = [ optIcu optPython optReadline optZlib optXz ];
  propagatedBuildInputs = [ findXMLCatalogs ];

  configureFlags = [
    (mkWith (optIcu != null)      "icu"                optIcu)
    (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;

  meta = with stdenv.lib; {
    homepage = http://xmlsoft.org/;
    description = "An XML parsing library for C";
    license = licenses.mit;
    platforms = platforms.unix;
    maintainers = with maintainers; [ eelco wkennington ];
  };

  passthru = {
    inherit version;
    pythonSupport = python != null;
  };
}