Package: db4.8
Version: 4.8.30-3
Severity: minor
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu natty ubuntu-patch

Hi Clint,

As part of an effort to make the Ubuntu base system cross-compilable, we've
found that the db4.8 debian/rules uses DEB_BUILD_* variables in several
places where DEB_HOST_* is meant, and also that it invokes binutils binaries
directly without accounting for possible cross-building.  Furthermore, the
--with-tcl argument doesn't play nicely with a cross-installed package; when
cross-building it's probably better to assume /usr/$(DEB_HOST_ARCH)/lib as a
path.

Attached is a patch that's been applied in Ubuntu to fix these three issues. 
The corresponding changelog entry is:

  * Enable both native & cross building by using DEB_HOST variables,
    rather than DEB_BUILD ones.
  * Pass correct values to configure for cross building
  * Use correct binutils for cross building

You may want to apply this fix in Debian as well.

BTW, while fixing this I noticed a certain inconsistency between the
arch-specific Java build-dependencies and debian/rules.  The package
build-depends on default-jdk-builddep on armel, but then checks if
$(DEB_HOST_GNU_CPU) matches arm - which it does because the GNU CPU variable
is the same for the old arm port and the new armel port.  I'm not sure if
this is a spurious build-dependency or an accidentally omitted java package
on armel so I'm not proposing a patch for this, but you might want to
reconcile this one way or the other.

Thanks,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
=== modified file 'debian/rules'
--- debian/rules	2010-04-04 09:07:08 +0000
+++ debian/rules	2011-02-01 00:56:47 +0000
@@ -20,6 +20,7 @@
 DEB_BUILD_GNU_CPU ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU)
 DEB_BUILD_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_SYSTEM)
 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
 DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
 DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
@@ -28,7 +29,14 @@
 JAVA_UNSUPPORTED_SYSTEMS = zgnuz zknetbsd-gnuz
 -include /usr/share/gcj/debian_defaults
 
-CONFIGURE_VARS = CC=gcc CFLAGS="$(CFLAGS)" CPPFLAGS="-I/usr/include/tcl8.5" 
+ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
+        CONFIGURE_VARS = CC=gcc CFLAGS="$(CFLAGS)" CPPFLAGS="-I/usr/include/tcl8.5" 
+	TCLDIR=/usr/lib/tcl8.5
+else
+        CONFIGURE_VARS = CC=$(DEB_HOST_GNU_TYPE)-gcc CXX=$(DEB_HOST_GNU_TYPE)-g++ CFLAGS="$(CFLAGS)" CPPFLAGS="-I/usr/$(DEB_HOST_GNU_TYPE)/include/tcl8.5"
+	TCLDIR=/usr/$(DEB_HOST_GNU_TYPE)/lib/tcl8.5
+endif
+
 CONFIGURE_SWITCHES =    --prefix=/usr \
 			--mandir=\$${prefix}/share/man \
 			--localstatedir=/var \
@@ -37,7 +45,7 @@
 			--enable-cxx \
 			--enable-compat185 \
 			--enable-tcl \
-			--with-tcl=/usr/lib/tcl8.5 \
+			--with-tcl=$(TCLDIR) \
 			--enable-test
 
 DB_BINARY_PKGS = libdb4.8 libdb4.8-dev libdb4.8++ libdb4.8++-dev libdb4.8-tcl db4.8-util libdb4.8-dbg
@@ -46,8 +54,17 @@
 CONFIGURE_SWITCHES += --with-mutex=POSIX/pthreads/library
 endif
 
-ifeq (,$(findstring z$(DEB_BUILD_GNU_CPU)z,$(JAVA_UNSUPPORTED_CPUS)))
-ifeq (,$(findstring z$(DEB_BUILD_GNU_SYSTEM)z,$(JAVA_UNSUPPORTED_SYSTEMS)))
+ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
+        STRIP = strip
+        OBJCOPY = objcopy
+else
+        STRIP = $(DEB_HOST_GNU_TYPE)-strip
+        OBJCOPY = $(DEB_HOST_GNU_TYPE)-objcopy
+        CONFIGURE_SWITCHES += --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) 
+endif
+
+ifeq (,$(findstring z$(DEB_HOST_GNU_CPU)z,$(JAVA_UNSUPPORTED_CPUS)))
+ifeq (,$(findstring z$(DEB_HOST_GNU_SYSTEM)z,$(JAVA_UNSUPPORTED_SYSTEMS)))
 JAVA_HOME = /usr/lib/jvm/default-java
 JAVA_BIN = $(JAVA_HOME)/bin
 CFLAGS += -I$(JAVA_HOME)/include
@@ -156,16 +173,16 @@
 			debian/lib$(package)-java-dev/usr/lib \
 			debian/lib$(package)-dbg/usr/lib/debug/usr/lib
 
-	objcopy --only-keep-debug debian/tmp/usr/lib/libdb-$(bdbversion).so \
+	$(OBJCOPY) --only-keep-debug debian/tmp/usr/lib/libdb-$(bdbversion).so \
                                   debian/lib$(package)-dbg/usr/lib/debug/usr/lib/libdb-$(bdbversion).so.debug
 
 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
