echo "Cleaning out old PolyBoRi and BRiAl installations"
rm -rf "$SAGE_LOCAL"/lib/python*/site-packages/{polybori,brial}
rm -f "$SAGE_LOCAL"/lib/lib{polybori,brial}*
rm -rf "$SAGE_LOCAL"/include/polybori*
rm -rf "$SAGE_LOCAL"/share/polybori

cd src

# Use C++11 to compile BRiAl, see https://trac.sagemath.org/ticket/21083
if [ "$UNAME" = "CYGWIN" ]; then
    # However, on Cygwin we need to use gnu++11:
    # https://trac.sagemath.org/ticket/24860
    export CXXFLAGS="$CXXFLAGS -std=gnu++11"
else
    export CXXFLAGS="$CXXFLAGS -std=c++11"
fi

export PYTHON=sage-python23

#
# BRiAl consists of a C++ library and a Python module
#
# First, install the library
#

sdh_configure \
    --enable-shared --disable-static \
    --with-boost-unit-test-framework=no
sdh_make
sdh_make_install

#
# Next, install the Python module
#

cd sage-brial && sdh_pip_install .
