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