-
-
Save veritech/84e520b159d6e4e5bbe8 to your computer and use it in GitHub Desktop.
Building a Fat binary for polarSSL with support for arm7, arm 7s, arm64 and i386. Pulls code directly from the polar ssl github
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Automatic build script for polarssl | |
# for iPhoneOS and iPhoneSimulator | |
# | |
# Created by Felix Schulze on 08.04.11. | |
# Copyright 2010 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.3.5" | |
SDKVERSION="8.1" | |
# | |
########################################################################### | |
# | |
# Don't change anything here | |
CURRENTPATH=`pwd` | |
ARCHS="i386 armv6 armv7 armv7s arm64" | |
#ARCHS="arm64" | |
########## | |
set -e | |
if [ ! -e polarssl-${VERSION}.tar.gz ]; then | |
echo "Downloading polarssl-${VERSION}.tar.gz" | |
curl -O -L https://github.com/polarssl/polarssl/archive/polarssl-${VERSION}.tar.gz | |
else | |
echo "Using polarssl-${VERSION}.tar.gz" | |
fi | |
mkdir -p bin | |
mkdir -p lib | |
mkdir -p src | |
for ARCH in ${ARCHS} | |
do | |
if [ "${ARCH}" == "i386" ]; | |
then | |
PLATFORM="iPhoneSimulator" | |
else | |
PLATFORM="iPhoneOS" | |
fi | |
tar -zxvf polarssl-${VERSION}.tar.gz -C src | |
cd src/polarssl-polarssl-${VERSION}/library | |
echo "Building polarssl for ${PLATFORM} ${SDKVERSION} ${ARCH}" | |
echo "Patching Makefile..." | |
sed -i.bak '4d' ${CURRENTPATH}/src/polarssl-polarssl-${VERSION}/library/Makefile | |
echo "Please stand by..." | |
export DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/${PLATFORM}.platform/Developer" | |
export SDKROOT="${DEVROOT}/SDKs/${PLATFORM}${SDKVERSION}.sdk" | |
#export CC=${DEVROOT}/usr/bin/gcc | |
export CC=$(xcrun -find -sdk iphoneos clang) | |
export LD=${DEVROOT}/usr/bin/ld | |
export CPP=${DEVROOT}/usr/bin/cpp | |
#export CXX=${DEVROOT}/usr/bin/g++ | |
export CXX=$(xcrun -find -sdk iphoneos clang++) | |
#export AR=${DEVROOT}/usr/bin/ar | |
export AS=${DEVROOT}/usr/bin/as | |
export NM=${DEVROOT}/usr/bin/nm | |
export CXXCPP=$DEVROOT/usr/bin/cpp | |
export RANLIB=$DEVROOT/usr/bin/ranlib | |
export LDFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT}" | |
export CFLAGS="-arch ${ARCH} -pipe -no-cpp-precomp -isysroot ${SDKROOT} -I${CURRENTPATH}/src/polarssl-${VERSION}/include" | |
make | |
cp libpolarssl.a ${CURRENTPATH}/bin/libpolarssl-${ARCH}.a | |
cp -R ${CURRENTPATH}/src/polarssl-polarssl-${VERSION}/include ${CURRENTPATH} | |
cp ${CURRENTPATH}/src/polarssl-polarssl-${VERSION}/LICENSE ${CURRENTPATH}/include/polarssl/LICENSE | |
cd ${CURRENTPATH} | |
rm -rf src/polarssl-polarssl-${VERSION} | |
done | |
args=`for ARCH in ${ARCHS}; do echo "'bin/libpolarssl-${ARCH}.a'"; done | xargs` | |
lipo $args -create -output "lib/libpolarssl.a" | |
echo "Build library..." | |
echo "Building done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment