#!/usr/bin/env bash
if [ -z "$SAGE_LOCAL" ]; then
echo >&2 "SAGE_LOCAL undefined ... exiting"
echo >&2 "Maybe run 'sage --sh'?"
exit 1
fi
cd src
# Apply patches.
for patch in ../patches/*.patch; do
patch -p1 <"$patch"
if [ $? -ne 0 ]; then
echo >&2 "Error applying '$patch'"
exit 1
fi
done
if [ "x$SAGE64" = xyes ]; then
# Despite being called makefile.osx64, this is a pretty generic
# makefile, which should build 64-bit on many platforms, not just
# OS X.
echo "Building a 64-bit version of William Hart's Quadratic Sieve"
cp makefile.osx64 makefile
else
cp makefile.sage makefile
fi
$MAKE
if [ $? -ne 0 ]; then
echo "Error building William Hart's Quadratic Sieve"
exit 1
fi
$CP QuadraticSieve "$SAGE_LOCAL"/bin/
if [ $? -ne 0 ]; then
echo "Error copying QuadraticSieve file"
exit 1
fi