From f36ceb7f544f2d5d993c09b316892dad43503da5 Mon Sep 17 00:00:00 2001 From: "Yann E. MORIN\"" Date: Thu, 25 Mar 2010 22:42:00 +0100 Subject: scripts/populate: properly locate the sysroot and required tools This fixes two problems: - the sysroot might be in a sub-directory (think SYSROOT_DIR_PREFIX) - it is not needed to have the target tuple to properly detect the sysroot and the required tools As a side effect, this script is now no longer dependent on the target tuple, and in the future, we might be able to share it across many toolchains (when/if we can install all of them in the same place). diff --git a/scripts/populate.in b/scripts/populate.in index 703b3b6..027303d 100644 --- a/scripts/populate.in +++ b/scripts/populate.in @@ -4,20 +4,32 @@ # Licensed under the GPL v2 set -e -# Detect where the toolchain is: -CT_PREFIX_DIR="$(cd "$(dirname "$0")/.."; pwd)" -CT_BIN_DIR="${CT_PREFIX_DIR}/bin" -CT_READELF="${CT_BIN_DIR}/@@CT_TARGET@@-readelf" -CT_LIB_DIR="${CT_PREFIX_DIR}/lib" -CT_SYSROOT_DIR="$(cd "${CT_BIN_DIR}/../@@CT_TARGET@@/sys-root"; pwd)" - -myname=$(basename "$0") - # Use the tools discovered by crosstool-NG's ./configure: install="@@CT_install@@" grep="@@CT_grep@@" sed="@@CT_sed@@" +# Detect where the toolchain is: +CT_PREFIX_DIR="$(cd "$(dirname "$0")/.."; pwd)" +CT_GCC="${0%-populate}-gcc" +CT_READELF="${0%-populate}-readelf" +CT_CFG_PREFIX_DIR="$("${CT_GCC}" -v 2>&1 \ + |tr ' ' '\n' \ + |"${grep}" -E -- '--prefix=' \ + |cut -d = -f 2- + )" +CT_CFG_SYSROOT_DIR="$("${CT_GCC}" -v 2>&1 \ + |tr ' ' '\n' \ + |"${grep}" -E -- '--with-sysroot=' \ + |cut -d = -f 2- + )" +CT_SYSROOT_DIR="$(echo "${CT_CFG_SYSROOT_DIR}" \ + |"${sed}" -r -e "s:^${CT_CFG_PREFIX_DIR}:${CT_PREFIX_DIR}:;" \ + |"${sed}" -r -e 's,/+,/,g;' \ + )" + +myname=$(basename "$0") + doHelp() { cat <<_EOF_ NAME -- cgit v0.10.2-6-g49f6