#!/bin/bash -e

version=1.1.1i

rm -fr openssl-$version
curl -f "https://www.openssl.org/source/openssl-$version.tar.gz" | tar xz
pushd openssl-$version
# no-afalgeng because we don't need afalgeng.
# no-dynamic-engine to prevent loading shared libraries at runtime.
./Configure "--config=../zoox-build.conf" zoox-linux-x86_64 no-afalgeng no-dynamic-engine
make include/openssl/opensslconf.h include/crypto/bn_conf.h include/crypto/dso_conf.h apps/progs.h
rm -rf ../generated
mkdir ../generated
perl -I. -l -Mconfigdata "../extract_srcs.pl" >> "../generated/constants.bzl"
cp -p include/openssl/opensslconf.h \
      include/crypto/bn_conf.h \
      include/crypto/dso_conf.h \
      apps/progs.h \
      ../generated
popd
rm -rf "openssl-$version"
