aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-01-29 17:42:58 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-01-29 17:42:58 +0000
commitd5cf09642c9ecb23029627707ff908d2fce70eea (patch)
tree10f2e7f9bcf286d3b5861a51d68c471226437657 /scripts
parent86ddf7c7a8abe74468d9fcbac8f512b9454f0bd2 (diff)
downloadupstream-d5cf09642c9ecb23029627707ff908d2fce70eea.tar.gz
upstream-d5cf09642c9ecb23029627707ff908d2fce70eea.tar.bz2
upstream-d5cf09642c9ecb23029627707ff908d2fce70eea.zip
patch-specs.sh: fallback to ext-toolchain.sh --wrap if spec file patching is not possible (gcc < 4.3.0)
SVN-Revision: 29945
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/patch-specs.sh96
1 files changed, 61 insertions, 35 deletions
diff --git a/scripts/patch-specs.sh b/scripts/patch-specs.sh
index 4d02a009ec..2ab779084b 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 | head -n1)"
+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