#!/bin/sh -e
## 124_multiarch.dpatch
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Description: Add multiarch directories to the search paths.
## DP: Author: Tollef Fog Heen <tfheen@debian.org>
## DP: Upstream status: Debian specific

if [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"

case "$1" in
       -patch) patch $patch_opts -p1 < $0;;
       -unpatch) patch $patch_opts -p1 -R < $0;;
        *)
                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
                exit 1;;
esac

exit 0

@DPATCH@
--- binutils/ld/genscripts.sh
+++ binutils/ld/genscripts.sh
@@ -191,7 +191,7 @@
   esac
 fi
 
-LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
+LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");SEARCH_DIR(\\"\1\\/'${TOOL_LIB}'");/g'`
 
 # We need it for testsuite.
 set $EMULATION_LIBPATH
