if [ "$SAGE_LOCAL" = "" ]; then
   echo "SAGE_LOCAL undefined ... exiting";
   echo "Maybe run 'sage -sh'?"
   exit 1
fi

cd src
grep -v "std..cout.*current max" mcqd.h > mcqd2.h &&
mv mcqd2.h mcqd.h &&
g++ -O3 -c mcqd.cpp -o $SAGE_LOCAL/lib/libmcqd.so &&
cp mcqd.h $SAGE_LOCAL/include/mcqd.h

if [ $? -ne 0 ]; then
    echo "An error occurred whilst building MCQD"
    exit 1
fi