Skip to content

Instantly share code, notes, and snippets.

@j0sh
Created March 31, 2011 07:05
Show Gist options
  • Save j0sh/895946 to your computer and use it in GitHub Desktop.
Save j0sh/895946 to your computer and use it in GitHub Desktop.
Sets up an autotoolized configure to cross-compile either an iOS device or simulator.
# Change the install prefix.
# Builds for i386 and ARMv7.
# Lipo them at your leisure.
PREFIX=/Users/josh/compiled
ERRSTR="Usage: ./ios-configure.sh <simulator | device>"
if [[ $# != 1 ]]; then
echo $ERRSTR
exit
fi
if [[ "$1" == simulator ]]; then
ARCH=i386
DEVICE=Simulator
HOST=i386
elif [[ "$1" == device ]]; then
ARCH=armv7
DEVICE=OS
CFLAGS_FLAGS="-mcpu=cortex-a8 -marm"
HOST=arm
else
echo $ERRSTR
exit
fi
DEVROOT=/Developer/Platforms/iPhone${DEVICE}.platform/Developer
SDKROOT=${DEVROOT}/SDKs/iPhone${DEVICE}4.3.sdk
export CFLAGS="-isysroot ${SDKROOT} ${CFLAGS_FLAGS}"
export LDFLAGS="-isysroot ${SDKROOT}"
./configure CC="${DEVROOT}/usr/bin/gcc -arch ${ARCH}" LD=$CC --host=${HOST}-apple-darwin --prefix=${PREFIX} --exec-prefix=${PREFIX}/${ARCH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment