+# Shellcheck flags the following functions that are unused as "unreachable",
+# ignore that.
+
+# shellcheck disable=SC2317
+verlte() {
+ vercomp "$1" "$2"
+ local res="$?"
+ [ "$res" -eq "0" ] || [ "$res" -eq "2" ]
+}
+
+# shellcheck disable=SC2317
+verlt() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -eq "2" ]
+}
+
+# shellcheck disable=SC2317
+vergte() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -eq "0" ] || [ "$res" -eq "1" ]
+}
+
+# shellcheck disable=SC2317
+vergt() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -eq "1" ]
+}
+
+# shellcheck disable=SC2317
+verne() {
+ vercomp "$1" "$2"; local res="$?"
+ [ "$res" -ne "0" ]
+}
+
+failed_configure() {
+ # Assume we are in the configured build directory
+ echo "#################### BEGIN config.log ####################"
+ cat config.log
+ echo "#################### END config.log ####################"
+ exit 1
+}
+
+
+# Required variables
+WORKSPACE=${WORKSPACE:-}
+
+platform=${platform:-}
+conf=${conf:-}
+build=${build:-}
+cc=${cc:-}
+
+# Controls if the tests are run
+BABELTRACE_RUN_TESTS="${BABELTRACE_RUN_TESTS:=yes}"
+
+SRCDIR="$WORKSPACE/src/babeltrace"
+TMPDIR="$WORKSPACE/tmp"
+PREFIX="/build"
+
+# Create tmp directory
+rm -rf "$TMPDIR"
+mkdir -p "$TMPDIR"
+
+export TMPDIR
+export CFLAGS="-g -O2"
+
+# Set compiler variables
+case "$cc" in
+gcc)
+ export CC=gcc
+ export CXX=g++
+ ;;
+gcc-*)
+ export CC=gcc-${cc#gcc-}
+ export CXX=g++-${cc#gcc-}
+ ;;
+clang)
+ export CC=clang
+ export CXX=clang++
+ ;;
+clang-*)
+ export CC=clang-${cc#clang-}
+ export CXX=clang++-${cc#clang-}
+ ;;
+*)
+ if [ "x$cc" != "x" ]; then
+ export CC="$cc"
+ fi
+ ;;
+esac
+
+if [ "x${CC:-}" != "x" ]; then
+ echo "Selected compiler:"
+ "$CC" -v
+fi
+
+# Set platform variables
+case "$platform" in
+macos*)
+ export MAKE=make
+ export TAR=tar
+ export NPROC="getconf _NPROCESSORS_ONLN"
+ export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
+ export CPPFLAGS="-I/opt/local/include"
+ export LDFLAGS="-L/opt/local/lib"
+ export PYTHON="python3"
+ export PYTHON_CONFIG="python3-config"
+ ;;
+
+freebsd*)
+ export MAKE=gmake
+ export TAR=tar
+ export NPROC="getconf _NPROCESSORS_ONLN"
+ export CPPFLAGS="-I/usr/local/include"
+ export LDFLAGS="-L/usr/local/lib"
+ export PYTHON="python3"
+ export PYTHON_CONFIG="python3-config"
+
+ # For bt 1.5
+ export YACC="bison -y"
+ ;;
+
+*)
+ export MAKE=make
+ export TAR=tar
+ export NPROC=nproc
+ export PYTHON="python3"
+ export PYTHON_CONFIG="python3-config"
+ ;;
+esac
+
+# Print build env details
+print_os || true
+print_tooling || true
+
+# Enter the source directory
+cd "$SRCDIR"
+
+# Run bootstrap in the source directory prior to configure