2010-05-12 10:59:20 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2010-05-13 04:35:16 +00:00
|
|
|
F="configure-iphone"
|
|
|
|
|
2010-05-12 10:59:20 +00:00
|
|
|
if test "$*" = "--help" -o "$*" = "-h"; then
|
2010-05-13 04:35:16 +00:00
|
|
|
echo "$F [OPTIONS]"
|
2010-05-12 10:59:20 +00:00
|
|
|
echo ""
|
2010-05-13 04:35:16 +00:00
|
|
|
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."
|
2010-10-13 23:57:11 +00:00
|
|
|
echo " ARCH Optional flags to specify target architecture, e.g."
|
2019-06-21 04:30:42 +00:00
|
|
|
echo " ARCH=\"-arch armv7\". Default is arm64."
|
2016-10-07 05:49:14 +00:00
|
|
|
echo " MIN_IOS Optional flags to specify minimum supported iOS"
|
|
|
|
echo " versions, e.g. MIN_IOS=\"-miphoneos-version-min=10.0\". "
|
|
|
|
echo " Default is 7.0."
|
2010-05-12 10:59:20 +00:00
|
|
|
echo ""
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set the main iPhone developer directory, if not set
|
|
|
|
if test "x${DEVPATH}" = "x"; then
|
2012-03-30 07:10:13 +00:00
|
|
|
DEVPATH=/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer
|
|
|
|
if test ! -d $DEVPATH; then
|
|
|
|
DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer
|
|
|
|
fi
|
2010-05-13 04:35:16 +00:00
|
|
|
echo "$F: DEVPATH is not specified, using ${DEVPATH}"
|
2010-05-12 10:59:20 +00:00
|
|
|
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
|
2010-05-13 00:04:51 +00:00
|
|
|
if test "$IPHONESDK" = ""; then
|
|
|
|
# If IPHONESDK is not set, use the latest one
|
2010-05-12 10:59:20 +00:00
|
|
|
for f in `ls $DEVPATH/SDKs/`; do echo $f | sed 's/\(.sdk\)//'; done | sort | tail -1 > tmpsdkname
|
2010-05-13 00:04:51 +00:00
|
|
|
IPHONESDK=`cat tmpsdkname`.sdk
|
2010-05-12 10:59:20 +00:00
|
|
|
rm -f tmpsdkname
|
2010-05-13 00:04:51 +00:00
|
|
|
SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
|
2010-05-13 04:57:13 +00:00
|
|
|
echo "$F: IPHONESDK is not specified, choosing ${IPHONESDK}"
|
2010-05-13 00:04:51 +00:00
|
|
|
elif test -d ${IPHONESDK}; then
|
|
|
|
# .. else if IPHONESDK is set and it points to a valid path, just use it
|
|
|
|
SDKPATH=${IPHONESDK}
|
2010-05-12 10:59:20 +00:00
|
|
|
else
|
|
|
|
# .. else assume the SDK name is used.
|
2010-05-13 00:04:51 +00:00
|
|
|
SDKPATH=${DEVPATH}/SDKs/${IPHONESDK}
|
2010-05-12 10:59:20 +00:00
|
|
|
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
|
|
|
|
|
2010-05-13 00:04:51 +00:00
|
|
|
# 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
|
|
|
|
|
2013-09-06 02:10:48 +00:00
|
|
|
# Test the toolchain directory
|
|
|
|
TCPATH="${DEVPATH}/../../../Toolchains/XcodeDefault.xctoolchain"
|
|
|
|
if test ! -d ${TCPATH}/usr/bin; then
|
|
|
|
TCPATH="${DEVPATH}"
|
|
|
|
fi
|
|
|
|
|
2010-05-13 04:35:16 +00:00
|
|
|
# Determine which gcc for this SDK. Binaries should have the
|
2010-05-13 00:04:51 +00:00
|
|
|
# full path as it's not normally in user's PATH
|
2010-05-13 04:35:16 +00:00
|
|
|
|
|
|
|
if test "${CC}" = ""; then
|
2013-09-05 02:15:19 +00:00
|
|
|
# Try to use clang if available
|
2013-09-06 02:10:48 +00:00
|
|
|
ccpath="${TCPATH}/usr/bin/clang"
|
2013-09-05 02:15:19 +00:00
|
|
|
# Next, try to use llvm-gcc
|
2011-10-24 09:28:13 +00:00
|
|
|
gccpath="${DEVPATH}/usr/bin/llvm-gcc"
|
2013-09-05 02:15:19 +00:00
|
|
|
if test -e ${ccpath}; then
|
|
|
|
export CC="${ccpath}"
|
|
|
|
elif test -e ${gccpath}; then
|
2011-10-24 09:28:13 +00:00
|
|
|
export CC="${gccpath}"
|
|
|
|
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
|
2010-05-13 04:35:16 +00:00
|
|
|
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
|
|
|
|
|
2013-09-05 02:15:19 +00:00
|
|
|
if test "${ARCH}" = ""; then
|
2019-06-21 04:30:42 +00:00
|
|
|
export ARCH="-arch arm64"
|
2013-09-05 02:15:19 +00:00
|
|
|
echo "$F: ARCH is not specified, choosing ${ARCH}"
|
|
|
|
fi
|
2015-07-29 02:31:12 +00:00
|
|
|
export ARCH_VAL=`echo ${ARCH} | sed 's/\-arch //' | sed -e 's/^[ \t]*//;s/[ \t]*$//' `
|
2013-09-05 02:15:19 +00:00
|
|
|
|
2016-10-07 05:49:14 +00:00
|
|
|
if test "${MIN_IOS}" = ""; then
|
2017-01-31 08:19:50 +00:00
|
|
|
MIN_IOS_VER="7.0"
|
|
|
|
echo "$F: MIN_IOS is not specified, choosing ${MIN_IOS_VER}"
|
|
|
|
MIN_IOS="-miphoneos-version-min=${MIN_IOS_VER}"
|
2016-10-07 05:49:14 +00:00
|
|
|
fi
|
2017-01-31 08:19:50 +00:00
|
|
|
CFLAGS="${CFLAGS} ${MIN_IOS}"
|
|
|
|
LDFLAGS="${LDFLAGS} ${MIN_IOS}"
|
|
|
|
|
2016-10-07 05:49:14 +00:00
|
|
|
|
2010-05-13 04:35:16 +00:00
|
|
|
# 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.
|
2010-05-13 04:57:13 +00:00
|
|
|
#ARCH="-arch armv6"
|
2011-03-01 05:25:27 +00:00
|
|
|
export CFLAGS="${CFLAGS} -DPJ_SDK_NAME=\"\\\"`basename $SDKPATH`\\\"\" ${ARCH} -isysroot ${SDKPATH}"
|
2010-05-13 04:57:13 +00:00
|
|
|
export LDFLAGS="${LDFLAGS} ${ARCH} -isysroot ${SDKPATH} -framework AudioToolbox -framework Foundation"
|
2013-09-06 02:10:48 +00:00
|
|
|
export AR="${TCPATH}/usr/bin/libtool -static -o"
|
2013-10-23 08:39:04 +00:00
|
|
|
export AR_FLAGS=" "
|
2010-05-12 10:59:20 +00:00
|
|
|
export RANLIB="echo ranlib"
|
|
|
|
# Use gcc -E as preprocessor instead of cpp, since cpp will find the
|
2010-05-13 00:04:51 +00:00
|
|
|
# header files in standard /usr/include instead of in isysroot
|
2010-10-13 23:57:11 +00:00
|
|
|
export CPP="${CC} ${ARCH} -E -isysroot ${SDKPATH}"
|
2010-05-12 10:59:20 +00:00
|
|
|
|
2010-05-13 04:35:16 +00:00
|
|
|
# Print settings
|
|
|
|
if test "1" = "1"; then
|
2010-05-13 04:57:13 +00:00
|
|
|
echo "$F: calling ./aconfigure with env vars:"
|
2017-01-31 08:19:50 +00:00
|
|
|
echo " MIN_IOS = ${MIN_IOS}"
|
2010-05-13 04:35:16 +00:00
|
|
|
echo " CC = ${CC}"
|
|
|
|
echo " CXX = ${CXX}"
|
|
|
|
echo " SDKPATH = ${SDKPATH}"
|
|
|
|
echo " CFLAGS = ${CFLAGS}"
|
2010-05-13 04:57:13 +00:00
|
|
|
echo " LDFLAGS = ${LDFLAGS}"
|
2010-05-13 04:35:16 +00:00
|
|
|
echo " AR = ${AR}"
|
2010-05-13 04:57:13 +00:00
|
|
|
echo " RANLIB = ${RANLIB}"
|
2015-07-29 02:31:12 +00:00
|
|
|
echo " ARCH = ${ARCH_VAL}"
|
2010-05-13 04:35:16 +00:00
|
|
|
fi
|
|
|
|
|
2010-05-13 00:04:51 +00:00
|
|
|
# And finally invoke the configure script itself
|
2015-08-06 09:15:11 +00:00
|
|
|
./aconfigure --host=${ARCH_VAL}-apple-darwin_ios --disable-sdl $*
|
2010-05-12 10:59:20 +00:00
|
|
|
|
2010-05-13 00:04:51 +00:00
|
|
|
if test "$?" = "0"; then
|
|
|
|
echo "Done configuring for `basename $SDKPATH`"
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|