Skip to content

Instantly share code, notes, and snippets.

@swisspol
Last active March 21, 2018 08:50
Show Gist options
  • Save swisspol/8498104 to your computer and use it in GitHub Desktop.
Save swisspol/8498104 to your computer and use it in GitHub Desktop.
Tentative build script to build libjpeg-turbo for iOS devices
#!/bin/sh -ex
DEVELOPER=`xcode-select --print-path`
PLATFORM="iPhoneOS"
ARCH="armv7"
IPHONE_SDK="7.0"
IPHONE_MIN_VERSION="5.0"
VERSION="1.3.0"
NASM_VERSION="2.10.09"
BUILD_DIR="`pwd`/build"
# Download gas preprocessor version compatible with Xcode 5 and append to $PATH
rm -f "gas-preprocessor.pl"
curl -O "http://sourceforge.net/p/libjpeg-turbo/code/HEAD/tree/gas-preprocessor/gas-preprocessor.pl"
chmod a+x "gas-preprocessor.pl"
export PATH="$PATH:`pwd`"
# Download source if necessary
if [ ! -f "libjpeg-turbo-${VERSION}.tar.gz" ]
then
curl -O "http://softlayer-dal.dl.sourceforge.net/project/libjpeg-turbo/${VERSION}/libjpeg-turbo-${VERSION}.tar.gz"
fi
# Extract source
rm -rf "libjpeg-turbo-${VERSION}"
tar -xvf "libjpeg-turbo-${VERSION}.tar.gz"
# Build
rm -rf "${BUILD_DIR}"
pushd "libjpeg-turbo-${VERSION}"
export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${IPHONE_SDK}.sdk"
export CC=`xcrun -find gcc`
export LD=`xcrun -find ld`
export IOS_CFLAGS="-no-integrated-as -arch ${ARCH}"
export CFLAGS="-O3 ${IOS_CFLAGS} -isysroot ${SDKROOT}"
export LDFLAGS="${IOS_CFLAGS} -isysroot ${SDKROOT}"
export CPPFLAGS="${CFLAGS}"
export CFLAGS="${CFLAGS} -miphoneos-version-min=${IPHONE_MIN_VERSION}"
export LDFLAGS="${LDFLAGS} -miphoneos-version-min=${IPHONE_MIN_VERSION}"
./configure --with-jpeg8 --host arm-apple-darwin --enable-static --disable-shared "--prefix=${BUILD_DIR}"
make -j4
make install
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment