Skip to content

Commit

Permalink
Merge pull request FreeRDP#2686 from bmiklautz/ios/openssl
Browse files Browse the repository at this point in the history
ios: update openssl build script
  • Loading branch information
awakecoding committed Jun 22, 2015
2 parents 3b3ffce + 1918b69 commit 9fab504
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 94 deletions.
6 changes: 2 additions & 4 deletions docs/README.ios
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ different install/build directory you specify it as first parameter:

In the example above the output can then be found in /tmp/openssl.

The script uses oldest iOS/iPhoneSimulator SDK found on the build machine per default. If you need to build against a different SDK you can set USER_OS_SDK
and/or USER_SIM_SDK in the top of the build script to the SDK version you need. E.g.:

USER_SIM_SDK="iPhoneSimulator6.0.sdk"
The script uses oldest iOS/iPhoneSimulator SDK found on the build machine per default. If it is required to build against a specific SDK version
the variable SDK_VERSION can be used to specify it. The minimum SDK version that should be used can be set with MIN_SDK_VERSION within the script.

When the script is finished you will find libcrypto.a and libssl.at, both universal libraries containing all openssl/lib
subfolder in the specified
Expand Down
136 changes: 71 additions & 65 deletions scripts/OpenSSL-DownloadAndBuild.command
Original file line number Diff line number Diff line change
@@ -1,44 +1,87 @@
#!/bin/bash
#
# Copyright 2013 Thincast Technologies GmbH
# Copyright 2015 Thincast Technologies GmbH
#
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This script will download and build openssl for iOS (armv7, armv7s) and simulator (i386)
# This script will download and build openssl for iOS and simulator - see ARCHS for architectures built

# Settings and definitions
USER_OS_SDK=""
USER_SIM_SDK=""
## Settings
# openssl version to use
OPENSSLVERSION="1.0.2a"
MD5SUM="a06c547dac9044161a477211049f60ef"
# SDK version to use - if not set latest version found is used
SDK_VERSION=""

OPENSSLVERSION="1.0.0e"
MD5SUM="7040b89c4c58c7a1016c0dfa6e821c86"
OPENSSLPATCH="OpenSSL-iFreeRDP.diff"
# Minimum SDK version the application supports
MIN_SDK_VERSION=""


## Defaults
INSTALLDIR="external"

# Architectures to build
ARCHS="i386 x86_64 armv7 armv7s arm64"

# Use default SDK version if not set
if [ -z ${SDK_VERSION} ]; then
SDK_VERSION=`xcrun -sdk iphoneos --show-sdk-version`
fi

CORES=`sysctl hw.ncpu | awk '{print $2}'`
MAKEOPTS="-j $CORES"
# disable parallell builds since openssl build
# fails sometimes
MAKEOPTS=""
CORES=`sysctl hw.ncpu | awk '{print $2}'`
SCRIPTDIR=$(dirname `cd ${0%/*} && echo $PWD/${0##*/}`)
OS_SDK=""
SIM_SDK=""
OS_SDK_PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs"
SIM_SDK_PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs"

DEVELOPER=`xcode-select -print-path`
if [ ! -d "$DEVELOPER" ]; then
echo "xcode path is not set correctly $DEVELOPER does not exist (most likely because of xcode > 4.3)"
echo "run"
echo "sudo xcode-select -switch <xcode path>"
echo "for default installation:"
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
exit 1
fi

# Functions
function buildArch(){
ARCH=$1
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]];
then
PLATFORM="iPhoneSimulator"
else
sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
PLATFORM="iPhoneOS"
fi

export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
if [ ! -z $MIN_SDK_VERSION ]; then
export CC="$CC -miphoneos-version-min=${MIN_SDK_VERSION}"
fi
echo "Building openssl-${OPENSSLVERSION} for ${PLATFORM} ${SDK_VERSION} ${ARCH} (min SDK set: ${MIN_SDK_VERSION:-"none"})"

