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