From e30d6109bca5c1dd202656716203fec0525f40a0 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Sat, 5 Oct 2013 23:53:53 +0200 Subject: [PATCH] Cleaned up and improved iOS openssl build script * Added support for optional build directory (first argument) * Automatically detect iOS/iPhoneSimulator SDKs (oldest SDK found is used) --- scripts/OpenSSL-DownloadAndBuild.command | 90 ++++++++++++++---------- scripts/OpenSSL-iFreeRDP.diff | 6 +- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/scripts/OpenSSL-DownloadAndBuild.command b/scripts/OpenSSL-DownloadAndBuild.command index 58901fed4..fdb1822d6 100755 --- a/scripts/OpenSSL-DownloadAndBuild.command +++ b/scripts/OpenSSL-DownloadAndBuild.command @@ -1,24 +1,46 @@ -#!/bin/sh +#!/bin/bash # # Copyright 2013 Thinstuff 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 i386 -# +# This script will download and build openssl for iOS (armv7, armv7s) and simulator (i386) OPENSSLVERSION="1.0.0e" MD5SUM="7040b89c4c58c7a1016c0dfa6e821c86" -OPENSSLPATCH="../../scripts/OpenSSL-iFreeRDP.diff" +OPENSSLPATCH="OpenSSL-iFreeRDP.diff" CORES=`sysctl hw.ncpu | awk '{print $2}'` +SCRIPTDIR=$(dirname `cd ${0%/*} && echo $PWD/${0##*/}`) MAKEOPTS="-j $CORES" # disable parallell builds since openssl build # fails sometimes MAKEOPTS="" +INSTALLDIR="external" -cd external +if [ $# -gt 0 ];then + INSTALLDIR=$1 + if [ ! -d $INSTALLDIR ];then + echo "Install directory \"$INSTALLDIR\" does not exist" + exit 1 + fi +fi + +function buildArch(){ + ARCH=$1 + LOGFILE="BuildLog.darwin-${ARCH}.txt" + echo "Building architecture ${ARCH}. Please wait ..." + ./Configure darwin-${ARCH}-cc > ${LOGFILE} + make ${MAKEOPTS} >> ${LOGFILE} 2>&1 + 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 +} + +cd $INSTALLDIR if [ ! -d openssl ];then mkdir openssl fi @@ -36,6 +58,7 @@ if [ ! "$CS" = "$MD5SUM" ]; then fi fi +# remove old build dir rm -rf openssltmp mkdir openssltmp cd openssltmp @@ -49,9 +72,27 @@ fi echo echo "Applying iFreeRDP patch ..." +OLDEST_OS_SDK=`ls -1 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs | sort -n | head -1` +if [ "x${OLDEST_OS_SDK}" == "x" ];then + echo "No iPhoneOS SDK found" + exit 1; +fi +echo "Using iPhoneOS SDK: ${OLDEST_OS_SDK}" + +OLDEST_SIM_SDK=`ls -1 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs | sort -n | head -1` +if [ "x${OLDEST_SIM_SDK}" == "x" ];then + echo "No iPhoneSimulator SDK found" + exit 1; +fi +echo "Using iPhoneSimulator SDK: ${OLDEST_SIM_SDK}" +echo cd "openssl-$OPENSSLVERSION" -patch -p1 < "../../$OPENSSLPATCH" +cp ${SCRIPTDIR}/${OPENSSLPATCH} . +sed -ie "s#__ISIMSDK__#${OLDEST_SIM_SDK}#" ${OPENSSLPATCH} +sed -ie "s#__IOSSDK__#${OLDEST_OS_SDK}#" ${OPENSSLPATCH} + +patch -p1 < $OPENSSLPATCH if [ ! $? = 0 ]; then echo "Patch failed." @@ -59,6 +100,7 @@ if [ ! $? = 0 ]; then fi echo +# Cleanup old build artifacts mkdir -p ../../include/openssl rm -f ../../include/openssl/*.h @@ -69,36 +111,12 @@ echo "Copying header hiles ..." cp include/openssl/*.h ../../include/openssl/ echo -echo "Building sim version (for simulator). Please wait ..." -./Configure darwin-sim-cc >BuildLog.darwin-sim.txt -make ${MAKEOPTS} >>BuildLog.darwin-sim.txt 2>&1 -echo "Done. Build log saved in BuildLog.darwin-sim.txt" -cp libcrypto.a ../../lib/libcrypto_sim.a -cp libssl.a ../../lib/libssl_sim.a -make clean >/dev/null 2>&1 -echo - -echo "Building armv7 version (for iPhone). Please wait ..." -./Configure darwin-armv7-cc >BuildLog.darwin-armv7.txt -make ${MAKEOPTS} >>BuildLog.darwin-armv7.txt 2>&1 -echo "Done. Build log saved in BuildLog.darwin-armv7.txt" -cp libcrypto.a ../../lib/libcrypto_armv7.a -cp libssl.a ../../lib/libssl_armv7.a -make clean >/dev/null 2>&1 -echo - -echo "Building armv7s version (for iPhone). Please wait ..." -./Configure darwin-armv7s-cc >BuildLog.darwin-armv7s.txt -make ${MAKEOPTS} >>BuildLog.darwin-armv7s.txt 2>&1 -echo "Done. Build log saved in BuildLog.darwin-armv7s.txt" -cp libcrypto.a ../../lib/libcrypto_armv7s.a -cp libssl.a ../../lib/libssl_armv7s.a -make clean >/dev/null 2>&1 -echo +buildArch i386 +buildArch armv7 +buildArch armv7s echo "Combining to unversal binary" -lipo -create ../../lib/libcrypto_sim.a ../../lib/libcrypto_armv7.a ../../lib/libcrypto_armv7s.a -o ../../lib/libcrypto.a -lipo -create ../../lib/libssl_sim.a ../../lib/libssl_armv7.a ../../lib/libssl_armv7s.a -o ../../lib/libssl.a - -echo "Finished. Please verify the contens of the openssl folder in your main project folder" +lipo -create ../../lib/libcrypto_*.a -o ../../lib/libcrypto.a +lipo -create ../../lib/libssl_*.a -o ../../lib/libssl.a +echo "Finished. Please verify the contens of the openssl folder in \"$INSTALLDIR\"" diff --git a/scripts/OpenSSL-iFreeRDP.diff b/scripts/OpenSSL-iFreeRDP.diff index 1348cdb2e..a282d70a1 100644 --- a/scripts/OpenSSL-iFreeRDP.diff +++ b/scripts/OpenSSL-iFreeRDP.diff @@ -5,9 +5,9 @@ diff -rupN openssl-1.0.0e-ori/Configure openssl-1.0.0e/Configure "debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", "darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", "debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -+"darwin-armv7s-cc","/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc:-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch armv4 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -+"darwin-armv7-cc","/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc:-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch armv4 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", -+"darwin-sim-cc","/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc: -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common: -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", ++"darwin-armv7s-cc","/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang:-arch armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/__IOSSDK__ -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch armv4 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", ++"darwin-armv7-cc","/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang:-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/__IOSSDK__ -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common:-arch armv4 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", ++"darwin-i386-cc","/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang: -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/__ISIMSDK__ -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${no_asm}:dlfcn:darwin-shared:-fPIC -fno-common: -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib", ##### A/UX "aux3-gcc","gcc:-O2 -DTERMIO::(unknown):AUX:-lbsd:RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",