Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 3 | F="configure-iphone" |
| 4 | |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 5 | if test "$*" = "--help" -o "$*" = "-h"; then |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 6 | echo "$F [OPTIONS]" |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 7 | echo "" |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 8 | echo "where:" |
| 9 | echo " OPTIONS Other options that will be passed directly to" |
| 10 | echo " ./aconfigure script. Run ./aconfigure --help" |
| 11 | echo " for more info." |
| 12 | echo "" |
| 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" |
| 16 | echo " will be used." |
| 17 | echo " CC Optionally specify the path of the ARM cross compiler" |
| 18 | echo " to use. By default, the compiler is deduced from the" |
| 19 | echo " SDK." |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 20 | echo "" |
| 21 | exit 0 |
| 22 | fi |
| 23 | |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 24 | # Set the main iPhone developer directory, if not set |
| 25 | if test "x${DEVPATH}" = "x"; then |
| 26 | DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 27 | echo "$F: DEVPATH is not specified, using ${DEVPATH}" |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 28 | fi |
| 29 | |
| 30 | # Make sure $DEVPATH directory exist |
| 31 | if test ! -d $DEVPATH; then |
| 32 | echo "$F error: directory $DEVPATH does not exist. Please install iPhone development kit" |
| 33 | exit 1 |
| 34 | fi |
| 35 | |
| 36 | # Choose SDK version to use |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 37 | if test "$IPHONESDK" = ""; then |
| 38 | # If IPHONESDK is not set, use the latest one |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 39 | for f in `ls $DEVPATH/SDKs/`; do echo $f | sed 's/\(.sdk\)//'; done | sort | tail -1 > tmpsdkname |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 40 | IPHONESDK=`cat tmpsdkname`.sdk |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 41 | rm -f tmpsdkname |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 42 | SDKPATH=${DEVPATH}/SDKs/${IPHONESDK} |
Benny Prijono | a9866ae | 2010-05-13 04:57:13 +0000 | [diff] [blame] | 43 | echo "$F: IPHONESDK is not specified, choosing ${IPHONESDK}" |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 44 | elif test -d ${IPHONESDK}; then |
| 45 | # .. else if IPHONESDK is set and it points to a valid path, just use it |
| 46 | SDKPATH=${IPHONESDK} |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 47 | else |
| 48 | # .. else assume the SDK name is used. |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 49 | SDKPATH=${DEVPATH}/SDKs/${IPHONESDK} |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 50 | fi |
| 51 | |
| 52 | # Test the SDK directory |
| 53 | if test ! -d ${SDKPATH}/usr/include; then |
| 54 | echo "$F error: unable to find valid iPhone SDK in ${SDKPATH}" |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 58 | # Default CFLAGS if it's not specified |
| 59 | if test "$CFLAGS" = ""; then |
| 60 | CFLAGS="-O2 -Wno-unused-label" |
| 61 | fi |
| 62 | |
| 63 | # Default LDFLAGS if it's not specified |
| 64 | if test "$LDFLAGS" = ""; then |
| 65 | LDFLAGS="-O2" |
| 66 | fi |
| 67 | |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 68 | # Determine which gcc for this SDK. Binaries should have the |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 69 | # full path as it's not normally in user's PATH |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 70 | |
| 71 | if test "${CC}" = ""; then |
| 72 | for archpath in `ls -d ${SDKPATH}/usr/lib/gcc/arm-apple-darwin*`; do |
| 73 | archname=`basename ${archpath}` |
| 74 | for gccver in `ls ${archpath}`; do |
| 75 | gccpath="${DEVPATH}/usr/bin/${archname}-gcc-${gccver}" |
| 76 | if test -e ${gccpath}; then |
| 77 | export CC="${gccpath}" |
| 78 | break |
| 79 | fi |
| 80 | done |
| 81 | if test ! "${CC}" = ""; then |
| 82 | echo "$F: CC is not specified, choosing ${CC}" |
| 83 | break |
| 84 | fi |
| 85 | done |
| 86 | fi |
| 87 | |
| 88 | if test "${CC}" = ""; then |
| 89 | 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." |
| 90 | exit 1 |
| 91 | fi |
| 92 | |
| 93 | # Set CXX if not set |
| 94 | if test "${CXX}" = ""; then |
| 95 | export CXX=`echo ${CC} | sed 's/gcc/g++/'` |
| 96 | echo "$F: CXX is not specified, using ${CXX}" |
| 97 | fi |
| 98 | |
| 99 | # Other settings to feed to configure script. |
Benny Prijono | a9866ae | 2010-05-13 04:57:13 +0000 | [diff] [blame] | 100 | #ARCH="-arch armv6" |
| 101 | export CFLAGS="${CFLAGS} ${ARCH} -isysroot ${SDKPATH}" |
| 102 | export LDFLAGS="${LDFLAGS} ${ARCH} -isysroot ${SDKPATH} -framework AudioToolbox -framework Foundation" |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 103 | export AR="${DEVPATH}/usr/bin/libtool -static -o" |
| 104 | export RANLIB="echo ranlib" |
| 105 | # Use gcc -E as preprocessor instead of cpp, since cpp will find the |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 106 | # header files in standard /usr/include instead of in isysroot |
| 107 | export CPP="${CC} -E -isysroot ${SDKPATH}" |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 108 | |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 109 | # Print settings |
| 110 | if test "1" = "1"; then |
Benny Prijono | a9866ae | 2010-05-13 04:57:13 +0000 | [diff] [blame] | 111 | echo "$F: calling ./aconfigure with env vars:" |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 112 | echo " CC = ${CC}" |
| 113 | echo " CXX = ${CXX}" |
| 114 | echo " SDKPATH = ${SDKPATH}" |
| 115 | echo " CFLAGS = ${CFLAGS}" |
Benny Prijono | a9866ae | 2010-05-13 04:57:13 +0000 | [diff] [blame] | 116 | echo " LDFLAGS = ${LDFLAGS}" |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 117 | echo " AR = ${AR}" |
Benny Prijono | a9866ae | 2010-05-13 04:57:13 +0000 | [diff] [blame] | 118 | echo " RANLIB = ${RANLIB}" |
Benny Prijono | c02fdd6 | 2010-05-13 04:35:16 +0000 | [diff] [blame] | 119 | fi |
| 120 | |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 121 | # And finally invoke the configure script itself |
Benny Prijono | 8ec5eae | 2010-05-12 10:59:20 +0000 | [diff] [blame] | 122 | ./aconfigure --host=arm-apple-darwin9 --disable-floating-point $* |
| 123 | |
Benny Prijono | fd71d3a | 2010-05-13 00:04:51 +0000 | [diff] [blame] | 124 | if test "$?" = "0"; then |
| 125 | echo "Done configuring for `basename $SDKPATH`" |
| 126 | echo "" |
| 127 | fi |
| 128 | |