Here is an updated binutils-cross patch for version 2.16.1cvs20060117. - Josh Triplett
diff -Naur binutils-2.16.1cvs20060117.orig/debian/README.cross binutils-2.16.1cvs20060117/debian/README.cross --- binutils-2.16.1cvs20060117.orig/debian/README.cross 1969-12-31 16:00:00.000000000 -0800 +++ binutils-2.16.1cvs20060117/debian/README.cross 2006-02-22 19:35:43.000000000 -0800 @@ -0,0 +1,13 @@ +Cross-binutils debian packages can be built directly from binutils +source package. + +To build cross-binutils package, download and unpack binutils +source package, and run + +TARGET=your-target fakeroot debian/rules binary-cross + +Target name may be set both as debian arch name (such as 'arm', 'powerpc', ...) +ans ad GNU system type (arm-linux-gnu, powerpc-linux-gnu, etc). + +--- +Nikita Youshchenko <[EMAIL PROTECTED]> diff -Naur binutils-2.16.1cvs20060117.orig/debian/generate-cross-control binutils-2.16.1cvs20060117/debian/generate-cross-control --- binutils-2.16.1cvs20060117.orig/debian/generate-cross-control 1969-12-31 16:00:00.000000000 -0800 +++ binutils-2.16.1cvs20060117/debian/generate-cross-control 2006-02-22 19:35:43.000000000 -0800 @@ -0,0 +1,31 @@ +#!/bin/sh + +target=`echo -n $1 | sed 's/_/-/g'` + +sed '/^$/ q' < debian/control + +echo "Package: binutils-$target" +echo 'Architecture: any' +echo 'Depends: binutils, ${shlibs:Depends}' +echo 'Suggests: binutils-doc (= ${Source-Version})' + +# Add conflicts/replaces/provides for older names of same binutils +oldtarget=`echo -n $target | sed 's/-linux-gnu$/-linux/'` +if [ "$target" != "$oldtarget" ]; then + # Add conflicts with old EmDebian toolchain which was available for + # arm and powerpc + if [ "$oldtarget" = "arm-linux" ] || [ "$oldtarget" = "powerpc-linux" ]; then + veryoldtarget=`echo -n $target | sed 's/-linux$//'` + echo "Conflicts: binutils-$oldtarget, binutils-$veryoldtarget" + else + echo "Conflicts: binutils-$oldtarget" + fi + echo "Replaces: binutils-$oldtarget" + echo "Provides: binutils-$oldtarget" +fi +echo "Description: The GNU binary utilities, for $target target" +echo " This package provides GNU assembler, linker and binary utilities" +echo " for $target target, for use in cross-compilation environment." +echo " ." +echo " You don't need this package unless you plan to cross-compile programs" +echo " for $target." diff -Naur binutils-2.16.1cvs20060117.orig/debian/patch-stamp binutils-2.16.1cvs20060117/debian/patch-stamp --- binutils-2.16.1cvs20060117.orig/debian/patch-stamp 1969-12-31 16:00:00.000000000 -0800 +++ binutils-2.16.1cvs20060117/debian/patch-stamp 2006-02-22 19:35:43.000000000 -0800 @@ -0,0 +1,2 @@ +Patches applied in the Debian version of : + diff -Naur binutils-2.16.1cvs20060117.orig/debian/patches/001_ld_makefile_patch.dpatch binutils-2.16.1cvs20060117/debian/patches/001_ld_makefile_patch.dpatch --- binutils-2.16.1cvs20060117.orig/debian/patches/001_ld_makefile_patch.dpatch 2006-02-22 19:37:29.000000000 -0800 +++ binutils-2.16.1cvs20060117/debian/patches/001_ld_makefile_patch.dpatch 2006-02-22 19:35:43.000000000 -0800 @@ -6,6 +6,10 @@ ## DP: Author: Chris Chimelis <[EMAIL PROTECTED]> ## DP: Upstream status: N/A ## DP: Date: ?? +## DP: Fixed by Nikita Youshchenko <[EMAIL PROTECTED]> to be correct for +## DP: cross-binutils - in that case change of $(scriptdir) to /usr/lib causes +## DP: cross-ld to look for libraries in /usr/lib instead of +## DP: /usr/$(target-alias)/lib if [ $# -ne 1 ]; then echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" @@ -29,24 +33,50 @@ diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.am /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am --- ./ld/Makefile.am 2005-08-31 03:27:36.000000000 +0000 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am 2005-09-02 21:42:18.000000000 +0000 -@@ -20,7 +20,7 @@ +@@ -20,7 +20,11 @@ # We put the scripts in the directory $(scriptdir)/ldscripts. # We can't put the scripts in $(datadir) because the SEARCH_DIR # directives need to be different for native and cross linkers. -scriptdir = $(tooldir)/lib -+scriptdir = $(libdir) ++scriptdir = `if [ "@host@" = "@target@" ] ; then \ ++ echo '$(libdir)'; \ ++ else \ ++ echo '$(tooldir)/lib'; \ ++ fi` EMUL = @EMUL@ EMULATION_OFILES = @EMULATION_OFILES@ +@@ -431,7 +435,7 @@ + + ldmain.o: ldmain.c config.status + $(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \ +- -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \ ++ -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \ + -DTOOLBINDIR='"$(tooldir)/bin"' \ + -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \ + $(srcdir)/ldmain.c diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.in /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in --- ./ld/Makefile.in 2005-08-31 03:27:36.000000000 +0000 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in 2005-09-02 21:43:37.259127535 +0000 -@@ -268,7 +268,7 @@ +@@ -268,7 +268,11 @@ # We put the scripts in the directory $(scriptdir)/ldscripts. # We can't put the scripts in $(datadir) because the SEARCH_DIR # directives need to be different for native and cross linkers. -scriptdir = $(tooldir)/lib -+scriptdir = $(libdir) ++scriptdir = `if [ "@host@" = "@target@" ] ; then \ ++ echo '$(libdir)'; \ ++ else \ ++ echo '$(tooldir)/lib'; \ ++ fi` BASEDIR = $(srcdir)/.. BFDDIR = $(BASEDIR)/bfd INCDIR = $(BASEDIR)/include +@@ -1173,7 +1177,7 @@ + + ldmain.o: ldmain.c config.status + $(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \ +- -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \ ++ -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \ + -DTOOLBINDIR='"$(tooldir)/bin"' \ + -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \ + $(srcdir)/ldmain.c diff -Naur binutils-2.16.1cvs20060117.orig/debian/patches/00list binutils-2.16.1cvs20060117/debian/patches/00list --- binutils-2.16.1cvs20060117.orig/debian/patches/00list 2006-02-22 19:37:29.000000000 -0800 +++ binutils-2.16.1cvs20060117/debian/patches/00list 2006-02-22 19:37:05.000000000 -0800 @@ -6,3 +6,4 @@ 012_check_ldrunpath_length 120_mips_xgot_multigot_workaround 121_i386_x86_64_biarch +999_lib64_for_cross diff -Naur binutils-2.16.1cvs20060117.orig/debian/patches/999_lib64_for_cross.dpatch binutils-2.16.1cvs20060117/debian/patches/999_lib64_for_cross.dpatch --- binutils-2.16.1cvs20060117.orig/debian/patches/999_lib64_for_cross.dpatch 1969-12-31 16:00:00.000000000 -0800 +++ binutils-2.16.1cvs20060117/debian/patches/999_lib64_for_cross.dpatch 2006-02-22 19:35:43.000000000 -0800 @@ -0,0 +1,56 @@ +#! /bin/sh -e +## 999_lib64_for_cross.dpatch by Nikita Youshchenko <[EMAIL PROTECTED]> +## +## DP: Add /usr/${target-alias}/lib${LIBPATH_SUFFIX} to ld's default +## DP: library search path for cross targets. Needed for cross targets that +## DP: try to support both 32bit and 64bit emulations. + +if [ $# -lt 1 ]; then + echo "`basename $0`: script expects -patch|-unpatch as argument" >&2 + exit 1 +fi + +[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts +patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}" + +case "$1" in + -patch) patch -p1 ${patch_opts} < $0;; + -unpatch) patch -R -p1 ${patch_opts} < $0;; + *) + echo "`basename $0`: script expects -patch|-unpatch as argument" >&2 + exit 1;; +esac + +exit 0 + [EMAIL PROTECTED]@ +diff -urNad /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh binutils-2.14.90.0.7.cross/ld/genscripts.sh +--- /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh 2003-10-29 20:37:48.000000000 +0300 ++++ binutils-2.14.90.0.7.cross/ld/genscripts.sh 2004-07-15 00:29:19.000000000 +0400 +@@ -176,6 +176,26 @@ + ::) LIB_PATH=${tool_lib} ;; + *) LIB_PATH=${tool_lib}:${LIB_PATH} ;; + esac ++ # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX} ++ # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} to default search path, because ++ # 64bit libraries may be in both places, depending on cross-development ++ # setup method (e.g.: /usr/s390x-linux/lib64 vs /usr/s390-linux/lib64) ++ case "${LIBPATH_SUFFIX}:${tool_lib}" in ++ :*) ;; ++ *:*${LIBPATH_SUFFIX}) ;; ++ *) ++ paths="${exec_prefix}/${target_alias}/lib${LIBPATH_SUFFIX}" ++ if [ "${TOOL_LIB}" != x ]; then ++ paths="${paths} ${exec_prefix}/${TOOL_LIB}/lib${LIBPATH_SUFFIX}" ++ fi ++ for path in $paths; do ++ case :${LIB_PATH}: in ++ ::: | *:${path}:*) ;; ++ *) LIB_PATH=${path}:${LIB_PATH} ;; ++ esac ++ done ++ ;; ++ esac + fi + + LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'` diff -Naur binutils-2.16.1cvs20060117.orig/debian/rules binutils-2.16.1cvs20060117/debian/rules --- binutils-2.16.1cvs20060117.orig/debian/rules 2006-02-22 19:37:29.000000000 -0800 +++ binutils-2.16.1cvs20060117/debian/rules 2006-02-22 19:35:43.000000000 -0800 @@ -381,7 +381,8 @@ endif $(install_file) $(pwd)/test-summary binutils/NEWS \ - debian/README.Debian $(d_bin)/usr/share/doc/$(p_bin)/ + debian/README.Debian debian/README.cross \ + $(d_bin)/usr/share/doc/$(p_bin)/ $(install_file) binutils/ChangeLog $(d_bin)/usr/share/doc/$(p_bin)/changelog @@ -440,6 +441,133 @@ ################################################################################ + +################# +# cross targets # +################# + +# If $(TARGET) is not set, try reading debian/target +ifeq ($(TARGET),) +TARGET := $(cat debian/target 2>/dev/null) +endif + +# Process the following only if $(TARGET) is set +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 -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null) +ifneq ($(try_convert),) +override TARGET := $(try_convert) +endif + +# Many people expect cross-binutils to be named like 'arm-linux-ld', not +# like 'arm-linux-gnu-ld'. Package will provide symlinks. In future, this may +# be replaced with alternatives. +tmp_cpu := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_CPU 2>/dev/null) +tmp_os := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_OS 2>/dev/null) +ifeq ($(TARGET),$(tmp_cpu)-$(tmp_os)-gnu) +do_symlinks := yes +else +do_symlinks := no +endif + +p_cross = $(subst _,-,binutils-$(TARGET)) +d_cross = debian/$(p_cross) + +ifneq ($(filter sparc-linux-gnu powerpc-linux-gnu mips-linux-gnu, $(TARGET)),) +ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu) +endif +ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu x86-linux-gnu, $(TARGET)),) +ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu +endif +ifeq ($(TARGET), x86_64-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=i486-linux-gnu +endif +ifeq ($(TARGET), mipsel-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=mips64el-linux-gnu +endif +ifeq ($(TARGET), sparc64-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=sparc-linux-gnu +endif +ifeq ($(TARGET), s390-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=s390x-linux-gnu +endif +ifeq ($(TARGET), s390x-linux-gnu) +ADDITIONAL_TARGETS = --enable-targets=s390-linux-gnu +endif + +configure-$(TARGET)-stamp: patch-stamp + $(checkdir) + test "" != "$(TARGET)" + rm -rf configure-$(TARGET)-stamp builddir-$(TARGET) + mkdir builddir-$(TARGET) + cd builddir-$(TARGET) \ + && env CC="$(CC)" ../configure --host=$(DEB_HOST_GNU_TYPE) \ + --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/usr \ + $(ADDITIONAL_TARGETS) + touch $@ + +build-$(TARGET)-stamp: configure-$(TARGET)-stamp + $(checkdir) + test "" != "$(TARGET)" + $(MAKE) -C builddir-$(TARGET) CFLAGS="$(CFLAGS)" + touch $@ + +install-$(TARGET)-stamp: build-$(TARGET)-stamp + $(checkdir) + test "" != "$(TARGET)" + rm -rf $(d_cross) + $(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/usr \ + mandir=$(pwd)/$(d_cross)/usr/share/man install + rm -rf $(d_cross)/usr/lib $(d_cross)/usr/info $(d_cross)/usr/share/locale + $(STRIP) $(d_cross)/usr/bin/* + gzip -9 $(d_cross)/usr/share/man/man1/* +ifeq ($(do_symlinks),yes) + cd $(d_cross)/usr/bin && for f in *; do \ + ln -s $$f `echo $$f | sed 's/-gnu//'`; \ + done + cd $(d_cross)/usr/share/man/man1 && for f in *; do \ + ln -s $$f `echo $$f | sed 's/-gnu//'`; \ + done +endif + touch $@ + +binary-cross: checkroot install-$(TARGET)-stamp + $(checkdir) + test "" != "$(TARGET)" + + chmod 755 debian/generate-cross-control + debian/generate-cross-control $(TARGET) > debian/control.$(TARGET) + + $(install_dir) $(d_cross)/DEBIAN + + $(install_dir) $(d_cross)/usr/share/doc/$(p_cross)/ + $(install_file) debian/changelog $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian + $(install_file) debian/copyright debian/README.cross $(d_cross)/usr/share/doc/$(p_cross)/ + gzip -f -9 $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian + + for pkg in bfd gas gprof ld; do \ + ln -sf ../binutils/$$pkg $(d_cross)/usr/share/doc/$(p_cross)/$$pkg; \ + done + + rm -f debian/substvars + dpkg-shlibdeps $(d_cross)/usr/bin/* + dpkg-gencontrol -cdebian/control.$(TARGET) -P$(d_cross) -p$(p_cross) + dpkg --build $(d_cross) .. + +clean-cross: unpatch + $(checkdir) + test "" != "$(TARGET)" + rm -rf $(d_cross) debian/control.$(TARGET) debian/files debian/substvars \ + builddir-$(TARGET) {configure,build,install}-$(TARGET)-stamp + +.PHONY: binary-cross clean-cross + +endif + +################################################################################ + define checkdir test -f bfd/elf32.c -a -f debian/rules endef
signature.asc
Description: OpenPGP digital signature