1 | #!/bin/bash -e |
---|
2 | |
---|
3 | # Configuration |
---|
4 | # TODO: configure absolute paths at install |
---|
5 | LD='/opt/local/bin/ld-latest' |
---|
6 | LD_97='/opt/local/bin/ld-97' |
---|
7 | LD_127='/opt/local/bin/ld-127' |
---|
8 | PPC_ARCHS='ppc ppc64 ppc750 ppc7400 ppc7450 ppc970' |
---|
9 | |
---|
10 | # Check for -v, -arch, and -macosx_version_min options |
---|
11 | for optarg in "$@"; do |
---|
12 | case "$option" in |
---|
13 | -arch) |
---|
14 | arch="$optarg" |
---|
15 | ;; |
---|
16 | -macosx_version_min) |
---|
17 | minor_version="${optarg#10.}" |
---|
18 | minor_version="${minor_version%%.*}" |
---|
19 | ;; |
---|
20 | esac |
---|
21 | option="$optarg" |
---|
22 | case "$option" in |
---|
23 | -v) |
---|
24 | verbose=1 |
---|
25 | ;; |
---|
26 | esac |
---|
27 | done |
---|
28 | |
---|
29 | # Switch to older ld version for ppc |
---|
30 | if [ "$arch" = 'ppc' ]; then |
---|
31 | if [ "$minor_version" -le 4 ] 2>/dev/null; then |
---|
32 | if [ -x "$LD_97" ]; then |
---|
33 | LD="$LD_97" |
---|
34 | else |
---|
35 | printf >&2 'requires ld-97\n' |
---|
36 | exit 1 |
---|
37 | fi |
---|
38 | else |
---|
39 | if [ -x "$LD_127" ]; then |
---|
40 | LD="$LD_127" |
---|
41 | elif [ -x "$LD_97" ]; then |
---|
42 | LD="$LD_97" |
---|
43 | else |
---|
44 | printf >&2 'requires ld-127 or ld-97\n' |
---|
45 | exit 1 |
---|
46 | fi |
---|
47 | fi |
---|
48 | fi |
---|
49 | |
---|
50 | # Filter stderr in verbose mode to add ppc to list of supported archs |
---|
51 | if [ $verbose ]; then |
---|
52 | # note: process substitution is not specified by POSIX |
---|
53 | exec 2> >(sed "s/^configured to support archs: /&$PPC_ARCHS /" >&2) |
---|
54 | fi |
---|
55 | |
---|
56 | exec "$LD" "$@" |
---|