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