#!/bin/sh
set -eu

root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
build="$root/ports/wasm/build.sh"
makefile="$root/ports/Makefile"
archive="$root/ports/libs/gmp-6.2.1.tar.xz"

# Keep release inputs explicit and checksum-protected.
grep -F "emscripten/emsdk@sha256:" "$build" >/dev/null
grep -F "gmp-6.2.1.tar.xz" "$build" >/dev/null
grep -F "symengine-0.13.0.tar.gz" "$build" >/dev/null
grep -F "gmp_sha=fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2" "$build" >/dev/null
grep -F "sym_sha=f46bcf037529cd1a422369327bf360ad4c7d2b02d0f607a62a5b09c74a55bb59" "$build" >/dev/null

test "$(sha256sum "$archive" | awk '{print $1}')" = fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2
grep -F 'include/symengine_version_check.h' "$makefile" >/dev/null
grep -F 'SYMENGINE_INCLUDE ?= /usr/local/include' "$makefile" >/dev/null
grep -F 'SYMENGINE_LIB ?= /usr/local/lib' "$makefile" >/dev/null

printf '%s\n' 'reproducible build inputs passed'
