From 204ac8784f6553146b2c2a582fbe1b9d793ee1ad Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 29 Jan 2012 20:21:46 +0000 Subject: [PATCH] scripts: merge r29944 - r29948 SVN-Revision: 29949 --- scripts/download.pl | 2 - scripts/ext-toolchain.sh | 63 ++++++++++++++++++++------ scripts/patch-specs.sh | 96 +++++++++++++++++++++++++--------------- 3 files changed, 111 insertions(+), 50 deletions(-) diff --git a/scripts/download.pl b/scripts/download.pl index 50ecfc6966..912d21bb08 100755 --- a/scripts/download.pl +++ b/scripts/download.pl @@ -142,8 +142,6 @@ foreach my $mirror (@ARGV) { push @extra, "$extra[0]/longterm/v$1"; } foreach my $dir (@extra) { - push @mirrors, "ftp://ftp.geo.kernel.org/pub/$dir"; - push @mirrors, "http://ftp.geo.kernel.org/pub/$dir"; push @mirrors, "ftp://ftp.all.kernel.org/pub/$dir"; push @mirrors, "http://ftp.all.kernel.org/pub/$dir"; push @mirrors, "ftp://ftp.de.kernel.org/pub/$dir"; diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index 257e0d8e82..a34ef06773 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -197,6 +197,47 @@ find_bins() { } +wrap_bin_cc() { + local out="$1" + local bin="$2" + + echo '#!/bin/sh' > "$out" + echo 'for arg in "$@"; do' >> "$out" + echo ' case "$arg" in -l*|-L*|-shared|-static)' >> "$out" + echo -n ' exec "'"$bin"'" '"$CFLAGS"' ${STAGING_DIR:+' >> "$out" + echo -n '-idirafter "$STAGING_DIR/usr/include" ' >> "$out" + echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" + echo '-Wl,-rpath-link,"$STAGING_DIR/usr/lib"} "$@" ;;' >> "$out" + echo ' esac' >> "$out" + echo 'done' >> "$out" + echo -n 'exec "'"$bin"'" '"$CFLAGS"' ${STAGING_DIR:+' >> "$out" + echo '-idirafter "$STAGING_DIR/usr/include"} "$@"' >> "$out" + + chmod +x "$out" +} + +wrap_bin_ld() { + local out="$1" + local bin="$2" + + echo '#!/bin/sh' > "$out" + echo -n 'exec "'"$bin"'" '"$CFLAGS"' ${STAGING_DIR:+' >> "$out" + echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" + echo '-rpath-link "$STAGING_DIR/usr/lib"} "$@"' >> "$out" + + chmod +x "$out" +} + +wrap_bin_other() { + local out="$1" + local bin="$2" + + echo '#!/bin/sh' > "$out" + echo 'exec "'"$bin"'" "$@"' >> "$out" + + chmod +x "$out" +} + wrap_bins() { if probe_cc; then mkdir -p "$1" || return 1 @@ -205,28 +246,24 @@ 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 '${STAGING_DIR:+-idirafter ' >> "$out" - echo -n '"$STAGING_DIR/usr/include" ' >> "$out" - echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" - echo -n '-Wl,-rpath-link,' >> "$out" - echo '"$STAGING_DIR/usr/lib"} "$@"' >> "$out" + wrap_bin_cc "$out" "$bin" ;; *-ld) - echo -n 'exec "'"$cmd"'" ${STAGING_DIR:+' >> "$out" - echo -n '-L "$STAGING_DIR/usr/lib" ' >> "$out" - echo -n '-rpath-link ' >> "$out" - echo '"$STAGING_DIR/usr/lib"} "$@"' >> "$out" + wrap_bin_ld "$out" "$bin" ;; *) - echo "exec '$cmd' \"\$@\"" >> "$out" + wrap_bin_other "$out" "$bin" ;; esac - chmod +x "$out" fi done diff --git a/scripts/patch-specs.sh b/scripts/patch-specs.sh index 4d02a009ec..3307b6b090 100755 --- a/scripts/patch-specs.sh +++ b/scripts/patch-specs.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash DIR="$1" -FOUND=0 if [ -d "$DIR" ]; then DIR="$(cd "$DIR"; pwd)" @@ -26,39 +25,66 @@ if [ ! -x "$CPP" ]; then exit 1 fi -for lib in $(STAGING_DIR="$dir" "$CPP" -x c -v /dev/null 2>&1 | sed -ne 's#:# #g; s#^LIBRARY_PATH=##p'); do - if [ -d "$lib" ]; then - grep -qs "STAGING_DIR" "$lib/specs" && rm -f "$lib/specs" - if [ $FOUND -lt 1 ]; then - echo -n "Patching specs ... " - STAGING_DIR="$dir" "$CPP" -dumpspecs | awk ' - mode ~ "link" { - sub("%{L.}", "%{L*} -L %:getenv(STAGING_DIR /usr/lib) -rpath-link %:getenv(STAGING_DIR /usr/lib)") - } - mode ~ "cpp" { - $0 = $0 " -idirafter %:getenv(STAGING_DIR /usr/include)" - } - { - print $0 - mode = "" - } - /^\*cpp:/ { - mode = "cpp" - } - /^\*link.*:/ { - mode = "link" - } - ' > "$lib/specs" - echo "ok" - FOUND=1 +patch_specs() { + local found=0 + + for lib in $(STAGING_DIR="$DIR" "$CPP" -x c -v /dev/null 2>&1 | sed -ne 's#:# #g; s#^LIBRARY_PATH=##p'); do + if [ -d "$lib" ]; then + grep -qs "STAGING_DIR" "$lib/specs" && rm -f "$lib/specs" + if [ $found -lt 1 ]; then + echo -n "Patching specs ... " + STAGING_DIR="$DIR" "$CPP" -dumpspecs | awk ' + mode ~ "link" { + sub("%{L.}", "%{L*} -L %:getenv(STAGING_DIR /usr/lib) -rpath-link %:getenv(STAGING_DIR /usr/lib)") + } + mode ~ "cpp" { + $0 = $0 " -idirafter %:getenv(STAGING_DIR /usr/include)" + } + { + print $0 + mode = "" + } + /^\*cpp:/ { + mode = "cpp" + } + /^\*link.*:/ { + mode = "link" + } + ' > "$lib/specs" + echo "ok" + found=1 + fi fi - fi -done + done -if [ $FOUND -lt 1 ]; then - echo "Failed to locate library directory!" - exit 1 -else - echo "Toolchain successfully patched." - exit 0 -fi + [ $found -gt 0 ] + return $? +} + + +VERSION="$(STAGING_DIR="$DIR" "$CPP" --version | sed -ne 's/^.* (.*) //; s/ .*$//; 1p')" +VERSION="${VERSION:-unknown}" + +case "${VERSION##* }" in + 2.*|3.*|4.0.*|4.1.*|4.2.*) + echo "The compiler version does not support getenv() in spec files." + echo -n "Wrapping binaries instead ... " + + if "${0%/*}/ext-toolchain.sh" --toolchain "$DIR" --wrap "${CPP%/*}"; then + echo "ok" + exit 0 + else + echo "failed" + exit $? + fi + ;; + *) + if patch_specs; then + echo "Toolchain successfully patched." + exit 0 + else + echo "Failed to locate library directory!" + exit 1 + fi + ;; +esac -- 2.30.2