#!/bin/sh
git clean -fXd
if [ $? -ne 0 ]
then
    echo "FAILED git clean"
    exit 1
fi
sh ./autogen.sh
if [ $? -ne 0 ]
then
    echo "FAILED autogen.sh"
    exit 125
fi
./configure --disable-shared CFLAGS='-fno-inline -g'
if [ $? -ne 0 ]
then
    echo "FAILED configure"
    exit 125
fi
touch doc/version.texi src/cd-drive.1 src/cd-info.1 src/cd-read.1 src/iso-read.1 src/iso-info.1
if [ $? -ne 0 ]
then
    echo "FAILED touch"
    exit 125
fi
make clean
if [ $? -ne 0 ]
then
    echo "FAILED make clean"
    exit 125
fi
make
if [ $? -ne 0 ]
then
    echo "FAILED make"
    exit 125
fi
# fix this path to wherever you put the test script
../iso-read-test/iso-read-test.sh src/iso-read
success=$?
if [ $success -ne 0 ]
then
    echo "FAILED iso-read-test.sh"
fi
git checkout -f
if [ $? -ne 0 ]
then
    echo "FAILED git checkout -f"
    exit 255
fi
exit $success

