[toolchain/eglibc] eglibc 2.14 needs our eglibc patchset as well
[openwrt.git] / scripts / patch-specs.sh
1 #!/usr/bin/env bash
2
3 DIR="$1"
4 FOUND=0
5
6 if [ -d "$DIR" ]; then
7 DIR="$(cd "$DIR"; pwd)"
8 else
9 echo "Usage: $0 toolchain-dir"
10 exit 1
11 fi
12
13 echo -n "Locating cpp ... "
14 for bin in bin usr/bin usr/local/bin; do
15 for cmd in "$DIR/$bin/"*-cpp; do
16 if [ -x "$cmd" ]; then
17 echo "$cmd"
18 CPP="$cmd"
19 break
20 fi
21 done
22 done
23
24 if [ ! -x "$CPP" ]; then
25 echo "Can't locate a cpp executable in '$DIR' !"
26 exit 1
27 fi
28
29 for lib in $(STAGING_DIR="$dir" "$CPP" -x c -v /dev/null 2>&1 | sed -ne 's#:# #g; s#^LIBRARY_PATH=##p'); do
30 if [ -d "$lib" ]; then
31 grep -qs "STAGING_DIR" "$lib/specs" && rm -f "$lib/specs"
32 if [ $FOUND -lt 1 ]; then
33 echo -n "Patching specs ... "
34 STAGING_DIR="$dir" "$CPP" -dumpspecs | awk '
35 mode ~ "link" {
36 sub("%{L.}", "%{L*} -L %:getenv(STAGING_DIR /usr/lib) -rpath-link %:getenv(STAGING_DIR /usr/lib)")
37 }
38 mode ~ "cpp" {
39 $0 = $0 " -idirafter %:getenv(STAGING_DIR /usr/include)"
40 }
41 {
42 print $0
43 mode = ""
44 }
45 /^\*cpp:/ {
46 mode = "cpp"
47 }
48 /^\*link.*:/ {
49 mode = "link"
50 }
51 ' > "$lib/specs"
52 echo "ok"
53 FOUND=1
54 fi
55 fi
56 done
57
58 if [ $FOUND -lt 1 ]; then
59 echo "Failed to locate library directory!"
60 exit 1
61 else
62 echo "Toolchain successfully patched."
63 exit 0
64 fi
This page took 0.047666 seconds and 5 git commands to generate.