#!/bin/bash

#autoreconf -vfi

# skip the creation of man pages by faking existance of help2man
if [ `uname` == Darwin ]; then
    export HELP2MAN=/usr/bin/true
fi
if [ `uname` == Linux ]; then
    export HELP2MAN=/bin/true
fi
if [[ ${HOST} =~ .*linux.* ]]; then
    export CC=${GCC}
    # TODO :: Handle cross-compilation properly here
    export CC_FOR_BUILD=${GCC}
fi

export ac_cv_func_realloc_0_nonnull=yes

LDFLAGS="${LDFLAGS} -L${PREFIX}/lib -L${BUILD_PREFIX}/lib"
export CPU_COUNT=1

./configure --prefix="$PREFIX"  \
            --host=aarch64-apple-darwin20.04  \
            --build=aarch64-apple-darwin20.04 --disable-bootstrap
make -j${CPU_COUNT} ${VERBOSE_AT}
# CXX restart fails?
# make check
make install
