[PATCH] Get library installation path for target architecture

Pavel Roskin proski at gnu.org
Thu Mar 23 22:12:27 UTC 2006


Hello!

applets/install.sh uses uname to determine where to install the
libraries.  So, cross-compiling on x86_64 to arm would install
libbusybox to /lib64.  I actually had this problem when I compiled
current buildroot with snapshot busybox a few days ago.  I see
libbusybox is disabled now, but the code to install it is still there,
and it's wrong.

Since Rules.mak exports CC, it could be used to find the library path.
"gcc -print-file-name=libc.so" would print path to libc.so, and the last
part of path before libc.so is what we need.  For safety reasons, only
paths starting with "lib" are matched.  In case the compiler fails to
produce something we recognize, /lib is the default value.

This would also work with systems that install 64-bit libraries in /lib
and 32-bit libraries in /lib32.

Signed-off-by: Pavel Roskin <proski at gnu.org>

Index: applets/install.sh
===================================================================
--- applets/install.sh	(revision 14611)
+++ applets/install.sh	(working copy)
@@ -18,11 +18,12 @@
 
 if [ "$DO_INSTALL_LIBS" != "n" ]; then
 	# get the target dir for the libs
-	# This is an incomplete/incorrect list for now
-	case $(uname -m) in
-	x86_64|ppc64*|sparc64*|ia64*|hppa*64*|s390x*) libdir=/lib64 ;;
-	*) libdir=/lib ;;
-	esac
+	# assume it starts with lib
+	libdir=$($CC -print-file-name=libc.so | \
+		 sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p')
+	if test -z "$libdir"; then
+		libdir=/lib
+	fi
 
 	mkdir -p $prefix/$libdir || exit 1
 	for i in $DO_INSTALL_LIBS; do


-- 
Regards,
Pavel Roskin




More information about the busybox mailing list