+# Python bindings documentation
+# Disabled by default
+AC_ARG_ENABLE([python-bindings-doc],
+ [AC_HELP_STRING([--enable-python-bindings-doc], [build the Python bindings documentation])],
+ [], dnl AC_ARG_ENABLE will fill enable_python_bindings_doc with the user choice
+ [enable_python_bindings_doc=no]
+)
+
+# Python bindings tests
+# Disabled by default
+AC_ARG_ENABLE([python-bindings-tests],
+ [AC_HELP_STRING([--enable-python-bindings-tests], [run the Python bindings tests])],
+ [], dnl AC_ARG_ENABLE will fill enable_python_bindings_tests with the user choice
+ [enable_python_bindings_tests=no]
+)
+
+# Python plugins
+# Disabled by default
+AC_ARG_ENABLE([python-plugins],
+ [AC_HELP_STRING([--enable-python-plugins], [enable the Python plugins support for the library and converter])],
+ [], dnl AC_ARG_ENABLE will fill enable_python_plugins with the user choice
+ [enable_python_plugins=no]
+)
+
+# Debug info
+# Enabled by default, except on some platforms
+AC_ARG_ENABLE([debug-info],
+ [AC_HELP_STRING([--disable-debug-info], [disable the debug info support (default on macOS, Solaris and Windows)])],
+ [], dnl AC_ARG_ENABLE will fill enable_debug_info with the user choice
+ [enable_debug_info="$DEFAULT_ENABLE_DEBUG_INFO"]
+)
+
+# API documentation
+# Disabled by default
+AC_ARG_ENABLE([api-doc],
+ [AC_HELP_STRING([--enable-api-doc], [build the HTML API documentation])],
+ [enable_api_doc=$enableval],
+ [enable_api_doc=no]
+)
+
+# Built-in plugins
+# Disabled by default
+AC_ARG_ENABLE([built-in-plugins],
+ [AC_HELP_STRING([--enable-built-in-plugins], [Statically-link in-tree plug-ins into the babeltrace binary])],
+ [], dnl AC_ARG_ENABLE will fill enable_built_in_plugins with the user choice
+ [enable_built_in_plugins=no]
+)
+
+# Built-in python plugin support
+# Disabled by default
+AC_ARG_ENABLE([built-in-python-plugin-support],
+ [AC_HELP_STRING([--enable-built-in-python-plugin-support], [Statically-link Python plugin support into the babeltrace library])],
+ [], dnl AC_ARG_ENABLE will fill enable_built_in_python_plugin_support with the user choice
+ [enable_built_in_python_plugin_support=no]
+)
+
+
+# Set automake variables for optionnal feature conditionnals in Makefile.am
+AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS], [test "x$enable_python_bindings" = xyes])
+AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS_DOC], [test "x$enable_python_bindings_doc" = xyes])
+AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS_TESTS], [test "x$enable_python_bindings_tests" = xyes])
+AM_CONDITIONAL([ENABLE_PYTHON_PLUGINS], [test "x$enable_python_plugins" = xyes])
+AM_CONDITIONAL([ENABLE_DEBUG_INFO], [test "x$enable_debug_info" = xyes])
+AM_CONDITIONAL([ENABLE_API_DOC], [test "x$enable_api_doc" = xyes])
+AM_CONDITIONAL([ENABLE_BUILT_IN_PLUGINS], [test "x$enable_built_in_plugins" = xyes])
+AM_CONDITIONAL([ENABLE_BUILT_IN_PYTHON_PLUGIN_SUPPORT], [test "x$enable_built_in_python_plugin_support" = xyes])
+
+
+# Set defines for optionnal features conditionnals in the source code
+
+## jgalar: still used?
+AS_IF([test "x$enable_python_plugins" = xyes],
+ [AC_DEFINE([PYTHON_PLUGINS], [1], [Python plugin support.])]
+)
+
+AS_IF([test "x$enable_debug_info" = xyes],
+ [AC_DEFINE([ENABLE_DEBUG_INFO], [1], [Define to 1 if you enable the 'debug info' feature])]
+)
+
+AS_IF([test "x$enable_built_in_plugins" = xyes],
+ [AC_DEFINE([BT_BUILT_IN_PLUGINS], [1], [Define to 1 to register plug-in attributes in static executable sections])]
+)
+
+AS_IF([test "x$enable_built_in_python_plugin_support" = xyes],
+ [AC_DEFINE([BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT], [1], [Define to 1 to register plug-in attributes in static executable sections])]
+)
+
+
+# Check for conflicting optional features user choices
+
+AS_IF([test "x$enable_python_bindings" = xno],
+ [
+ AS_IF([test "x$enable_python_bindings_doc" = xyes], [AC_MSG_ERROR([--enable-python-bindings-doc was specified without --enable-python-bindings])])
+ AS_IF([test "x$enable_python_bindings_tests" = xyes], AC_MSG_ERROR([--enable-python-bindings-tests was specified without --enable-python-bindings]))
+ ]
+)
+
+AS_IF([test "x$enable_built_in_plugins" = xyes],
+ [
+ # Built-in plug-ins are only available when the --disable-shared --enable-static options are used.
+ AS_IF([test "x$enable_static" != xyes], [AC_MSG_ERROR(--enable-static must be used to bundle plug-ins in the babeltrace executable)])
+ AS_IF([test "x$enable_shared" = xyes], [AC_MSG_ERROR(--disable-shared must be used to bundle plug-ins in the babeltrace executable)])
+ ]
+)
+
+AS_IF([test "x$enable_built_in_python_plugin_support" = xyes],
+ [
+ AS_IF([test "x$enable_python_plugins" = xno], [AC_MSG_ERROR([--enable-python-plugins must be used to bundle Python plugin support in the babeltrace executable])])
+ # Built-in plug-ins are only available when the --disable-shared --enable-static options are used.
+ AS_IF([test "x$enable_static" != xyes], [AC_MSG_ERROR(--enable-static must be used to bundle Python plugin support in the babeltrace executable)])
+ AS_IF([test "x$enable_shared" = xyes], [AC_MSG_ERROR(--disable-shared must be used to bundle Python plugin support in the babeltrace executable)])
+ ]
+)
+
+
+# Check for optionnal features dependencies
+
+AS_IF([test "x$enable_python_bindings" = xyes],
+ [AX_PKG_SWIG(2.0.0, [], [AC_MSG_ERROR([SWIG 2.0.0 or newer is required to build the python bindings])])]
+)
+
+AS_IF([test "x$enable_python_bindings" = xyes || test "x$enable_python_plugins" = xyes],
+ [
+ AM_PATH_PYTHON([3.0], [], [AC_MSG_ERROR(Python 3 is not available or is not the default Python interpreter on your system. See the README file to learn how to override your distribution's default Python interpreter.)])
+
+ AM_PATH_PYTHON_MODULES([PYTHON])
+ # pythondir is the path where extra modules are to be installed
+ pythondir=$PYTHON_PREFIX/$PYTHON_MODULES_PATH
+ # pyexecdir is the path that contains shared objects used by the extra modules
+ pyexecdir=$PYTHON_EXEC_PREFIX/$PYTHON_MODULES_PATH
+ AS_IF([test -z "$PYTHON_INCLUDE"], [
+ AS_IF([test -z "$PYTHON_CONFIG"], [
+ AC_PATH_PROGS([PYTHON_CONFIG],
+ [python$PYTHON_VERSION-config python-config],
+ [no],
+ [`dirname $PYTHON`])
+ AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON. Is python-dev installed?])])
+ ])
+ AC_MSG_CHECKING([Python include flags])
+ PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`
+ AC_MSG_RESULT([$PYTHON_INCLUDE])
+ ])
+ AS_IF([test -z "$PYTHON_LIBS"], [
+ AS_IF([test -z "$PYTHON_CONFIG"], [
+ AC_PATH_PROGS([PYTHON_CONFIG],
+ [python$PYTHON_VERSION-config python-config],
+ [no],
+ [`dirname $PYTHON`])
+ AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON. Is python-dev installed?])])
+ ])
+ AC_MSG_CHECKING([Python library flags])
+ PYTHON_LIBS=`$PYTHON_CONFIG --libs`
+ AC_MSG_RESULT([$PYTHON_LIBS])
+ ])
+ ]
+)
+
+AS_IF([test "x$enable_python_bindings_doc" = xyes],
+ [
+ AM_CHECK_PYTHON_SPHINX([PYTHON])
+ AS_IF([test "x$PYTHON_SPHINX_EXISTS" = xno],
+ [AC_MSG_ERROR([The Sphinx package for Python 3 is required to build the Python bindings documentation])]
+ )
+ ]
+)
+
+AS_IF([test "x$enable_python_bindings_tests" = xyes],
+ [
+ AM_CHECK_PYTHON_TAPPY([PYTHON])
+ AS_IF([test "x$PYTHON_TAPPY_EXISTS" = xno],
+ [AC_MSG_ERROR([You need the tappy Python project to test the Python bindings (see <https://github.com/python-tap/tappy>)])]
+ )
+ ]
+)
+
+AS_IF([test "x$enable_debug_info" = xyes],
+ [
+ # Check if libelf and libdw are present
+ AC_CHECK_LIB([elf], [elf_version], [:], [AC_MSG_ERROR(Missing libelf (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)])
+ AC_CHECK_LIB([dw], [dwarf_begin], [:], [AC_MSG_ERROR(Missing libdw (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)])
+ BT_LIB_ELFUTILS([0], [154], [:], [AC_MSG_ERROR(elfutils >= 0.154 is required to use the debug info feature. You can disable this feature using --disable-debug-info.)])
+ ELFUTILS_LIBS="-lelf -ldw"
+ ]
+)
+AC_SUBST([ELFUTILS_LIBS])
+
+AS_IF([test "x$enable_api_doc" = "xyes"],
+ [
+ DX_DOXYGEN_FEATURE(ON)
+ DX_DOT_FEATURE(OFF)
+ DX_HTML_FEATURE(ON)
+ DX_CHM_FEATURE(OFF)
+ DX_CHI_FEATURE(OFF)
+ DX_MAN_FEATURE(OFF)
+ DX_RTF_FEATURE(OFF)
+ DX_XML_FEATURE(OFF)
+ DX_PDF_FEATURE(OFF)
+ DX_PS_FEATURE(OFF)
+ DX_INIT_DOXYGEN([Babeltrace], [$(srcdir)/Doxyfile], [output])
+ AS_IF([test -z "$DX_DOXYGEN"],
+ [AC_MSG_ERROR([You need doxygen to enable the API documentation])]
+ )
+ ]
+)
+
+
+# Set global CFLAGS in AM_CFLAGS
+AM_CFLAGS="-Wall -Wformat $PTHREAD_CFLAGS $GLIB_CFLAGS"
+AC_SUBST(AM_CFLAGS)
+
+# Set global CPPFLAGS in AM_CPPFLAGS
+AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
+AC_SUBST(AM_CPPFLAGS)
+
+# Add glib to global link libs
+LIBS="$LIBS $GLIB_LIBS"
+
+# Check that the current size_t matches the size that glib thinks it should
+# be. This catches problems on multi-arch where people try to do a 32-bit
+# build while pointing at 64-bit glib headers. This is a common error because
+# glib.h is not platform specific but it includes glibconfig.h which is and
+# is usually installed in a non-standard path.
+
+save_CFLAGS=${CFLAGS}
+CFLAGS="${CFLAGS} ${AM_CFLAGS}"
+AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([dnl
+#include <glib.h>
+#include <unistd.h>
+ ], [dnl
+G_STATIC_ASSERT(sizeof(size_t) == GLIB_SIZEOF_SIZE_T);
+ ])
+],[:],[
+ AC_MSG_ERROR([dnl
+sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T. You probably need to set
+PKG_CONFIG_LIBDIR to point to the right pkg-config files for your build
+target.
+ ])
+])
+CFLAGS=${save_CFLAGS}
+
+# Abuse autoconf's AC_ARG_PROGRAM output variable 'program_transform_name'
+# to rename babeltrace.bin to babeltrace at install time.
+program_transform_name="s&babeltrace\.bin&babeltrace&;s&babeltrace-log\.bin&babeltrace-log&;$program_transform_name"
+AC_SUBST(program_transform_name)