Package: iproute
Version: 20120319-1
User: crossbu...@debian.org
Usertags: cross

iproute does not cross-build. It hardcodes 'gcc' rather than using the
correct cross-compiler. This simple patch fixes that.

Aside: It also specifies $HOSTCC in the top-level makefile and uses it
in netem/Makefile. So far as I can see this achieves nothing and it
should just use $CC everywhere, but I haven't corrected that in case
there is some mysterious upstream reason.

The 'don't override $CC' part of this patch (i.e the non
debian-specific part) should go upstream.

-- 
Wookey
diff -urN origs/iproute-20120319/debian/patches/cross-compile-fix.diff patched/iproute-20120319/debian/patches/cross-compile-fix.diff
--- origs/iproute-20120319/debian/patches/cross-compile-fix.diff	1970-01-01 00:00:00.000000000 +0000
+++ patched/iproute-20120319/debian/patches/cross-compile-fix.diff	2012-04-27 16:54:47.000000000 +0000
@@ -0,0 +1,76 @@
+Description: Set correct compiler binary so crossbuilding works
+ Use $CC instead of 'gcc' and if crossbuilding set $CC to <triplet>-gcc
+ .
+Author: Wookey <woo...@linaro.org> 
+
+---
+Last-Update: <2012-04-10>
+
+--- iproute-20120319.orig/configure
++++ iproute-20120319/configure
+@@ -2,6 +2,7 @@
+ # This is not an autconf generated configure
+ #
+ INCLUDE=${1:-"$PWD/include"}
++: ${CC=gcc}
+ 
+ # Make a temp directory in build tree.
+ TMPDIR=$(mktemp -d config.XXXXXX)
+@@ -17,7 +18,7 @@ int main(int argc, char **argv) {
+ 	return 0;
+ }
+ EOF
+-gcc -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1 
++${CC} -I$INCLUDE -o $TMPDIR/atmtest $TMPDIR/atmtest.c -latm >/dev/null 2>&1 
+ if [ $? -eq 0 ]
+ then
+     echo "TC_CONFIG_ATM:=y" >>Config
+@@ -51,7 +52,7 @@ int main(int argc, char **argv)
+ 
+ EOF
+ 
+-if gcc -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL $(pkg-config xtables --cflags --libs) -ldl >/dev/null 2>&1
++if ${CC} -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL $(pkg-config xtables --cflags --libs) -ldl >/dev/null 2>&1
+ then
+ 	echo "TC_CONFIG_XT:=y" >>Config
+ 	echo "using xtables"
+@@ -88,7 +89,7 @@ int main(int argc, char **argv) {
+ }
+ 
+ EOF
+-gcc -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
++${CC} -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
+ 
+ if [ $? -eq 0 ]
+ then
+@@ -128,7 +129,7 @@ int main(int argc, char **argv) {
+ }
+ 
+ EOF
+-gcc -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
++${CC} -I$INCLUDE $IPTC -o $TMPDIR/ipttest $TMPDIR/ipttest.c $IPTL -ldl >/dev/null 2>&1
+ 
+ if [ $? -eq 0 ]
+ then
+@@ -172,7 +173,7 @@ int main(int argc, char **argv)
+ 	return 0;
+ }
+ EOF
+-gcc -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
++${CC} -I$INCLUDE -o $TMPDIR/setnstest $TMPDIR/setnstest.c >/dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ 	echo "IP_CONFIG_SETNS:=y" >>Config
+--- iproute-20120319.orig/Makefile
++++ iproute-20120319/Makefile
+@@ -27,8 +27,8 @@ ADDLIB+=dnet_ntop.o dnet_pton.o
+ #options for ipx
+ ADDLIB+=ipx_ntop.o ipx_pton.o
+ 
+-CC = gcc
+-HOSTCC = gcc
++CC ?= gcc
++HOSTCC ?= gcc
+ CCOPTS = -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall
+ CFLAGS = $(CCOPTS) -I../include $(DEFINES)
+ YACCFLAGS = -d -t -v
diff -urN origs/iproute-20120319/debian/patches/series patched/iproute-20120319/debian/patches/series
--- origs/iproute-20120319/debian/patches/series	2012-03-20 15:52:12.000000000 +0000
+++ patched/iproute-20120319/debian/patches/series	2012-04-27 17:44:56.000000000 +0000
@@ -1,2 +1,3 @@
 moo.diff
 txtdocs.diff
+cross-compile-fix.diff
diff -urN origs/iproute-20120319/debian/rules patched/iproute-20120319/debian/rules
--- origs/iproute-20120319/debian/rules	2012-03-14 18:46:57.000000000 +0000
+++ patched/iproute-20120319/debian/rules	2012-04-27 13:39:06.000000000 +0000
@@ -1,8 +1,19 @@
 #!/usr/bin/make -f
 
+include /usr/share/dpkg/architecture.mk
+
+ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+  CROSS :=
+else
+  CROSS := CC=$(DEB_HOST_GNU_TYPE)-gcc
+endif
+
 %:
 	dh $@
 
+override_dh_auto_configure:
+	$(CROSS) dh_auto_configure
+
 override_dh_clean:
 	dh_clean
 	make distclean
@@ -17,4 +28,4 @@
 
 override_dh_auto_build:
 	$(MAKE) -C doc all txt
-	$(MAKE) KERNEL_INCLUDE=./include
+	$(MAKE) KERNEL_INCLUDE=./include $(CROSS)

Reply via email to