# Make sure we do not include conflicting complex.h from cephes Sage package
CFLAGS="$CFLAGS -D__CEPHES_COMPLEX_H"
export CFLAGS

cd src

set -e

if [ `uname` = "Darwin" ]; then
    unset ATLAS
    unset BLAS
    unset LAPACK
else
    export {ATLAS,PTATLAS,OPENBLAS,MKL,MKLROOT}=None
    export LDFLAGS="${LDFLAGS} -shared"
fi

sage-python23 ../lapack_conf.py

# Make sure that the fortran objects are compiled with -fPIC
export FFLAGS="$FFLAGS -fPIC"
export FCFLAGS="$FCFLAGS -fPIC"

export NUMPY_FCONFIG="config_fc --noopt --noarch"

################################################

rm -rf "$SAGE_LOCAL/lib/python*/site-packages/numpy"

sage-python23 setup.py \
        --no-user-cfg \
       install \
       --single-version-externally-managed \
       --root "$SAGE_DESTDIR" \
       ${NUMPY_FCONFIG} || sdh_die "Error building / installing numpy"
