forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / development / libraries / libpng / default.nix
blob57b75a949b7d6265dea5abced4d886a954306b7b
1 { lib, stdenv, fetchurl, zlib, apngSupport ? true
2 , testers
3 }:
5 assert zlib != null;
7 let
8   patchVersion = "1.6.43";
9   patch_src = fetchurl {
10     url = "mirror://sourceforge/libpng-apng/libpng-${patchVersion}-apng.patch.gz";
11     hash = "sha256-0QdXnpDVU4bQDmCG6nUJQvIqBLmrR2u6DGYHcM76/iI=";
12   };
13   whenPatched = lib.optionalString apngSupport;
15 in stdenv.mkDerivation (finalAttrs: {
16   pname = "libpng" + whenPatched "-apng";
17   version = "1.6.43";
19   src = fetchurl {
20     url = "mirror://sourceforge/libpng/libpng-${finalAttrs.version}.tar.xz";
21     hash = "sha256-alygZSOSotfJ2yrltAIQhDwLvAgcvUEIJasAzFnxSmw=";
22   };
23   postPatch = whenPatched "gunzip < ${patch_src} | patch -Np1"
24   + lib.optionalString stdenv.hostPlatform.isFreeBSD ''
26     sed -i 1i'int feenableexcept(int __mask);' contrib/libtests/pngvalid.c
27   '';
29   outputs = [ "out" "dev" "man" ];
30   outputBin = "dev";
32   propagatedBuildInputs = [ zlib ];
34   doCheck = true;
36   passthru = {
37     inherit zlib;
39     tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
40   };
42   meta = with lib; {
43     description = "Official reference implementation for the PNG file format" + whenPatched " with animation patch";
44     homepage = "http://www.libpng.org/pub/png/libpng.html";
45     changelog = "https://github.com/pnggroup/libpng/blob/v${finalAttrs.version}/CHANGES";
46     license = licenses.libpng2;
47     pkgConfigModules = [ "libpng" "libpng16" ];
48     platforms = platforms.all;
49     maintainers = with maintainers; [ vcunat ];
50   };