+ set -x
+}
+
+failed_configure() {
+ # Assume we are in the configured build directory
+ print_header "BEGIN config.log"
+ cat config.log
+ print_header "END config.log"
+
+ # End the build with failure
+ exit 1
+}
+
+set_execute_traversal_bit()
+{
+ path=$1
+
+ level="$path"
+ if [ ! -d "$path" ]; then
+ fail "Path is not a directory"
+ fi
+ while level="$(dirname "$level")"
+ do
+ if [ "$level" = / ]; then
+ break
+ fi
+ chmod a+x "$level"
+ done
+ chmod a+x "$path"
+}
+
+print_header "LTTng-tools build script starting"
+
+# Required variables
+WORKSPACE=${WORKSPACE:-}
+
+# Axis
+platform=${platform:-}
+conf=${conf:-}
+build=${build:-}
+cc=${cc:-}
+
+# Build steps that can be overriden by the environment
+LTTNG_TOOLS_MAKE_INSTALL="${LTTNG_TOOLS_MAKE_INSTALL:-yes}"
+LTTNG_TOOLS_MAKE_CLEAN="${LTTNG_TOOLS_MAKE_CLEAN:-yes}"
+LTTNG_TOOLS_GEN_COMPILE_COMMANDS="${LTTNG_TOOLS_GEN_COMPILE_COMMANDS:-no}"
+LTTNG_TOOLS_RUN_TESTS="${LTTNG_TOOLS_RUN_TESTS:-yes}"
+LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION="${LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION:-no}"
+LTTNG_TOOLS_RUN_UST_JAVA_TESTS="${LTTNG_TOOLS_RUN_UST_JAVA_TESTS:-yes}"
+LTTNG_TOOLS_CLANG_TIDY="${LTTNG_TOOLS_CLANG_TIDY:-no}"
+
+SRCDIR="$WORKSPACE/src/lttng-tools"
+TAPDIR="$WORKSPACE/tap"
+PREFIX="/build"
+LIBDIR="lib"
+LIBDIR_ARCH="$LIBDIR"
+
+# RHEL and SLES both use lib64 but don't bother shipping a default autoconf
+# site config that matches this.
+if [[ ( -f /etc/redhat-release || -f /etc/products.d/SLES.prod || -f /etc/yocto-release ) ]]; then
+ # Detect the userspace bitness in a distro agnostic way
+ if file -L /bin/bash | grep '64-bit' >/dev/null 2>&1; then
+ LIBDIR_ARCH="${LIBDIR}64"
+ fi
+fi
+
+DEPS_INC="$WORKSPACE/deps/build/include"
+DEPS_LIB="$WORKSPACE/deps/build/$LIBDIR_ARCH"
+DEPS_PKGCONFIG="$DEPS_LIB/pkgconfig"
+DEPS_BIN="$WORKSPACE/deps/build/bin"
+DEPS_JAVA="$WORKSPACE/deps/build/share/java"
+
+export PATH="$DEPS_BIN:$PATH"
+export LD_LIBRARY_PATH="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
+export PKG_CONFIG_PATH="$DEPS_PKGCONFIG"
+export CPPFLAGS="-I$DEPS_INC"
+export LDFLAGS="-L$DEPS_LIB"
+
+exit_status=0
+
+# Use bear to generate compile_commands.json when enabled
+BEAR=""
+if [ "$LTTNG_TOOLS_GEN_COMPILE_COMMANDS" = "yes" ]; then
+ BEAR="bear"
+fi
+
+# Create tmp directory
+TMPDIR="$WORKSPACE/tmp"
+mkdir -p "$TMPDIR"
+
+# Use a symlink in /tmp to point to the the tmp directory
+# inside the workspace, this is to work around the path length
+# limit of unix sockets which are created by the test suite.
+tmpdir="$(mktemp)"
+ln -sf "$TMPDIR" "$tmpdir"
+export TMPDIR="$tmpdir"
+
+# Create a symlink to "babeltrace" when the "babeltrace2" executable is found.
+# This is a temporary workaround until lttng-tools either allows the override of
+# the trace reader in its test suite or that we move to only supporting
+# babeltrace2
+if [ -x "$DEPS_BIN/babeltrace2" ]; then
+ ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace"
+fi
+
+# When using babeltrace2 make sure that it finds its plugins and
+# plugin-providers.
+export BABELTRACE_PLUGIN_PATH="$DEPS_LIB/babeltrace2/plugins/"
+export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR="$DEPS_LIB/babeltrace2/plugin-providers/"
+
+export CFLAGS="-g -O2"
+export CXXFLAGS="-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