#! /bin/sh
set -e

# All travis-* scripts must begin by initializing perlbrew if
# possible; travis does not do this for us.  Unfortunately, the
# code in $PERLBREW_ROOT/etc/bashrc is crawling with bashisms,
# and the only alternatives offered are for fish and csh, not
# portable sh.  Fortunately, what we need to do is simple
# enough to open-code.
if [ -f "$PERLBREW_HOME/init" ]; then
    . "$PERLBREW_HOME/init"
    PATH="$(echo $PATH | sed "s%:$PERLBREW_ROOT/bin:%:$PERLBREW_PATH:%")"
fi

# Log the identities and versions of the build tools.
for tool in \
    "${CC-cc}" \
    "${NM-nm}" \
    "${AUTOCONF-autoconf}" \
    "${AUTOMAKE-automake}" \
    "${LIBTOOLIZE-libtoolize}" \
    "${PKG_CONFIG-pkg-config}" \
    "${PERL-perl}" \
    "${PYTHON-python3}"
do
    # $tool might include mandatory command-line arguments.
    # Interpret it the same way Make would.
    set fnord $tool
    shift
    if command -V $1; then
        echo + "$@" --version
        "$@" --version
    fi
    echo
done
set fnord; shift  # clear $@

# Prepare the configure scripts.
set -x
. ./autogen.sh
