Skip to content

Commit

Permalink
version 1.1.1s
Browse files Browse the repository at this point in the history
  • Loading branch information
apotocki committed Dec 25, 2022
1 parent 58c0fbe commit 27ebe3f
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 101 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
## OpenSSL for iOS and Mac OS X (Intel & Apple Silicon M1) & Catalyst - arm64 / x86_64

Supported version: 1.1.1q
Supported version: 1.1.1s

This repo provides a universal script for building static OpenSSL libraries for use in iOS and Mac OS X applications.
The actual library version is taken from https://github.com/openssl/openssl with tag 'OpenSSL_1_1_1q'
The actual library version is taken from https://github.com/openssl/openssl with tag 'OpenSSL_1_1_1s'

## Prerequisites
1) Xcode must be installed because xcodebuild is used to create xcframeworks
Expand All @@ -14,7 +14,7 @@ The actual library version is taken from https://github.com/openssl/openssl with
- Manually
```
# clone the repo
git clone -b 1.1.1q https://github.com/apotocki/openssl-iosx
git clone -b 1.1.1s https://github.com/apotocki/openssl-iosx
# build libraries
cd openssl-iosx
Expand All @@ -25,9 +25,9 @@ The actual library version is taken from https://github.com/openssl/openssl with
- Use cocoapods. Add the following lines into your project's Podfile:
```
use_frameworks!
pod 'openssl-iosx', '~> 1.1.1q'
pod 'openssl-iosx', '~> 1.1.1s'
# or optionally more precisely
# pod 'openssl-iosx', :git => 'https://github.com/apotocki/openssl-iosx', :tag => '1.1.1q.1'
# pod 'openssl-iosx', :git => 'https://github.com/apotocki/openssl-iosx', :tag => '1.1.1s.1'
```
install new dependency:
```
Expand All @@ -43,4 +43,4 @@ This app is designed for viewing and editing files at byte or character level.

