2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchsvn, darwin, libtiff
|
|
|
|
, libpng, zlib, libwebp, libraw, openexr, openjpeg
|
2021-05-20 23:08:51 +00:00
|
|
|
, libjpeg, jxrlib, pkg-config
|
2022-10-21 18:38:19 +00:00
|
|
|
, fixDarwinDylibNames, autoSignDarwinBinariesHook }:
|
2020-06-15 15:56:04 +00:00
|
|
|
|
2023-08-22 20:05:09 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2021-02-05 17:12:51 +00:00
|
|
|
pname = "freeimage";
|
2022-04-27 09:35:20 +00:00
|
|
|
version = "unstable-2021-11-01";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
src = fetchsvn {
|
|
|
|
url = "svn://svn.code.sf.net/p/freeimage/svn/";
|
2022-04-27 09:35:20 +00:00
|
|
|
rev = "1900";
|
|
|
|
sha256 = "rWoNlU/BWKZBPzRb1HqU6T0sT7aK6dpqKPe88+o/4sA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-08-22 20:05:09 +00:00
|
|
|
|
|
|
|
sourceRoot = "${finalAttrs.src.name}/FreeImage/trunk";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
# Ensure that the bundled libraries are not used at all
|
2022-07-14 12:49:19 +00:00
|
|
|
prePatch = ''
|
|
|
|
rm -rf Source/Lib* Source/OpenEXR Source/ZLib
|
|
|
|
'';
|
|
|
|
patches = [
|
|
|
|
./unbundle.diff
|
|
|
|
./libtiff-4.4.0.diff
|
|
|
|
];
|
2021-02-05 17:12:51 +00:00
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
postPatch = ''
|
|
|
|
# To support cross compilation, use the correct `pkg-config`.
|
|
|
|
substituteInPlace Makefile.fip \
|
|
|
|
--replace "pkg-config" "$PKG_CONFIG"
|
|
|
|
substituteInPlace Makefile.gnu \
|
|
|
|
--replace "pkg-config" "$PKG_CONFIG"
|
2021-12-06 16:07:01 +00:00
|
|
|
'' + lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) ''
|
|
|
|
# Upstream Makefile hardcodes i386 and x86_64 architectures only
|
|
|
|
substituteInPlace Makefile.osx --replace "x86_64" "arm64"
|
2021-09-18 10:52:07 +00:00
|
|
|
'';
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
darwin.cctools
|
|
|
|
fixDarwinDylibNames
|
2022-10-21 18:38:19 +00:00
|
|
|
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
|
|
|
autoSignDarwinBinariesHook
|
2021-05-20 23:08:51 +00:00
|
|
|
];
|
2021-02-05 17:12:51 +00:00
|
|
|
buildInputs = [ libtiff libtiff.dev_private libpng zlib libwebp libraw openexr openjpeg libjpeg libjpeg.dev_private jxrlib ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postBuild = lib.optionalString (!stdenv.isDarwin) ''
|
|
|
|
make -f Makefile.fip
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
INCDIR = "${placeholder "out"}/include";
|
|
|
|
INSTALLDIR = "${placeholder "out"}/lib";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preInstall = ''
|
2021-02-05 17:12:51 +00:00
|
|
|
mkdir -p $INCDIR $INSTALLDIR
|
2021-04-25 03:57:28 +00:00
|
|
|
''
|
|
|
|
# Workaround for Makefiles.osx not using ?=
|
|
|
|
+ lib.optionalString stdenv.isDarwin ''
|
|
|
|
makeFlagsArray+=( "INCDIR=$INCDIR" "INSTALLDIR=$INSTALLDIR" )
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = lib.optionalString (!stdenv.isDarwin) ''
|
|
|
|
make -f Makefile.fip install
|
2021-02-05 17:12:51 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
ln -s $out/lib/libfreeimage.3.dylib $out/lib/libfreeimage.dylib
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Open Source library for accessing popular graphics image file formats";
|
|
|
|
homepage = "http://freeimage.sourceforge.net/";
|
|
|
|
license = "GPL";
|
2024-02-29 20:09:43 +00:00
|
|
|
knownVulnerabilities = [
|
|
|
|
"CVE-2021-33367"
|
|
|
|
"CVE-2021-40262"
|
|
|
|
"CVE-2021-40263"
|
|
|
|
"CVE-2021-40264"
|
|
|
|
"CVE-2021-40265"
|
|
|
|
"CVE-2021-40266"
|
|
|
|
|
|
|
|
"CVE-2023-47992"
|
|
|
|
"CVE-2023-47993"
|
|
|
|
"CVE-2023-47994"
|
|
|
|
"CVE-2023-47995"
|
|
|
|
"CVE-2023-47996"
|
|
|
|
];
|
2021-02-05 17:12:51 +00:00
|
|
|
maintainers = with lib.maintainers; [viric l-as];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = with lib.platforms; unix;
|
|
|
|
};
|
2023-08-22 20:05:09 +00:00
|
|
|
})
|