1 | #! /bin/bash |
---|
2 | |
---|
3 | PREFIX="/opt/local" |
---|
4 | |
---|
5 | if [ "$ARCH" == "" ]; then |
---|
6 | ARCH="$(grep '^build_arch' $PREFIX/etc/macports/macports.conf \ |
---|
7 | | awk '{print $2}')" |
---|
8 | fi |
---|
9 | |
---|
10 | if [ "$OSVER" == "" ]; then |
---|
11 | OSFULLVER="$(sw_vers -productVersion)" |
---|
12 | if echo $OSFULLVER | egrep -q '[0-9]+[.][0-9]+[.][0-9]+'; then |
---|
13 | OSVER="$(echo $OSFULLVER | sed -E 's/[.][0-9]+$//')" |
---|
14 | else |
---|
15 | OSVER="$OSFULLVER" |
---|
16 | fi |
---|
17 | fi |
---|
18 | |
---|
19 | if [ "$CC" == "" ]; then |
---|
20 | case $OSVER in |
---|
21 | |
---|
22 | 10.4 ) |
---|
23 | export CC="$PREFIX/bin/gcc-apple-4.2" |
---|
24 | export TIGER="-Itiger_only/include" |
---|
25 | ;; |
---|
26 | |
---|
27 | 10.5 ) |
---|
28 | export CC="/Developer/usr/bin/gcc-4.2" |
---|
29 | ;; |
---|
30 | esac |
---|
31 | fi |
---|
32 | |
---|
33 | if echo $CC | grep -q "/clang" ; then |
---|
34 | export CXX="$(echo $CC | sed 's|/clang|/clang++|')" |
---|
35 | fi |
---|
36 | if echo $CC | grep -q "/gcc" ; then |
---|
37 | export CXX="$(echo $CC | sed 's|/gcc|/g++|')" |
---|
38 | fi |
---|
39 | if echo $CC | grep -q "/cc" ; then |
---|
40 | export CXX="$(echo $CC | sed 's|/cc|/c++|')" |
---|
41 | fi |
---|
42 | |
---|
43 | export CFLAGS="-arch $ARCH $CFLAGS $TIGER" |
---|
44 | export CXXFLAGS="-arch $ARCH $CXXFLAGS $TIGER" |
---|
45 | export LDFLAGS="-arch $ARCH $LDFLAGS" |
---|
46 | |
---|
47 | exec "$@" |
---|