#!/bin/bash

export LDFLAGS="-L$PREFIX/lib $LDFLAGS"
# Yes, this is actually meant to be CPPFLAGS (preprocessor flags)
export CPPFLAGS="-I$PREFIX/include $CPPFLAGS"
export CXXFLAGS="-I$PREFIX/include $CXXFLAGS -std=c++14"

autoreconf --force --install

bash configure --prefix=$PREFIX \
               --with-xml2=$PREFIX \
               --with-curl=$PREFIX \
               --enable-threads=pth

make -j${CPU_COUNT} ${VERBOSE_AT}
# Check fails on OS X for some reason.
if [ $(uname) == Linux ]; then
    make check
fi
make install
