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

74 lines
2.9 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, unzip, darwin }:
2017-01-21 13:43:22 +00:00
stdenv.mkDerivation {
name = "freeimage-3.17.0";
2017-01-21 13:43:22 +00:00
src = fetchurl {
url = mirror://sourceforge/freeimage/FreeImage3170.zip;
sha256 = "12bz57asdcfsz3zr9i9nska0fb6h3z2aizy412qjqkixkginbz7v";
};
2017-01-21 13:43:22 +00:00
patches = let
patchURL = https://anonscm.debian.org/cgit/debian-science/packages/freeimage.git/plain/debian/patches;
in [
(fetchurl {
url = patchURL + "/Fix-CVE-2015-0852.patch";
sha256 = "1vxdck4i5qi5j6i3cjja0gfy79mmbf0lq2qdrnqdsl4kclbvw2c8";
})
(fetchurl {
url = patchURL + "/Fix-CVE-2016-5684.patch";
sha256 = "14ffgqbnwg28r6sjvm3z89zbnnm9ghbc81hdhrzxlyk3vwvd6cw3";
})
2018-06-03 21:37:40 +01:00
(fetchurl {
url = https://raw.githubusercontent.com/buildroot/buildroot/2018.05/package/libfreeimage/0005-Manage-powf64-with-glibc.patch;
sha256 = "1lis479ad5cfkhqm044nk4x97wfwm3hry3bvij1w5xkndnlfppc2";
})
];
2016-11-03 01:16:12 +00:00
buildInputs = [ unzip ] ++ stdenv.lib.optional stdenv.isDarwin darwin.cctools;
2017-01-21 13:43:22 +00:00
2016-11-03 01:16:12 +00:00
prePatch = if stdenv.isDarwin
then ''
sed -e 's/gcc-4.0/clang/g' \
-e 's/g++-4.0/clang++/g' \
-e 's/COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS/COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS -D__ANSI__/' \
-e "s|PREFIX = /usr/local|PREFIX = $out|" \
-e 's|-Wl,-syslibroot /Developer/SDKs/MacOSX10.5.sdk||g' \
-e 's|-Wl,-syslibroot /Developer/SDKs/MacOSX10.6.sdk||g' \
-e 's|-isysroot /Developer/SDKs/MacOSX10.6.sdk||g' \
-e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||g' \
-e 's| $(STATICLIB)-ppc $(STATICLIB)-i386||g' \
-e 's| $(SHAREDLIB)-ppc $(SHAREDLIB)-i386||g' \
-e 's| install -d -m 755 -o root -g wheel $(INCDIR) $(INSTALLDIR)||' \
-e 's| -m 644 -o root -g wheel||g' \
-i ./Makefile.osx
# Fix LibJXR performance timers
sed 's|^SRCS = \(.*\)$|SRCS = \1 Source/LibJXR/image/sys/perfTimerANSI.c|' -i ./Makefile.srcs
''
else ''
sed -e s@/usr/@$out/@ \
-e 's@-o root -g root@@' \
-e 's@ldconfig@echo not running ldconfig@' \
-i Makefile.gnu Makefile.fip
2016-11-03 01:16:12 +00:00
# Fix gcc 5.1 macro problems
# https://chromium.googlesource.com/webm/libwebp/+/eebaf97f5a1cb713d81d311308d8a48c124e5aef%5E!/
sed -i -e 's/"\(#[^"]*\)"/" \1 "/g' Source/LibWebP/src/dsp/*
'';
2016-11-03 01:16:12 +00:00
postBuild = stdenv.lib.optionalString (!stdenv.isDarwin) "make -f Makefile.fip";
preInstall = "mkdir -p $out/include $out/lib";
2016-11-03 01:16:12 +00:00
postInstall = stdenv.lib.optionalString (!stdenv.isDarwin) "make -f Makefile.fip install";
2017-01-21 13:43:22 +00:00
NIX_CFLAGS_COMPILE = "-Wno-narrowing";
2018-06-03 21:37:40 +01:00
enableParallelBuilding = true;
meta = {
description = "Open Source library for accessing popular graphics image file formats";
homepage = http://freeimage.sourceforge.net/;
license = "GPL";
maintainers = with stdenv.lib.maintainers; [viric];
2016-11-03 01:16:12 +00:00
platforms = with stdenv.lib.platforms; unix;
};
}