From 491b6845f93d66f3fe2d8bd0903ac0b2868b02e5 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sat, 30 May 2015 19:01:55 -0700 Subject: [PATCH 01/10] linux/make-bootstrap-tools: Only copy needed runtime libraries for tools inside of bootstrap tools This makes it easier to add tools in the future and helps to minimize the amount of included libraries to the minimum without breaking executables. --- pkgs/stdenv/linux/make-bootstrap-tools.nix | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index 6bd67d8c7a016..24616daefc015 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -78,9 +78,7 @@ rec { cp -d ${patch}/bin/* $out/bin cp ${patchelf}/bin/* $out/bin cp ${curl-light}/bin/curl $out/bin - cp -d ${curl-light}/lib/libcurl* $out/lib - cp -d ${gnugrep.pcre}/lib/libpcre*.so* $out/lib # needed by grep # Copy what we need of GCC. cp -d ${gcc.cc}/bin/gcc $out/bin @@ -105,17 +103,28 @@ rec { rm -rf $out/include/c++/*/ext/pb_ds rm -rf $out/include/c++/*/ext/parallel - cp -d ${gmpxx}/lib/libgmp*.so* $out/lib - cp -d ${mpfr}/lib/libmpfr*.so* $out/lib - cp -d ${libmpc}/lib/libmpc*.so* $out/lib - cp -d ${zlib}/lib/libz.so* $out/lib - cp -d ${libelf}/lib/libelf.so* $out/lib - # Copy binutils. for i in as ld ar ranlib nm strip readelf objdump; do cp ${binutils}/bin/$i $out/bin done - cp -d ${binutils}/lib/lib*.so* $out/lib + + # Copy all of the needed libraries for the binaries + for BIN in $(find $out/bin -type f); do + echo "Copying libs for bin $BIN" + LDD="$(ldd $BIN)" || continue + LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')" + for LIB in $LIBS; do + [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib + while [ "$(readlink $LIB)" != "" ]; do + LINK="$(readlink $LIB)" + if [ "${LINK:0:1}" != "/" ]; then + LINK="$(dirname $LIB)/$LINK" + fi + LIB="$LINK" + [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib + done + done + done chmod -R u+w $out From b9cceff29e86f800ccb54b43a73e43df6de6c106 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sat, 30 May 2015 19:02:49 -0700 Subject: [PATCH 02/10] linux/make-boostrap-tools: Add a real version of XZ as it has minimal overhead --- pkgs/stdenv/linux/make-bootstrap-tools.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index 24616daefc015..fd57082fda010 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -74,6 +74,7 @@ rec { cp ${gnutar}/bin/tar $out/bin cp ${gzip}/bin/gzip $out/bin cp ${bzip2}/bin/bzip2 $out/bin + cp ${xz}/bin/xz $out/bin cp -d ${gnumake}/bin/* $out/bin cp -d ${patch}/bin/* $out/bin cp ${patchelf}/bin/* $out/bin From d320ecd5f8e0a1277da63677c8c1914758553129 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sat, 30 May 2015 19:03:04 -0700 Subject: [PATCH 03/10] linux/make-bootstrap-tools: Add support for ssl to curl This will open up options for sourcing tarballs from repositories like github as they only serve tarballs over ssl. It will also allow us to eventually verify all tls connections made by fetchurl. --- pkgs/stdenv/linux/make-bootstrap-tools.nix | 3 +++ pkgs/tools/networking/curl/default.nix | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index fd57082fda010..ef1b748e115f1 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -80,6 +80,9 @@ rec { cp ${patchelf}/bin/* $out/bin cp ${curl-light}/bin/curl $out/bin + # Add ca certificates for curl + mkdir -p $out/etc/ssl/certs + cp -d ${cacert}/ca-bundle.crt $out/etc/ssl/certs # Copy what we need of GCC. cp -d ${gcc.cc}/bin/gcc $out/bin diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix index 8a101e9845a66..3c246571c9302 100644 --- a/pkgs/tools/networking/curl/default.nix +++ b/pkgs/tools/networking/curl/default.nix @@ -17,7 +17,7 @@ let # Normal Depedencies optZlib = if isLight then null else shouldUsePkg zlib; - optOpenssl = if isLight then null else shouldUsePkg openssl; + optOpenssl = shouldUsePkg openssl; optLibssh2 = if isLight then null else shouldUsePkg libssh2; optLibnghttp2 = if isLight then null else shouldUsePkg libnghttp2; optC-ares = if isLight then null else shouldUsePkg c-ares; From e46b130b0e8bfb394b4335982ed644c30d01063e Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sat, 30 May 2015 19:33:55 -0700 Subject: [PATCH 04/10] linux/make-bootstrap-tools-cross: Port the patches --- .../linux/make-bootstrap-tools-cross.nix | 57 +++++++++++-------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix index 520bdd208e36c..b0f5d33f62052 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix @@ -82,6 +82,9 @@ let libmpc = pkgs.libmpc.crossDrv; binutils = pkgs.binutils.crossDrv; libelf = pkgs.libelf.crossDrv; + curl-light = pkgs.curl-light.crossDrv; + xz = pkgs.xz.crossDrv; + cacert = pkgs.cacert.crossDrv; in @@ -92,8 +95,6 @@ rec { aclSupport = false; })).crossDrv; - curl-light = pkgs.curl-light.crossDrv; - busyboxMinimal = (pkgs.busybox.override { # TBD: uClibc is broken. # useUclibc = true; @@ -122,11 +123,11 @@ rec { crossConfig = stdenv.cross.config; buildCommand = '' - set -x + set -x mkdir -p $out/bin $out/lib $out/libexec # Copy what we need of Glibc. - cp -d ${glibc}/lib/ld-*.so* $out/lib + cp -d ${glibc}/lib/ld*.so* $out/lib cp -d ${glibc}/lib/libc*.so* $out/lib cp -d ${glibc}/lib/libc_nonshared.a $out/lib cp -d ${glibc}/lib/libm*.so* $out/lib @@ -138,20 +139,20 @@ rec { cp -d ${glibc}/lib/libnss*.so* $out/lib cp -d ${glibc}/lib/libresolv*.so* $out/lib cp -d ${glibc}/lib/crt?.o $out/lib - + cp -rL ${glibc}/include $out chmod -R u+w $out/include - + # Hopefully we won't need these. rm -rf $out/include/mtd $out/include/rdma $out/include/sound $out/include/video find $out/include -name .install -exec rm {} \; find $out/include -name ..install.cmd -exec rm {} \; mv $out/include $out/include-glibc - + # Copy coreutils, bash, etc. cp ${coreutilsMinimal}/bin/* $out/bin (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users) - + cp ${bash}/bin/bash $out/bin cp ${findutils}/bin/find $out/bin cp ${findutils}/bin/xargs $out/bin @@ -163,14 +164,16 @@ rec { cp ${gnutar}/bin/tar $out/bin cp ${gzip}/bin/gzip $out/bin cp ${bzip2}/bin/bzip2 $out/bin + cp ${xz}/bin/xz $out/bin cp -d ${gnumake}/bin/* $out/bin cp -d ${patch}/bin/* $out/bin cp ${patchelf}/bin/* $out/bin cp ${curl-light}/bin/curl $out/bin - cp -d ${curl-light}/lib/libcurl* $out/lib - cp -d ${gnugrep.pcre.crossDrv}/lib/libpcre*.so* $out/lib # needed by grep - + # Add ca certificates for curl + mkdir -p $out/etc/ssl/certs + cp -d ${cacert}/ca-bundle.crt $out/etc/ssl/certs + # Copy what we need of GCC. cp -d ${gcc}/bin/gcc $out/bin cp -d ${gcc}/bin/cpp $out/bin @@ -194,25 +197,31 @@ rec { rm -rf $out/include/c++/*/ext/pb_ds rm -rf $out/include/c++/*/ext/parallel - cp -d ${gmpxx}/lib/libgmp*.so* $out/lib - cp -d ${mpfr}/lib/libmpfr*.so* $out/lib - cp -d ${libmpc}/lib/libmpc*.so* $out/lib - cp -d ${zlib}/lib/libz.so* $out/lib - cp -d ${libelf}/lib/libelf.so* $out/lib - - # TBD: Why are these needed for cross but not native tools? - cp -d ${cloogppl}/lib/libcloog*.so* $out/lib - cp -d ${cloog}/lib/libcloog*.so* $out/lib - cp -d ${isl}/lib/libisl*.so* $out/lib - # Copy binutils. for i in as ld ar ranlib nm strip readelf objdump; do cp ${binutils}/bin/$i $out/bin done - cp -d ${binutils}/lib/lib*.so* $out/lib + + # Copy all of the needed libraries for the binaries + for BIN in $(find $out/bin -type f); do + echo "Copying libs for bin $BIN" + LDD="$(ldd $BIN)" || continue + LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')" + for LIB in $LIBS; do + [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib + while [ "$(readlink $LIB)" != "" ]; do + LINK="$(readlink $LIB)" + if [ "${LINK:0:1}" != "/" ]; then + LINK="$(dirname $LIB)/$LINK" + fi + LIB="$LINK" + [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib + done + done + done chmod -R u+w $out - + # Strip executables even further. for i in $out/bin/* $out/libexec/gcc/*/*/*; do if test -x $i -a ! -L $i; then From 54e74bcea6bf6bdeec4620c057ca312fc7f27bec Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sun, 31 May 2015 14:32:26 -0700 Subject: [PATCH 05/10] busyboxBootstrap: Build on hydra --- .../linux/make-bootstrap-tools-cross.nix | 19 ++------------- pkgs/stdenv/linux/make-bootstrap-tools.nix | 23 +------------------ pkgs/top-level/all-packages.nix | 15 ++++++++++++ 3 files changed, 18 insertions(+), 39 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix index b0f5d33f62052..03c9cd5b923c6 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix @@ -85,6 +85,7 @@ let curl-light = pkgs.curl-light.crossDrv; xz = pkgs.xz.crossDrv; cacert = pkgs.cacert.crossDrv; + busyboxBootstrap = pkgs.busyboxBootstrap.crossDrv; in @@ -95,22 +96,6 @@ rec { aclSupport = false; })).crossDrv; - busyboxMinimal = (pkgs.busybox.override { - # TBD: uClibc is broken. - # useUclibc = true; - enableStatic = true; - enableMinimal = true; - extraConfig = '' - CONFIG_ASH y - CONFIG_ASH_BUILTIN_ECHO y - CONFIG_ASH_BUILTIN_TEST y - CONFIG_ASH_OPTIMIZE_FOR_SIZE y - CONFIG_MKDIR y - CONFIG_TAR y - CONFIG_UNXZ y - ''; - }).crossDrv; - inherit pkgs; build = @@ -240,7 +225,7 @@ rec { mkdir $out/on-server tar cvfJ $out/on-server/bootstrap-tools.tar.xz -C $out/pack . - cp ${busyboxMinimal}/bin/busybox $out/on-server + cp ${busyboxBootstrap}/bin/busybox $out/on-server chmod u+w $out/on-server/busybox nuke-refs $out/on-server/busybox ''; # */ diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index ef1b748e115f1..0a47dbc4ba0e8 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -4,27 +4,6 @@ with import ../../top-level/all-packages.nix {inherit system;}; rec { - - # We want coreutils without ACL support. - coreutilsMinimal = coreutils.override (args: { - aclSupport = false; - }); - - busyboxMinimal = busybox.override { - useMusl = true; - enableStatic = true; - enableMinimal = true; - extraConfig = '' - CONFIG_ASH y - CONFIG_ASH_BUILTIN_ECHO y - CONFIG_ASH_BUILTIN_TEST y - CONFIG_ASH_OPTIMIZE_FOR_SIZE y - CONFIG_MKDIR y - CONFIG_TAR y - CONFIG_UNXZ y - ''; - }; - build = stdenv.mkDerivation { @@ -150,7 +129,7 @@ rec { mkdir $out/on-server tar cvfJ $out/on-server/bootstrap-tools.tar.xz -C $out/pack . - cp ${busyboxMinimal}/bin/busybox $out/on-server + cp ${busyboxBootstrap}/bin/busybox $out/on-server chmod u+w $out/on-server/busybox nuke-refs $out/on-server/busybox ''; # */ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 78be647f15ae3..cde523aadd423 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9220,6 +9220,21 @@ let busybox = callPackage ../os-specific/linux/busybox { }; + busyboxBootstrap = busybox.override { + useMusl = true; + enableStatic = true; + enableMinimal = true; + extraConfig = '' + CONFIG_ASH y + CONFIG_ASH_BUILTIN_ECHO y + CONFIG_ASH_BUILTIN_TEST y + CONFIG_ASH_OPTIMIZE_FOR_SIZE y + CONFIG_MKDIR y + CONFIG_TAR y + CONFIG_UNXZ y + ''; + }; + cgmanager = callPackage ../os-specific/linux/cgmanager { }; checkpolicy = callPackage ../os-specific/linux/checkpolicy { }; From 0df632e3de4b1335028fb6a0538cd4dcc8bc0c2d Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sun, 31 May 2015 14:26:15 -0700 Subject: [PATCH 06/10] coreutils: Just use the default as it doesn't much space --- pkgs/stdenv/linux/make-bootstrap-tools-cross.nix | 8 ++------ pkgs/stdenv/linux/make-bootstrap-tools.nix | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix index 03c9cd5b923c6..8928a3df965f0 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix @@ -85,16 +85,12 @@ let curl-light = pkgs.curl-light.crossDrv; xz = pkgs.xz.crossDrv; cacert = pkgs.cacert.crossDrv; + coreutils = pkgs.coreutils.crossDrv; busyboxBootstrap = pkgs.busyboxBootstrap.crossDrv; in rec { - - # We want coreutils without ACL support. - coreutilsMinimal = (pkgs.coreutils.override (args: { - aclSupport = false; - })).crossDrv; inherit pkgs; @@ -135,7 +131,7 @@ rec { mv $out/include $out/include-glibc # Copy coreutils, bash, etc. - cp ${coreutilsMinimal}/bin/* $out/bin + cp ${coreutils}/bin/* $out/bin (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users) cp ${bash}/bin/bash $out/bin diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index 0a47dbc4ba0e8..a827fac696261 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -39,7 +39,7 @@ rec { mv $out/include $out/include-glibc # Copy coreutils, bash, etc. - cp ${coreutilsMinimal}/bin/* $out/bin + cp ${coreutils}/bin/* $out/bin (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users) cp ${bash}/bin/bash $out/bin From 495fbc03c404bf5d04343dce4c2468e1c1527769 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Sun, 31 May 2015 15:12:29 -0700 Subject: [PATCH 07/10] busyboxBootstrap: Use glibc instead of musl as it is broken for many archs --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cde523aadd423..bb30abfe9d187 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9221,7 +9221,7 @@ let busybox = callPackage ../os-specific/linux/busybox { }; busyboxBootstrap = busybox.override { - useMusl = true; + useMusl = false; # Broken for all systems except x86_64-linux enableStatic = true; enableMinimal = true; extraConfig = '' From 477c83ba640af6815f2a170804b2e1a99b40267a Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Mon, 1 Jun 2015 10:40:24 -0700 Subject: [PATCH 08/10] make-bootstrap-tools-cross: Fix the method for determining shared libraries --- .../linux/make-bootstrap-tools-cross.nix | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix index 8928a3df965f0..a2d8091501154 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix @@ -88,6 +88,8 @@ let coreutils = pkgs.coreutils.crossDrv; busyboxBootstrap = pkgs.busyboxBootstrap.crossDrv; + readelf = "${binutilsCross}/bin/${selectedCrossSystem.crossSystem.config}-readelf"; + in rec { @@ -184,21 +186,42 @@ rec { done # Copy all of the needed libraries for the binaries - for BIN in $(find $out/bin -type f); do - echo "Copying libs for bin $BIN" - LDD="$(ldd $BIN)" || continue - LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')" + copy_libs_in_elf() { + local BIN=$1 + + # Determine what libraries are needed by the elf + RELF="$(${readelf} -a $BIN 2>&1)" || continue + RPATH="$(echo "$RELF" | grep rpath | sed 's,.*\[\([^]]*\)\].*,\1,')" + LIBS="$(echo "$RELF" | grep 'Shared library' | sed 's,.*\[\([^]]*\)\].*,\1,')" for LIB in $LIBS; do - [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib - while [ "$(readlink $LIB)" != "" ]; do - LINK="$(readlink $LIB)" - if [ "${LINK:0:1}" != "/" ]; then - LINK="$(dirname $LIB)/$LINK" + # Find the libraries on the system + for LIBPATH in $(echo "$RPATH" | tr ':' ' '); do + if [ -f "$LIBPATH/$LIB" ]; then + LIB="$LIBPATH/$LIB" + break + fi + done + + # Copy the library and possibly symlinks + while [ ! -f "$out/lib/$(basename $LIB)" ]; do + LINK="$(readlink $LIB)" || true + if [ -z "$LINK" ]; then + cp -pdv $LIB $out/lib + copy_libs_in_elf $LIB + break + else + ln -sv "$(basename $LINK)" "$out/lib/$(basename $LIB)" + if [ "${LINK:0:1}" != "/" ]; then + LINK="$(dirname $LIB)/$LINK" + fi + LIB="$LINK" fi - LIB="$LINK" - [ ! -f "$out/lib/$(basename $LIB)" ] && cp -pdv $LIB $out/lib done done + } + for BIN in $(find $out/bin -type f); do + echo "Copying libs for bin $BIN" + copy_libs_in_elf $BIN done chmod -R u+w $out From 2e3773ac9e8b219c75a987f9fbc83be6b120063c Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Mon, 1 Jun 2015 10:40:24 -0700 Subject: [PATCH 09/10] make-bootstrap-tools-cross: Fix the method for determining shared libraries --- pkgs/stdenv/linux/make-bootstrap-tools-cross.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix index a2d8091501154..065fb50c09ff7 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix @@ -219,7 +219,7 @@ rec { done done } - for BIN in $(find $out/bin -type f); do + for BIN in $out/bin/* $out/libexec/gcc/*/*/*; do echo "Copying libs for bin $BIN" copy_libs_in_elf $BIN done From b32f310584a1b8b4976abf0a1a6c79597f102148 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Mon, 1 Jun 2015 11:03:09 -0700 Subject: [PATCH 10/10] make-bootstrap-tools-cross: Add strangely missing rpath for libmpc --- pkgs/stdenv/linux/make-bootstrap-tools-cross.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix index 065fb50c09ff7..de481bacf5c30 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix @@ -195,7 +195,7 @@ rec { LIBS="$(echo "$RELF" | grep 'Shared library' | sed 's,.*\[\([^]]*\)\].*,\1,')" for LIB in $LIBS; do # Find the libraries on the system - for LIBPATH in $(echo "$RPATH" | tr ':' ' '); do + for LIBPATH in $(echo "$RPATH:${libmpc}/lib" | tr ':' ' '); do if [ -f "$LIBPATH/$LIB" ]; then LIB="$LIBPATH/$LIB" break