From 3fb7b207726aa7500b761c7056f7dbf82ac5015d Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Mon, 17 May 2010 13:07:39 +0000 Subject: Merge #1050, #1052, #1053, #1054 into the main trunk. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3175 74dad513-b988-da41-8d7b-12977e46ad98 --- configure-iphone | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100755 configure-iphone (limited to 'configure-iphone') diff --git a/configure-iphone b/configure-iphone new file mode 100755 index 00000000..67d80dfd --- /dev/null +++ b/configure-iphone @@ -0,0 +1,128 @@ +#!/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 "" + exit 0 +fi + +# Set the main iPhone developer directory, if not set +if test "x${DEVPATH}" = "x"; then + DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer + 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 + 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}" + break + fi + done + if test ! "${CC}" = ""; then + echo "$F: CC is not specified, choosing ${CC}" + break + fi + done +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} ${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} -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 $* + +if test "$?" = "0"; then + echo "Done configuring for `basename $SDKPATH`" + echo "" +fi + -- cgit v1.2.3