Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchurl,
5 zlib,
6 apngSupport ? true,
7 testers,
8}:
9
10assert zlib != null;
11
12let
13 patchVersion = "1.6.49";
14 patch_src = fetchurl {
15 url = "mirror://sourceforge/libpng-apng/libpng-${patchVersion}-apng.patch.gz";
16 hash = "sha256-Zmdtgn4y7hc0ezmjU+kbW4sFR7RArrE/AjzU+irXjTI=";
17 };
18 whenPatched = lib.optionalString apngSupport;
19
20in
21stdenv.mkDerivation (finalAttrs: {
22 pname = "libpng" + whenPatched "-apng";
23 version = "1.6.49";
24
25 src = fetchurl {
26 url = "mirror://sourceforge/libpng/libpng-${finalAttrs.version}.tar.xz";
27 hash = "sha256-QxgqpI451ksatOxrcas+kQtn7tOg//N3fPjPQNbvcCQ=";
28 };
29 postPatch =
30 whenPatched "gunzip < ${patch_src} | patch -Np1"
31 + lib.optionalString stdenv.hostPlatform.isFreeBSD ''
32
33 sed -i 1i'int feenableexcept(int __mask);' contrib/libtests/pngvalid.c
34 '';
35
36 outputs = [
37 "out"
38 "dev"
39 "man"
40 ];
41 outputBin = "dev";
42
43 propagatedBuildInputs = [ zlib ];
44
45 doCheck = true;
46
47 passthru = {
48 inherit zlib;
49
50 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
51 };
52
53 meta = with lib; {
54 description =
55 "Official reference implementation for the PNG file format" + whenPatched " with animation patch";
56 homepage = "http://www.libpng.org/pub/png/libpng.html";
57 changelog = "https://github.com/pnggroup/libpng/blob/v${finalAttrs.version}/CHANGES";
58 license = licenses.libpng2;
59 pkgConfigModules = [
60 "libpng"
61 "libpng16"
62 ];
63 platforms = platforms.all;
64 maintainers = with maintainers; [ vcunat ];
65 };
66})