From 3ab308442fb42269d6b6b30427c8b6773ae23739 Mon Sep 17 00:00:00 2001
From: P. J. McDermott <pjm@nac.net>
Date: Sun, 11 Nov 2012 15:09:06 -0500
Subject: We don't need no stinkin' patch for the lib path.

---
diff --git a/README b/README
index 9cde205..daf007e 100644
--- a/README
+++ b/README
@@ -1,12 +1,6 @@
 Binutils Package
 ================
 
-Interesting Patches
--------------------
-
-ld needs to be built with multiarch library directories in its list of search
-paths.  Debian has [a patch][debian-ld-ma-patch] to which we can refer for this.
-
 Building the Binutils Package
 -----------------------------
 
@@ -57,6 +51,3 @@ Makefile.in (unlikely) and changes in the features (e.g. gold) we enable
 
 The trivial patch (which adds just three lines) should apply cleanly across
 Binutils releases, so it seems best to just stick with that.
-
-
-[debian-ld-ma-patch]: http://patch-tracker.debian.org/patch/series/view/binutils/2.22-7.1/129_ld_mulitarch_dirs.patch
diff --git a/build b/build
index 0b16f5c..6bdaa7a 100755
--- a/build
+++ b/build
@@ -4,13 +4,27 @@ CFLAGS = -g -O2
 
 configure:
 	# Generate the main makefile.
+	# Use (optionally sysroot-prefixed) multiarch library search directories.
 	# Use shared BFD and opcodes libraries for all utilities.
 	# Don't enable multilib (multiarch is better).
 	# Enable plugins.
 	# Don't expect to find Gettext.
 	for target in $$(cat ../targets); do \
-		CFLAGS='$(CFLAGS)' oh-autoconfigure \
-			-B "build-$${target}" -t "$${target}" -- \
+		if [ -n '$(OPK_SYSROOT)' ]; then \
+			LIB_PATH="=/usr/local/lib/$${target}:=/usr/local/lib"; \
+			LIB_PATH="$${LIB_PATH}:=/lib/$${target}:=/lib"; \
+			LIB_PATH="$${LIB_PATH}:=/usr/lib/$${target}:=/usr/lib"; \
+		elif [ '$(OPK_HOST_ARCH)' = "$${target}" ]; then \
+			LIB_PATH="/usr/local/lib/$${target}:/usr/local/lib"; \
+			LIB_PATH="$${LIB_PATH}:/lib/$${target}:/lib"; \
+			LIB_PATH="$${LIB_PATH}:/usr/lib/$${target}:/usr/lib"; \
+		else \
+			LIB_PATH="/usr/local/lib/$${target}"; \
+			LIB_PATH="$${LIB_PATH}:/lib/$${target}"; \
+			LIB_PATH="$${LIB_PATH}:/usr/lib/$${target}"; \
+		fi; \
+		CFLAGS='$(CFLAGS)' host_configargs="--with-lib-path=$${LIB_PATH}" \
+			oh-autoconfigure -B "build-$${target}" -t "$${target}" -- \
 			$$([ -n "$${OPK_SYSROOT}" ] && \
 				printf "--with-sysroot='%s'" "$${OPK_SYSROOT}") \
 			--program-transform-name="s&^&$${target}-&" \
diff --git a/patches/02_use-multiarch-lib-search-dirs-in-ldscripts.patch b/patches/02_use-multiarch-lib-search-dirs-in-ldscripts.patch
deleted file mode 100644
index b8cf899..0000000
--- a/patches/02_use-multiarch-lib-search-dirs-in-ldscripts.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-Description: Use multiarch library search directories in ldscripts
- The ldscripts of course control the linking of *target-architecture* binary
- objects, so we need to search for libraries in the target architecture's
- library path.
-From: "P. J. McDermott" <pjm@nac.net>
-
-diff -Naur src.orig/ld/genscripts.sh src/ld/genscripts.sh
---- src.orig/ld/genscripts.sh	2010-12-15 09:56:37.000000000 -0500
-+++ src/ld/genscripts.sh	2012-11-11 05:23:39.143135998 -0500
-@@ -242,6 +242,7 @@
- fi
- 
- LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
-+LIB_SEARCH_DIRS="${LIB_SEARCH_DIRS}SEARCH_DIR(\"${OPK_TARGET_ARCH}\");"
- 
- # We need it for testsuite.
- set $EMULATION_LIBPATH
--
cgit v0.9.1