blob: 812e4eb0ebaaefb4c8aaca1e8a41b0105a4c305e [file] [log] [blame]
Ilya Shipitsin054a5b82019-05-03 14:31:20 +05001#!/bin/sh
2set -eux
3
4download_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
11build_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
19build_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
28build_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
40download_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 Shipitsin054a5b82019-05-03 14:31:20 +050047build_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
59if [ ! -z ${LIBRESSL_VERSION+x} ]; then
60 download_libressl
61 build_libressl
62fi
63
64if [ ! -z ${OPENSSL_VERSION+x} ]; then
65 download_openssl
66 build_openssl
67fi
68
Ilya Shipitsin35d20af2019-05-09 01:15:59 +050069if [ ! -z ${BORINGSSL+x} ]; then
70 (
71 git clone --depth=1 https://boringssl.googlesource.com/boringssl
72 cd boringssl
73 mkdir build
74 cd build
75 cmake -DCMAKE_BUILD_TYPE=release -DBUILD_SHARED_LIBS=1 ..
76 make
77
78 rm -rf ${SSL_LIB} || exit 0
79 rm -rf ${SSL_INC} || exit 0
80
81 mkdir -p ${SSL_LIB}
82 cp crypto/libcrypto.so ssl/libssl.so ${SSL_LIB}
83
84 mkdir -p ${SSL_INC}
85 mv ../include/* ${SSL_INC}
86 )
87fi
Ilya Shipitsin054a5b82019-05-03 14:31:20 +050088