Skip to content

Instantly share code, notes, and snippets.

@RGPaul
Forked from tmiz/build_openssl_dylib.sh
Last active February 20, 2017 15:38
Show Gist options
  • Save RGPaul/0cd572aa7694d6902260 to your computer and use it in GitHub Desktop.
Save RGPaul/0cd572aa7694d6902260 to your computer and use it in GitHub Desktop.
Build latest OpenSSL Universal Binary on OSX
#!/bin/bash
# this is the dynamic library version of this script
# set the version to build
declare OPENSSL_VERSION="1.0.2k"
# only download if not already present
if [ ! -f openssl-${OPENSSL_VERSION}.tar.gz ]; then
curl -O http://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
fi
# unpack tar file
tar -xvzf openssl-${OPENSSL_VERSION}.tar.gz
mv openssl-${OPENSSL_VERSION} openssl_i386
tar -xvzf openssl-${OPENSSL_VERSION}.tar.gz
mv openssl-${OPENSSL_VERSION} openssl_x86_64
# build i386
cd openssl_i386
./Configure darwin-i386-cc -shared
make
cd ../
# build x86_64
cd openssl_x86_64
./Configure darwin64-x86_64-cc -shared
make
cd ../
# create folders for openssl version
mkdir ${OPENSSL_VERSION}
mkdir ${OPENSSL_VERSION}/include
mkdir ${OPENSSL_VERSION}/lib
# create fat libraries
lipo -create openssl_i386/libcrypto.1.0.0.dylib openssl_x86_64/libcrypto.1.0.0.dylib -output ${OPENSSL_VERSION}/lib/libcrypto.1.0.0.dylib
lipo -create openssl_i386/libssl.1.0.0.dylib openssl_x86_64/libssl.1.0.0.dylib -output ${OPENSSL_VERSION}/lib/libssl.1.0.0.dylib
# copy header files
cp -r openssl_x86_64/include/openssl ${OPENSSL_VERSION}/include/
# remove temporary building folders
rm -rf openssl_i386
rm -rf openssl_x86_64
#!/bin/bash
# this is the static library version of this script
# set the version to build
declare OPENSSL_VERSION="1.0.2k"
# only download if not already present
if [ ! -f openssl-${OPENSSL_VERSION}.tar.gz ]; then
curl -O https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
fi
# unpack tar file
tar -xvzf openssl-${OPENSSL_VERSION}.tar.gz
mv openssl-${OPENSSL_VERSION} openssl_i386
tar -xvzf openssl-${OPENSSL_VERSION}.tar.gz
mv openssl-${OPENSSL_VERSION} openssl_x86_64
# build i386
cd openssl_i386
./Configure darwin-i386-cc no-shared
make
cd ../
# build x86_64
cd openssl_x86_64
./Configure darwin64-x86_64-cc no-shared
make
cd ../
# create folders for openssl version
mkdir ${OPENSSL_VERSION}
mkdir ${OPENSSL_VERSION}/include
mkdir ${OPENSSL_VERSION}/lib
# create fat libraries
lipo -create openssl_i386/libcrypto.a openssl_x86_64/libcrypto.a -output ${OPENSSL_VERSION}/lib/libcrypto.a
lipo -create openssl_i386/libssl.a openssl_x86_64/libssl.a -output ${OPENSSL_VERSION}/lib/libssl.a
# copy header files
cp -r openssl_x86_64/include/openssl ${OPENSSL_VERSION}/include/
# remove temporary building folders
rm -rf openssl_i386
rm -rf openssl_x86_64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment