#!/bin/sh
set -eu

. $(pwd)/nix_build_vars

mkdir -p build-mbedtls
(cd build-mbedtls

# CMAKE_POLICY_VERSION_MINIMUM=3.5 is Needed to build this version of mbedtls
# with recent versions of cmake. It should be possible to remove this for newer
# versions.
CFLAGS="${CFLAGS:--g -std=c99 -O2 ${HARDENING_FLAGS}}" \
cmake -G "Unix Makefiles" \
	-DENABLE_TESTING=OFF \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
	../mbedtls
)
