2010-12-16 19:08:02 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Automatic build script for libssl and libcrypto
|
|
|
|
# for iPhoneOS and iPhoneSimulator
|
|
|
|
#
|
|
|
|
# Created by Felix Schulze on 16.12.10.
|
|
|
|
# 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 #
|
2014-01-07 15:07:40 +00:00
|
|
|
#
|
2014-04-07 19:33:14 +00:00
|
|
|
VERSION="1.0.1g" #
|
2014-03-12 14:22:49 +00:00
|
|
|
SDKVERSION="7.1" #
|
2010-12-16 19:08:02 +00:00
|
|
|
# #
|
|
|
|
###########################################################################
|
|
|
|
# #
|
|
|
|
# Don't change anything under this line! #
|
|
|
|
# #
|
|
|
|
###########################################################################
|
|
|
|
|
|
|
|
|
|
|
|
CURRENTPATH=`pwd`
|
2013-10-12 12:05:36 +00:00
|
|
|
ARCHS="i386 x86_64 armv7 armv7s arm64"
|
2012-02-21 19:41:47 +00:00
|
|
|
DEVELOPER=`xcode-select -print-path`
|
2010-12-16 19:08:02 +00:00
|
|
|
|
2012-07-11 18:34:48 +00:00
|
|
|
if [ ! -d "$DEVELOPER" ]; then
|
2012-09-21 20:23:49 +00:00
|
|
|
echo "xcode path is not set correctly $DEVELOPER does not exist (most likely because of xcode > 4.3)"
|
2012-07-11 18:34:48 +00:00
|
|
|
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
|
|
|
|
|
2014-02-07 06:45:57 +00:00
|
|
|
case $DEVELOPER in
|
|
|
|
*\ * )
|
|
|
|
echo "Your Xcode path contains whitespaces, which is not supported."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2013-10-12 12:42:23 +00:00
|
|
|
case $CURRENTPATH in
|
|
|
|
*\ * )
|
|
|
|
echo "Your path contains whitespaces, which is not supported by 'make install'."
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-12-16 19:08:02 +00:00
|
|
|
set -e
|
|
|
|
if [ ! -e openssl-${VERSION}.tar.gz ]; then
|
|
|
|
echo "Downloading openssl-${VERSION}.tar.gz"
|
|
|
|
curl -O http://www.openssl.org/source/openssl-${VERSION}.tar.gz
|
|
|
|
else
|
|
|
|
echo "Using openssl-${VERSION}.tar.gz"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "${CURRENTPATH}/src"
|
2012-01-28 19:20:37 +00:00
|
|
|
mkdir -p "${CURRENTPATH}/bin"
|
|
|
|
mkdir -p "${CURRENTPATH}/lib"
|
|
|
|
|
2010-12-16 19:08:02 +00:00
|
|
|
tar zxf openssl-${VERSION}.tar.gz -C "${CURRENTPATH}/src"
|
|
|
|
cd "${CURRENTPATH}/src/openssl-${VERSION}"
|
|
|
|
|
|
|
|
|
2012-01-28 19:20:37 +00:00
|
|
|
for ARCH in ${ARCHS}
|
|
|
|
do
|
2013-10-12 12:05:36 +00:00
|
|
|
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]];
|
2012-01-28 19:20:37 +00:00
|
|
|
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
|
|
|
|
|
2012-07-22 12:08:12 +00:00
|
|
|
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
|
2012-07-22 12:01:18 +00:00
|
|
|
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
|
2013-09-22 17:25:42 +00:00
|
|
|
export BUILD_TOOLS="${DEVELOPER}"
|
2012-07-22 12:01:18 +00:00
|
|
|
|
2012-01-28 19:20:37 +00:00
|
|
|
echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}"
|
|
|
|
echo "Please stand by..."
|
|
|
|
|
2013-09-22 17:25:42 +00:00
|
|
|
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
|
2012-01-28 19:20:37 +00:00
|
|
|
mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
|
|
|
|
LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-openssl-${VERSION}.log"
|
|
|
|
|
2013-11-11 19:17:59 +00:00
|
|
|
set +e
|
2013-05-17 10:34:19 +00:00
|
|
|
if [[ "$VERSION" =~ 1.0.0. ]]; then
|
|
|
|
./Configure BSD-generic32 --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1
|
2013-10-12 12:05:36 +00:00
|
|
|
elif [ "${ARCH}" == "x86_64" ]; then
|
|
|
|
./Configure darwin64-x86_64-cc --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1
|
2013-05-17 10:34:19 +00:00
|
|
|
else
|
|
|
|
./Configure iphoneos-cross --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1
|
|
|
|
fi
|
2013-11-11 19:17:59 +00:00
|
|
|
|
|
|
|
if [ $? != 0 ];
|
|
|
|
then
|
|
|
|
echo "Problem while configure - Please check ${LOG}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2013-05-17 10:34:19 +00:00
|
|
|
|
2012-01-28 19:20:37 +00:00
|
|
|
# add -isysroot to CC=
|
2013-10-12 12:05:36 +00:00
|
|
|
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=7.0 !" "Makefile"
|
2012-01-28 19:20:37 +00:00
|
|
|
|
2014-04-17 13:38:35 +00:00
|
|
|
if [ "$1" == "verbose" ];
|
|
|
|
then
|
|
|
|
make
|
|
|
|
else
|
|
|
|
make >> "${LOG}" 2>&1
|
|
|
|
fi
|
2013-11-11 19:17:59 +00:00
|
|
|
|
|
|
|
if [ $? != 0 ];
|
|
|
|
then
|
|
|
|
echo "Problem while make - Please check ${LOG}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
2012-01-28 19:20:37 +00:00
|
|
|
make install >> "${LOG}" 2>&1
|
|
|
|
make clean >> "${LOG}" 2>&1
|
|
|
|
done
|
2010-12-16 19:08:02 +00:00
|
|
|
|
|
|
|
echo "Build library..."
|
2013-10-12 12:05:36 +00:00
|
|
|
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libssl.a -output ${CURRENTPATH}/lib/libssl.a
|
2010-12-16 19:08:02 +00:00
|
|
|
|
2013-10-12 12:05:36 +00:00
|
|
|
lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libcrypto.a -output ${CURRENTPATH}/lib/libcrypto.a
|
2010-12-16 19:08:02 +00:00
|
|
|
|
|
|
|
mkdir -p ${CURRENTPATH}/include
|
2012-01-28 19:20:37 +00:00
|
|
|
cp -R ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/include/openssl ${CURRENTPATH}/include/
|
2010-12-16 19:08:02 +00:00
|
|
|
echo "Building done."
|
|
|
|
echo "Cleaning up..."
|
2012-01-28 19:20:37 +00:00
|
|
|
rm -rf ${CURRENTPATH}/src/openssl-${VERSION}
|
2012-07-11 18:34:48 +00:00
|
|
|
echo "Done."
|