+# Get source version from configure script
+eval "$(grep '^PACKAGE_VERSION=' ./configure)"
+PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/}
+
+# Enable dev mode by default for BT 2.0 builds
+export BABELTRACE_DEBUG_MODE=1
+export BABELTRACE_DEV_MODE=1
+export BABELTRACE_MINIMAL_LOG_LEVEL=TRACE
+
+# Set configure options and environment variables for each build
+# configuration.
+CONF_OPTS=("--prefix=$PREFIX" "--libdir=$PREFIX/$LIBDIR_ARCH" "--disable-maintainer-mode")
+
+# -Werror is enabled by default in stable-2.0 but won't be in 2.1
+# Explicitly disable it for consistency.
+if vergte "$PACKAGE_VERSION" "2.0"; then
+ CONF_OPTS+=("--disable-Werror")
+fi
+
+case "$conf" in
+static)
+ print_header "Conf: Static lib only"
+
+ CONF_OPTS+=("--enable-static" "--disable-shared")
+
+ if vergte "$PACKAGE_VERSION" "2.0"; then
+ CONF_OPTS+=("--enable-built-in-plugins")
+ fi
+ ;;
+
+python-bindings)
+ print_header "Conf: Python bindings"
+
+ CONF_OPTS+=("--enable-python-bindings")
+
+ if vergte "$PACKAGE_VERSION" "2.0"; then
+ CONF_OPTS+=("--enable-python-bindings-doc" "--enable-python-plugins")
+ fi
+ ;;
+
+prod)
+ print_header "Conf: Production"
+
+ # Unset the developper variables
+ unset BABELTRACE_DEBUG_MODE
+ unset BABELTRACE_DEV_MODE
+ unset BABELTRACE_MINIMAL_LOG_LEVEL
+
+ # Enable the python bindings
+ CONF_OPTS+=("--enable-python-bindings" "--enable-python-plugins")
+ ;;
+
+doc)
+ print_header "Conf: Documentation"
+
+ CONF_OPTS+=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins" "--enable-api-doc")
+ ;;
+
+asan)
+ print_header "Conf: Address Sanitizer"
+
+ # --enable-asan was introduced after 2.0 but don't check the version, we
+ # want this configuration to fail if ASAN is unavailable.
+ CONF_OPTS+=("--enable-asan" "--enable-python-bindings" "--enable-python-plugins")
+ ;;
+
+min)
+ print_header "Conf: Minimal"
+ ;;
+
+*)
+ print_header "Conf: Standard"
+
+ # Enable the python bindings / plugins by default with babeltrace2,
+ # the test suite is mostly useless without it.
+ if vergte "$PACKAGE_VERSION" "2.0"; then
+ CONF_OPTS+=("--enable-python-bindings" "--enable-python-plugins")
+ fi
+
+ # Something is broken in docbook-xml on yocto
+ if [[ "$platform" = yocto* ]]; then
+ CONF_OPTS+=("--disable-man-pages")
+ fi
+ ;;
+esac