6 DIR="$(cd "$DIR"; pwd)"
8 echo "Usage: $0 toolchain-dir"
12 echo -n "Locating cpp ... "
13 for bin in bin usr/bin usr/local/bin; do
14 for cmd in "$DIR/$bin/"*-cpp; do
15 if [ -x "$cmd" ]; then
23 if [ ! -x "$CPP" ]; then
24 echo "Can't locate a cpp executable in '$DIR' !"
31 for lib in $(STAGING_DIR="$DIR" "$CPP" -x c -v /dev/null 2>&1 | sed -ne 's#:# #g; s#^LIBRARY_PATH=##p'); do
32 if [ -d "$lib" ]; then
33 grep -qs "STAGING_DIR" "$lib/specs" && rm -f "$lib/specs"
34 if [ $found -lt 1 ]; then
35 echo -n "Patching specs ... "
36 STAGING_DIR="$DIR" "$CPP" -dumpspecs | awk '
38 sub("%{L.}", "%{L*} -L %:getenv(STAGING_DIR /usr/lib) -rpath-link %:getenv(STAGING_DIR /usr/lib)")
41 $0 = $0 " -idirafter %:getenv(STAGING_DIR /usr/include)"
65 VERSION="$(STAGING_DIR="$DIR" "$CPP" --version | sed -ne 's/^.* (.*) //; s/ .*$//; 1p')"
66 VERSION="${VERSION:-unknown}"
68 case "${VERSION##* }" in
69 2.*|3.*|4.0.*|4.1.*|4.2.*)
70 echo "The compiler version does not support getenv() in spec files."
71 echo -n "Wrapping binaries instead ... "
73 if "${0%/*}/ext-toolchain.sh" --toolchain "$DIR" --wrap "${CPP%/*}"; then
83 echo "Toolchain successfully patched."
86 echo "Failed to locate library directory!"