summaryrefslogtreecommitdiff
path: root/pkgs/development/libraries/libdevil/default.nix
blob: e36402b68b5aefebe636f91b49971cdccf3d5a05 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
  lib,
  stdenv,
  fetchurl,
  cmake,
  libjpeg,
  libpng,
  libmng,
  lcms1,
  libtiff,
  openexr,
  libGL,
  libX11,
  pkg-config,
  OpenGL,
  runtimeShell,
  withXorg ? true,
  testers,
  libgbm,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "libdevil";
  version = "1.8.0";

  outputs = [
    "out"
    "dev"
  ];

  src = fetchurl {
    url = "mirror://sourceforge/openil/DevIL-${finalAttrs.version}.tar.gz";
    hash = "sha256-AHWXPufdifBQeHPiWArHgzZFLSnTSgcTSyCPROL+twk=";
  };

  sourceRoot = "DevIL/DevIL";

  nativeBuildInputs = [
    cmake
    pkg-config
  ];

  buildInputs =
    [
      libjpeg
      libpng
      libmng
      lcms1
      libtiff
      openexr
    ]
    ++ lib.optionals withXorg [
      libX11
      libGL
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [ OpenGL ];

  configureFlags = [
    "--enable-ILU"
    "--enable-ILUT"
  ];

  CXXFLAGS = lib.optionalString stdenv.cc.isClang "-Wno-register";

  preConfigure = ''
    sed -i 's,malloc.h,stdlib.h,g' src-ILU/ilur/ilur.c
  '';

  patches = [
    ./0001-il_endian.h-Fix-endian-handling.patch
  ];

  enableParallelBuilding = true;

  postPatch = ''
    for a in test/Makefile.am test/format_test/format_checks.sh.in ; do
      substituteInPlace $a \
        --replace /bin/bash ${runtimeShell}
    done
  '';

  passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;

  meta = with lib; {
    homepage = "https://openil.sourceforge.net/";
    description = "Image library which can can load, save, convert, manipulate, filter and display a wide variety of image formats";
    mainProgram = "ilur";
    license = licenses.lgpl2;
    pkgConfigModules = [ "IL" ];
    inherit (libgbm.meta) platforms;
    maintainers = [ ];
  };
})