1#!/usr/bin/env bash
2
3echo "Downloading OpenSSL"
4if ! curl -L -k -s -o openssl-1.1.1d.tar.gz https://www.openssl.org/source/openssl-1.1.1d.tar.gz;
5then
6    echo "Failed to download OpenSSL"
7    exit 1
8fi
9
10echo "Unpacking OpenSSL"
11rm -rf ./openssl-1.1.1d
12if ! tar -xf openssl-1.1.1d.tar.gz;
13then
14    echo "Failed to unpack OpenSSL"
15    exit 1
16fi
17
18cd openssl-1.1.1d || exit 1
19
20if ! cp ../contrib/android/15-android.conf Configurations/; then
21    echo "Failed to copy OpenSSL Android config"
22    exit 1
23fi
24
25echo "Configuring OpenSSL"
26if ! ./Configure "$OPENSSL_HOST" no-comp no-asm no-hw no-engine shared \
27       --prefix="$ANDROID_PREFIX" --openssldir="$ANDROID_PREFIX"; then
28    echo "Failed to configure OpenSSL"
29    exit 1
30fi
31
32echo "Building OpenSSL"
33if ! make; then
34    echo "Failed to build OpenSSL"
35    exit 1
36fi
37
38echo "Installing OpenSSL"
39if ! make install_sw; then
40    echo "Failed to install OpenSSL"
41    exit 1
42fi
43
44exit 0
45