2019-05-03 14:31:20 +05:00
#!/bin/sh
set -eux
download_openssl ( ) {
if [ ! -f " download-cache/openssl- ${ OPENSSL_VERSION } .tar.gz " ] ; then
2020-04-07 23:35:49 +05:00
#
# OpenSSL has different links for latest and previous releases
# since we want to download several versions, let us try to treat
# current version as latest, if it fails, follow with previous
#
wget -P download-cache/ \
" https://www.openssl.org/source/openssl- ${ OPENSSL_VERSION } .tar.gz " || \
2019-05-03 14:31:20 +05:00
wget -P download-cache/ \
2024-02-02 20:33:16 +01:00
" https://www.openssl.org/source/old/ ${ OPENSSL_VERSION %[a-z] } /openssl- ${ OPENSSL_VERSION } .tar.gz " || \
wget -P download-cache/ \
" https://github.com/openssl/openssl/releases/download/openssl- ${ OPENSSL_VERSION } /openssl- ${ OPENSSL_VERSION } .tar.gz "
2019-05-03 14:31:20 +05:00
fi
}
2021-06-17 15:39:30 +02:00
# recent openssl versions support parallel builds and skipping the docs,
# while older ones require to build everything sequentially.
2019-05-03 14:31:20 +05:00
build_openssl_linux ( ) {
(
cd " openssl- ${ OPENSSL_VERSION } / "
2021-08-21 16:01:25 +05:00
./config shared --prefix= " ${ HOME } /opt " --openssldir= " ${ HOME } /opt " --libdir= lib -DPURIFY
2021-06-17 15:39:30 +02:00
if [ -z " ${ OPENSSL_VERSION ##1.* } " ] ; then
make all
else
make -j$( nproc) build_sw
fi
2021-06-10 07:52:23 +02:00
make install_sw
2019-05-03 14:31:20 +05:00
)
}
build_openssl_osx ( ) {
(
cd " openssl- ${ OPENSSL_VERSION } / "
./Configure darwin64-x86_64-cc shared \
2021-08-21 16:01:25 +05:00
--prefix= " ${ HOME } /opt " --openssldir= " ${ HOME } /opt " --libdir= lib -DPURIFY
2021-06-10 07:52:23 +02:00
make depend build_sw install_sw
2019-05-03 14:31:20 +05:00
)
}
build_openssl ( ) {
if [ " $( cat ${ HOME } /opt/.openssl-version) " != " ${ OPENSSL_VERSION } " ] ; then
tar zxf " download-cache/openssl- ${ OPENSSL_VERSION } .tar.gz "
2020-02-11 14:36:23 +05:00
case ` uname` in
'Darwin' )
build_openssl_osx
; ;
'Linux' )
build_openssl_linux
; ;
esac
2019-05-03 14:31:20 +05:00
echo " ${ OPENSSL_VERSION } " > " ${ HOME } /opt/.openssl-version "
fi
}
download_libressl ( ) {
if [ ! -f " download-cache/libressl- ${ LIBRESSL_VERSION } .tar.gz " ] ; then
wget -P download-cache/ \
2023-04-26 12:15:11 +02:00
" https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl- ${ LIBRESSL_VERSION } .tar.gz "
2019-05-03 14:31:20 +05:00
fi
}
build_libressl ( ) {
if [ " $( cat ${ HOME } /opt/.libressl-version) " != " ${ LIBRESSL_VERSION } " ] ; then
tar zxf " download-cache/libressl- ${ LIBRESSL_VERSION } .tar.gz "
(
cd " libressl- ${ LIBRESSL_VERSION } / "
./configure --prefix= " ${ HOME } /opt "
make all install
)
echo " ${ LIBRESSL_VERSION } " > " ${ HOME } /opt/.libressl-version "
fi
}
2019-06-05 02:16:51 +05:00
download_boringssl ( ) {
if [ ! -d "download-cache/boringssl" ] ; then
git clone --depth= 1 https://boringssl.googlesource.com/boringssl download-cache/boringssl
else
(
cd download-cache/boringssl
git pull
)
fi
}
2023-09-05 16:23:05 -07:00
download_aws_lc ( ) {
if [ ! -f " download-cache/aws-lc- ${ AWS_LC_VERSION } .tar.gz " ] ; then
mkdir -p download-cache
wget -q -O " download-cache/aws-lc- ${ AWS_LC_VERSION } .tar.gz " \
" https://github.com/aws/aws-lc/archive/refs/tags/v ${ AWS_LC_VERSION } .tar.gz "
fi
}
build_aws_lc ( ) {
if [ " $( cat ${ HOME } /opt/.aws_lc-version) " != " ${ AWS_LC_VERSION } " ] ; then
tar zxf " download-cache/aws-lc- ${ AWS_LC_VERSION } .tar.gz "
(
cd " aws-lc- ${ AWS_LC_VERSION } / "
mkdir -p build
cd build
cmake -version
cmake -DCMAKE_BUILD_TYPE= Release -DBUILD_SHARED_LIBS= 1 -DDISABLE_GO= 1 -DDISABLE_PERL= 1 \
-DBUILD_TESTING= 0 -DCMAKE_INSTALL_PREFIX= ${ HOME } /opt ..
make -j$( nproc)
make install
)
echo " ${ AWS_LC_VERSION } " > " ${ HOME } /opt/.aws_lc-version "
fi
}
2021-11-18 18:27:56 +05:00
download_quictls ( ) {
if [ ! -d "download-cache/quictls" ] ; then
git clone --depth= 1 https://github.com/quictls/openssl download-cache/quictls
else
(
cd download-cache/quictls
git pull
)
fi
}
2023-10-09 23:34:44 +02:00
download_wolfssl ( ) {
if [ ! -f " download-cache/wolfssl- ${ WOLFSSL_VERSION } .tar.gz " ] ; then
mkdir -p download-cache
2023-10-10 00:26:46 +02:00
if [ " ${ WOLFSSL_VERSION %%-* } " != "git" ] ; then
2023-10-09 23:34:44 +02:00
wget -q -O " download-cache/wolfssl- ${ WOLFSSL_VERSION } .tar.gz " \
2023-10-10 00:26:46 +02:00
" https://github.com/wolfSSL/wolfssl/archive/refs/tags/v ${ WOLFSSL_VERSION } -stable.tar.gz "
else
wget -q -O " download-cache/wolfssl- ${ WOLFSSL_VERSION } .tar.gz " \
" https://github.com/wolfSSL/wolfssl/archive/ ${ WOLFSSL_VERSION ##git- } .tar.gz "
fi
2023-10-09 23:34:44 +02:00
fi
}
build_wolfssl ( ) {
if [ " $( cat ${ HOME } /opt/.wolfssl-version) " != " ${ WOLFSSL_VERSION } " ] ; then
2023-10-10 00:26:46 +02:00
mkdir " wolfssl- ${ WOLFSSL_VERSION } / "
tar zxf " download-cache/wolfssl- ${ WOLFSSL_VERSION } .tar.gz " -C " wolfssl- ${ WOLFSSL_VERSION } / " --strip-components= 1
2023-10-09 23:34:44 +02:00
(
2023-10-10 00:26:46 +02:00
cd " wolfssl- ${ WOLFSSL_VERSION } / "
2023-10-09 23:34:44 +02:00
autoreconf -i
./configure --enable-haproxy --enable-quic --prefix= " ${ HOME } /opt "
make -j$( nproc)
make install
)
echo " ${ WOLFSSL_VERSION } " > " ${ HOME } /opt/.wolfssl-version "
fi
}
2019-05-03 14:31:20 +05:00
if [ ! -z ${ LIBRESSL_VERSION +x } ] ; then
download_libressl
build_libressl
fi
if [ ! -z ${ OPENSSL_VERSION +x } ] ; then
download_openssl
build_openssl
fi
2019-05-09 01:15:59 +05:00
if [ ! -z ${ BORINGSSL +x } ] ; then
(
2019-09-16 16:13:10 +05:00
# travis-ci comes with go-1.11, while boringssl requires go-1.13
eval " $( curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION = 1.13 bash) "
2019-06-05 02:16:51 +05:00
download_boringssl
cd download-cache/boringssl
if [ -d build ] ; then rm -rf build; fi
2019-05-09 01:15:59 +05:00
mkdir build
cd build
2020-06-21 16:39:30 +05:00
cmake -GNinja -DCMAKE_BUILD_TYPE= release -DBUILD_SHARED_LIBS= 1 ..
ninja
2019-05-09 01:15:59 +05:00
2020-10-11 23:42:51 +05:00
rm -rf ${ HOME } /opt/lib || exit 0
rm -rf ${ HOME } /opt/include || exit 0
2019-05-09 01:15:59 +05:00
2020-10-11 23:42:51 +05:00
mkdir -p ${ HOME } /opt/lib
cp crypto/libcrypto.so ssl/libssl.so ${ HOME } /opt/lib
2019-05-09 01:15:59 +05:00
2020-10-11 23:42:51 +05:00
mkdir -p ${ HOME } /opt/include
cp -r ../include/* ${ HOME } /opt/include
2019-05-09 01:15:59 +05:00
)
fi
2019-05-03 14:31:20 +05:00
2023-09-05 16:23:05 -07:00
if [ ! -z ${ AWS_LC_VERSION +x } ] ; then
download_aws_lc
build_aws_lc
fi
2021-11-18 18:27:56 +05:00
if [ ! -z ${ QUICTLS +x } ] ; then
(
download_quictls
cd download-cache/quictls
2022-10-15 09:55:49 +05:00
./config shared no-tests ${ QUICTLS_EXTRA_ARGS :- } --prefix= " ${ HOME } /opt " --openssldir= " ${ HOME } /opt " --libdir= lib -DPURIFY
2021-11-18 18:27:56 +05:00
make -j$( nproc) build_sw
make install_sw
)
fi
2023-10-09 23:34:44 +02:00
if [ ! -z ${ WOLFSSL_VERSION +x } ] ; then
download_wolfssl
build_wolfssl
fi