Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 8cb4506b91
Fetching contributors…

Cannot retrieve contributors at this time

executable file 142 lines (120 sloc) 4.295 kb
#!/bin/bash
# ios-configure runs a "configure" script using the iOS 4.3 SDK, generating a
# static library that will load and run on your choice of iPhone, iPad, and
# their respective simulators.
#
# Simply run in the same directory as a "configure" script.
# You can run this script for multiple targets and use lipo(1) to stitch them
# together into a universal library.
#
# Collected and maintained by Nolan Waite (nolan@nolanw.ca)
#
# Magic compiler flags and incantations by Michael Aaron Safyan
# (michaelsafyan@gmail.com). Generality by Christopher J. Stawarz
# (http://pseudogreen.org/bzr/sandbox/iphone/build_for_iphoneos)
#
default_gcc_version=4.2
default_ios_version=`xcodebuild -showsdks | grep iphoneos | sed -e 's/.*iphoneos//' | tail -n 1`
default_min_ios_version=4.3
default_macosx_version=10.6
DEVELOPER=${DEVELOPER:-`xcode-select -print-path`}
GCC_VERSION="${GCC_VERSION:-$default_gcc_version}"
export IOS_VERSION="${IOS_VERSION:-$default_ios_version}"
export MIN_IOS_VERSION="${MIN_IOS_VERSION:-$default_min_ios_version}"
export MACOSX_VERSION="${MACOSX_VERSION:-$default_macosx_version}"
usage ()
{
cat >&2 << EOF
Usage: ${0##*/} [-h] [-p prefix] target [configure_args]
-h Print help message
-p Installation prefix
(default: `pwd`/build/[target]-[version])
-k The pkgconfig directory.
The target must be one of "iphone", "ipad", or "simulator". Any additional
arguments are passed to configure.
The following environment variables affect the build process:
GCC_VERSION (default: $default_gcc_version)
IOS_VERSION (default: $default_ios_version)
MIN_IOS_VERSION (default: $default_min_ios_version)
MACOSX_VERSION (default: $default_macosx_version)
EOF
}
extra_pkg_config=""
while getopts ":hp:tk:" opt; do
case $opt in
h ) usage ; exit 0 ;;
p ) prefix="$OPTARG" ;;
k ) extra_pkg_config="$OPTARG:" ;;
\? ) usage ; exit 2 ;;
esac
done
shift $(( $OPTIND - 1 ))
if (( $# < 1 )); then
usage
exit 2
fi
target=$1
shift
case $target in
iphone-armv6 )
arch=armv6
platform=iPhoneOS
host=arm-apple-darwin10
;;
iphone )
arch=armv7
platform=iPhoneOS
host=arm-apple-darwin10
;;
ipad )
arch=armv7
platform=iPhoneOS
host=arm-apple-darwin10
;;
simulator )
arch=i686
platform=iPhoneSimulator
host=i686-apple-darwin9
;;
* )
usage
exit 2
esac
export DEVROOT="${DEVELOPER}/Platforms/${platform}.platform/Developer"
export SDKROOT="$DEVROOT/SDKs/${platform}${IOS_VERSION}.sdk"
prefix="${prefix:-`pwd`/build/${target}-${IOS_VERSION}}"
if [ ! \( -d "$DEVROOT" \) ] ; then
echo "The iPhone SDK could not be found. Folder \"$DEVROOT\" does not exist."
exit 1
fi
if [ ! \( -d "$SDKROOT" \) ] ; then
echo "The iPhone SDK could not be found. Folder \"$SDKROOT\" does not exist."
exit 1
fi
if [ ! \( -x "./configure" \) ] ; then
echo "This script must be run in the folder containing the \"configure\" script."
exit 1
fi
export PKG_CONFIG_PATH="${extra_pkg_config}$SDKROOT/usr/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_PATH"
export AS="$DEVROOT/usr/bin/as"
export ASCPP="$DEVROOT/usr/bin/as"
export AR="$DEVROOT/usr/bin/ar"
export RANLIB="$DEVROOT/usr/bin/ranlib"
export CPPFLAGS="-miphoneos-version-min=${MIN_IOS_VERSION} -pipe -no-cpp-precomp -I$SDKROOT/usr/include"
export CFLAGS="$CPPFLAGS -g2 -std=c99 -arch ${arch} -isysroot $SDKROOT -isystem $SDKROOT/usr/include"
export CXXFLAGS="$CPPFLAGS -g2 -arch ${arch} -isysroot $SDKROOT -isystem $SDKROOT/usr/include"
export LDFLAGS="-miphoneos-version-min=${MIN_IOS_VERSION} -arch ${arch} -isysroot $SDKROOT -L$SDKROOT/usr/lib -L$DEVROOT/usr/lib"
export CPP="$DEVROOT/usr/bin/llvm-cpp-${GCC_VERSION}"
export CXXCPP="$DEVROOT/usr/bin/llvm-cpp-${GCC_VERSION}"
export CC="$DEVROOT/usr/bin/llvm-gcc-${GCC_VERSION}"
export CXX="$DEVROOT/usr/bin/llvm-g++-${GCC_VERSION}"
export LD="$DEVROOT/usr/bin/ld"
export STRIP="$DEVROOT/usr/bin/strip"
export ac_cv_func_malloc_0_nonnull=yes
./configure \
--prefix="$prefix" \
--host="${host}" \
--enable-static \
--disable-shared \
"$@" || exit
Jump to Line
Something went wrong with that request. Please try again.