1{ lib
2, stdenv
3, fetchurl
4, libjpeg
5, libpng
6, libmng
7, lcms1
8, libtiff
9, openexr
10, libGL
11, libX11
12, pkg-config
13, OpenGL
14, runtimeShell
15, withXorg ? true
16, testers
17}:
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "libdevil";
21 version = "1.7.8";
22
23 outputs = [ "out" "dev" ];
24
25 src = fetchurl {
26 url = "mirror://sourceforge/openil/DevIL-${finalAttrs.version}.tar.gz";
27 sha256 = "1zd850nn7nvkkhasrv7kn17kzgslr5ry933v6db62s4lr0zzlbv8";
28 };
29
30 nativeBuildInputs = [ pkg-config ];
31
32 buildInputs = [ libjpeg libpng libmng lcms1 libtiff openexr ]
33 ++ lib.optionals withXorg [ libX11 libGL ]
34 ++ lib.optionals stdenv.isDarwin [ OpenGL ];
35
36 configureFlags = [ "--enable-ILU" "--enable-ILUT" ];
37
38 preConfigure = ''
39 sed -i 's, -std=gnu99,,g' configure
40 sed -i 's,malloc.h,stdlib.h,g' src-ILU/ilur/ilur.c
41 '' + lib.optionalString stdenv.cc.isClang ''
42 sed -i 's/libIL_la_CXXFLAGS = $(AM_CFLAGS)/libIL_la_CXXFLAGS =/g' lib/Makefile.in
43 '';
44
45 postConfigure = ''
46 sed -i '/RESTRICT_KEYWORD/d' include/IL/config.h
47 '';
48
49 patches = [
50 (fetchurl {
51 url = "https://sources.debian.org/data/main/d/devil/1.7.8-10/debian/patches/03_CVE-2009-3994.diff";
52 sha256 = "0qkx2qfv02igbrmsn6z5a3lbrbwjfh3rb0c2sj54wy0j1f775hbc";
53 })
54 ./ftbfs-libpng15.patch
55 ./il_endian.h.patch
56 ];
57
58 enableParallelBuilding = true;
59
60 postPatch = ''
61 for a in test/Makefile.in test/format_test/format_checks.sh.in ; do
62 substituteInPlace $a \
63 --replace /bin/bash ${runtimeShell}
64 done
65 '';
66
67 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
68
69 meta = with lib; {
70 homepage = "https://openil.sourceforge.net/";
71 description = "An image library which can can load, save, convert, manipulate, filter and display a wide variety of image formats";
72 license = licenses.lgpl2;
73 pkgConfigModules = [ "IL" ];
74 platforms = platforms.mesaPlatforms;
75 maintainers = with maintainers; [ ];
76 };
77})