#!/bin/sh

export LD_LIBRARY_PATH=/usr/local/lib

if [ "$JAVA_HOME" = "" ] ; then
    if [ -d "/usr/lib/jvm/java-6-openjdk" ]; then
        export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
    elif [ -d "/usr/local/openjdk6" ]; then
        export JAVA_HOME=/usr/local/openjdk6
    fi
fi

make -s clean

using_java=`grep "^JAVA=" ../../../config.log|sed 's/JAVA=//'`
if [ "$using_java" = "''" -o "$using_java" = "" ]; then
## Could not test without java, but return pass to make check goes through
   echo '---running (java) attr script'
   echo "   PASSED"
   echo '---running (java) prover script'
   echo "   PASSED"
   exit 0
fi

echo '---running (java) attr script'
make run_attr 1>/dev/null 2>& 1
result=`grep "prover success" attr.log 2>/dev/null`
if [ "$result" = "" ]; then
   echo "   ERROR"
else   
   echo "   PASSED"
fi

echo '---running (java) prover script'
make run_prove 1>/dev/null 2>& 1
result=`grep "prover success" prover.log 2>/dev/null`
if [ "$result" = "" ]; then
   echo "   ERROR"
else   
   echo "   PASSED"
fi

