Michael ABBOTT reported that populate is not relocatable.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Aug 04 08:44:54 2008 +0000 (2008-08-04)
changeset 755c2212f59e1cf
parent 754 b13657cd64b3
child 756 63d3f428f302
Michael ABBOTT reported that populate is not relocatable.
Fix this by determining both the cross-readelf and the sys-root at runtime, not at build time.

/trunk/configure | 1 1 0 0 +
/trunk/scripts/crosstool.sh | 14 6 8 0 ++++++--------
/trunk/tools/populate.in | 6 4 2 0 ++++--
3 files changed, 11 insertions(+), 10 deletions(-)
configure
scripts/crosstool.sh
tools/populate.in
     1.1 --- a/configure	Fri Aug 01 09:23:58 2008 +0000
     1.2 +++ b/configure	Mon Aug 04 08:44:54 2008 +0000
     1.3 @@ -23,6 +23,7 @@
     1.4  tar
     1.5  gzip
     1.6  bzip2
     1.7 +readlink
     1.8  '
     1.9  
    1.10  PREFIX_DEFAULT=/usr/local
     2.1 --- a/scripts/crosstool.sh	Fri Aug 01 09:23:58 2008 +0000
     2.2 +++ b/scripts/crosstool.sh	Mon Aug 04 08:44:54 2008 +0000
     2.3 @@ -427,9 +427,9 @@
     2.4  
     2.5      # Install the /populator/
     2.6      CT_DoLog EXTRA "Installing the populate helper"
     2.7 -    sed -r -e 's,@@CT_READELF@@,'"${CT_PREFIX_DIR}/bin/${CT_TARGET}-readelf"',g;'   \
     2.8 -           -e 's,@@CT_SYSROOT_DIR@@,'"${CT_SYSROOT_DIR}"',g;'                       \
     2.9 -           "${CT_LIB_DIR}/tools/populate.in" >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    2.10 +    sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
    2.11 +        "${CT_LIB_DIR}/tools/populate.in"           \
    2.12 +        >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    2.13      chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    2.14  
    2.15      # Create the aliases to the target tools
    2.16 @@ -438,15 +438,13 @@
    2.17      for t in "${CT_TARGET}-"*; do
    2.18          if [ -n "${CT_TARGET_ALIAS}" ]; then
    2.19              _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
    2.20 -            CT_DoLog DEBUG "Linking '${_t}' -> '${t}'"
    2.21 -            ln -sv "${t}" "${_t}" 2>&1 |CT_DoLog ALL
    2.22 +            ln -sv "${t}" "${_t}" 2>&1
    2.23          fi
    2.24          if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
    2.25              _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
    2.26 -            CT_DoLog DEBUG "Linking '${_t}' -> '${t}'"
    2.27 -            ln -sv "${t}" "${_t}" 2>&1 |CT_DoLog ALL
    2.28 +            ln -sv "${t}" "${_t}" 2>&1
    2.29          fi
    2.30 -    done
    2.31 +    done |CT_DoLog ALL
    2.32      CT_Popd
    2.33      CT_EndStep
    2.34  
     3.1 --- a/tools/populate.in	Fri Aug 01 09:23:58 2008 +0000
     3.2 +++ b/tools/populate.in	Mon Aug 04 08:44:54 2008 +0000
     3.3 @@ -4,8 +4,10 @@
     3.4  # (C) 2007 Yann E. MORIN
     3.5  # Licensed under the GPL v2
     3.6  
     3.7 -CT_READELF="@@CT_READELF@@"
     3.8 -CT_SYSROOT_DIR="@@CT_SYSROOT_DIR@@"
     3.9 +# Detect where the toolchain is:
    3.10 +BIN_DIR="$(cd "$(dirname "$(readlink -fn "$0")")"; pwd)"
    3.11 +CT_READELF="${BIN_DIR}/@@CT_TARGET@@-readelf"
    3.12 +CT_SYSROOT_DIR="${BIN_DIR}/../@@CT_TARGET@@/sys-root"
    3.13  
    3.14  myname=$(basename "$0")
    3.15