tildefriends/tools/ssl-android
Cory McWilliams a5814074fe
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 7m26s
OpenSSL 3.3.2.
2024-09-04 20:24:32 -04:00

136 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
if [ -z $ANDROID_NDK_ROOT ]; then
ANDROID_NDK_ROOT=~/Android/Sdk/ndk/26.1.10909125
fi
API_LEVEL=24
BUILD_DIR=out/openssl_android_build
BUILD_TARGETS="x86_64 x86 arm64-v8a armeabi-v7a"
WORK_DIR=out/openssl-android
rm -rf $WORK_DIR
cp -arf deps/openssl_src/ $WORK_DIR
export ANDROID_NDK_ROOT
echo ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT
build_the_thing() {
TOOLCHAIN=$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64
export PATH=$TOOLCHAIN/$TRIBLE/bin:$TOOLCHAIN/bin:$PATH
echo $PATH
export GLOBAL_OPTIONS="
no-apps
no-asm
no-async
no-autoerrinit
no-autoload-config
no-cmp
no-cms
no-comp
no-deprecated
no-dgram
no-docs
no-dsa
no-dso
no-dtls
no-dtls1
no-dtls1-method
no-dynamic-engine
no-ec2m
no-egd
no-engine
no-err
no-filenames
no-gost
no-http
no-idea
no-legacy
no-md2
no-md4
no-module
no-multiblock
no-nextprotoneg
no-ocsp
no-psk
no-shared
no-sock
no-srp
no-ssl
no-ssl3
no-ssl-trace
no-stdio
no-tests
no-thread-pool
no-threads
no-tls1
no-tls1-method
no-trace
no-ui-console
no-uplink
no-whirlpool
no-weak-ssl-ciphers
no-zlib
-Os
-DOPENSSL_SMALL_FOOTPRINT
-flto"
pwd
echo "./Configure $SSL_TARGET $OPTIONS $GLOBAL_OPTIONS" && \
./Configure $SSL_TARGET $OPTIONS $GLOBAL_OPTIONS && \
make -s clean && \
make -s build_generated && \
make -s libcrypto.a libssl.a || exit 128
}
for build_target in $BUILD_TARGETS
do
echo "Building $build_target"
pwd
pushd $WORK_DIR || exit 128
case $build_target in
armeabi-v7a)
TRIBLE="arm-linux-androideabi"
OPTIONS="--target=armv7a-linux-androideabi -ffunction-sections -fdata-sections -Wl,--fix-cortex-a8 -fPIC -D__ANDROID_API__=$API_LEVEL -Wno-macro-redefined"
DESTDIR="/tmp/$BUILD_DIR/armeabi-v7a"
SSL_TARGET="android-arm"
CC=clang
;;
x86)
TRIBLE="i686-linux-android"
OPTIONS="-fPIC -ffunction-sections -fdata-sections -D__ANDROID_API__=${API_LEVEL} -Wno-macro-redefined"
DESTDIR="/tmp/$BUILD_DIR/x86"
SSL_TARGET="android-x86"
CC=clang
;;
x86_64)
TRIBLE="x86_64-linux-android"
OPTIONS="--static -static -ffunction-sections -fdata-sections -D__ANDROID_API__=${API_LEVEL} -Wno-macro-redefined"
DESTDIR="/tmp/$BUILD_DIR/x86_64"
SSL_TARGET="android-x86_64"
CC=clang
;;
arm64-v8a)
TRIBLE="aarch64-linux-android"
OPTIONS="--static -static -ffunction-sections -fdata-sections -fPIC -D__ANDROID_API__=${API_LEVEL} -Wno-macro-redefined"
DESTDIR="/tmp/$BUILD_DIR/arm64-v8a"
SSL_TARGET="android-arm64"
CC=clang
;;
esac
rm -rf $DESTDIR
build_the_thing
popd
echo WORK_DIR=$WORK_DIR
rm -rf deps/openssl/android/$build_target/
mkdir -p deps/openssl/android/$build_target/usr/local/include/
mkdir -p deps/openssl/android/$build_target/usr/local/lib/
cp -R $WORK_DIR/include/* deps/openssl/android/$build_target/usr/local/include/
cp $WORK_DIR/*.a deps/openssl/android/$build_target/usr/local/lib/
done
echo Success