summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Nicolas <patricknicolas@laposte.net>2018-11-13 22:11:07 +0100
committerJames Le Cuirot <chewi@gentoo.org>2019-04-14 13:44:08 +0100
commit3b0e97797339cd968083a5da4829db5d6c81e619 (patch)
tree9d29ecc06129a2bf66cddcb693be0ae9d469b485 /media-libs/freeimage
parentgnome-extra/gnome-shell-extensions-topicons-plus: Fix stacktrace when removin... (diff)
downloadgentoo-3b0e97797339cd968083a5da4829db5d6c81e619.tar.gz
gentoo-3b0e97797339cd968083a5da4829db5d6c81e619.tar.bz2
gentoo-3b0e97797339cd968083a5da4829db5d6c81e619.zip
media-libs/freeimage: version bump to 3.18.0
Bug: https://bugs.gentoo.org/671106 Signed-off-by: Patrick Nicolas <patricknicolas@laposte.net> Package-Manager: Portage-2.3.51, Repoman-2.3.12 Closes: https://github.com/gentoo/gentoo/pull/10411 Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Diffstat (limited to 'media-libs/freeimage')
-rw-r--r--media-libs/freeimage/Manifest2
-rw-r--r--media-libs/freeimage/files/freeimage-3.18.0-disable-plugin-G3.patch56
-rw-r--r--media-libs/freeimage/files/freeimage-3.18.0-raw.patch15
-rw-r--r--media-libs/freeimage/files/freeimage-3.18.0-remove-jpeg-transform.patch82
-rw-r--r--media-libs/freeimage/files/freeimage-3.18.0-rename-jpeg_read_icc_profile.patch34
-rw-r--r--media-libs/freeimage/files/freeimage-3.18.0-unbundling.patch724
-rw-r--r--media-libs/freeimage/freeimage-3.18.0.ebuild116
7 files changed, 1029 insertions, 0 deletions
diff --git a/media-libs/freeimage/Manifest b/media-libs/freeimage/Manifest
index 79302f32dcf7..d7eb8ba5764f 100644
--- a/media-libs/freeimage/Manifest
+++ b/media-libs/freeimage/Manifest
@@ -1,2 +1,4 @@
DIST FreeImage3154.pdf 1007480 BLAKE2B 801d39c4b7eeab833c7225c2d53a3a0e8e9d2a91ea3f7173047705c8b750706f3a4a9ac60f7ba9d5e8150b548bd5add242e9e40f498c57ad9e5a623972bbb239 SHA512 cebde5e2609c9a0c06b4e07e1c595d7d6714895095cd9935f59c8b2ff9b34116248f5453b41f469f6242d87cae79be82d59f6a9ec0f75b1ea3df61ac1f651b28
DIST FreeImage3154.zip 5513923 BLAKE2B 376b00faaae2c10c9eb36f89726a022734e109ca7ca11951c9e6525f21d2a7ee305ec195be29a272ecb7935ba5d0b61f3d84f26a6aec5f7a9229d5e47cd665bb SHA512 0db9eb7d0ed8e08e10ff4fa274c4484541ca119c3d437a85fdc3b2d9232bf14a7877c79b1e62c8c99278d7020a9f623c161f2342475f3ee526233404138112cc
+DIST FreeImage3180.pdf 1665541 BLAKE2B 5d40ee6fa0a1e73df0cc961edbd70a2835ef88fb540f123fd81f2bb826d4c949d2a60dfe3fc02406ce632a389935abac0d471c963c9803b8c2aece2b48afb003 SHA512 632f68b14f7a5916a1b95bbf86c268d0afe786a2537472301bb002254aa3195f046efb41f073133633211e985e90edbb99285ab6f42bc55501c756292a3c4c03
+DIST FreeImage3180.zip 7415716 BLAKE2B b695271f4e80eb304eccde66e38b5095eceae51fbe0dd97df69c55f364f8440d8c97139b8edc2f01c400f5c53a7336fdfab1e28aa3ea04f485901d5def443d25 SHA512 9d9cc7e2d57552c3115e277aeb036e0455204d389026b17a3f513da5be1fd595421655488bb1ec2f76faebed66049119ca55e26e2a6d37024b3fb7ef36ad4818
diff --git a/media-libs/freeimage/files/freeimage-3.18.0-disable-plugin-G3.patch b/media-libs/freeimage/files/freeimage-3.18.0-disable-plugin-G3.patch
new file mode 100644
index 000000000000..a541bfa9464e
--- /dev/null
+++ b/media-libs/freeimage/files/freeimage-3.18.0-disable-plugin-G3.patch
@@ -0,0 +1,56 @@
+From d07a573fa1e0593e6af4f59e7bef15b78a8edfca Mon Sep 17 00:00:00 2001
+From: Patrick Nicolas <xytovl@laposte.net>
+Date: Tue, 13 Nov 2018 20:48:39 +0100
+Subject: [PATCH 4/4] disable plugin G3
+
+---
+ Makefile.srcs | 3 ---
+ Source/FreeImage/Plugin.cpp | 3 ---
+ fipMakefile.srcs | 3 ---
+ 3 files changed, 9 deletions(-)
+
+diff --git a/Makefile.srcs b/Makefile.srcs
+index a306aae..dac3ec2 100644
+--- a/Makefile.srcs
++++ b/Makefile.srcs
+@@ -37,9 +37,6 @@ SRCS-yes += \
+ SRCS-$(USE_EXR) += \
+ Source/FreeImage/PluginEXR.cpp \
+
+-SRCS-$(USE_TIFF) += \
+- Source/FreeImage/PluginG3.cpp \
+-
+ SRCS-yes += \
+ Source/FreeImage/PluginGIF.cpp \
+ Source/FreeImage/PluginHDR.cpp \
+diff --git a/Source/FreeImage/Plugin.cpp b/Source/FreeImage/Plugin.cpp
+index 7768a32..43d8b6d 100644
+--- a/Source/FreeImage/Plugin.cpp
++++ b/Source/FreeImage/Plugin.cpp
+@@ -273,9 +273,6 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
+ s_plugins->AddNode(InitDDS);
+ s_plugins->AddNode(InitGIF);
+ s_plugins->AddNode(InitHDR);
+-#ifdef USE_TIFF
+- s_plugins->AddNode(InitG3);
+-#endif
+ s_plugins->AddNode(InitSGI);
+ #ifdef USE_EXR
+ s_plugins->AddNode(InitEXR);
+diff --git a/fipMakefile.srcs b/fipMakefile.srcs
+index 74c9ec0..8a48b67 100644
+--- a/fipMakefile.srcs
++++ b/fipMakefile.srcs
+@@ -37,9 +37,6 @@ SRCS-yes += \
+ SRCS-$(USE_EXR) += \
+ Source/FreeImage/PluginEXR.cpp \
+
+-SRCS-$(USE_TIFF) += \
+- Source/FreeImage/PluginG3.cpp \
+-
+ SRCS-yes += \
+ Source/FreeImage/PluginGIF.cpp \
+ Source/FreeImage/PluginHDR.cpp \
+--
+2.19.1
+
diff --git a/media-libs/freeimage/files/freeimage-3.18.0-raw.patch b/media-libs/freeimage/files/freeimage-3.18.0-raw.patch
new file mode 100644
index 000000000000..94accaba9695
--- /dev/null
+++ b/media-libs/freeimage/files/freeimage-3.18.0-raw.patch
@@ -0,0 +1,15 @@
+Index: FreeImage/Source/FreeImage.h
+===================================================================
+--- FreeImage.orig/Source/FreeImage.h
++++ FreeImage/Source/FreeImage.h
+@@ -155,8 +155,10 @@ typedef uint8_t BYTE;
+ typedef uint16_t WORD;
+ typedef uint32_t DWORD;
+ typedef int32_t LONG;
++#ifndef _LIBRAW_TYPES_H
+ typedef int64_t INT64;
+ typedef uint64_t UINT64;
++#endif
+ #else
+ // MS is not C99 ISO compliant
+ typedef long BOOL;
diff --git a/media-libs/freeimage/files/freeimage-3.18.0-remove-jpeg-transform.patch b/media-libs/freeimage/files/freeimage-3.18.0-remove-jpeg-transform.patch
new file mode 100644
index 000000000000..fb79cf7b5135
--- /dev/null
+++ b/media-libs/freeimage/files/freeimage-3.18.0-remove-jpeg-transform.patch
@@ -0,0 +1,82 @@
+From cb27fc742dd0b569f9ffe91a99ebeb5f077971da Mon Sep 17 00:00:00 2001
+From: Patrick Nicolas <xytovl@laposte.net>
+Date: Tue, 13 Nov 2018 20:27:59 +0100
+Subject: [PATCH 2/4] remove jpeg transform
+
+---
+ Makefile.srcs | 7 -------
+ Source/FreeImage.h | 2 ++
+ fipMakefile.srcs | 8 --------
+ 3 files changed, 2 insertions(+), 15 deletions(-)
+
+diff --git a/Makefile.srcs b/Makefile.srcs
+index cb41903..a306aae 100644
+--- a/Makefile.srcs
++++ b/Makefile.srcs
+@@ -141,17 +141,10 @@ SRCS-yes += \
+ Source/FreeImageToolkit/CopyPaste.cpp \
+ Source/FreeImageToolkit/Display.cpp \
+ Source/FreeImageToolkit/Flip.cpp \
+-
+-SRCS-$(USE_JPEG) += \
+- Source/FreeImageToolkit/JPEGTransform.cpp \
+-
+-SRCS-yes += \
+ Source/FreeImageToolkit/MultigridPoissonSolver.cpp \
+ Source/FreeImageToolkit/Rescale.cpp \
+ Source/FreeImageToolkit/Resize.cpp \
+
+-SRCS-$(USE_JPEG) += \
+- Source/transupp.c
+ SRCS = $(SRCS-yes)
+
+ INCLS = Dist/FreeImage.h \
+diff --git a/Source/FreeImage.h b/Source/FreeImage.h
+index 12182cd..ac4e6a0 100644
+--- a/Source/FreeImage.h
++++ b/Source/FreeImage.h
+@@ -1089,6 +1089,7 @@ DLL_API const char* DLL_CALLCONV FreeImage_TagToString(FREE_IMAGE_MDMODEL model,
+ // JPEG lossless transformation routines
+ // --------------------------------------------------------------------------
+
++#if 0 // not supported on Gentoo
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransform(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE));
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, BOOL perfect FI_DEFAULT(TRUE));
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGCrop(const char *src_file, const char *dst_file, int left, int top, int right, int bottom);
+@@ -1097,6 +1098,7 @@ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformFromHandle(FreeImageIO* src_io,
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombined(const char *src_file, const char *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedU(const wchar_t *src_file, const wchar_t *dst_file, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
+ DLL_API BOOL DLL_CALLCONV FreeImage_JPEGTransformCombinedFromMemory(FIMEMORY* src_stream, FIMEMORY* dst_stream, FREE_IMAGE_JPEG_OPERATION operation, int* left, int* top, int* right, int* bottom, BOOL perfect FI_DEFAULT(TRUE));
++#endif
+
+
+ // --------------------------------------------------------------------------
+diff --git a/fipMakefile.srcs b/fipMakefile.srcs
+index e58f046..74c9ec0 100644
+--- a/fipMakefile.srcs
++++ b/fipMakefile.srcs
+@@ -141,11 +141,6 @@ SRCS-yes += \
+ Source/FreeImageToolkit/CopyPaste.cpp \
+ Source/FreeImageToolkit/Display.cpp \
+ Source/FreeImageToolkit/Flip.cpp \
+-
+-SRCS-$(USE_JPEG) += \
+- Source/FreeImageToolkit/JPEGTransform.cpp \
+-
+-SRCS-yes += \
+ Source/FreeImageToolkit/MultigridPoissonSolver.cpp \
+ Source/FreeImageToolkit/Rescale.cpp \
+ Source/FreeImageToolkit/Resize.cpp \
+@@ -157,9 +152,6 @@ SRCS-yes += \
+ Wrapper/FreeImagePlus/src/fipWinImage.cpp \
+ Wrapper/FreeImagePlus/src/FreeImagePlus.cpp
+
+-SRCS-$(USE_JPEG) += \
+- Source/transupp.c
+-
+ SRCS = $(SRCS-yes)
+ INCLUDE = -I. \
+ -ISource \
+--
+2.19.1
+
diff --git a/media-libs/freeimage/files/freeimage-3.18.0-rename-jpeg_read_icc_profile.patch b/media-libs/freeimage/files/freeimage-3.18.0-rename-jpeg_read_icc_profile.patch
new file mode 100644
index 000000000000..982d00747c59
--- /dev/null
+++ b/media-libs/freeimage/files/freeimage-3.18.0-rename-jpeg_read_icc_profile.patch
@@ -0,0 +1,34 @@
+From 27c02a3ed6196b4b0bab5524f2825da58a76d706 Mon Sep 17 00:00:00 2001
+From: Patrick Nicolas <xytovl@laposte.net>
+Date: Tue, 13 Nov 2018 20:28:51 +0100
+Subject: [PATCH 3/4] rename jpeg_read_icc_profile
+
+---
+ Source/FreeImage/PluginJPEG.cpp | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Source/FreeImage/PluginJPEG.cpp b/Source/FreeImage/PluginJPEG.cpp
+index dd97e63..569f71e 100644
+--- a/Source/FreeImage/PluginJPEG.cpp
++++ b/Source/FreeImage/PluginJPEG.cpp
+@@ -507,7 +507,7 @@ marker_is_icc(jpeg_saved_marker_ptr marker) {
+ return FALSE. You might want to issue an error message instead.
+ */
+ static BOOL
+-jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) {
++_jpeg_read_icc_profile(j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned *icc_data_len) {
+ jpeg_saved_marker_ptr marker;
+ int num_markers = 0;
+ int seq_no;
+@@ -749,7 +749,7 @@ read_markers(j_decompress_ptr cinfo, FIBITMAP *dib) {
+ BYTE *icc_profile = NULL;
+ unsigned icc_length = 0;
+
+- if( jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length) ) {
++ if( _jpeg_read_icc_profile(cinfo, &icc_profile, &icc_length) ) {
+ // copy ICC profile data
+ FreeImage_CreateICCProfile(dib, icc_profile, icc_length);
+ // clean up
+--
+2.19.1
+
diff --git a/media-libs/freeimage/files/freeimage-3.18.0-unbundling.patch b/media-libs/freeimage/files/freeimage-3.18.0-unbundling.patch
new file mode 100644
index 000000000000..ad2e4961e440
--- /dev/null
+++ b/media-libs/freeimage/files/freeimage-3.18.0-unbundling.patch
@@ -0,0 +1,724 @@
+From 03a713e62529d1bcb45aedf767c7cb33ddd6e1a7 Mon Sep 17 00:00:00 2001
+From: Patrick Nicolas <xytovl@laposte.net>
+Date: Tue, 13 Nov 2018 19:40:58 +0100
+Subject: [PATCH 1/4] unbundling
+
+diff --git a/Makefile.fip b/Makefile.fip
+index b59c419..c6b82bb 100644
+--- a/Makefile.fip
++++ b/Makefile.fip
+@@ -11,7 +11,26 @@ INSTALLDIR ?= $(DESTDIR)/usr/lib
+ # Converts cr/lf to just lf
+ DOS2UNIX = dos2unix
+
+-LIBRARIES = -lstdc++
++PKG_CONFIG ?= pkg-config
++
++USE_EXR ?= yes
++USE_JPEG ?= yes
++USE_JPEG2K ?= yes
++USE_MNG ?= yes
++USE_PNG ?= yes
++USE_TIFF ?= yes
++USE_RAW ?= yes
++USE_WEBP ?= yes
++
++LIBRARIES-yes = $(shell $(PKG_CONFIG) --libs zlib)
++LIBRARIES-$(USE_EXR) += $(shell $(PKG_CONFIG) --libs OpenEXR)
++LIBRARIES-$(USE_JPEG) += -ljpeg
++LIBRARIES-$(USE_JPEG2K) += $(shell $(PKG_CONFIG) --libs libopenjp2)
++LIBRARIES-$(USE_MNG) += -lmng
++LIBRARIES-$(USE_PNG) += $(shell $(PKG_CONFIG) --libs libpng)
++LIBRARIES-$(USE_TIFF) += $(shell $(PKG_CONFIG) --libs libtiff-4 IlmBase)
++LIBRARIES-$(USE_RAW) += $(shell $(PKG_CONFIG) --libs libraw)
++LIBRARIES-$(USE_WEBP) += $(shell $(PKG_CONFIG) --libs libwebp)
+
+ MODULES = $(SRCS:.c=.o)
+ MODULES := $(MODULES:.cpp=.o)
+@@ -68,16 +87,18 @@ $(STATICLIB): $(MODULES)
+ $(AR) r $@ $(MODULES)
+
+ $(SHAREDLIB): $(MODULES)
+- $(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
++ $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES-yes)
+
+ install:
+ install -d $(INCDIR) $(INSTALLDIR)
+- install -m 644 -o root -g root $(HEADER) $(INCDIR)
+- install -m 644 -o root -g root $(HEADERFIP) $(INCDIR)
+- install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
+- install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
++ install -m 644 $(HEADER) $(INCDIR)
++ install -m 644 $(HEADERFIP) $(INCDIR)
++ifneq ($(STATICLIB),)
++ install -m 644 $(STATICLIB) $(INSTALLDIR)
++endif
++ install -m 755 $(SHAREDLIB) $(INSTALLDIR)
+ ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
+- ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)
++ ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)
+
+ clean:
+ rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
+diff --git a/Makefile.gnu b/Makefile.gnu
+index 92f6358..345f0db 100644
+--- a/Makefile.gnu
++++ b/Makefile.gnu
+@@ -11,7 +11,26 @@ INSTALLDIR ?= $(DESTDIR)/usr/lib
+ # Converts cr/lf to just lf
+ DOS2UNIX = dos2unix
+
+-LIBRARIES = -lstdc++
++PKG_CONFIG ?= pkg-config
++
++USE_EXR ?= yes
++USE_JPEG ?= yes
++USE_JPEG2K ?= yes
++USE_MNG ?= yes
++USE_PNG ?= yes
++USE_TIFF ?= yes
++USE_RAW ?= yes
++USE_WEBP ?= yes
++
++LIBRARIES-yes = $(shell $(PKG_CONFIG) --libs zlib)
++LIBRARIES-$(USE_EXR) += $(shell $(PKG_CONFIG) --libs OpenEXR)
++LIBRARIES-$(USE_JPEG) += -ljpeg
++LIBRARIES-$(USE_JPEG2K) += $(shell $(PKG_CONFIG) --libs libopenjp2)
++LIBRARIES-$(USE_MNG) += -lmng
++LIBRARIES-$(USE_PNG) += $(shell $(PKG_CONFIG) --libs libpng)
++LIBRARIES-$(USE_TIFF) += $(shell $(PKG_CONFIG) --libs libtiff-4 IlmBase)
++LIBRARIES-$(USE_RAW) += $(shell $(PKG_CONFIG) --libs libraw)
++LIBRARIES-$(USE_WEBP) += $(shell $(PKG_CONFIG) --libs libwebp)
+
+ MODULES = $(SRCS:.c=.o)
+ MODULES := $(MODULES:.cpp=.o)
+@@ -67,13 +86,15 @@ $(STATICLIB): $(MODULES)
+ $(AR) r $@ $(MODULES)
+
+ $(SHAREDLIB): $(MODULES)
+- $(CC) -s -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES)
++ $(CXX) $(CXXFLAGS) -shared -Wl,-soname,$(VERLIBNAME) $(LDFLAGS) -o $@ $(MODULES) $(LIBRARIES-yes)
+
+ install:
+ install -d $(INCDIR) $(INSTALLDIR)
+- install -m 644 -o root -g root $(HEADER) $(INCDIR)
+- install -m 644 -o root -g root $(STATICLIB) $(INSTALLDIR)
+- install -m 755 -o root -g root $(SHAREDLIB) $(INSTALLDIR)
++ install -m 644 $(HEADER) $(INCDIR)
++ifneq ($(STATICLIB),)
++ install -m 644 $(STATICLIB) $(INSTALLDIR)
++endif
++ install -m 755 $(SHAREDLIB) $(INSTALLDIR)
+ ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(VERLIBNAME)
+ ln -sf $(VERLIBNAME) $(INSTALLDIR)/$(LIBNAME)
+ # ldconfig
+diff --git a/Makefile.srcs b/Makefile.srcs
+index de25754..cb41903 100644
+--- a/Makefile.srcs
++++ b/Makefile.srcs
+@@ -1,6 +1,15 @@
++USE_EXR ?= yes
++USE_JPEG ?= yes
++USE_JPEG2K ?= yes
++USE_MNG ?= yes
++USE_PNG ?= yes
++USE_TIFF ?= yes
++USE_RAW ?= yes
++USE_WEBP ?= yes
++
+ VER_MAJOR = 3
+ VER_MINOR = 18.0
+-SRCS = \
++SRCS-yes = \
+ Source/FreeImage/BitmapAccess.cpp \
+ Source/FreeImage/ColorLookup.cpp \
+ Source/FreeImage/ConversionRGBA16.cpp \
+@@ -12,39 +21,80 @@ SRCS = \
+ Source/FreeImage/LFPQuantizer.cpp \
+ Source/FreeImage/MemoryIO.cpp \
+ Source/FreeImage/PixelAccess.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/J2KHelper.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/MNGHelper.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/Plugin.cpp \
+ Source/FreeImage/PluginBMP.cpp \
+ Source/FreeImage/PluginCUT.cpp \
+ Source/FreeImage/PluginDDS.cpp \
++
++SRCS-$(USE_EXR) += \
+ Source/FreeImage/PluginEXR.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/FreeImage/PluginG3.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginGIF.cpp \
+ Source/FreeImage/PluginHDR.cpp \
+ Source/FreeImage/PluginICO.cpp \
+ Source/FreeImage/PluginIFF.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/PluginJ2K.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/PluginJNG.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/PluginJP2.cpp \
++
++SRCS-$(USE_JPEG) += \
+ Source/FreeImage/PluginJPEG.cpp \
+- Source/FreeImage/PluginJXR.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginKOALA.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/PluginMNG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginPCD.cpp \
+ Source/FreeImage/PluginPCX.cpp \
+ Source/FreeImage/PluginPFM.cpp \
+ Source/FreeImage/PluginPICT.cpp \
++
++SRCS-$(USE_PNG) += \
+ Source/FreeImage/PluginPNG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginPNM.cpp \
+ Source/FreeImage/PluginPSD.cpp \
+ Source/FreeImage/PluginRAS.cpp \
++
++SRCS-$(USE_RAW) += \
+ Source/FreeImage/PluginRAW.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginSGI.cpp \
+ Source/FreeImage/PluginTARGA.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/FreeImage/PluginTIFF.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginWBMP.cpp \
++
++SRCS-$(USE_WEBP) += \
+ Source/FreeImage/PluginWebP.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginXBM.cpp \
+ Source/FreeImage/PluginXPM.cpp \
+ Source/FreeImage/PSDParser.cpp \
+@@ -78,7 +128,11 @@ SRCS = \
+ Source/Metadata/IPTC.cpp \
+ Source/Metadata/TagConversion.cpp \
+ Source/Metadata/TagLib.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/Metadata/XTIFF.cpp \
++
++SRCS-yes += \
+ Source/FreeImageToolkit/Background.cpp \
+ Source/FreeImageToolkit/BSplineRotate.cpp \
+ Source/FreeImageToolkit/Channels.cpp \
+@@ -87,11 +141,19 @@ SRCS = \
+ Source/FreeImageToolkit/CopyPaste.cpp \
+ Source/FreeImageToolkit/Display.cpp \
+ Source/FreeImageToolkit/Flip.cpp \
++
++SRCS-$(USE_JPEG) += \
+ Source/FreeImageToolkit/JPEGTransform.cpp \
++
++SRCS-yes += \
+ Source/FreeImageToolkit/MultigridPoissonSolver.cpp \
+ Source/FreeImageToolkit/Rescale.cpp \
+ Source/FreeImageToolkit/Resize.cpp \
+
++SRCS-$(USE_JPEG) += \
++ Source/transupp.c
++SRCS = $(SRCS-yes)
++
+ INCLS = Dist/FreeImage.h \
+ Examples/OpenGL/TextureManager/TextureManager.h \
+ Examples/Plugin/PluginCradle.h \
+@@ -117,7 +179,18 @@ INCLS = Dist/FreeImage.h \
+ Wrapper/FreeImagePlus/test/fipTest.h \
+ TestAPI/TestSuite.h
+
+-INCLUDE = -I. \
++INCLUDE-yes = -I. \
+ -ISource \
+ -ISource/Metadata \
+ -ISource/FreeImageToolkit \
++
++INCLUDE-yes += $(shell $(PKG_CONFIG) --cflags-only-I zlib)
++INCLUDE-$(USE_EXR) += -DUSE_EXR $(shell $(PKG_CONFIG) --cflags-only-I OpenEXR)
++INCLUDE-$(USE_JPEG) += -DUSE_JPEG
++INCLUDE-$(USE_JPEG2K) += -DUSE_JPEG2K $(shell $(PKG_CONFIG) --cflags-only-I libopenjp2)
++INCLUDE-$(USE_MNG) += -DUSE_MNG
++INCLUDE-$(USE_PNG) += -DUSE_PNG $(shell $(PKG_CONFIG) --cflags-only-I libpng)
++INCLUDE-$(USE_TIFF) += -DUSE_TIFF $(shell $(PKG_CONFIG) --cflags-only-I libtiff-4 IlmBase)
++INCLUDE-$(USE_RAW) += -DUSE_RAW $(shell $(PKG_CONFIG) --cflags-only-I libraw)
++INCLUDE-$(USE_WEBP) += -DUSE_WEBP $(shell $(PKG_CONFIG) --cflags-only-I libwebp)
++INCLUDE = $(INCLUDE-yes)
+diff --git a/Source/FreeImage/J2KHelper.cpp b/Source/FreeImage/J2KHelper.cpp
+index 1776c3b..538f1c5 100644
+--- a/Source/FreeImage/J2KHelper.cpp
++++ b/Source/FreeImage/J2KHelper.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // --------------------------------------------------------------------------
+diff --git a/Source/FreeImage/Plugin.cpp b/Source/FreeImage/Plugin.cpp
+index 11e7294..7768a32 100644
+--- a/Source/FreeImage/Plugin.cpp
++++ b/Source/FreeImage/Plugin.cpp
+@@ -238,23 +238,33 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
+ */
+ s_plugins->AddNode(InitBMP);
+ s_plugins->AddNode(InitICO);
++#ifdef USE_JPEG
+ s_plugins->AddNode(InitJPEG);
++#endif
++#ifdef USE_MNG
+ s_plugins->AddNode(InitJNG);
++#endif
+ s_plugins->AddNode(InitKOALA);
+ s_plugins->AddNode(InitIFF);
++#ifdef USE_MNG
+ s_plugins->AddNode(InitMNG);
++#endif
+ s_plugins->AddNode(InitPNM, NULL, "PBM", "Portable Bitmap (ASCII)", "pbm", "^P1");
+ s_plugins->AddNode(InitPNM, NULL, "PBMRAW", "Portable Bitmap (RAW)", "pbm", "^P4");
+ s_plugins->AddNode(InitPCD);
+ s_plugins->AddNode(InitPCX);
+ s_plugins->AddNode(InitPNM, NULL, "PGM", "Portable Greymap (ASCII)", "pgm", "^P2");
+ s_plugins->AddNode(InitPNM, NULL, "PGMRAW", "Portable Greymap (RAW)", "pgm", "^P5");
++#ifdef USE_PNG
+ s_plugins->AddNode(InitPNG);
++#endif
+ s_plugins->AddNode(InitPNM, NULL, "PPM", "Portable Pixelmap (ASCII)", "ppm", "^P3");
+ s_plugins->AddNode(InitPNM, NULL, "PPMRAW", "Portable Pixelmap (RAW)", "ppm", "^P6");
+ s_plugins->AddNode(InitRAS);
+ s_plugins->AddNode(InitTARGA);
++#ifdef USE_TIFF
+ s_plugins->AddNode(InitTIFF);
++#endif
+ s_plugins->AddNode(InitWBMP);
+ s_plugins->AddNode(InitPSD);
+ s_plugins->AddNode(InitCUT);
+@@ -263,16 +273,26 @@ FreeImage_Initialise(BOOL load_local_plugins_only) {
+ s_plugins->AddNode(InitDDS);
+ s_plugins->AddNode(InitGIF);
+ s_plugins->AddNode(InitHDR);
++#ifdef USE_TIFF
+ s_plugins->AddNode(InitG3);
++#endif
+ s_plugins->AddNode(InitSGI);
++#ifdef USE_EXR
+ s_plugins->AddNode(InitEXR);
++#endif
++#ifdef USE_JPEG2K
+ s_plugins->AddNode(InitJ2K);
+ s_plugins->AddNode(InitJP2);
++#endif
+ s_plugins->AddNode(InitPFM);
+ s_plugins->AddNode(InitPICT);
++#ifdef USE_RAW
+ s_plugins->AddNode(InitRAW);
++#endif
++#ifdef USE_WEBP
+ s_plugins->AddNode(InitWEBP);
+-#if !(defined(_MSC_VER) && (_MSC_VER <= 1310))
++#endif
++#if 0
+ s_plugins->AddNode(InitJXR);
+ #endif // unsupported by MS Visual Studio 2003 !!!
+
+diff --git a/Source/FreeImage/PluginEXR.cpp b/Source/FreeImage/PluginEXR.cpp
+index b286430..faa8037 100644
+--- a/Source/FreeImage/PluginEXR.cpp
++++ b/Source/FreeImage/PluginEXR.cpp
+@@ -28,16 +28,16 @@
+ #pragma warning (disable : 4800) // ImfVersion.h - 'const int' : forcing value to bool 'true' or 'false' (performance warning)
+ #endif
+
+-#include "../OpenEXR/IlmImf/ImfIO.h"
+-#include "../OpenEXR/Iex/Iex.h"
+-#include "../OpenEXR/IlmImf/ImfOutputFile.h"
+-#include "../OpenEXR/IlmImf/ImfInputFile.h"
+-#include "../OpenEXR/IlmImf/ImfRgbaFile.h"
+-#include "../OpenEXR/IlmImf/ImfChannelList.h"
+-#include "../OpenEXR/IlmImf/ImfRgba.h"
+-#include "../OpenEXR/IlmImf/ImfArray.h"
+-#include "../OpenEXR/IlmImf/ImfPreviewImage.h"
+-#include "../OpenEXR/Half/half.h"
++#include <ImfIO.h>
++#include <Iex.h>
++#include <ImfOutputFile.h>
++#include <ImfInputFile.h>
++#include <ImfRgbaFile.h>
++#include <ImfChannelList.h>
++#include <ImfRgba.h>
++#include <ImfArray.h>
++#include <ImfPreviewImage.h>
++#include <half.h>
+
+
+ // ==========================================================
+diff --git a/Source/FreeImage/PluginG3.cpp b/Source/FreeImage/PluginG3.cpp
+index 0a083b4..b3a9bd7 100644
+--- a/Source/FreeImage/PluginG3.cpp
++++ b/Source/FreeImage/PluginG3.cpp
+@@ -20,7 +20,7 @@
+ // Use at your own risk!
+ // ==========================================================
+
+-#include "../LibTIFF4/tiffiop.h"
++#include "tiffiop.h"
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+diff --git a/Source/FreeImage/PluginJ2K.cpp b/Source/FreeImage/PluginJ2K.cpp
+index b8bcfc8..621a903 100644
+--- a/Source/FreeImage/PluginJ2K.cpp
++++ b/Source/FreeImage/PluginJ2K.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // ==========================================================
+diff --git a/Source/FreeImage/PluginJP2.cpp b/Source/FreeImage/PluginJP2.cpp
+index 742fe2c..c57f626 100644
+--- a/Source/FreeImage/PluginJP2.cpp
++++ b/Source/FreeImage/PluginJP2.cpp
+@@ -21,7 +21,7 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibOpenJPEG/openjpeg.h"
++#include <openjpeg.h>
+ #include "J2KHelper.h"
+
+ // ==========================================================
+diff --git a/Source/FreeImage/PluginJPEG.cpp b/Source/FreeImage/PluginJPEG.cpp
+index 8db177d..dd97e63 100644
+--- a/Source/FreeImage/PluginJPEG.cpp
++++ b/Source/FreeImage/PluginJPEG.cpp
+@@ -35,11 +35,15 @@ extern "C" {
+ #undef FAR
+ #include <setjmp.h>
+
+-#include "../LibJPEG/jinclude.h"
+-#include "../LibJPEG/jpeglib.h"
+-#include "../LibJPEG/jerror.h"
++#include <string.h>
++#include <stdio.h>
++#include <jconfig.h>
++#include <jpeglib.h>
++#include <jerror.h>
+ }
+
++#define SIZEOF(object) ((size_t) sizeof(object))
++
+ #include "FreeImage.h"
+ #include "Utilities.h"
+
+diff --git a/Source/FreeImage/PluginPNG.cpp b/Source/FreeImage/PluginPNG.cpp
+index 661f160..504fafe 100644
+--- a/Source/FreeImage/PluginPNG.cpp
++++ b/Source/FreeImage/PluginPNG.cpp
+@@ -40,8 +40,8 @@
+
+ // ----------------------------------------------------------
+
+-#include "../ZLib/zlib.h"
+-#include "../LibPNG/png.h"
++#include <zlib.h>
++#include <png.h>
+
+ // ----------------------------------------------------------
+
+diff --git a/Source/FreeImage/PluginRAW.cpp b/Source/FreeImage/PluginRAW.cpp
+index e9bd5bf..680e634 100644
+--- a/Source/FreeImage/PluginRAW.cpp
++++ b/Source/FreeImage/PluginRAW.cpp
+@@ -19,7 +19,7 @@
+ // Use at your own risk!
+ // ==========================================================
+
+-#include "../LibRawLite/libraw/libraw.h"
++#include <libraw.h>
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+diff --git a/Source/FreeImage/PluginTIFF.cpp b/Source/FreeImage/PluginTIFF.cpp
+index 67fab0b..36f99e8 100644
+--- a/Source/FreeImage/PluginTIFF.cpp
++++ b/Source/FreeImage/PluginTIFF.cpp
+@@ -37,9 +37,9 @@
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../LibTIFF4/tiffiop.h"
++#include "tiffiop.h"
+ #include "../Metadata/FreeImageTag.h"
+-#include "../OpenEXR/Half/half.h"
++#include <half.h>
+
+ #include "FreeImageIO.h"
+ #include "PSDParser.h"
+diff --git a/Source/FreeImage/PluginWebP.cpp b/Source/FreeImage/PluginWebP.cpp
+index 7c9f62f..c401447 100644
+--- a/Source/FreeImage/PluginWebP.cpp
++++ b/Source/FreeImage/PluginWebP.cpp
+@@ -24,9 +24,9 @@
+
+ #include "../Metadata/FreeImageTag.h"
+
+-#include "../LibWebP/src/webp/decode.h"
+-#include "../LibWebP/src/webp/encode.h"
+-#include "../LibWebP/src/webp/mux.h"
++#include <webp/decode.h>
++#include <webp/encode.h>
++#include <webp/mux.h>
+
+ // ==========================================================
+ // Plugin Interface
+diff --git a/Source/FreeImage/ZLibInterface.cpp b/Source/FreeImage/ZLibInterface.cpp
+index 3ab6d32..7e32110 100644
+--- a/Source/FreeImage/ZLibInterface.cpp
++++ b/Source/FreeImage/ZLibInterface.cpp
+@@ -19,10 +19,10 @@
+ // Use at your own risk!
+ // ==========================================================
+
+-#include "../ZLib/zlib.h"
++#include <zlib.h>
+ #include "FreeImage.h"
+ #include "Utilities.h"
+-#include "../ZLib/zutil.h" /* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */
++#define OS_CODE 0x03
+
+ /**
+ Compresses a source buffer into a target buffer, using the ZLib library.
+diff --git a/Source/FreeImageToolkit/JPEGTransform.cpp b/Source/FreeImageToolkit/JPEGTransform.cpp
+index 6f9ba8e..988d777 100644
+--- a/Source/FreeImageToolkit/JPEGTransform.cpp
++++ b/Source/FreeImageToolkit/JPEGTransform.cpp
+@@ -26,10 +26,11 @@ extern "C" {
+ #undef FAR
+ #include <setjmp.h>
+
+-#include "../LibJPEG/jinclude.h"
+-#include "../LibJPEG/jpeglib.h"
+-#include "../LibJPEG/jerror.h"
+-#include "../LibJPEG/transupp.h"
++#include <string.h>
++#include <stdio.h>
++#include <jpeglib.h>
++#include <jerror.h>
++#include "transupp.h"
+ }
+
+ #include "FreeImage.h"
+diff --git a/Source/Metadata/XTIFF.cpp b/Source/Metadata/XTIFF.cpp
+index d5be902..7f2be42 100644
+--- a/Source/Metadata/XTIFF.cpp
++++ b/Source/Metadata/XTIFF.cpp
+@@ -29,7 +29,7 @@
+ #pragma warning (disable : 4786) // identifier was truncated to 'number' characters
+ #endif
+
+-#include "../LibTIFF4/tiffiop.h"
++#include "tiffiop.h"
+
+ #include "FreeImage.h"
+ #include "Utilities.h"
+diff --git a/Source/tiffiop.h b/Source/tiffiop.h
+index 2fe7556..1642582 100644
+--- a/Source/tiffiop.h
++++ b/Source/tiffiop.h
+@@ -28,7 +28,10 @@
+ * ``Library-private'' definitions.
+ */
+
+-#include "tif_config.h"
++#include <tiffconf.h>
++#define HAVE_SEARCH_H
++#define HAVE_FCNTL_H
++#define HAVE_SNPRINTF
+
+ #ifdef HAVE_FCNTL_H
+ # include <fcntl.h>
+diff --git a/Source/transupp.c b/Source/transupp.c
+index d10f57b..d50216c 100644
+--- a/Source/transupp.c
++++ b/Source/transupp.c
+@@ -15,8 +15,7 @@
+ /* Although this file really shouldn't have access to the library internals,
+ * it's helpful to let it call jround_up() and jcopy_block_row().
+ */
+-#define JPEG_INTERNALS
+-
++#include <jerror.h>
+ #include "jinclude.h"
+ #include "jpeglib.h"
+ #include "transupp.h" /* My own external interface */
+diff --git a/fipMakefile.srcs b/fipMakefile.srcs
+index d271b4b..e58f046 100644
+--- a/fipMakefile.srcs
++++ b/fipMakefile.srcs
+@@ -1,6 +1,15 @@
++USE_EXR ?= yes
++USE_JPEG ?= yes
++USE_JPEG2K ?= yes
++USE_MNG ?= yes
++USE_PNG ?= yes
++USE_TIFF ?= yes
++USE_RAW ?= yes
++USE_WEBP ?= yes
++
+ VER_MAJOR = 3
+ VER_MINOR = 18.0
+-SRCS = \
++SRCS-yes = \
+ Source/FreeImage/BitmapAccess.cpp \
+ Source/FreeImage/ColorLookup.cpp \
+ Source/FreeImage/ConversionRGBA16.cpp \
+@@ -12,39 +21,80 @@ SRCS = \
+ Source/FreeImage/LFPQuantizer.cpp \
+ Source/FreeImage/MemoryIO.cpp \
+ Source/FreeImage/PixelAccess.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/J2KHelper.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/MNGHelper.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/Plugin.cpp \
+ Source/FreeImage/PluginBMP.cpp \
+ Source/FreeImage/PluginCUT.cpp \
+ Source/FreeImage/PluginDDS.cpp \
++
++SRCS-$(USE_EXR) += \
+ Source/FreeImage/PluginEXR.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/FreeImage/PluginG3.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginGIF.cpp \
+ Source/FreeImage/PluginHDR.cpp \
+ Source/FreeImage/PluginICO.cpp \
+ Source/FreeImage/PluginIFF.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/PluginJ2K.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/PluginJNG.cpp \
++
++SRCS-$(USE_JPEG2K) += \
+ Source/FreeImage/PluginJP2.cpp \
++
++SRCS-$(USE_JPEG) += \
+ Source/FreeImage/PluginJPEG.cpp \
+- Source/FreeImage/PluginJXR.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginKOALA.cpp \
++
++SRCS-$(USE_MNG) += \
+ Source/FreeImage/PluginMNG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginPCD.cpp \
+ Source/FreeImage/PluginPCX.cpp \
+ Source/FreeImage/PluginPFM.cpp \
+ Source/FreeImage/PluginPICT.cpp \
++
++SRCS-$(USE_PNG) += \
+ Source/FreeImage/PluginPNG.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginPNM.cpp \
+ Source/FreeImage/PluginPSD.cpp \
+ Source/FreeImage/PluginRAS.cpp \
++
++SRCS-$(USE_RAW) += \
+ Source/FreeImage/PluginRAW.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginSGI.cpp \
+ Source/FreeImage/PluginTARGA.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/FreeImage/PluginTIFF.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginWBMP.cpp \
++
++SRCS-$(USE_WEBP) += \
+ Source/FreeImage/PluginWebP.cpp \
++
++SRCS-yes += \
+ Source/FreeImage/PluginXBM.cpp \
+ Source/FreeImage/PluginXPM.cpp \
+ Source/FreeImage/PSDParser.cpp \
+@@ -78,7 +128,11 @@ SRCS = \
+ Source/Metadata/IPTC.cpp \
+ Source/Metadata/TagConversion.cpp \
+ Source/Metadata/TagLib.cpp \
++
++SRCS-$(USE_TIFF) += \
+ Source/Metadata/XTIFF.cpp \
++
++SRCS-yes += \
+ Source/FreeImageToolkit/Background.cpp \
+ Source/FreeImageToolkit/BSplineRotate.cpp \
+ Source/FreeImageToolkit/Channels.cpp \
+@@ -87,7 +141,11 @@ SRCS = \
+ Source/FreeImageToolkit/CopyPaste.cpp \
+ Source/FreeImageToolkit/Display.cpp \
+ Source/FreeImageToolkit/Flip.cpp \
++
++SRCS-$(USE_JPEG) += \
+ Source/FreeImageToolkit/JPEGTransform.cpp \
++
++SRCS-yes += \
+ Source/FreeImageToolkit/MultigridPoissonSolver.cpp \
+ Source/FreeImageToolkit/Rescale.cpp \
+ Source/FreeImageToolkit/Resize.cpp \
+@@ -98,6 +156,11 @@ SRCS = \
+ Wrapper/FreeImagePlus/src/fipTag.cpp \
+ Wrapper/FreeImagePlus/src/fipWinImage.cpp \
+ Wrapper/FreeImagePlus/src/FreeImagePlus.cpp
++
++SRCS-$(USE_JPEG) += \
++ Source/transupp.c
++
++SRCS = $(SRCS-yes)
+ INCLUDE = -I. \
+ -ISource \
+ -ISource/Metadata \
+--
+2.19.1
+
diff --git a/media-libs/freeimage/freeimage-3.18.0.ebuild b/media-libs/freeimage/freeimage-3.18.0.ebuild
new file mode 100644
index 000000000000..bde23753bf04
--- /dev/null
+++ b/media-libs/freeimage/freeimage-3.18.0.ebuild
@@ -0,0 +1,116 @@
+# Copyright 1999-2018 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit eutils toolchain-funcs
+
+MY_PN=FreeImage
+MY_PV=${PV//.}
+MY_P=${MY_PN}${MY_PV}
+
+DESCRIPTION="Image library supporting many formats"
+HOMEPAGE="http://freeimage.sourceforge.net/"
+SRC_URI="mirror://sourceforge/${PN}/${MY_P}.zip
+ mirror://sourceforge/${PN}/${MY_P}.pdf"
+
+LICENSE="|| ( GPL-2 FIPL-1.0 )"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~x86 ~amd64-linux ~x86-linux"
+IUSE="jpeg jpeg2k mng openexr png raw static-libs tiff webp"
+
+# The tiff/ilmbase isn't a typo. The TIFF plugin cheats and
+# uses code from it to handle 16bit<->float conversions.
+RDEPEND="
+ sys-libs/zlib
+ jpeg? ( virtual/jpeg:0 )
+ jpeg2k? ( media-libs/openjpeg:2= )
+ mng? ( media-libs/libmng:= )
+ openexr? ( media-libs/openexr:= )
+ png? ( media-libs/libpng:0= )
+ raw? ( media-libs/libraw:= )
+ tiff? (
+ media-libs/ilmbase:=
+ media-libs/tiff:0
+ )
+ webp? ( media-libs/libwebp:= )"
+DEPEND="${RDEPEND}
+ virtual/pkgconfig
+ app-arch/unzip"
+
+S=${WORKDIR}/${MY_PN}
+
+DOCS=( "${DISTDIR}"/${MY_P}.pdf README.linux Whatsnew.txt )
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.18.0-unbundling.patch
+ "${FILESDIR}"/${PN}-3.18.0-remove-jpeg-transform.patch
+ "${FILESDIR}"/${PN}-3.18.0-rename-jpeg_read_icc_profile.patch
+ "${FILESDIR}"/${PN}-3.18.0-disable-plugin-G3.patch
+ "${FILESDIR}"/${PN}-3.18.0-raw.patch
+)
+
+src_prepare() {
+ pushd Source >/dev/null || die
+ cp LibJPEG/{transupp.c,transupp.h,jinclude.h} . || die
+ cp LibTIFF4/{tiffiop,tif_dir}.h . || die
+ rm -rf LibPNG LibMNG LibOpenJPEG ZLib OpenEXR LibRawLite LibTIFF4 LibJPEG LibWebP LibJXR || die
+ popd >/dev/null || die
+
+ edos2unix Makefile.{gnu,fip,srcs} fipMakefile.srcs */*.h */*/*.cpp
+ sed -i \
+ -e "s:/./:/:g" \
+ -e "s: ./: :g" \
+ -e 's: Source: \\\n\tSource:g' \
+ -e 's: Wrapper: \\\n\tWrapper:g' \
+ -e 's: Examples: \\\n\tExamples:g' \
+ -e 's: TestAPI: \\\n\tTestAPI:g' \
+ -e 's: -ISource: \\\n\t-ISource:g' \
+ -e 's: -IWrapper: \\\n\t-IWrapper:g' \
+ -e 's:INCLS:\nINCLS:g' \
+ Makefile.srcs fipMakefile.srcs || die
+ sed -i \
+ -e "/LibJPEG/d" \
+ -e "/LibJXR/d" \
+ -e "/LibPNG/d" \
+ -e "/LibTIFF/d" \
+ -e "/Source\/ZLib/d" \
+ -e "/LibOpenJPEG/d" \
+ -e "/OpenEXR/d" \
+ -e "/LibRawLite/d" \
+ -e "/LibMNG/d" \
+ -e "/LibWebP/d" \
+ -e "/LibJXR/d" \
+ Makefile.srcs fipMakefile.srcs || die
+
+ default
+}
+
+foreach_make() {
+ local m
+ for m in Makefile.{gnu,fip} ; do
+ emake -f ${m} \
+ USE_EXR=$(usex openexr) \
+ USE_JPEG=$(usex jpeg) \
+ USE_JPEG2K=$(usex jpeg2k) \
+ USE_MNG=$(usex mng) \
+ USE_PNG=$(usex png) \
+ USE_TIFF=$(usex tiff) \
+ USE_RAW=$(usex raw) \
+ USE_WEBP=$(usex webp) \
+ $(usex static-libs '' STATICLIB=) \
+ "$@"
+ done
+}
+
+src_compile() {
+ tc-export AR PKG_CONFIG
+ foreach_make \
+ CXX="$(tc-getCXX) -fPIC" \
+ CC="$(tc-getCC) -fPIC" \
+ ${MY_PN}
+}
+
+src_install() {
+ foreach_make install DESTDIR="${ED}" INSTALLDIR="${ED%/}"/usr/$(get_libdir)
+ einstalldocs
+}