scripts/populate: properly locate the sysroot and required tools
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Mar 25 22:42:00 2010 +0100 (2010-03-25)
changeset 1861a5c020c3d31d
parent 1860 ed94d8e12b63
child 1862 7fec5db8933c
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).
scripts/populate.in
     1.1 --- a/scripts/populate.in	Wed Mar 24 22:36:51 2010 +0100
     1.2 +++ b/scripts/populate.in	Thu Mar 25 22:42:00 2010 +0100
     1.3 @@ -4,20 +4,32 @@
     1.4  # Licensed under the GPL v2
     1.5  set -e
     1.6  
     1.7 -# Detect where the toolchain is:
     1.8 -CT_PREFIX_DIR="$(cd "$(dirname "$0")/.."; pwd)"
     1.9 -CT_BIN_DIR="${CT_PREFIX_DIR}/bin"
    1.10 -CT_READELF="${CT_BIN_DIR}/@@CT_TARGET@@-readelf"
    1.11 -CT_LIB_DIR="${CT_PREFIX_DIR}/lib"
    1.12 -CT_SYSROOT_DIR="$(cd "${CT_BIN_DIR}/../@@CT_TARGET@@/sys-root"; pwd)"
    1.13 -
    1.14 -myname=$(basename "$0")
    1.15 -
    1.16  # Use the tools discovered by crosstool-NG's ./configure:
    1.17  install="@@CT_install@@"
    1.18  grep="@@CT_grep@@"
    1.19  sed="@@CT_sed@@"
    1.20  
    1.21 +# Detect where the toolchain is:
    1.22 +CT_PREFIX_DIR="$(cd "$(dirname "$0")/.."; pwd)"
    1.23 +CT_GCC="${0%-populate}-gcc"
    1.24 +CT_READELF="${0%-populate}-readelf"
    1.25 +CT_CFG_PREFIX_DIR="$("${CT_GCC}" -v 2>&1            \
    1.26 +                     |tr ' ' '\n'                   \
    1.27 +                     |"${grep}" -E -- '--prefix='   \
    1.28 +                     |cut -d = -f 2-
    1.29 +                    )"
    1.30 +CT_CFG_SYSROOT_DIR="$("${CT_GCC}" -v 2>&1                   \
    1.31 +                      |tr ' ' '\n'                          \
    1.32 +                      |"${grep}" -E -- '--with-sysroot='    \
    1.33 +                      |cut -d = -f 2-
    1.34 +                     )"
    1.35 +CT_SYSROOT_DIR="$(echo "${CT_CFG_SYSROOT_DIR}"                                  \
    1.36 +                  |"${sed}" -r -e "s:^${CT_CFG_PREFIX_DIR}:${CT_PREFIX_DIR}:;"  \
    1.37 +                  |"${sed}" -r -e 's,/+,/,g;'                                   \
    1.38 +                 )"
    1.39 +
    1.40 +myname=$(basename "$0")
    1.41 +
    1.42  doHelp() {
    1.43      cat <<_EOF_
    1.44  NAME