greenmask: 0.2.6 -> 0.2.7 (#378403)
[NixPkgs.git] / pkgs / development / libraries / freeimage / default.nix
blobcd58f37d4937eb85b31d07a23c63664cca9a0759
2   lib,
3   stdenv,
4   fetchsvn,
5   cctools,
6   libtiff,
7   libpng,
8   zlib,
9   libwebp,
10   libraw,
11   openexr,
12   openjpeg,
13   libjpeg,
14   jxrlib,
15   pkg-config,
16   fixDarwinDylibNames,
17   autoSignDarwinBinariesHook,
20 stdenv.mkDerivation (finalAttrs: {
21   pname = "freeimage";
22   version = "unstable-2021-11-01";
24   src = fetchsvn {
25     url = "svn://svn.code.sf.net/p/freeimage/svn/";
26     rev = "1900";
27     sha256 = "rWoNlU/BWKZBPzRb1HqU6T0sT7aK6dpqKPe88+o/4sA=";
28   };
30   sourceRoot = "${finalAttrs.src.name}/FreeImage/trunk";
32   # Ensure that the bundled libraries are not used at all
33   prePatch = ''
34     rm -rf Source/Lib* Source/OpenEXR Source/ZLib
35   '';
36   patches = [
37     ./unbundle.diff
38     ./libtiff-4.4.0.diff
39   ];
41   postPatch =
42     ''
43       # To support cross compilation, use the correct `pkg-config`.
44       substituteInPlace Makefile.fip \
45         --replace "pkg-config" "$PKG_CONFIG"
46       substituteInPlace Makefile.gnu \
47         --replace "pkg-config" "$PKG_CONFIG"
48     ''
49     + lib.optionalString (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) ''
50       # Upstream Makefile hardcodes i386 and x86_64 architectures only
51       substituteInPlace Makefile.osx --replace "x86_64" "arm64"
52     '';
54   nativeBuildInputs =
55     [
56       pkg-config
57     ]
58     ++ lib.optionals stdenv.hostPlatform.isDarwin [
59       cctools
60       fixDarwinDylibNames
61     ]
62     ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
63       autoSignDarwinBinariesHook
64     ];
65   buildInputs = [
66     libtiff
67     libtiff.dev_private
68     libpng
69     zlib
70     libwebp
71     libraw
72     openexr
73     openjpeg
74     libjpeg
75     libjpeg.dev_private
76     jxrlib
77   ];
79   postBuild = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
80     make -f Makefile.fip
81   '';
83   INCDIR = "${placeholder "out"}/include";
84   INSTALLDIR = "${placeholder "out"}/lib";
86   preInstall =
87     ''
88       mkdir -p $INCDIR $INSTALLDIR
89     ''
90     # Workaround for Makefiles.osx not using ?=
91     + lib.optionalString stdenv.hostPlatform.isDarwin ''
92       makeFlagsArray+=( "INCDIR=$INCDIR" "INSTALLDIR=$INSTALLDIR" )
93     '';
95   postInstall =
96     lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
97       make -f Makefile.fip install
98     ''
99     + lib.optionalString stdenv.hostPlatform.isDarwin ''
100       ln -s $out/lib/libfreeimage.3.dylib $out/lib/libfreeimage.dylib
101     '';
103   enableParallelBuilding = true;
105   meta = {
106     description = "Open Source library for accessing popular graphics image file formats";
107     homepage = "http://freeimage.sourceforge.net/";
108     license = "GPL";
109     knownVulnerabilities = [
110       "CVE-2021-33367"
111       "CVE-2021-40262"
112       "CVE-2021-40263"
113       "CVE-2021-40264"
114       "CVE-2021-40265"
115       "CVE-2021-40266"
117       "CVE-2023-47992"
118       "CVE-2023-47993"
119       "CVE-2023-47994"
120       "CVE-2023-47995"
121       "CVE-2023-47996"
122     ];
123     maintainers = with lib.maintainers; [ l-as ];
124     platforms = with lib.platforms; unix;
125   };