Ilya Shipitsin | 054a5b8 | 2019-05-03 14:31:20 +0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | set -eux |
| 3 | |
| 4 | download_openssl () { |
| 5 | if [ ! -f "download-cache/openssl-${OPENSSL_VERSION}.tar.gz" ]; then |
| 6 | wget -P download-cache/ \ |
| 7 | "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz" |
| 8 | fi |
| 9 | } |
| 10 | |
| 11 | build_openssl_linux () { |
| 12 | ( |
| 13 | cd "openssl-${OPENSSL_VERSION}/" |
| 14 | ./config shared --prefix="${HOME}/opt" --openssldir="${HOME}/opt" -DPURIFY |
| 15 | make all install_sw |
| 16 | ) |
| 17 | } |
| 18 | |
| 19 | build_openssl_osx () { |
| 20 | ( |
| 21 | cd "openssl-${OPENSSL_VERSION}/" |
| 22 | ./Configure darwin64-x86_64-cc shared \ |
| 23 | --prefix="${HOME}/opt" --openssldir="${HOME}/opt" -DPURIFY |
| 24 | make depend all install_sw |
| 25 | ) |
| 26 | } |
| 27 | |
| 28 | build_openssl () { |
| 29 | if [ "$(cat ${HOME}/opt/.openssl-version)" != "${OPENSSL_VERSION}" ]; then |
| 30 | tar zxf "download-cache/openssl-${OPENSSL_VERSION}.tar.gz" |
| 31 | if [ "${TRAVIS_OS_NAME}" = "osx" ]; then |
| 32 | build_openssl_osx |
| 33 | elif [ "${TRAVIS_OS_NAME}" = "linux" ]; then |
| 34 | build_openssl_linux |
| 35 | fi |
| 36 | echo "${OPENSSL_VERSION}" > "${HOME}/opt/.openssl-version" |
| 37 | fi |
| 38 | } |
| 39 | |
| 40 | download_libressl () { |
| 41 | if [ ! -f "download-cache/libressl-${LIBRESSL_VERSION}.tar.gz" ]; then |
| 42 | wget -P download-cache/ \ |
| 43 | "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz" |
| 44 | fi |
| 45 | } |
| 46 | |
Ilya Shipitsin | 054a5b8 | 2019-05-03 14:31:20 +0500 | [diff] [blame] | 47 | build_libressl () { |
| 48 | if [ "$(cat ${HOME}/opt/.libressl-version)" != "${LIBRESSL_VERSION}" ]; then |
| 49 | tar zxf "download-cache/libressl-${LIBRESSL_VERSION}.tar.gz" |
| 50 | ( |
| 51 | cd "libressl-${LIBRESSL_VERSION}/" |
| 52 | ./configure --prefix="${HOME}/opt" |
| 53 | make all install |
| 54 | ) |
| 55 | echo "${LIBRESSL_VERSION}" > "${HOME}/opt/.libressl-version" |
| 56 | fi |
| 57 | } |
| 58 | |
Ilya Shipitsin | a088d3d | 2019-06-05 02:16:51 +0500 | [diff] [blame] | 59 | download_boringssl () { |
| 60 | if [ ! -d "download-cache/boringssl" ]; then |
| 61 | git clone --depth=1 https://boringssl.googlesource.com/boringssl download-cache/boringssl |
| 62 | else |
| 63 | ( |
| 64 | cd download-cache/boringssl |
| 65 | git pull |
| 66 | ) |
| 67 | fi |
| 68 | } |
| 69 | |
Ilya Shipitsin | 054a5b8 | 2019-05-03 14:31:20 +0500 | [diff] [blame] | 70 | if [ ! -z ${LIBRESSL_VERSION+x} ]; then |
| 71 | download_libressl |
| 72 | build_libressl |
| 73 | fi |
| 74 | |
| 75 | if [ ! -z ${OPENSSL_VERSION+x} ]; then |
| 76 | download_openssl |
| 77 | build_openssl |
| 78 | fi |
| 79 | |
Ilya Shipitsin | 35d20af | 2019-05-09 01:15:59 +0500 | [diff] [blame] | 80 | if [ ! -z ${BORINGSSL+x} ]; then |
| 81 | ( |
Ilya Shipitsin | 8abf026 | 2019-09-16 16:13:10 +0500 | [diff] [blame] | 82 | |
| 83 | # travis-ci comes with go-1.11, while boringssl requires go-1.13 |
| 84 | eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.13 bash)" |
| 85 | |
Ilya Shipitsin | a088d3d | 2019-06-05 02:16:51 +0500 | [diff] [blame] | 86 | download_boringssl |
| 87 | cd download-cache/boringssl |
| 88 | if [ -d build ]; then rm -rf build; fi |
Ilya Shipitsin | 35d20af | 2019-05-09 01:15:59 +0500 | [diff] [blame] | 89 | mkdir build |
| 90 | cd build |
| 91 | cmake -DCMAKE_BUILD_TYPE=release -DBUILD_SHARED_LIBS=1 .. |
| 92 | make |
| 93 | |
| 94 | rm -rf ${SSL_LIB} || exit 0 |
| 95 | rm -rf ${SSL_INC} || exit 0 |
| 96 | |
| 97 | mkdir -p ${SSL_LIB} |
| 98 | cp crypto/libcrypto.so ssl/libssl.so ${SSL_LIB} |
| 99 | |
| 100 | mkdir -p ${SSL_INC} |
Ilya Shipitsin | a088d3d | 2019-06-05 02:16:51 +0500 | [diff] [blame] | 101 | cp -r ../include/* ${SSL_INC} |
Ilya Shipitsin | 35d20af | 2019-05-09 01:15:59 +0500 | [diff] [blame] | 102 | ) |
| 103 | fi |
Ilya Shipitsin | 054a5b8 | 2019-05-03 14:31:20 +0500 | [diff] [blame] | 104 | |