First, thanks for taking this on!

On Mon, Sep  6, 2010 at 23:16:43 +0200, Cosme Domínguez Díaz wrote:

> "Workaround for use system libs
> -------------------------------
> 
>   Consists in generate symbolic links from /usr/include/* to some dirs
> of Source/*
> 
>    At the moment this seems works with LibOpenJPEG, OpenEXR, LibMNG
> and LibRawLite but with:
>   -> ZLib: missing file in debian package (zutil.h).
>   -> LibJPEG: missing file in debian package (jinclude.h).
>   -> LibTIFF: missing file in debian package (tiffiop.h).

They're not missing, they're internal and not supposed to be used
outside of said libraries.  I managed to get rid of most of this, except
for tiff, where freeimage is using and abusing lots of internals and I
would have to poke at it a while longer, which I'm not going to do in
the foreseeable future.

Preliminary patches attached, I haven't tested at all (other than
whether it builds).  There's some more changes to Makefile.srcs and
fipMakefile.srcs to remove most of Source/Lib*, but keep libjpeg's
transupp.{c,h} which are still needed, and add OpenEXR's include path.

>   -> LibPNG: debian package is too outdated. (1.2.44 vs 1.4.3 that
> uses FreeImage)
> 
Seems possible to sort that out, see attached patch.

>  The aim is to use all necessary system libraries."
> 
> also debian/changelog
> 
> freeimage (3.14.1-1) unstable; urgency=low
> 
>   * New upstream release. Closes: #595559, #595560 and #492762
>    - Add libfreeimage3.symbols that fix #558857
>    - Switch to dpkg-source 3.0 (quilt) format.
>    - Don't ship obsolete Chinese doc (3.14.1 >> 3.8.0)
>    - Add debian/misc/{*.srcs,SystemLibs} as a initial
>      workaround for use system libraries. Please, see
>      debian/README.debian for further information.
>   * debian/rules
>    - Switch to tiny dh_ system.
>   * debian/control
>    - Add myself as uploader.
>    - Bump debhelper to (>= 7.0.50~).
>    - Bump Standards-Version to 3.9.1.
>    - Remove unneeded tofrodos dependency.
>    - Add pkg-config, libmng-dev, libopenjpeg-dev,
>      libraw-dev and libopenexr-dev packages to Build-Depends.
>   * debian/get-orig-source
>    - Updated for 3.14.1 release.
>    - Remove LibMNG, LibOpenJPEG, LibRawLite
>      and OpenEXR and embedded code copies.
>    - Make an tar.bz2 tarball (instead of tar.gz)
>      and force to be of root.
>   * debian/copyright
>    - Updated to DEP-5.
>    - Update FreeImage license link.
>   * debian/patches
>    - Add fix_FTBFS_in_Makefile
>   * lintian
>    - binary-control-field-duplicates-source
> 
>  -- Cosme Domínguez Díaz <[email protected]>  Mon, 06 Sep 2010
> 20:32:46 +0000
> 
That's a whole lot of changes here and as such isn't really appropriate
during a freeze.  We'd need minimal changes to at least reduce the
amount of code duplication for now.  Your package would probably make
sense in experimental though, until squeeze is released.

Cheers, and thanks for your work,
Julien
From f107c66a4397802b92f6ea4b91e2d1b2c5d439d1 Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:50:00 +0200
Subject: [PATCH 1/9] J2KHelper: use external openjpeg header

---
 Source/FreeImage/J2KHelper.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Source/FreeImage/J2KHelper.cpp b/Source/FreeImage/J2KHelper.cpp
index 537b601..6827cc3 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>
 
 /**
 Divide an integer by a power of 2 and round upwards
-- 
1.7.1

From 3a5c587ce4ab21f43ad7da608aec619738c6d7af Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:50:35 +0200
Subject: [PATCH 2/9] PluginEXR: use external headers

---
 Source/FreeImage/PluginEXR.cpp |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Source/FreeImage/PluginEXR.cpp b/Source/FreeImage/PluginEXR.cpp
index 5ea40e9..f4fab7c 100644
--- a/Source/FreeImage/PluginEXR.cpp
+++ b/Source/FreeImage/PluginEXR.cpp
@@ -21,15 +21,15 @@
 
 #include "FreeImage.h"
 #include "Utilities.h"
-#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/Half/half.h"
+#include <OpenEXR/ImfIO.h>
+#include <OpenEXR/Iex.h>
+#include <OpenEXR/ImfOutputFile.h>
+#include <OpenEXR/ImfInputFile.h>
+#include <OpenEXR/ImfRgbaFile.h>
+#include <OpenEXR/ImfChannelList.h>
+#include <OpenEXR/ImfRgba.h>
+#include <OpenEXR/ImfArray.h>
+#include <OpenEXR/half.h>
 
 
 // ==========================================================
-- 
1.7.1

From cc35dcce22d1f5e6ddb3f64c23d74e16f03283b1 Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:50:53 +0200
Subject: [PATCH 3/9] PluginJ2K: use external headers

---
 Source/FreeImage/PluginJ2K.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Source/FreeImage/PluginJ2K.cpp b/Source/FreeImage/PluginJ2K.cpp
index 44ec794..bb3b6ac 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>
 
 // ==========================================================
 // Plugin Interface
-- 
1.7.1

From 96219e809e5aff882961ffa30042792f23780362 Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:51:08 +0200
Subject: [PATCH 4/9] PluginJP2: use external headers

---
 Source/FreeImage/PluginJP2.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Source/FreeImage/PluginJP2.cpp b/Source/FreeImage/PluginJP2.cpp
index f34ebe8..d32b73e 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>
 
 // ==========================================================
 // Plugin Interface
-- 
1.7.1

From 33627c114bb484b3fef2cc5780d5c7b3d444a96d Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:51:21 +0200
Subject: [PATCH 5/9] PluginJPEG: use external headers

---
 Source/FreeImage/PluginJPEG.cpp |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Source/FreeImage/PluginJPEG.cpp b/Source/FreeImage/PluginJPEG.cpp
index 6a27d1c..121fb3d 100644
--- a/Source/FreeImage/PluginJPEG.cpp
+++ b/Source/FreeImage/PluginJPEG.cpp
@@ -34,9 +34,10 @@ extern "C" {
 #undef FAR
 #include <setjmp.h>
 
-#include "../LibJPEG/jinclude.h"
-#include "../LibJPEG/jpeglib.h"
-#include "../LibJPEG/jerror.h"
+#include <sys/types.h>
+#include <stdio.h>
+#include <jpeglib.h>
+#include <jerror.h>
 }
 
 #include "FreeImage.h"
@@ -158,7 +159,7 @@ init_destination (j_compress_ptr cinfo) {
 
 	dest->buffer = (JOCTET *)
 	  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
-				  OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
+				  OUTPUT_BUF_SIZE * sizeof(JOCTET));
 
 	dest->pub.next_output_byte = dest->buffer;
 	dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
@@ -333,12 +334,12 @@ jpeg_freeimage_src (j_decompress_ptr cinfo, fi_handle infile, FreeImageIO *io) {
 
 	if (cinfo->src == NULL) {
 		cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
-			((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(SourceManager));
+			((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(SourceManager));
 
 		src = (freeimage_src_ptr) cinfo->src;
 
 		src->buffer = (JOCTET *) (*cinfo->mem->alloc_small)
-			((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * SIZEOF(JOCTET));
+			((j_common_ptr) cinfo, JPOOL_PERMANENT, INPUT_BUF_SIZE * sizeof(JOCTET));
 	}
 
 	// initialize the jpeg pointer struct with pointers to functions
@@ -366,7 +367,7 @@ jpeg_freeimage_dst (j_compress_ptr cinfo, fi_handle outfile, FreeImageIO *io) {
 
 	if (cinfo->dest == NULL) {
 		cinfo->dest = (struct jpeg_destination_mgr *)(*cinfo->mem->alloc_small)
-			((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(DestinationManager));
+			((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(DestinationManager));
 	}
 
 	dest = (freeimage_dst_ptr) cinfo->dest;
-- 
1.7.1

From ef0c1dab0cce6c61eda2f86a7e2bb1b364fa59d1 Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:51:35 +0200
Subject: [PATCH 6/9] PluginMNG: use external headers

---
 Source/FreeImage/PluginMNG.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Source/FreeImage/PluginMNG.cpp b/Source/FreeImage/PluginMNG.cpp
index 3fa770e..ae50f0f 100644
--- a/Source/FreeImage/PluginMNG.cpp
+++ b/Source/FreeImage/PluginMNG.cpp
@@ -22,7 +22,7 @@
 #include "FreeImage.h"
 #include "Utilities.h"
 
-#include "../LibMNG/libmng.h"
+#include <libmng.h>
 
 // ----------------------------------------------------------
 //   Constants + headers
-- 
1.7.1

From c20e2a091324ccf18a6b83118928674ea23594ed Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:51:47 +0200
Subject: [PATCH 7/9] PluginPNG: use external headers

Only use iTXt if supported by libpng
---
 Source/FreeImage/PluginPNG.cpp |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/Source/FreeImage/PluginPNG.cpp b/Source/FreeImage/PluginPNG.cpp
index 989c6e6..129d4a0 100644
--- a/Source/FreeImage/PluginPNG.cpp
+++ b/Source/FreeImage/PluginPNG.cpp
@@ -37,7 +37,7 @@
 
 // ----------------------------------------------------------
 
-#include "../LibPNG/png.h"
+#include <png.h>
 
 // ----------------------------------------------------------
 
@@ -101,7 +101,10 @@ ReadMetadata(png_structp png_ptr, png_infop info_ptr, FIBITMAP *dib) {
 			tag = FreeImage_CreateTag();
 			if(!tag) return FALSE;
 
-			DWORD tag_length = MAX(text_ptr[i].text_length, text_ptr[i].itxt_length);
+			DWORD tag_length = text_ptr[i].text_length;
+#ifdef PNG_iTXt_SUPPORTED
+			tag_length = MAX(tag_length, text_ptr[i].itxt_length);
+#endif
 
 			FreeImage_SetTagLength(tag, tag_length);
 			FreeImage_SetTagCount(tag, tag_length);
@@ -144,13 +147,19 @@ WriteMetadata(png_structp png_ptr, png_infop info_ptr, FIBITMAP *dib) {
 	if(mdhandle) {
 		do {
 			memset(&text_metadata, 0, sizeof(png_text));
+#ifdef PNG_iTXt_SUPPORTED
 			text_metadata.compression = 1;							// iTXt, none
+#else
+			text_metadata.compression = -1;
+#endif
 			text_metadata.key = (char*)FreeImage_GetTagKey(tag);	// keyword, 1-79 character description of "text"
 			text_metadata.text = (char*)FreeImage_GetTagValue(tag);	// comment, may be an empty string (ie "")
 			text_metadata.text_length = FreeImage_GetTagLength(tag);// length of the text string
+#ifdef PNG_iTXt_SUPPORTED
 			text_metadata.itxt_length = FreeImage_GetTagLength(tag);// length of the itxt string
 			text_metadata.lang = 0;		 // language code, 0-79 characters or a NULL pointer
 			text_metadata.lang_key = 0;	 // keyword translated UTF-8 string, 0 or more chars or a NULL pointer
+#endif
 
 			// set the tag 
 			png_set_text(png_ptr, info_ptr, &text_metadata, 1);
@@ -166,13 +175,19 @@ WriteMetadata(png_structp png_ptr, png_infop info_ptr, FIBITMAP *dib) {
 	FreeImage_GetMetadata(FIMD_XMP, dib, g_TagLib_XMPFieldName, &tag);
 	if(tag && FreeImage_GetTagLength(tag)) {
 		memset(&text_metadata, 0, sizeof(png_text));
+#ifdef PNG_iTXt_SUPPORTED
 		text_metadata.compression = 1;							// iTXt, none
+#else
+		text_metadata.compression = -1;
+#endif
 		text_metadata.key = g_png_xmp_keyword;					// keyword, 1-79 character description of "text"
 		text_metadata.text = (char*)FreeImage_GetTagValue(tag);	// comment, may be an empty string (ie "")
 		text_metadata.text_length = FreeImage_GetTagLength(tag);// length of the text string
+#ifdef PNG_iTXt_SUPPORTED
 		text_metadata.itxt_length = FreeImage_GetTagLength(tag);// length of the itxt string
 		text_metadata.lang = 0;		 // language code, 0-79 characters or a NULL pointer
 		text_metadata.lang_key = 0;	 // keyword translated UTF-8 string, 0 or more chars or a NULL pointer
+#endif
 
 		// set the tag 
 		png_set_text(png_ptr, info_ptr, &text_metadata, 1);
-- 
1.7.1

From 435d48c128c40536093efd010bf79cf7c732def5 Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:52:15 +0200
Subject: [PATCH 8/9] Zlib: use external headers

Don't use internal OS_CODE macro
---
 Source/FreeImage/ZLibInterface.cpp |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Source/FreeImage/ZLibInterface.cpp b/Source/FreeImage/ZLibInterface.cpp
index 47fa161..7b7d5fa 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) */
+//#include "../ZLib/zutil.h"	/* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */
 
 /**
 Compresses a source buffer into a target buffer, using the ZLib library. 
@@ -115,7 +115,7 @@ FreeImage_ZLibGZip(BYTE *target, DWORD target_size, BYTE *source, DWORD source_s
 			return 0;
         case Z_OK: {
             // patch header, setup crc and length (stolen from mod_trace_output)
-            BYTE *p = target + 8; *p++ = 2; *p = OS_CODE; // xflags, os_code
+            BYTE *p = target + 8; *p++ = 2; *p = 0x03; // xflags, os_code
  	        crc = crc32(crc, source, source_size);
 	        memcpy(target + 4 + dest_len, &crc, 4);
 	        memcpy(target + 8 + dest_len, &source_size, 4);
-- 
1.7.1

From f900247cc10aeda7fcb34b1cc60c65eb44c0c4e9 Mon Sep 17 00:00:00 2001
From: Julien Cristau <[email protected]>
Date: Fri, 8 Oct 2010 13:52:27 +0200
Subject: [PATCH 9/9] JPEGTransform: use external headers

---
 Source/FreeImageToolkit/JPEGTransform.cpp |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Source/FreeImageToolkit/JPEGTransform.cpp b/Source/FreeImageToolkit/JPEGTransform.cpp
index 989b9fd..2110e93 100644
--- a/Source/FreeImageToolkit/JPEGTransform.cpp
+++ b/Source/FreeImageToolkit/JPEGTransform.cpp
@@ -25,9 +25,10 @@ extern "C" {
 #undef FAR
 #include <setjmp.h>
 
-#include "../LibJPEG/jinclude.h"
-#include "../LibJPEG/jpeglib.h"
-#include "../LibJPEG/jerror.h"
+#include <sys/types.h>
+#include <stdio.h>
+#include <jpeglib.h>
+#include <jerror.h>
 #include "../LibJPEG/transupp.h"
 }
 
-- 
1.7.1

diff --git a/debian/patches/makefile_modifications.patch b/debian/patches/makefile_modifications.patch
index 098513b..de6c158 100644
--- a/debian/patches/makefile_modifications.patch
+++ b/debian/patches/makefile_modifications.patch
@@ -2,9 +2,11 @@ Some modificatoins to the makefiles to help in build Debian packages.
 Also removed -s (strip) option so we can make debug package. With the compiler
 options we're using by default, debugging should still be possible.
 ==========================================================================
---- freeimage/Makefile.fip.bak	2008-05-08 14:41:23.000000000 -0400
-+++ freeimage/Makefile.fip	2008-05-08 14:40:30.000000000 -0400
-@@ -4,17 +4,19 @@
+Index: freeimage/Makefile.fip
+===================================================================
+--- freeimage.orig/Makefile.fip
++++ freeimage/Makefile.fip
+@@ -4,18 +4,20 @@
  include fipMakefile.srcs
  
  # General configuration variables:
@@ -25,16 +27,18 @@ options we're using by default, debugging should still be possible.
  DOS2UNIX = dos2unix
  
 -COMPILERFLAGS = -O3 -fexceptions -fvisibility=hidden
+-LIBRARIES = -lstdc++
 +COMPILERFLAGS ?= -O3 -fexceptions -fvisibility=hidden
- LIBRARIES = -lstdc++
++LIBRARIES = -lmng -ltiff -lz -lpng -lm -ljpeg -lopenjpeg $(shell pkg-config --libs OpenEXR)
  
  MODULES = $(SRCS:.c=.o)
+ MODULES := $(MODULES:.cpp=.o)
 @@ -56,7 +58,7 @@
  	$(AR) r $@ $(MODULES)
  
  $(SHAREDLIB): $(MODULES)
 -	$(CC) -s -shared -Wl,-soname,$(VERLIBNAME) -o $@ $(MODULES) $(LIBRARIES)
-+	$(CC) -shared -Wl,-soname,$(VERLIBNAME) -o $@ $(MODULES) $(LIBRARIES)
++	$(CXX) -shared -Wl,-soname,$(VERLIBNAME) -Wl,-z,defs -o $@ $(MODULES) $(CXXFLAGS) $(LIBRARIES)
  
  install:
  	install -m 644 -o root -g root $(HEADER) $(INCDIR)
@@ -46,9 +50,11 @@ options we're using by default, debugging should still be possible.
  
  clean:
  	rm -f core Dist/*.* u2dtmp* $(MODULES) $(STATICLIB) $(SHAREDLIB) $(LIBNAME)
---- freeimage/Makefile.gnu.bak	2008-05-08 14:41:22.000000000 -0400
-+++ freeimage/Makefile.gnu	2008-05-08 14:40:23.000000000 -0400
-@@ -4,17 +4,19 @@
+Index: freeimage/Makefile.gnu
+===================================================================
+--- freeimage.orig/Makefile.gnu
++++ freeimage/Makefile.gnu
+@@ -4,18 +4,20 @@
  include Makefile.srcs
  
  # General configuration variables:
@@ -69,16 +75,18 @@ options we're using by default, debugging should still be possible.
  DOS2UNIX = dos2unix
  
 -COMPILERFLAGS = -O3 -fPIC -fexceptions -fvisibility=hidden
+-LIBRARIES = -lstdc++
 +COMPILERFLAGS ?= -O3 -fPIC -fexceptions -fvisibility=hidden
- LIBRARIES = -lstdc++
++LIBRARIES = -ljpeg -lmng -lopenjpeg -lpng -ltiff $(shell pkg-config --libs OpenEXR) -lz -lm
  
  MODULES = $(SRCS:.c=.o)
+ MODULES := $(MODULES:.cpp=.o)
 @@ -55,7 +57,7 @@
  	$(AR) r $@ $(MODULES)
  
  $(SHAREDLIB): $(MODULES)
 -	$(CC) -s -shared -Wl,-soname,$(VERLIBNAME) -o $@ $(MODULES) $(LIBRARIES)
-+	$(CC) -shared -Wl,-soname,$(VERLIBNAME) -o $@ $(MODULES) $(LIBRARIES)
++	$(CXX) -shared -Wl,-soname,$(VERLIBNAME) -Wl,-z,defs -o $@ $(MODULES) $(CXXFLAGS) $(LIBRARIES)
  
  install:
  	install -m 644 -o root -g root $(HEADER) $(INCDIR)

Attachment: signature.asc
Description: Digital signature

Reply via email to