Skip to content

Instantly share code, notes, and snippets.

@pguyot
Created May 21, 2014 07:20
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save pguyot/dce18af64a71b93c0204 to your computer and use it in GitHub Desktop.
Save pguyot/dce18af64a71b93c0204 to your computer and use it in GitHub Desktop.
Build script for potrace for iOS
#!/bin/sh
# Automatic build script for potrace
# for iPhoneOS and iPhoneSimulator
#
# Created by Felix Schulze on 19.02.12.
# Copyright 2012 Felix Schulze. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
# Change values here #
# #
VERSION="1.11" #
SDKVERSION="7.1" #
MIN_VERSION="7.0" #
# #
###########################################################################
# #
# Don't change anything under this line! #
# #
###########################################################################
CURRENTPATH=`pwd`
ARCHS="i386 x86_64 armv7 armv7s arm64"
DEVELOPER=`xcode-select -print-path`
set -e
if [ ! -e potrace-${VERSION}.tar.gz ]; then
echo "Downloading potrace-${VERSION}.tar.gz"
curl -O http://potrace.sourceforge.net/download/potrace-${VERSION}.tar.gz
else
echo "Using potrace-${VERSION}.tar.gz"
fi
mkdir -p "${CURRENTPATH}/src"
mkdir -p "${CURRENTPATH}/bin"
mkdir -p "${CURRENTPATH}/lib"
for ARCH in ${ARCHS}
do
tar zxf potrace-${VERSION}.tar.gz -C "${CURRENTPATH}/src"
cd "${CURRENTPATH}/src/potrace-${VERSION}"
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]];
then
PLATFORM="iPhoneSimulator"
else
PLATFORM="iPhoneOS"
fi
echo "Building potrace-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}"
echo "Please stand by..."
export DEVROOT="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${SDKVERSION}.sdk"
export LD=${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
export CC=${DEVELOPER}/usr/bin/gcc
export CXX=${DEVELOPER}/usr/bin/g++
export AR=${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar
export AS=${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/as
export NM=${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm
export RANLIB=${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib
export LDFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -L${CURRENTPATH}/lib -miphoneos-version-min=${MIN_VERSION} -fheinous-gnu-extensions"
export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${CURRENTPATH}/include -miphoneos-version-min=${MIN_VERSION} -fheinous-gnu-extensions"
export CPPFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${CURRENTPATH}/include -miphoneos-version-min=${MIN_VERSION} -fheinous-gnu-extensions"
export CXXFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${CURRENTPATH}/include -miphoneos-version-min=${MIN_VERSION} -fheinous-gnu-extensions"
HOST="${ARCH}"
if [ "${ARCH}" == "arm64" ];
then
HOST="aarch64"
#Fetch a recent config.sub
curl -o config.sub "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD"
fi
mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-potrace-${VERSION}.log"
echo "Configure..."
./configure --host="${HOST}-apple-darwin" --prefix="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" --disable-shared --enable-static --with-libpotrace > "${LOG}" 2>&1
echo "Make..."
make -j4 >> "${LOG}" 2>&1
echo "Make install..."
make install >> "${LOG}" 2>&1
cd "${CURRENTPATH}"
rm -rf "${CURRENTPATH}/src/potrace-${VERSION}"
done
echo "Build library..."
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libpotrace.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libpotrace.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libpotrace.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libpotrace.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libpotrace.a -output ${CURRENTPATH}/lib/libpotrace.a
lipo -info ${CURRENTPATH}/lib/libpotrace.a
mkdir -p ${CURRENTPATH}/include/potrace
cp ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/include/potrace* ${CURRENTPATH}/include/potrace
echo "Building done."
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment