diff -u binutils-2.22/debian/rules binutils-2.22/debian/rules --- binutils-2.22/debian/rules +++ binutils-2.22/debian/rules @@ -50,6 +50,13 @@ install_script = install -m 755 install_binary = install -m 755 -s +# If $(TARGET) is not set, try reading debian/target +ifeq (,$(TARGET)) + ifneq (,$(wildcard debian/target)) + TARGET := $(shell cat debian/target 2>/dev/null) + endif +endif + vafilt = $(subst $(2)=,,$(filter $(2)=%,$(1))) DPKG_VARS := $(shell dpkg-architecture) DEB_BUILD_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE) @@ -57,6 +64,19 @@ DEB_HOST_GNU_TYPE ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_TYPE) DEB_HOST_MULTIARCH ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_MULTIARCH) +ifneq (,$(TARGET)) + # Support TARGET both as Debian architecture specification (e.g. arm), + # and as the target name (e.g. arm-linux-gnu). + try_convert := $(shell dpkg-architecture -f -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null) + ifneq ($(try_convert),) + override TARGET := $(try_convert) + endif + + DPKG_VARS := $(shell dpkg-architecture -f -t$(TARGET)) + DEB_TARGET_MULTIARCH = $(call vafilt,$(DPKG_VARS),DEB_HOST_MULTIARCH) + export DEB_TARGET_MULTIARCH +endif + ifeq (,$(DEB_HOST_MULTIARCH)) ifeq ($(DEB_HOST_ARCH),i386) DEB_HOST_MULTIARCH = i386-linux-gnu @@ -151,13 +171,6 @@ with_multiarch = disabled in DEB_BUILD_OPTIONS endif -# If $(TARGET) is not set, try reading debian/target -ifeq (,$(TARGET)) - ifneq (,$(wildcard debian/target)) - TARGET := $(shell cat debian/target 2>/dev/null) - endif -endif - # PF is the installation prefix for the package without the leading slash. # It's "usr" for gcc releases, so use this if not explicitly set ifeq ($(PF),) @@ -1181,14 +1194,6 @@ # cross targets # ################# - -# Support TARGET both as Debian architecture specification (e.g. arm), -# and as the target name (e.g. arm-linux-gnu). -try_convert := $(shell dpkg-architecture -f -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null) -ifneq ($(try_convert),) -override TARGET := $(try_convert) -endif - # Process the following only if $(TARGET) is set ifneq (,$(TARGET)) diff -u binutils-2.22/debian/patches/163_multiarch_search_path.patch binutils-2.22/debian/patches/163_multiarch_search_path.patch --- binutils-2.22/debian/patches/163_multiarch_search_path.patch +++ binutils-2.22/debian/patches/163_multiarch_search_path.patch @@ -25,8 +25,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -+if test x$target = x$host; then -+ multiarch=`$CC -print-multiarch 2>/dev/null` ++if test x$target != x; then ++ multiarch=`echo $target | sed -e 's/-unknown//g'` + if test -n "$multiarch"; then + MULTIARCH_DIRNAME='-DMULTIARCH_DIRNAME=\"'$multiarch'\"' + fi @@ -42,8 +42,8 @@ AC_LANG_POP(C++) -+if test x$target = x$host; then -+ multiarch=`$CC -print-multiarch 2>/dev/null` ++if test x$target != x; then ++ multiarch=`echo $target | sed -e 's/-unknown//g'` + if test -n "$multiarch"; then + MULTIARCH_DIRNAME='-DMULTIARCH_DIRNAME=\"'$multiarch'\"' + fi diff -u binutils-2.22/debian/patches/series binutils-2.22/debian/patches/series --- binutils-2.22/debian/patches/series +++ binutils-2.22/debian/patches/series @@ -49,0 +50,2 @@ + +cross-use-multiarch-dirs.patch --- binutils-2.22.orig/debian/patches/cross-use-multiarch-dirs.patch +++ binutils-2.22/debian/patches/cross-use-multiarch-dirs.patch @@ -0,0 +1,20 @@ +--- + ld/genscripts.sh | 3 +++ + 1 file changed, 3 insertions(+) + +--- binutils-2.22.orig/ld/genscripts.sh ++++ binutils-2.22/ld/genscripts.sh +@@ -299,10 +299,13 @@ if [ -n "$DEB_HOST_MULTIARCH" ]; then + continue + fi + LIB_SEARCH_DIRS="${LIB_SEARCH_DIRS}SEARCH_DIR(\"$dir\"); " + done + fi ++if [ -n "$DEB_TARGET_MULTIARCH" ]; then ++ LIB_SEARCH_DIRS="SEARCH_DIR(\"/lib/${DEB_TARGET_MULTIARCH}\"); SEARCH_DIR(\"/usr/lib/${DEB_TARGET_MULTIARCH}\");${LIB_SEARCH_DIRS} " ++fi + + # We need it for testsuite. + set $EMULATION_LIBPATH + if [ "x$1" = "x$EMULATION_NAME" ]; then + test -d tmpdir || mkdir tmpdir