Bug#845279: freeimage FTCBFS: uses build architecture compiler and pkg-config

Helmut Grohne helmut at subdivi.de
Tue Nov 22 05:34:21 UTC 2016


Source: freeimage
Version: 3.17.0+ds1-3
Tags: patch
User: helmutg at debian.org
Usertags: rebootstrap

freeimage fails to cross build from source, because it generally uses
the build architecture toolchain. Supplying a triplet-prefixed CC and
CXX solves most of it, but the upstream Makefile calls directly into an
unprefixed pkg-config. The attached patch addresses both issues and
makes freeimage cross build successfully. Please consider applying it.

Helmut
-------------- next part --------------
--- freeimage-3.17.0+ds1/debian/changelog
+++ freeimage-3.17.0+ds1/debian/changelog
@@ -1,3 +1,10 @@
+freeimage (3.17.0+ds1-3.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: Use triplet-prefixed build tools (Closes: #-1)
+
+ -- Helmut Grohne <helmut at subdivi.de>  Thu, 22 Nov 2016 06:12:06 +0100
+
 freeimage (3.17.0+ds1-3) unstable; urgency=critical
 
   [ Ghislain Antony Vaillant ]
--- freeimage-3.17.0+ds1/debian/patches/cross.patch
+++ freeimage-3.17.0+ds1/debian/patches/cross.patch
@@ -0,0 +1,31 @@
+From: Helmut Grohne <helmut at subdivi.de>
+Subject: make pkg-config substitutable with triplet-prefixed tools
+
+--- freeimage-3.17.0+ds1.orig/Makefile.gnu
++++ freeimage-3.17.0+ds1/Makefile.gnu
+@@ -10,8 +10,9 @@
+ 
+ # Converts cr/lf to just lf
+ DOS2UNIX = dos2unix
++PKG_CONFIG ?= pkg-config
+ 
+-LIBRARIES = -lstdc++ -ljxrglue $(shell pkg-config --libs libjpeg libopenjp2 libpng libraw libtiff-4 libwebpmux OpenEXR zlib) -lm
++LIBRARIES = -lstdc++ -ljxrglue $(shell $(PKG_CONFIG) --libs libjpeg libopenjp2 libpng libraw libtiff-4 libwebpmux OpenEXR zlib) -lm
+ 
+ MODULES = $(SRCS:.c=.o)
+ MODULES := $(MODULES:.cpp=.o)
+@@ -23,12 +24,12 @@
+ override CFLAGS += -DNO_LCMS
+ # LibJXR
+ override CFLAGS += -DDISABLE_PERF_MEASUREMENT -D__ANSI__
+-override CFLAGS += $(INCLUDE) -I/usr/include/jxrlib $(shell pkg-config --cflags libjpeg libopenjp2 libpng libraw libtiff-4 libwebpmux OpenEXR zlib)
++override CFLAGS += $(INCLUDE) -I/usr/include/jxrlib $(shell $(PKG_CONFIG) --cflags libjpeg libopenjp2 libpng libraw libtiff-4 libwebpmux OpenEXR zlib)
+ CXXFLAGS ?= -O3 -fPIC
+ override CXXFLAGS += -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy
+ # LibJXR
+ override CXXFLAGS += -D__ANSI__
+-override CXXFLAGS += $(INCLUDE) -I/usr/include/jxrlib $(shell pkg-config --cflags libjpeg libopenjp2 libpng libraw libtiff-4 libwebpmux OpenEXR zlib)
++override CXXFLAGS += $(INCLUDE) -I/usr/include/jxrlib $(shell $(PKG_CONFIG) --cflags libjpeg libopenjp2 libpng libraw libtiff-4 libwebpmux OpenEXR zlib)
+ 
+ TARGET  = freeimage
+ STATICLIB = lib$(TARGET).a
--- freeimage-3.17.0+ds1/debian/patches/series
+++ freeimage-3.17.0+ds1/debian/patches/series
@@ -12,3 +12,4 @@
 Fix-CVE-2015-0852.patch
 Fix-encoding-of-fi-header.patch
 Fix-CVE-2016-5684.patch
+cross.patch
--- freeimage-3.17.0+ds1/debian/rules
+++ freeimage-3.17.0+ds1/debian/rules
@@ -7,7 +7,14 @@
 export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
 
 # Environment information.
-DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+include /usr/share/dpkg/architecture.mk
+ifeq ($(origin CC),default)
+CC := $(DEB_HOST_GNU_TYPE)-gcc
+endif
+ifeq ($(origin CXX),default)
+CXX := $(DEB_HOST_GNU_TYPE)-g++
+endif
+export PKG_CONFIG ?= $(DEB_HOST_GNU_TYPE)-pkg-config
 
 # Installation paths.
 DESTDIR = $(CURDIR)/debian/tmp
@@ -27,8 +34,8 @@
 	dh_autoreconf $(MAKE) -- -f $(CURDIR)/debian/rules gen-src-list
 
 override_dh_auto_build-arch:
-	$(MAKE) CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)"
-	$(MAKE) -f Makefile.fip CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)"
+	$(MAKE) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)"
+	$(MAKE) -f Makefile.fip CC="$(CC)" CXX="$(CXX)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)"
 
 override_dh_auto_build-indep:
 	cd $(CURDIR)/Wrapper/FreeImagePlus/doc && doxygen FreeImagePlus.dox


More information about the debian-science-maintainers mailing list