1{ stdenv, fetchurl, zlib, apngSupport ? true }:
2
3assert zlib != null;
4
5let
6 version = "1.6.18";
7 sha256 = "0qq96rf31483kxz32h6l6921hy6p2v2pfqfvc74km229g4xw241f";
8 patch_src = fetchurl {
9 url = "mirror://sourceforge/libpng-apng/libpng-${version}-apng.patch.gz";
10 sha256 = "0g2ljh2vhclas1hacys1c4gk6l6hyy6sngb2yvdsnjz50nyq16kv";
11 };
12 whenPatched = stdenv.lib.optionalString apngSupport;
13
14in stdenv.mkDerivation rec {
15 name = "libpng" + whenPatched "-apng" + "-${version}";
16
17 src = fetchurl {
18 url = "mirror://sourceforge/libpng/libpng-${version}.tar.xz";
19 inherit sha256;
20 };
21
22 postPatch = whenPatched "gunzip < ${patch_src} | patch -Np1";
23
24 propagatedBuildInputs = [ zlib ];
25
26 doCheck = true;
27
28 passthru = { inherit zlib; };
29
30 meta = with stdenv.lib; {
31 description = "The official reference implementation for the PNG file format" + whenPatched " with animation patch";
32 homepage = http://www.libpng.org/pub/png/libpng.html;
33 license = licenses.libpng;
34 platforms = platforms.all;
35 maintainers = [ maintainers.vcunat maintainers.fuuzetsu ];
36 };
37}