mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
ios: update openssl build script
* remove patch - not required anymore * add support for arm64 and x86_64 openssl builds * update documentation
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user