if [ -z "$SAGE_LOCAL" ] ; then
    echo >&2 "Error: SAGE_LOCAL undefined - exiting..."
    echo >&2 "Maybe run 'sage -sh'?"
    exit 1
fi

CFLAGS="-O2 -g $CFLAGS -DFAST -DALLTRUE"
export CFLAGS LDFLAGS # Currently redundant, but safe.


cd src

$MAKE test # Just *builds* an example / test program.
if [ $? -ne 0 ]; then
    echo >&2 "Error building Symmetrica's test program."
    exit 1
fi

echo 123 | ./test > spkg-check.actual

cat <<EOF > spkg-check.expected
 12.146304.367025.329675.766243.241881.295855.454217.088483.382315.
 328918.161829.235892.362167.668831.156960.612640.202170.735835.221294.
 047782.591091.570411.651472.186029.519906.261646.730733.907419.814952.
 960000.000000.000000.000000.000000
EOF

if ! diff -b spkg-check.actual spkg-check.expected; then
    echo >&2 "Error: The Symmetrica check failed."
    exit 1
fi
echo "The Symmetrica check passed."
