abinfo "Preparing build environment ..."
export QTDIR="$SRCDIR"
export LD_LIBRARY_PATH="${QTDIR}/qtbase/lib:${QTDIR}/qttools/lib:${LD_LIBRARY_PATH}"
export QT_PLUGIN_PATH="${QTDIR}/qtbase/plugins"

# FIXME: Somehow FindPostgreSQL.cmake can't figure out the root path of
# our new PostgreSQL installation.
abinfo "Finding PostgreSQL ..."
pgroot=$(pg_config --libdir)
if [ ! -d "$pgroot" ] ; then
	abdie "Failed to fetch the root path of the PostgreSQL installation."
fi
export PostgreSQL_ROOT=$(realpath "$pgroot"/..)

if [[ "${CROSS:-$ARCH}" = "riscv64" ]]; then
    abinfo "RISC-V: injecting -pthread ..."
    export LDFLAGS+=" -pthread"
fi

if ab_match_arch loongarch64; then
    abinfo "Tweaking compiler flags for loongarch64 ..."
    export CFLAGS+=" -mcmodel=medium"
    export CXXFLAGS+=" -mcmodel=medium"
    export LDFLAGS+=" -mcmodel=medium"
fi
