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 [
44 libjpeg
45 libpng
46 libmng
47 lcms1
48 libtiff
49 openexr
50 ]
51 ++ lib.optionals withXorg [
52 libX11
53 libGL
54 ];
55
56 configureFlags = [
57 "--enable-ILU"
58 "--enable-ILUT"
59 ];
60
61 CXXFLAGS = lib.optionalString stdenv.cc.isClang "-Wno-register";
62
63 preConfigure = ''
64 sed -i 's,malloc.h,stdlib.h,g' src-ILU/ilur/ilur.c
65 '';
66
67 patches = [
68 ./0001-il_endian.h-Fix-endian-handling.patch
69 ];
70
71 enableParallelBuilding = true;
72
73 postPatch = ''
74 for a in test/Makefile.am test/format_test/format_checks.sh.in ; do
75 substituteInPlace $a \
76 --replace /bin/bash ${runtimeShell}
77 done
78 '';
79
80 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
81
82 meta = with lib; {
83 homepage = "https://openil.sourceforge.net/";
84 description = "Image library which can can load, save, convert, manipulate, filter and display a wide variety of image formats";
85 mainProgram = "ilur";
86 license = licenses.lgpl2;
87 pkgConfigModules = [ "IL" ];
88 inherit (libgbm.meta) platforms;
89 maintainers = [ ];
90 };
91})