nixpkgs/pkgs/development/libraries/freeimage/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
2.3 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchsvn, darwin, libtiff
, libpng, zlib, libwebp, libraw, openexr, openjpeg
, libjpeg, jxrlib, pkg-config
2022-10-12 16:46:32 +00:00
, fixDarwinDylibNames, autoSignDarwinBinariesHook }:
2020-05-13 19:17:27 +00:00
stdenv.mkDerivation {
pname = "freeimage";
version = "unstable-2021-11-01";
2017-01-21 13:43:22 +00:00
src = fetchsvn {
url = "svn://svn.code.sf.net/p/freeimage/svn/";
rev = "1900";
sha256 = "rWoNlU/BWKZBPzRb1HqU6T0sT7aK6dpqKPe88+o/4sA=";
};
sourceRoot = "svn-r1900/FreeImage/trunk";
2017-01-21 13:43:22 +00:00
# Ensure that the bundled libraries are not used at all
prePatch = ''
rm -rf Source/Lib* Source/OpenEXR Source/ZLib
'';
patches = [
./unbundle.diff
./libtiff-4.4.0.diff
];
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"
'' + lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) ''
# Upstream Makefile hardcodes i386 and x86_64 architectures only
substituteInPlace Makefile.osx --replace "x86_64" "arm64"
'';
nativeBuildInputs = [
pkg-config
] ++ lib.optionals stdenv.isDarwin [
darwin.cctools
fixDarwinDylibNames
2022-10-12 16:46:32 +00:00
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
autoSignDarwinBinariesHook
];
buildInputs = [ libtiff libtiff.dev_private libpng zlib libwebp libraw openexr openjpeg libjpeg libjpeg.dev_private jxrlib ];
2019-09-08 14:46:03 +00:00
postBuild = lib.optionalString (!stdenv.isDarwin) ''
make -f Makefile.fip
'';
INCDIR = "${placeholder "out"}/include";
INSTALLDIR = "${placeholder "out"}/lib";
2019-09-08 14:46:03 +00:00
preInstall = ''
mkdir -p $INCDIR $INSTALLDIR
2021-04-22 00:22:33 +00:00
''
# Workaround for Makefiles.osx not using ?=
+ lib.optionalString stdenv.isDarwin ''
makeFlagsArray+=( "INCDIR=$INCDIR" "INSTALLDIR=$INSTALLDIR" )
2019-09-08 14:46:03 +00:00
'';
2019-09-08 14:46:03 +00:00
postInstall = lib.optionalString (!stdenv.isDarwin) ''
make -f Makefile.fip install
'' + lib.optionalString stdenv.isDarwin ''
ln -s $out/lib/libfreeimage.3.dylib $out/lib/libfreeimage.dylib
2019-09-08 14:46:03 +00:00
'';
2017-01-21 13:43:22 +00:00
2018-06-03 20:37:40 +00:00
enableParallelBuilding = true;
meta = {
description = "Open Source library for accessing popular graphics image file formats";
homepage = "http://freeimage.sourceforge.net/";
license = "GPL";
maintainers = with lib.maintainers; [viric l-as];
2019-09-08 14:46:03 +00:00
platforms = with lib.platforms; unix;
};
}