5
if test "$*" = "--help" -o "$*" = "-h"; then
9
echo " OPTIONS Other options that will be passed directly to"
10
echo " ./aconfigure script. Run ./aconfigure --help"
11
echo " for more info."
13
echo "Environment variables:"
14
echo " IPHONESDK Optionally specify which SDK to use. Value is the full "
15
echo " path of the SDK. By default, the latest SDK installed"
17
echo " CC Optionally specify the path of the ARM cross compiler"
18
echo " to use. By default, the compiler is deduced from the"
20
echo " ARCH Optional flags to specify target architecture, e.g."
21
echo " ARCH='-arch armv6'"
26
# Set the main iPhone developer directory, if not set
27
if test "x${DEVPATH}" = "x"; then
28
DEVPATH=/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
29
if test ! -d $DEVPATH; then
30
DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer
32
echo "$F: DEVPATH is not specified, using ${DEVPATH}"
35
# Make sure $DEVPATH directory exist
36
if test ! -d $DEVPATH; then
37
echo "$F error: directory $DEVPATH does not exist. Please install iPhone development kit"
41
# Choose SDK version to use
42
if test "$IPHONESDK" = ""; then
43
# If IPHONESDK is not set, use the latest one
44
for f in `ls $DEVPATH/SDKs/`; do echo $f | sed 's/\(.sdk\)//'; done | sort | tail -1 > tmpsdkname
45
IPHONESDK=`cat tmpsdkname`.sdk
47
SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
48
echo "$F: IPHONESDK is not specified, choosing ${IPHONESDK}"
49
elif test -d ${IPHONESDK}; then
50
# .. else if IPHONESDK is set and it points to a valid path, just use it
53
# .. else assume the SDK name is used.
54
SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
57
# Test the SDK directory
58
if test ! -d ${SDKPATH}/usr/include; then
59
echo "$F error: unable to find valid iPhone SDK in ${SDKPATH}"
63
# Default CFLAGS if it's not specified
64
if test "$CFLAGS" = ""; then
65
CFLAGS="-O2 -Wno-unused-label"
68
# Default LDFLAGS if it's not specified
69
if test "$LDFLAGS" = ""; then
73
# Determine which gcc for this SDK. Binaries should have the
74
# full path as it's not normally in user's PATH
76
if test "${CC}" = ""; then
77
# Try to use llvm-gcc if available
78
gccpath="${DEVPATH}/usr/bin/llvm-gcc"
79
if test -e ${gccpath}; then
80
export CC="${gccpath}"
82
if test "${ARCH}" = ""; then
83
export ARCH="-arch armv7"
84
echo "$F: ARCH is not specified, choosing ${ARCH}"
87
for archpath in `ls -d ${SDKPATH}/usr/lib/gcc/arm-apple-darwin*`; do
88
archname=`basename ${archpath}`
89
for gccver in `ls ${archpath}`; do
90
gccpath="${DEVPATH}/usr/bin/${archname}-gcc-${gccver}"
91
if test -e ${gccpath}; then
92
export CC="${gccpath}"
97
if test ! "${CC}" = ""; then
98
echo "$F: CC is not specified, choosing ${CC}"
102
if test "${CC}" = ""; then
103
echo "$F error: unable to find gcc for ${IPHONESDK}. If you think you have the right gcc, set the full path in CC environment variable."
108
if test "${CXX}" = ""; then
109
export CXX=`echo ${CC} | sed 's/gcc/g++/'`
110
echo "$F: CXX is not specified, using ${CXX}"
113
# Other settings to feed to configure script.
115
export CFLAGS="${CFLAGS} -DPJ_SDK_NAME=\"\\\"`basename $SDKPATH`\\\"\" ${ARCH} -isysroot ${SDKPATH}"
116
export LDFLAGS="${LDFLAGS} ${ARCH} -isysroot ${SDKPATH} -framework AudioToolbox -framework Foundation"
117
export AR="${DEVPATH}/usr/bin/libtool -static -o"
118
export RANLIB="echo ranlib"
119
# Use gcc -E as preprocessor instead of cpp, since cpp will find the
120
# header files in standard /usr/include instead of in isysroot
121
export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}"
124
if test "1" = "1"; then
125
echo "$F: calling ./aconfigure with env vars:"
128
echo " SDKPATH = ${SDKPATH}"
129
echo " CFLAGS = ${CFLAGS}"
130
echo " LDFLAGS = ${LDFLAGS}"
132
echo " RANLIB = ${RANLIB}"
135
# And finally invoke the configure script itself
136
./aconfigure --host=arm-apple-darwin9 --disable-sdl $*
138
if test "$?" = "0"; then
139
echo "Done configuring for `basename $SDKPATH`"