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" |
Ilya Shipitsin | 47e09dd | 2020-02-11 14:36:23 +0500 | [diff] [blame] | 31 | case `uname` in |
| 32 | 'Darwin') |
| 33 | build_openssl_osx |
| 34 | ;; |
| 35 | 'Linux') |
| 36 | build_openssl_linux |
| 37 | ;; |
| 38 | esac |
Ilya Shipitsin | 054a5b8 | 2019-05-03 14:31:20 +0500 | [diff] [blame] | 39 | echo "${OPENSSL_VERSION}" > "${HOME}/opt/.openssl-version" |
| 40 | fi |
| 41 | } |
| 42 | |
| 43 | download_libressl () { |
| 44 | if [ ! -f "download-cache/libressl-${LIBRESSL_VERSION}.tar.gz" ]; then |
| 45 | wget -P download-cache/ \ |
| 46 | "https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz" |
| 47 | fi |
| 48 | } |
| 49 | |
Ilya Shipitsin | 054a5b8 | 2019-05-03 14:31:20 +0500 | [diff] [blame] | 50 | build_libressl () { |
| 51 | if [ "$(cat ${HOME}/opt/.libressl-version)" != "${LIBRESSL_VERSION}" ]; then |
| 52 | tar zxf "download-cache/libressl-${LIBRESSL_VERSION}.tar.gz" |
| 53 | ( |
| 54 | cd "libressl-${LIBRESSL_VERSION}/" |
| 55 | ./configure --prefix="${HOME}/opt" |
| 56 | make all install |
| 57 | ) |
| 58 | echo "${LIBRESSL_VERSION}" > "${HOME}/opt/.libressl-version" |
| 59 | fi |
| 60 | } |
| 61 | |
Ilya Shipitsin | a088d3d | 2019-06-05 02:16:51 +0500 | [diff] [blame] | 62 | download_boringssl () { |
| 63 | if [ ! -d "download-cache/boringssl" ]; then |
| 64 | git clone --depth=1 https://boringssl.googlesource.com/boringssl download-cache/boringssl |
| 65 | else |
| 66 | ( |
| 67 | cd download-cache/boringssl |
| 68 | git pull |
| 69 | ) |
| 70 | fi |
| 71 | } |
| 72 | |
Ilya Shipitsin | 054a5b8 | 2019-05-03 14:31:20 +0500 | [diff] [blame] | 73 | if [ ! -z ${LIBRESSL_VERSION+x} ]; then |
| 74 | download_libressl |
| 75 | build_libressl |
| 76 | fi |
| 77 | |
| 78 | if [ ! -z ${OPENSSL_VERSION+x} ]; then |
| 79 | download_openssl |
| 80 | build_openssl |
| 81 | fi |
| 82 | |
Ilya Shipitsin | 35d20af | 2019-05-09 01:15:59 +0500 | [diff] [blame] | 83 | if [ ! -z ${BORINGSSL+x} ]; then |
| 84 | ( |
Ilya Shipitsin | 8abf026 | 2019-09-16 16:13:10 +0500 | [diff] [blame] | 85 | |
| 86 | # travis-ci comes with go-1.11, while boringssl requires go-1.13 |
| 87 | eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.13 bash)" |
| 88 | |
Ilya Shipitsin | a088d3d | 2019-06-05 02:16:51 +0500 | [diff] [blame] | 89 | download_boringssl |
| 90 | cd download-cache/boringssl |
| 91 | if [ -d build ]; then rm -rf build; fi |
Ilya Shipitsin | 35d20af | 2019-05-09 01:15:59 +0500 | [diff] [blame] | 92 | mkdir build |
| 93 | cd build |
| 94 | cmake -DCMAKE_BUILD_TYPE=release -DBUILD_SHARED_LIBS=1 .. |
| 95 | make |
| 96 | |
| 97 | rm -rf ${SSL_LIB} || exit 0 |
| 98 | rm -rf ${SSL_INC} || exit 0 |
| 99 | |
| 100 | mkdir -p ${SSL_LIB} |
| 101 | cp crypto/libcrypto.so ssl/libssl.so ${SSL_LIB} |
| 102 | |
| 103 | mkdir -p ${SSL_INC} |
Ilya Shipitsin | a088d3d | 2019-06-05 02:16:51 +0500 | [diff] [blame] | 104 | cp -r ../include/* ${SSL_INC} |
Ilya Shipitsin | 35d20af | 2019-05-09 01:15:59 +0500 | [diff] [blame] | 105 | ) |
| 106 | fi |
Ilya Shipitsin | 054a5b8 | 2019-05-03 14:31:20 +0500 | [diff] [blame] | 107 | |