-	strip --remove-section=.note --remove-section=.comment \
+	$(STRIP) --remove-section=.note --remove-section=.comment \
 	      debian/tmp/usr/lib/*.so debian/tmp/usr/bin/*
-	strip --strip-debug debian/tmp/usr/lib/*.a
+	$(STRIP) --strip-debug debian/tmp/usr/lib/*.a
 endif
 
-	objcopy --add-gnu-debuglink=debian/lib$(package)-dbg/usr/lib/debug/usr/lib/libdb-$(bdbversion).so.debug \
+	$(OBJCOPY) --add-gnu-debuglink=debian/lib$(package)-dbg/usr/lib/debug/usr/lib/libdb-$(bdbversion).so.debug \
 				debian/tmp/usr/lib/libdb-$(bdbversion).so
 
 	chmod 644 debian/tmp/usr/lib/*.so debian/tmp/usr/include/*.h
@@ -175,13 +192,13 @@
 	cp -a debian/tmp/usr/bin debian/$(package)-util/usr
 	cp -a debian/tmp/usr/lib/*.so debian/tmp/usr/lib/*.a \
 	        debian/tmp/usr/lib/*.la debian/lib$(package)-dev/usr/lib
-ifeq (,$(findstring z$(DEB_BUILD_GNU_CPU)z,$(JAVA_UNSUPPORTED_CPUS)))
-ifeq (,$(findstring z$(DEB_BUILD_GNU_SYSTEM)z,$(JAVA_UNSUPPORTED_SYSTEMS)))
+ifeq (,$(findstring z$(DEB_HOST_GNU_CPU)z,$(JAVA_UNSUPPORTED_CPUS)))
+ifeq (,$(findstring z$(DEB_HOST_GNU_SYSTEM)z,$(JAVA_UNSUPPORTED_SYSTEMS)))
 	cp -a debian/tmp/usr/lib/db.jar \
 		debian/lib$(package)-java/usr/share/java/lib$(package)-java-$(version).jar
 	ln -s lib$(package)-java-$(version).jar \
 		debian/lib$(package)-java/usr/share/java/lib$(package)-java.jar
-ifneq (,$(filter $(DEB_BUILD_ARCH), $(gcj_native_archs)))
+ifneq (,$(filter $(DEB_HOST_ARCH), $(gcj_native_archs)))
 	mkdir debian/lib$(package)-java-gcj
 	(TMPFILE=$$(mktemp --tmpdir sourcelist.XXXXXXXXXX) && \
 	find $(CURDIR) -type f ! -type l >$$TMPFILE && \
@@ -196,8 +213,8 @@
 	mv debian/lib$(package)-dev/usr/lib/*cxx* debian/lib$(package)++-dev/usr/lib
 	mv debian/lib$(package)-dev/usr/include/*cxx* debian/lib$(package)++-dev/usr/include
 	mv debian/lib$(package)-dev/usr/lib/*tcl* debian/lib$(package)-tcl/usr/lib
-ifeq (,$(findstring z$(DEB_BUILD_GNU_CPU)z,$(JAVA_UNSUPPORTED_CPUS)))
-ifeq (,$(findstring z$(DEB_BUILD_GNU_SYSTEM)z,$(JAVA_UNSUPPORTED_SYSTEMS)))
+ifeq (,$(findstring z$(DEB_HOST_GNU_CPU)z,$(JAVA_UNSUPPORTED_CPUS)))
+ifeq (,$(findstring z$(DEB_HOST_GNU_SYSTEM)z,$(JAVA_UNSUPPORTED_SYSTEMS)))
 	mv debian/lib$(package)-dev/usr/lib/*java* debian/lib$(package)-java/usr/lib
 
 	mv debian/lib$(package)-java/usr/lib/libdb*.a \
@@ -230,12 +247,12 @@
 	echo 'libdb $(bdbversion) lib$(package)' >debian/lib$(package)/DEBIAN/shlibs
 	echo 'libdb_cxx $(bdbversion) lib$(package)++' >debian/lib$(package)++/DEBIAN/shlibs
 	echo 'libdb_tcl $(bdbversion) lib$(package)-tcl' >debian/lib$(package)-tcl/DEBIAN/shlibs
-ifeq (,$(findstring z$(DEB_BUILD_GNU_CPU)z,$(JAVA_UNSUPPORTED_CPUS)))
-ifeq (,$(findstring z$(DEB_BUILD_GNU_SYSTEM)z,$(JAVA_UNSUPPORTED_SYSTEMS)))
+ifeq (,$(findstring z$(DEB_HOST_GNU_CPU)z,$(JAVA_UNSUPPORTED_CPUS)))
+ifeq (,$(findstring z$(DEB_HOST_GNU_SYSTEM)z,$(JAVA_UNSUPPORTED_SYSTEMS)))
 	echo 'libdb_java $(bdbversion) lib$(package)-java' >debian/lib$(package)-java/DEBIAN/shlibs
 	$(INSTALL_SCRIPT) debian/libjava.postinst debian/lib$(package)-java/DEBIAN/postinst
 
-ifneq (,$(filter $(DEB_BUILD_ARCH), $(gcj_native_archs)))
+ifneq (,$(filter $(DEB_HOST_ARCH), $(gcj_native_archs)))
 	$(INSTALL_SCRIPT) debian/java-gcj.postrm debian/lib$(package)-java-gcj/DEBIAN/postrm
 	$(INSTALL_SCRIPT) debian/java-gcj.postinst debian/lib$(package)-java-gcj/DEBIAN/postinst
 endif

Reply via email to