about summary refs log tree commit diff
path: root/pkgs/development/libraries/libpng/default.nix
blob: 11e3fb31604f7dda804621804b6883d1a692ad61 (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
{ lib, stdenv, fetchurl, zlib, apngSupport ? true
, testers
}:

assert zlib != null;

let
  patchVersion = "1.6.43";
  patch_src = fetchurl {
    url = "mirror://sourceforge/libpng-apng/libpng-${patchVersion}-apng.patch.gz";
    hash = "sha256-0QdXnpDVU4bQDmCG6nUJQvIqBLmrR2u6DGYHcM76/iI=";
  };
  whenPatched = lib.optionalString apngSupport;

in stdenv.mkDerivation (finalAttrs: {
  pname = "libpng" + whenPatched "-apng";
  version = "1.6.43";

  src = fetchurl {
    url = "mirror://sourceforge/libpng/libpng-${finalAttrs.version}.tar.xz";
    hash = "sha256-alygZSOSotfJ2yrltAIQhDwLvAgcvUEIJasAzFnxSmw=";
  };
  postPatch = whenPatched "gunzip < ${patch_src} | patch -Np1"
  + lib.optionalString stdenv.isFreeBSD ''

    sed -i 1i'int feenableexcept(int __mask);' contrib/libtests/pngvalid.c
  '';

  outputs = [ "out" "dev" "man" ];
  outputBin = "dev";

  propagatedBuildInputs = [ zlib ];

  doCheck = true;

  passthru = {
    inherit zlib;

    tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
  };

  meta = with lib; {
    description = "Official reference implementation for the PNG file format" + whenPatched " with animation patch";
    homepage = "http://www.libpng.org/pub/png/libpng.html";
    changelog = "https://github.com/pnggroup/libpng/blob/v${finalAttrs.version}/CHANGES";
    license = licenses.libpng2;
    pkgConfigModules = [ "libpng" "libpng16" ];
    platforms = platforms.all;
    maintainers = with maintainers; [ vcunat ];
  };
})