diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2012-01-29 17:42:10 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2012-01-29 17:42:10 +0000 |
commit | 86ddf7c7a8abe74468d9fcbac8f512b9454f0bd2 (patch) | |
tree | 7c823bfd7ee483cb71f7474c17888a5e52558208 | |
parent | 8c4813b75e7f77ef7f1853a883e3019d0b688ee1 (diff) | |
download | mtk-20170518-86ddf7c7a8abe74468d9fcbac8f512b9454f0bd2.zip mtk-20170518-86ddf7c7a8abe74468d9fcbac8f512b9454f0bd2.tar.gz mtk-20170518-86ddf7c7a8abe74468d9fcbac8f512b9454f0bd2.tar.bz2 |
ext-toolchain.sh: support --wrap with src == dest
SVN-Revision: 29944
-rwxr-xr-x | scripts/ext-toolchain.sh | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index 257e0d8..23d14a7 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -205,11 +205,17 @@ wrap_bins() { for cmd in "${CC%-*}-"*; do if [ -x "$cmd" ]; then local out="$1/${cmd##*/}" + local bin="$cmd" + + if [ -x "$out" ] && ! grep -q STAGING_DIR "$out"; then + mv "$out" "$out.bin" + bin='$(dirname "$0")/'"${out##*/}"'.bin' + fi echo '#!/bin/sh' > "$out" case "${cmd##*/}" in *-*cc|*-*cc-*|*-*++|*-*++-*|*-cpp) - echo -n 'exec "'"$cmd"'" '"$CFLAGS"' ' >> "$out" + echo -n 'exec "'"$bin"'" '"$CFLAGS"' ' >> "$out" echo -n '${STAGING_DIR:+-idirafter ' >> "$out" echo -n '"$STAGING_DIR/usr/include" ' >> "$out" echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" @@ -217,13 +223,13 @@ wrap_bins() { echo '"$STAGING_DIR/usr/lib"} "$@"' >> "$out" ;; *-ld) - echo -n 'exec "'"$cmd"'" ${STAGING_DIR:+' >> "$out" + echo -n 'exec "'"$bin"'" ${STAGING_DIR:+' >> "$out" echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" echo -n '-rpath-link ' >> "$out" echo '"$STAGING_DIR/usr/lib"} "$@"' >> "$out" ;; *) - echo "exec '$cmd' \"\$@\"" >> "$out" + echo 'exec "'"$bin"'" "$@"' >> "$out" ;; esac chmod +x "$out" |