1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-27 18:23:09 +02:00

[scripts] patch-specs.sh: fallback to ext-toolchain.sh --wrap if spec file patching is not possible (gcc < 4.3.0)

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29945 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2012-01-29 17:42:58 +00:00
parent 33451c5fb0
commit e23aeca7d2

View File

@ -1,7 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
DIR="$1" DIR="$1"
FOUND=0
if [ -d "$DIR" ]; then if [ -d "$DIR" ]; then
DIR="$(cd "$DIR"; pwd)" DIR="$(cd "$DIR"; pwd)"
@ -26,12 +25,15 @@ if [ ! -x "$CPP" ]; then
exit 1 exit 1
fi fi
for lib in $(STAGING_DIR="$dir" "$CPP" -x c -v /dev/null 2>&1 | sed -ne 's#:# #g; s#^LIBRARY_PATH=##p'); do 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 if [ -d "$lib" ]; then
grep -qs "STAGING_DIR" "$lib/specs" && rm -f "$lib/specs" grep -qs "STAGING_DIR" "$lib/specs" && rm -f "$lib/specs"
if [ $FOUND -lt 1 ]; then if [ $found -lt 1 ]; then
echo -n "Patching specs ... " echo -n "Patching specs ... "
STAGING_DIR="$dir" "$CPP" -dumpspecs | awk ' STAGING_DIR="$DIR" "$CPP" -dumpspecs | awk '
mode ~ "link" { mode ~ "link" {
sub("%{L.}", "%{L*} -L %:getenv(STAGING_DIR /usr/lib) -rpath-link %:getenv(STAGING_DIR /usr/lib)") sub("%{L.}", "%{L*} -L %:getenv(STAGING_DIR /usr/lib) -rpath-link %:getenv(STAGING_DIR /usr/lib)")
} }
@ -50,15 +52,39 @@ for lib in $(STAGING_DIR="$dir" "$CPP" -x c -v /dev/null 2>&1 | sed -ne 's#:# #g
} }
' > "$lib/specs" ' > "$lib/specs"
echo "ok" echo "ok"
FOUND=1 found=1
fi fi
fi fi
done done
if [ $FOUND -lt 1 ]; then [ $found -gt 0 ]
echo "Failed to locate library directory!" return $?
exit 1 }
else
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." echo "Toolchain successfully patched."
exit 0 exit 0
fi else
echo "Failed to locate library directory!"
exit 1
fi
;;
esac