X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=scripts%2Fext-toolchain.sh;h=ee7d9532f5de79588900920e73046221679541b7;hp=616b54f21f04c808307d098dd508cec371558c17;hb=3262fce1cd12cd9dbd3b3e50d034233b2b884101;hpb=ee62b0d75163567b5eefa63871a33d4882eb6fd5 diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh index 616b54f21f..ee7d9532f5 100755 --- a/scripts/ext-toolchain.sh +++ b/scripts/ext-toolchain.sh @@ -3,7 +3,7 @@ # Script for various external toolchain tasks, refer to # the --help output for more information. # -# Copyright (C) 2012 Jo-Philipp Wich +# Copyright (C) 2012 Jo-Philipp Wich # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,9 +35,11 @@ LIB_SPECS=" rt: librt-* librt pthread: libpthread-* libpthread stdcpp: libstdc++ + thread_db: libthread-db gcc: libgcc_s ssp: libssp gfortran: libgfortran + gomp: libgomp " # Binary specs @@ -91,7 +93,7 @@ test_uclibc() { local sysroot="$("$CC" $CFLAGS -print-sysroot 2>/dev/null)" if [ -d "${sysroot:-$TOOLCHAIN}" ]; then local lib - for lib in "${sysroot:-$TOOLCHAIN}"/{lib,usr/lib,usr/local/lib}/ld-uClibc*.so*; do + for lib in "${sysroot:-$TOOLCHAIN}"/{lib,usr/lib,usr/local/lib}/ld*-uClibc*.so*; do if [ -f "$lib" ] && [ ! -h "$lib" ]; then return 0 fi @@ -197,6 +199,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"'" ${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 +248,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 @@ -308,9 +347,9 @@ print_config() { fi if test_feature "locale"; then - echo "CONFIG_NLS=y" >> "$config" + echo "CONFIG_BUILD_NLS=y" >> "$config" else - echo "# CONFIG_NLS is not set" >> "$config" + echo "# CONFIG_BUILD_NLS is not set" >> "$config" fi echo "CONFIG_DEVEL=y" >> "$config" @@ -319,8 +358,12 @@ print_config() { echo "CONFIG_TOOLCHAIN_PREFIX=\"$prefix\"" >> "$config" echo "CONFIG_TARGET_NAME=\"$target\"" >> "$config" + if [ "$LIBC_TYPE" != glibc ]; then + echo "CONFIG_TOOLCHAIN_LIBC=\"$LIBC_TYPE\"" >> "$config" + fi + local lib - for lib in C RT PTHREAD GCC STDCPP SSP GFORTRAN; do + for lib in C RT PTHREAD GCC STDCPP SSP GFORTRAN GOMP; do local file local spec="" local llib="$(echo "$lib" | sed -e 's#.*#\L&#')"