LOGFILE="BuildLog.darwin-${ARCH}.txt"
echo "Building architecture ${ARCH}. Please wait ..."
./Configure darwin-${ARCH}-cc > ${LOGFILE}
echo -n " Please wait ..."
if [[ "$OPENSSLVERSION" =~ 1.0.0. ]]; then
./Configure BSD-generic32 > "${LOGFILE}" 2>&1
elif [ "${ARCH}" == "x86_64" ]; then
./Configure darwin64-x86_64-cc > "${LOGFILE}" 2>&1
elif [ "${ARCH}" == "i386" ]; then
./Configure iphoneos-cross no-asm > "${LOGFILE}" 2>&1
else
./Configure iphoneos-cross > "${LOGFILE}" 2>&1
fi

make ${MAKEOPTS} >> ${LOGFILE} 2>&1
echo "Done. Build log saved in ${LOGFILE}"
echo " Done. Build log saved in ${LOGFILE}"
cp libcrypto.a ../../lib/libcrypto_${ARCH}.a
cp libssl.a ../../lib/libssl_${ARCH}.a
make clean >/dev/null 2>&1
echo
}

# main
Expand All @@ -50,38 +93,6 @@ if [ $# -gt 0 ];then
fi
fi

echo "Detecting SDKs..."
if [ "x${USER_OS_SDK}" == "x" ];then
OS_SDK=`ls -1 ${OS_SDK_PATH} | sort -n | head -1`
if [ "x${OS_SDK}" == "x" ];then
echo "No iPhoneOS SDK found"
exit 1;
fi
else
OS_SDK=${USER_OS_SDK}
if [ ! -d "${OS_SDK_PATH}/${OS_SDK}" ];then
echo "User specified iPhoneOS SDK not found"
exit 1
fi
fi
echo "Using iPhoneOS SDK: ${OS_SDK}"

if [ "x${USER_SIM_SDK}" == "x" ];then
SIM_SDK=`ls -1 ${SIM_SDK_PATH} | sort -n | head -1`
if [ "x${SIM_SDK}" == "x" ];then
echo "No iPhoneSimulator SDK found"
exit 1;
fi
else
SIM_SDK=${USER_SIM_SDK}
if [ ! -d "${SIM_SDK_PATH}/${SIM_SDK}" ];then
echo "User specified iPhoneSimulator SDK not found"
exit 1
fi
fi
echo "Using iPhoneSimulator SDK: ${SIM_SDK}"
echo

cd $INSTALLDIR
if [ ! -d openssl ];then
mkdir openssl
Expand Down Expand Up @@ -113,19 +124,14 @@ if [ ! $? = 0 ]; then
fi
echo

echo "Applying iFreeRDP patch ..."
cd "openssl-$OPENSSLVERSION"
cp ${SCRIPTDIR}/${OPENSSLPATCH} .
sed -ie "s#__ISIMSDK__#${SIM_SDK}#" ${OPENSSLPATCH}
sed -ie "s#__IOSSDK__#${OS_SDK}#" ${OPENSSLPATCH}

patch -p1 < $OPENSSLPATCH

if [ ! $? = 0 ]; then
echo "Patch failed."
exit 1
fi
echo
case `pwd` in
*\ * )
echo "The build path (`pwd`) contains whitepsaces - fix this."
exit 1
;;
esac

# Cleanup old build artifacts
mkdir -p ../../include/openssl
Expand All @@ -134,13 +140,13 @@ rm -f ../../include/openssl/*.h
mkdir -p ../../lib
rm -f ../../lib/*.a

echo "Copying header hiles ..."
echo "Copying header files ..."
cp include/openssl/*.h ../../include/openssl/
echo

buildArch i386
buildArch armv7
buildArch armv7s
for i in ${ARCHS}; do
buildArch $i
done

echo "Combining to unversal binary"
lipo -create ../../lib/libcrypto_*.a -o ../../lib/libcrypto.a
Expand Down
25 changes: 0 additions & 25 deletions scripts/OpenSSL-iFreeRDP.diff

This file was deleted.

0 comments on commit 9fab504

Please sign in to comment.