Package: zlib
Version: 1:1.2.3.3.dfsg-5
Severity: normal
Tags: patch

zlib used to cross-build successfully but only because of a bug in the
cross-build scripts that consistently forced the override of
$ENV{'MAKEFLAGS'}. Fixing this bug to allow other packages to build
internal build tools correctly (e.g. libx11-6) has resulted in a failure
to build certain packages that relied on the former behaviour. zlib is
one of those packages.

The top level 'make' command tries to use gcc instead of
$(DEB_HOST_GNU_TYPE)-gcc and the LDSHARED value also sets 'gcc' instead
of $(DEB_HOST_GNU_TYPE)-gcc. Similarly, the install targets try to use
gcc. Finally, 'make test' or 'make check' cannot operate in a
cross-building environment. The current build does ignore that error but
I've wrapped the call to 'make test' in the attached patch for clarity.

The patch has no effect if $(DEB_HOST_GNU_TYPE) matches the value of
$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) so I hope you will be
able to apply it and help Emdebian cross-build zlib more easily.

Thanks.

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.22-2-amd64 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
--- zlib.old/debian/rules	2007-09-30 15:09:14.000000000 +0100
+++ zlib-1.2.3.3.dfsg/debian/rules	2007-09-30 15:42:52.000000000 +0100
@@ -15,6 +15,15 @@
 # from having to guess our platform (since we know it already)
 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
 DEB_HOST_ARCH       ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_BUILD_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
+	CROSSFLAGS += CC=$(DEB_HOST_GNU_TYPE)-gcc
+	CROSSLDSHARED += LDSHARED="$(DEB_HOST_GNU_TYPE)-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"
+else
+	CROSSFLAGS +=
+	CROSSLDSHARED +=
+endif
 
 CFLAGS = -Wall -g -D_REENTRANT
 
@@ -73,10 +82,11 @@
 build-stamp: configure-stamp
 	dh_testdir
 
-	$(MAKE)
+	$(MAKE) $(CROSSFLAGS) $(CROSSLDSHARED)
 	$(MAKE) CC=$(DEB_HOST_GNU_TYPE)-gcc OPT="$(CFLAGS)" -C contrib/minizip
+ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 	-$(MAKE) test
-
+endif
 	touch $@
 
 build64-stamp: configure64-stamp
@@ -110,13 +120,13 @@
 	dh_clean -k 
 	dh_installdirs
 
-	$(MAKE) prefix=$(CURDIR)/debian/tmp/usr install
+	$(MAKE) $(CROSSFLAGS) prefix=$(CURDIR)/debian/tmp/usr install
 
 install64: install build64-stamp
-	$(MAKE) -C debian/64 prefix=$(CURDIR)/debian/tmp install
+	$(MAKE) $(CROSSFLAGS) -C debian/64 prefix=$(CURDIR)/debian/tmp install
 
 install32: install build32-stamp
-	$(MAKE) -C debian/32 prefix=$(CURDIR)/debian/tmp install
+	$(MAKE) $(CROSSFLAGS) -C debian/32 prefix=$(CURDIR)/debian/tmp install
 
 # Build architecture-independent files here.
 binary-indep: build install

Reply via email to