aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2014-07-29 01:50:38 -0400
committerMike Frysinger <vapier@gentoo.org>2014-07-29 01:50:38 -0400
commita8d5eab601c99724dec4dae611d1cb316f92318d (patch)
tree517148b8068714774d3fc4fbf95aa404e6d7a43d
parentcross-pkg-config: utilize PKG_CONFIG_SYSROOT_DIR (diff)
downloadcrossdev-a8d5eab601c99724dec4dae611d1cb316f92318d.tar.gz
crossdev-a8d5eab601c99724dec4dae611d1cb316f92318d.tar.bz2
crossdev-a8d5eab601c99724dec4dae611d1cb316f92318d.zip
cross-pkg-config: set up PKG_CONFIG_SYSTEM_LIBRARY_PATH
Rather than hardcode /usr/lib, set PKG_CONFIG_SYSTEM_LIBRARY_PATH to the right libdir paths. This should handle lib vs lib64 vs lib correctly. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rwxr-xr-xwrappers/cross-pkg-config24
1 files changed, 21 insertions, 3 deletions
diff --git a/wrappers/cross-pkg-config b/wrappers/cross-pkg-config
index 859ef05..f928bd0 100755
--- a/wrappers/cross-pkg-config
+++ b/wrappers/cross-pkg-config
@@ -42,6 +42,10 @@ if [ "$1" = "--cross-pkg-config-install" ] ; then
fi
unset EXTRA_PKG_CONFIG_LIBDIR
+if [ -z "${CHOST}" ] ; then
+ CHOST=${0##*/}
+ CHOST=${CHOST%-pkg-config}
+fi
if [ -z "${SYSROOT}" ] ; then
if [ "@CROSS_PKG_CONFIG_INSTALLED@" = "installed" ] ; then
# Manual install
@@ -55,8 +59,6 @@ if [ -z "${SYSROOT}" ] ; then
EXTRA_PKG_CONFIG_LIBDIR=${UCLINUX_PKG_CONFIG_LIBDIR}
else
# /usr/<target>
- CHOST=${0##*/}
- CHOST=${CHOST%-pkg-config}
SYSROOT="/usr/${CHOST}"
if [ -z "${CHOST}" ] || [ ! -d "${SYSROOT}" ] ; then
error "Need \$ROOT or \$STAGEDIR set first"
@@ -75,9 +77,25 @@ unset PKG_CONFIG_ALLOW_SYSTEM_CFLAGS
unset PKG_CONFIG_ALLOW_SYSTEM_LIBS
#
+# Try and figure out the appropriate libdir for this target.
+# This logic matches Gentoo's get_libdir which uses $ABI.
+#
+: ${ABI:=${DEFAULT_ABI:-default}}
+var="LIBDIR_${ABI}"
+libdir=${!var}
+if [ -z "${libdir}" ] ; then
+ # Fall back to probing the compiler.
+ libc=$(realpath $(${CC:-${CHOST}-gcc} ${CFLAGS} ${LDFLAGS} -print-file-name=libc.so))
+ # Chopping the basename isn't exactly correct, but it's good enough for now.
+ libdir=$(basename "${libc%/*}")
+fi
+: ${libdir:=lib}
+export PKG_CONFIG_SYSTEM_LIBRARY_PATH="/usr/${libdir}:/${libdir}"
+
+#
# Set the pkg-config search paths to our staging directory.
#
-export PKG_CONFIG_LIBDIR="${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/share/pkgconfig"
+export PKG_CONFIG_LIBDIR="${SYSROOT}/usr/${libdir}/pkgconfig:${SYSROOT}/usr/share/pkgconfig"
if [ -n "${EXTRA_PKG_CONFIG_LIBDIR}" ] ; then
PKG_CONFIG_LIBDIR="${EXTRA_PKG_CONFIG_LIBDIR}:${PKG_CONFIG_LIBDIR}"
fi