You can support my open-source development by trying the [App](https://apps.apple.com/us/app/potohex/id1620963302).

Feedbacks are also welcome!
Feedback is welcome!
2 changes: 1 addition & 1 deletion openssl-iosx.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "openssl-iosx"
s.version = "1.1.1q.1"
s.version = "1.1.1s.1"
s.summary = "OpenSSL"
s.homepage = "https://github.com/apotocki/openssl-iosx"
s.license = "Apache"
Expand Down
183 changes: 89 additions & 94 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
THREAD_COUNT=$(sysctl hw.ncpu | awk '{print $2}')
HOST_ARC=$( uname -m )
XCODE_ROOT=$( xcode-select -print-path )
OPENSSL_VER=OpenSSL_1_1_1q
OPENSSL_VER=OpenSSL_1_1_1s
################## SETUP END
#DEVSYSROOT=$XCODE_ROOT/Platforms/iPhoneOS.platform/Developer
#SIMSYSROOT=$XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer
Expand All @@ -14,123 +14,118 @@ OPENSSL_VER_NAME=${OPENSSL_VER//.//-}
BUILD_DIR="$( cd "$( dirname "./" )" >/dev/null 2>&1 && pwd )"

if [ "$HOST_ARC" = "arm64" ]; then
BUILD_ARC=arm
FOREIGN_ARC=x86_64
else
BUILD_ARC=$HOST_ARC
FOREIGN_ARC=arm64
fi

if [ ! -d $BUILD_DIR/frameworks ]; then

if [ ! -d $OPENSSL_VER_NAME ]; then
if [[ ! -d $BUILD_DIR/frameworks ]]; then

if [[ ! -d $OPENSSL_VER_NAME ]]; then
echo downloading $OPENSSL_VER ...
git clone --depth 1 -b $OPENSSL_VER https://github.com/openssl/openssl $OPENSSL_VER_NAME
fi

echo patching $OPENSSL_VER ...
pushd $OPENSSL_VER_NAME
if [ ! -f test/v3ext.c.orig ]; then
mv test/v3ext.c test/v3ext.c.orig
fi
sed 's/#include <stdio.h>/#include <stdio.h>\n#include <string.h>/' test/v3ext.c.orig > test/v3ext.c


echo building $OPENSSL_VER "(-j$THREAD_COUNT)" ...


if [ -d $BUILD_DIR/build ]; then
rm -rf $BUILD_DIR/build
fi

if [ ! -d $BUILD_DIR/build/lib ]; then
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$HOST_ARC-cc
make clean
make -j$THREAD_COUNT
make install
make clean
fi

if [ $HOST_ARC == "arm64" ]; then
FOREIGN_ARCH=x86_64
else
FOREIGN_ARCH=arm64
fi

if [ ! -d $BUILD_DIR/build/lib.catalyst-host ]; then
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$HOST_ARC-cc --target=$BUILD_ARC-apple-ios13.4-macabi -isysroot $MACSYSROOT/SDKs/MacOSX.sdk -I$MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/usr/include/ -isystem $MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/usr/include -iframework $MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/System/Library/Frameworks
make clean
make -j$THREAD_COUNT

mkdir $BUILD_DIR/build/lib.catalyst-host
cp libssl.a $BUILD_DIR/build/lib.catalyst-host/
cp libcrypto.a $BUILD_DIR/build/lib.catalyst-host/
make clean
function arc()
{
if [[ $1 == arm* ]]; then
echo "arm"
elif [[ $1 == x86* ]]; then
echo "x86"
else
echo "unknown"
fi
}

build_catalyst_libs()
{
if [[ ! -d $BUILD_DIR/build/lib.catalyst-$1 ]]; then
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$1-cc --target=$(arc $1)-apple-ios13.4-macabi -isysroot $MACSYSROOT/SDKs/MacOSX.sdk
# -I$MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/usr/include/ -isystem $MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/usr/include -iframework $MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/System/Library/Frameworks
make clean
make -j$THREAD_COUNT

mkdir $BUILD_DIR/build/lib.catalyst-$1
cp libssl.a $BUILD_DIR/build/lib.catalyst-$1/
cp libcrypto.a $BUILD_DIR/build/lib.catalyst-$1/
make clean
fi
}

build_sim_libs()
{
if [[ ! -d $BUILD_DIR/build/lib.iossim-$1 ]]; then
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared iossimulator-xcrun CFLAGS="-arch $1"
make clean
make -j$THREAD_COUNT

mkdir $BUILD_DIR/build/lib.iossim-$1
cp libssl.a $BUILD_DIR/build/lib.iossim-$1/
cp libcrypto.a $BUILD_DIR/build/lib.iossim-$1/
make clean
fi
}

build_ios_libs()
{
if [[ ! -d $BUILD_DIR/build/lib.ios ]]; then
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared no-dso no-hw no-engine ios64-xcrun -fembed-bitcode -mios-version-min=13.4
make clean
make -j$THREAD_COUNT

mkdir $BUILD_DIR/build/lib.ios
cp libssl.a $BUILD_DIR/build/lib.ios/
cp libcrypto.a $BUILD_DIR/build/lib.ios/
make clean
fi
}

if [[ ! -d $BUILD_DIR/build/lib ]]; then
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$HOST_ARC-cc
make clean
make -j$THREAD_COUNT
make install
make clean
fi
if [[ ! -d $BUILD_DIR/build/lib.macos ]]; then
./Configure --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$FOREIGN_ARC-cc CFLAGS="-arch $FOREIGN_ARC"
make clean
make -j$THREAD_COUNT

if [ ! -d $BUILD_DIR/build/lib.catalyst-$FOREIGN_ARCH ]; then
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared darwin64-$FOREIGN_ARCH-cc --target=$FOREIGN_ARCH-apple-ios13.4-macabi -isysroot $MACSYSROOT/SDKs/MacOSX.sdk -I$MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/usr/include/ -isystem $MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/usr/include -iframework $MACSYSROOT/SDKs/MacOSX.sdk/System/iOSSupport/System/Library/Frameworks
make clean
make -j$THREAD_COUNT

mkdir $BUILD_DIR/build/lib.catalyst-$FOREIGN_ARCH
cp libssl.a $BUILD_DIR/build/lib.catalyst-$FOREIGN_ARCH/
cp libcrypto.a $BUILD_DIR/build/lib.catalyst-$FOREIGN_ARCH/
make clean
fi
mkdir $BUILD_DIR/build/lib.macos
lipo -create $BUILD_DIR/build/lib/libssl.a libssl.a -output $BUILD_DIR/build/lib.macos/libssl.a
lipo -create $BUILD_DIR/build/lib/libcrypto.a libcrypto.a -output $BUILD_DIR/build/lib.macos/libcrypto.a

if [ -d $BUILD_DIR/build/lib.catalyst ]; then
rm -rf $BUILD_DIR/build/lib.catalyst
make clean
fi
mkdir $BUILD_DIR/build/lib.catalyst
lipo -create $BUILD_DIR/build/lib.catalyst-$FOREIGN_ARCH/libssl.a $BUILD_DIR/build/lib.catalyst-host/libssl.a -output $BUILD_DIR/build/lib.catalyst/libssl.a
lipo -create $BUILD_DIR/build/lib.catalyst-$FOREIGN_ARCH/libcrypto.a $BUILD_DIR/build/lib.catalyst-host/libcrypto.a -output $BUILD_DIR/build/lib.catalyst/libcrypto.a

if [ ! -d $BUILD_DIR/build/lib.iossim-host ]; then
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared iossimulator-xcrun
make clean
make -j$THREAD_COUNT

mkdir $BUILD_DIR/build/lib.iossim-host
cp libssl.a $BUILD_DIR/build/lib.iossim-host/
cp libcrypto.a $BUILD_DIR/build/lib.iossim-host/
make clean
fi

if [ ! -d $BUILD_DIR/build/lib.iossim-$FOREIGN_ARCH ]; then
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared iossimulator-xcrun CFLAGS="-arch $FOREIGN_ARCH"
make clean
make -j$THREAD_COUNT

mkdir $BUILD_DIR/build/lib.iossim-$FOREIGN_ARCH
cp libssl.a $BUILD_DIR/build/lib.iossim-$FOREIGN_ARCH/
cp libcrypto.a $BUILD_DIR/build/lib.iossim-$FOREIGN_ARCH/
make clean
if [[ ! -d $BUILD_DIR/build/lib.catalyst ]]; then
build_catalyst_libs arm64
build_catalyst_libs x86_64
mkdir $BUILD_DIR/build/lib.catalyst
lipo -create $BUILD_DIR/build/lib.catalyst-x86_64/libssl.a $BUILD_DIR/build/lib.catalyst-arm64/libssl.a -output $BUILD_DIR/build/lib.catalyst/libssl.a
lipo -create $BUILD_DIR/build/lib.catalyst-x86_64/libcrypto.a $BUILD_DIR/build/lib.catalyst-arm64/libcrypto.a -output $BUILD_DIR/build/lib.catalyst/libcrypto.a
fi

if [ -d $BUILD_DIR/build/lib.iossim ]; then
rm -rf $BUILD_DIR/build/lib.iossim
if [[ ! -d $BUILD_DIR/build/lib.iossim ]]; then
build_sim_libs arm64
build_sim_libs x86_64
mkdir $BUILD_DIR/build/lib.iossim
lipo -create $BUILD_DIR/build/lib.iossim-x86_64/libssl.a $BUILD_DIR/build/lib.iossim-arm64/libssl.a -output $BUILD_DIR/build/lib.iossim/libssl.a
lipo -create $BUILD_DIR/build/lib.iossim-x86_64/libcrypto.a $BUILD_DIR/build/lib.iossim-arm64/libcrypto.a -output $BUILD_DIR/build/lib.iossim/libcrypto.a
fi
mkdir $BUILD_DIR/build/lib.iossim
lipo -create $BUILD_DIR/build/lib.iossim-$FOREIGN_ARCH/libssl.a $BUILD_DIR/build/lib.iossim-host/libssl.a -output $BUILD_DIR/build/lib.iossim/libssl.a
lipo -create $BUILD_DIR/build/lib.iossim-$FOREIGN_ARCH/libcrypto.a $BUILD_DIR/build/lib.iossim-host/libcrypto.a -output $BUILD_DIR/build/lib.iossim/libcrypto.a


if [ ! -d $BUILD_DIR/build/lib.ios ]; then
./Configure --prefix="$BUILD_DIR/build" --openssldir="$BUILD_DIR/build/ssl" no-shared no-dso no-hw no-engine ios64-xcrun -fembed-bitcode -mios-version-min=13.4
make clean
make -j$THREAD_COUNT

mkdir $BUILD_DIR/build/lib.ios
cp libssl.a $BUILD_DIR/build/lib.ios/
cp libcrypto.a $BUILD_DIR/build/lib.ios/
make clean
fi
build_ios_libs

mkdir $BUILD_DIR/frameworks

cp -R $BUILD_DIR/build/include $BUILD_DIR/frameworks/Headers

xcodebuild -create-xcframework -library $BUILD_DIR/build/lib/libssl.a -library $BUILD_DIR/build/lib.catalyst/libssl.a -library $BUILD_DIR/build/lib.iossim/libssl.a -library $BUILD_DIR/build/lib.ios/libssl.a -output $BUILD_DIR/frameworks/ssl.xcframework
xcodebuild -create-xcframework -library $BUILD_DIR/build/lib/libcrypto.a -library $BUILD_DIR/build/lib.catalyst/libcrypto.a -library $BUILD_DIR/build/lib.iossim/libcrypto.a -library $BUILD_DIR/build/lib.ios/libcrypto.a -output $BUILD_DIR/frameworks/crypto.xcframework
xcodebuild -create-xcframework -library $BUILD_DIR/build/lib.macos/libssl.a -library $BUILD_DIR/build/lib.catalyst/libssl.a -library $BUILD_DIR/build/lib.iossim/libssl.a -library $BUILD_DIR/build/lib.ios/libssl.a -output $BUILD_DIR/frameworks/ssl.xcframework
xcodebuild -create-xcframework -library $BUILD_DIR/build/lib.macos/libcrypto.a -library $BUILD_DIR/build/lib.catalyst/libcrypto.a -library $BUILD_DIR/build/lib.iossim/libcrypto.a -library $BUILD_DIR/build/lib.ios/libcrypto.a -output $BUILD_DIR/frameworks/crypto.xcframework

popd

Expand Down

0 comments on commit 27ebe3f

Please sign in to comment.