#!/bin/sh

set -e

if [ -x /usr/bin/ocamlopt ]; then
    TARGET=native-code
else
    TARGET=byte-code
fi

testdir=${AUTOPKGTEST_TMP:-/tmp}

cp -r examples ${testdir}
cd ${testdir}/examples
echo "** Compiling examples."
make $TARGET
echo -n "** Executing pdfhello ... "
./pdfhello
echo "done."
echo -n "** Checking generated PDF ... "
pdftotext -layout hello.pdf - | grep -q 'Hello, World!'
echo "OK."
