Last active
July 20, 2018 04:35
-
-
Save sammcj/ac02e98d7740666a2b8908ebbf270a3e to your computer and use it in GitHub Desktop.
build openssl with statically linked libraries for old software rebuilds on macOS x86_64 / iOS emulator (x86_64) (fork of many other scripts)
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 | |
# This script builds the Mac openSSL libraries with Bitcode enabled | |
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script | |
# Modified and messed with by @sammcj | |
# Credits: | |
# Peter Steinberger, PSPDFKit GmbH, @steipete. | |
# Doron Adler, GlideTalk, @Norod78 | |
# Updated to work with Xcode 9 | |
set -e | |
################################### | |
# OpenSSL Version | |
################################### | |
OPENSSL_VERSION="openssl-1.0.2o" | |
################################### | |
################################################ | |
# Minimum OS X deployment target version | |
################################################ | |
MIN_OSX_VERSION="10.13" | |
echo "----------------------------------------" | |
echo "OpenSSL version: ${OPENSSL_VERSION}" | |
echo "OS X deployment target: ${MIN_OSX_VERSION}" | |
echo "----------------------------------------" | |
echo " " | |
DEVELOPER=`xcode-select -print-path` | |
buildMac() | |
{ | |
ARCH=x86_64 | |
echo "Start Building ${OPENSSL_VERSION} for ${ARCH}" | |
TARGET="darwin64-x86_64-cc" | |
export CC="${BUILD_TOOLS}/usr/bin/clang -mmacosx-version-min=${MIN_OSX_VERSION} -Wl,-undefined -Wl,dynamic_lookup" | |
pushd . > /dev/null | |
cd "${OPENSSL_VERSION}" | |
echo "Configure" | |
./Configure ${TARGET} --openssldir="/tmp/${OPENSSL_VERSION}-${ARCH}" &> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" | |
make >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1 | |
echo "make install" | |
make install >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1 | |
echo "make clean" | |
make clean >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1 | |
popd > /dev/null | |
echo "Done Building ${OPENSSL_VERSION} for ${ARCH}" | |
} | |
echo "Cleaning up" | |
rm -rf include/openssl/* lib/* | |
rm -rf /tmp/${OPENSSL_VERSION}-* | |
rm -rf ${OPENSSL_VERSION} | |
mkdir -p lib/Mac | |
mkdir -p include/openssl/ | |
rm -rf "/tmp/${OPENSSL_VERSION}-*" | |
rm -rf "/tmp/${OPENSSL_VERSION}-*.log" | |
rm -rf "${OPENSSL_VERSION}" | |
if [ ! -e ${OPENSSL_VERSION}.tar.gz ]; then | |
echo "Downloading ${OPENSSL_VERSION}.tar.gz" | |
curl -O https://www.openssl.org/source/${OPENSSL_VERSION}.tar.gz | |
else | |
echo "Using ${OPENSSL_VERSION}.tar.gz" | |
fi | |
echo "Unpacking openssl" | |
tar xfz "${OPENSSL_VERSION}.tar.gz" | |
buildMac "x86_64" | |
echo "Copying headers" | |
cp /tmp/${OPENSSL_VERSION}-x86_64/include/openssl/* include/openssl/ | |
echo "Building Mac libraries" | |
lipo \ | |
"/tmp/${OPENSSL_VERSION}-x86_64/lib/libcrypto.a" \ | |
-create -output lib/Mac/libcrypto.a | |
lipo \ | |
"/tmp/${OPENSSL_VERSION}-x86_64/lib/libssl.a" \ | |
-create -output lib/Mac/libssl.a | |
echo "Cleaning up" | |
rm -rf /tmp/${OPENSSL_VERSION}-* | |
rm -rf ${OPENSSL_VERSION} | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment