summaryrefslogtreecommitdiff
path: root/configure-iphone
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-01-07 14:24:28 -0600
committerDavid M. Lee <dlee@digium.com>2013-01-07 14:24:28 -0600
commitf3ab456a17af1c89a6e3be4d20c5944853df1cb0 (patch)
treed00e1a332cd038a6d906a1ea0ac91e1a4458e617 /configure-iphone
Import pjproject-2.0.1
Diffstat (limited to 'configure-iphone')
-rwxr-xr-xconfigure-iphone142
1 files changed, 142 insertions, 0 deletions
diff --git a/configure-iphone b/configure-iphone
new file mode 100755
index 0000000..742dce0
--- /dev/null
+++ b/configure-iphone
@@ -0,0 +1,142 @@
+#!/bin/bash
+
+F="configure-iphone"
+
+if test "$*" = "--help" -o "$*" = "-h"; then
+ echo "$F [OPTIONS]"
+ echo ""
+ echo "where:"
+ echo " OPTIONS Other options that will be passed directly to"
+ echo " ./aconfigure script. Run ./aconfigure --help"
+ echo " for more info."
+ echo ""
+ echo "Environment variables:"
+ echo " IPHONESDK Optionally specify which SDK to use. Value is the full "
+ echo " path of the SDK. By default, the latest SDK installed"
+ echo " will be used."
+ echo " CC Optionally specify the path of the ARM cross compiler"
+ echo " to use. By default, the compiler is deduced from the"
+ echo " SDK."
+ echo " ARCH Optional flags to specify target architecture, e.g."
+ echo " ARCH='-arch armv6'"
+ echo ""
+ exit 0
+fi
+
+# Set the main iPhone developer directory, if not set
+if test "x${DEVPATH}" = "x"; then
+ DEVPATH=/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
+ if test ! -d $DEVPATH; then
+ DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer
+ fi
+ echo "$F: DEVPATH is not specified, using ${DEVPATH}"
+fi
+
+# Make sure $DEVPATH directory exist
+if test ! -d $DEVPATH; then
+ echo "$F error: directory $DEVPATH does not exist. Please install iPhone development kit"
+ exit 1
+fi
+
+# Choose SDK version to use
+if test "$IPHONESDK" = ""; then
+ # If IPHONESDK is not set, use the latest one
+ for f in `ls $DEVPATH/SDKs/`; do echo $f | sed 's/\(.sdk\)//'; done | sort | tail -1 > tmpsdkname
+ IPHONESDK=`cat tmpsdkname`.sdk
+ rm -f tmpsdkname
+ SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
+ echo "$F: IPHONESDK is not specified, choosing ${IPHONESDK}"
+elif test -d ${IPHONESDK}; then
+ # .. else if IPHONESDK is set and it points to a valid path, just use it
+ SDKPATH=${IPHONESDK}
+else
+ # .. else assume the SDK name is used.
+ SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
+fi
+
+# Test the SDK directory
+if test ! -d ${SDKPATH}/usr/include; then
+ echo "$F error: unable to find valid iPhone SDK in ${SDKPATH}"
+ exit 1
+fi
+
+# Default CFLAGS if it's not specified
+if test "$CFLAGS" = ""; then
+ CFLAGS="-O2 -Wno-unused-label"
+fi
+
+# Default LDFLAGS if it's not specified
+if test "$LDFLAGS" = ""; then
+ LDFLAGS="-O2"
+fi
+
+# Determine which gcc for this SDK. Binaries should have the
+# full path as it's not normally in user's PATH
+
+if test "${CC}" = ""; then
+ # Try to use llvm-gcc if available
+ gccpath="${DEVPATH}/usr/bin/llvm-gcc"
+ if test -e ${gccpath}; then
+ export CC="${gccpath}"
+
+ if test "${ARCH}" = ""; then
+ export ARCH="-arch armv7"
+ echo "$F: ARCH is not specified, choosing ${ARCH}"
+ fi
+ else
+ for archpath in `ls -d ${SDKPATH}/usr/lib/gcc/arm-apple-darwin*`; do
+ archname=`basename ${archpath}`
+ for gccver in `ls ${archpath}`; do
+ gccpath="${DEVPATH}/usr/bin/${archname}-gcc-${gccver}"
+ if test -e ${gccpath}; then
+ export CC="${gccpath}"
+ fi
+ done
+ done
+ fi
+ if test ! "${CC}" = ""; then
+ echo "$F: CC is not specified, choosing ${CC}"
+ fi
+fi
+
+if test "${CC}" = ""; then
+ 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."
+ exit 1
+fi
+
+# Set CXX if not set
+if test "${CXX}" = ""; then
+ export CXX=`echo ${CC} | sed 's/gcc/g++/'`
+ echo "$F: CXX is not specified, using ${CXX}"
+fi
+
+# Other settings to feed to configure script.
+#ARCH="-arch armv6"
+export CFLAGS="${CFLAGS} -DPJ_SDK_NAME=\"\\\"`basename $SDKPATH`\\\"\" ${ARCH} -isysroot ${SDKPATH}"
+export LDFLAGS="${LDFLAGS} ${ARCH} -isysroot ${SDKPATH} -framework AudioToolbox -framework Foundation"
+export AR="${DEVPATH}/usr/bin/libtool -static -o"
+export RANLIB="echo ranlib"
+# Use gcc -E as preprocessor instead of cpp, since cpp will find the
+# header files in standard /usr/include instead of in isysroot
+export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}"
+
+# Print settings
+if test "1" = "1"; then
+ echo "$F: calling ./aconfigure with env vars:"
+ echo " CC = ${CC}"
+ echo " CXX = ${CXX}"
+ echo " SDKPATH = ${SDKPATH}"
+ echo " CFLAGS = ${CFLAGS}"
+ echo " LDFLAGS = ${LDFLAGS}"
+ echo " AR = ${AR}"
+ echo " RANLIB = ${RANLIB}"
+fi
+
+# And finally invoke the configure script itself
+./aconfigure --host=arm-apple-darwin9 --disable-floating-point --disable-sdl $*
+
+if test "$?" = "0"; then
+ echo "Done configuring for `basename $SDKPATH`"
+ echo ""
+fi
+