#!/bin/sh

set -e

this=why+coq
indir=debian/tests/why
outdir=${ADT_ARTIFACTS:-/tmp}/${this}
mkdir -p ${outdir}

why3 config detect > /dev/null 2>&1

for infile in ${indir}/minimum.mlw
do
    base=$(basename $infile)
    coqfile=${outdir}/${base%.mlw}.v
    why3 prove -D coq ${infile} | sed -e '1s/^/Require Import Lia. /' -e 's/Qed./lia. Qed./' > ${coqfile} 
    coqc -R `why3 --print-libdir`/coq/ Why3 ${coqfile} 2>&1 
done
