fail () {
    echo -e >&2 $1
    exit 1
}

if [ "$SAGE_LOCAL" = "" ]; then
    fail "SAGE_LOCAL undefined ... exiting\nMaybe run 'sage -sh'?"
fi

cd src

cmake -DCMAKE_INSTALL_PREFIX="${SAGE_LOCAL}" -DUSE_GAUSS='ON' -DZLIB_ROOT="${SAGE_LOCAL}" . || fail 'Error configuring cryptominisat'

$MAKE VERBOSE=ON || fail 'Error building cryptominisat'

$MAKE VERBOSE=ON install || fail 'Error installing cryptominisat'

exit 0

