xref: /freebsd-src/contrib/unbound/contrib/ios/install_openssl.sh (revision e25152834cdf3b353892835a4f3b157e066a8ed4)
1*25039b37SCy Schubert#!/usr/bin/env bash
2*25039b37SCy Schubert
3*25039b37SCy Schubertecho "Downloading OpenSSL"
4*25039b37SCy Schubertif ! curl -L -k -s -o openssl-1.1.1d.tar.gz https://www.openssl.org/source/openssl-1.1.1d.tar.gz;
5*25039b37SCy Schubertthen
6*25039b37SCy Schubert    echo "Failed to download OpenSSL"
7*25039b37SCy Schubert    exit 1
8*25039b37SCy Schubertfi
9*25039b37SCy Schubert
10*25039b37SCy Schubertecho "Unpacking OpenSSL"
11*25039b37SCy Schubertrm -rf ./openssl-1.1.1d
12*25039b37SCy Schubertif ! tar -xf openssl-1.1.1d.tar.gz;
13*25039b37SCy Schubertthen
14*25039b37SCy Schubert    echo "Failed to unpack OpenSSL"
15*25039b37SCy Schubert    exit 1
16*25039b37SCy Schubertfi
17*25039b37SCy Schubert
18*25039b37SCy Schubertcd openssl-1.1.1d || exit 1
19*25039b37SCy Schubert
20*25039b37SCy Schubertif ! cp ../contrib/ios/15-ios.conf Configurations/; then
21*25039b37SCy Schubert    echo "Failed to copy OpenSSL ios config"
22*25039b37SCy Schubert    exit 1
23*25039b37SCy Schubertfi
24*25039b37SCy Schubert
25*25039b37SCy Schubert# OpenSSL 1.1.1d patch. OK to remove once OpenSSL version is bumped.
26*25039b37SCy Schubert# ocsp.c:947:23: error: 'fork' is unavailable: not available on tvOS and watchOS.
27*25039b37SCy Schubert# Also see https://github.com/openssl/openssl/issues/7607.
28*25039b37SCy Schubertif ! patch -u -p0 < ../contrib/ios/openssl.patch; then
29*25039b37SCy Schubert    echo "Failed to patch OpenSSL"
30*25039b37SCy Schubert    exit 1
31*25039b37SCy Schubertfi
32*25039b37SCy Schubert
33*25039b37SCy Schubertecho "Configuring OpenSSL"
34*25039b37SCy Schubertif ! ./Configure "$OPENSSL_HOST" -DNO_FORK no-comp no-asm no-hw no-engine no-tests no-unit-test \
35*25039b37SCy Schubert       --prefix="$IOS_PREFIX" --openssldir="$IOS_PREFIX"; then
36*25039b37SCy Schubert    echo "Failed to configure OpenSSL"
37*25039b37SCy Schubert    exit 1
38*25039b37SCy Schubertfi
39*25039b37SCy Schubert
40*25039b37SCy Schubertecho "Building OpenSSL"
41*25039b37SCy Schubertif ! make; then
42*25039b37SCy Schubert    echo "Failed to build OpenSSL"
43*25039b37SCy Schubert    exit 1
44*25039b37SCy Schubertfi
45*25039b37SCy Schubert
46*25039b37SCy Schubertecho "Installing OpenSSL"
47*25039b37SCy Schubertif ! make install_sw; then
48*25039b37SCy Schubert    echo "Failed to install OpenSSL"
49*25039b37SCy Schubert    exit 1
50*25039b37SCy Schubertfi
51*25039b37SCy Schubert
52*25039b37SCy Schubertexit 0
53