+# Check kmod library
+AC_ARG_WITH(kmod-prefix,
+ AS_HELP_STRING([--with-kmod-prefix=PATH],
+ [Specify the installation prefix of the kmod library.
+ Headers must be in PATH/include; libraries in PATH/lib.]),
+ [
+ CPPFLAGS="$CPPFLAGS -I${withval}/include"
+ LDFLAGS="$LDFLAGS -L${withval}/lib64 -L${withval}/lib"
+ ])
+
+AC_ARG_ENABLE(kmod,
+ AS_HELP_STRING([--disable-kmod],[build without kmod support]),
+ kmod_support=zz$enableval, kmod_support=yes)
+
+AS_IF([test "x$kmod_support" = "xyes"], [
+ AC_CHECK_LIB([kmod], [kmod_module_probe_insert_module],
+ [
+ AC_DEFINE([HAVE_KMOD], [1], [has kmod support])
+ LIBS="$LIBS -lkmod"
+ kmod_found=yes
+ ],
+ kmod_found=no
+ )
+])
+AM_CONDITIONAL([HAVE_KMOD], [test "x$kmod_found" = xyes])
+
+AC_ARG_WITH(lttng-ust-prefix,
+ AS_HELP_STRING([--with-lttng-ust-prefix=PATH],
+ [Specify the installation prefix of the lttng-ust library.
+ Headers must be in PATH/include; libraries in PATH/lib.]),
+ [
+ CPPFLAGS="$CPPFLAGS -I${withval}/include"
+ LDFLAGS="$LDFLAGS -L${withval}/lib64 -L${withval}/lib"
+ ])
+
+# Check liblttng-ust-ctl library
+AC_ARG_ENABLE(lttng-ust,
+ AS_HELP_STRING([--disable-lttng-ust],[build without LTTng-UST (Userspace Tracing) support]),
+ lttng_ust_support=$enableval, lttng_ust_support=yes)
+
+AS_IF([test "x$lttng_ust_support" = "xyes"], [
+ AC_CHECK_LIB([lttng-ust-ctl], [ustctl_recv_channel_from_consumer],
+ [
+ AC_DEFINE([HAVE_LIBLTTNG_UST_CTL], [1], [has LTTng-UST control support])
+ lttng_ust_ctl_found=yes
+ ],
+ [AC_MSG_ERROR([Cannot find LTTng-UST >= 2.2.x. Use --with-lttng-ust-prefix=PREFIX to specify its location, or specify --disable-lttng-ust to build lttng-tools without LTTng-UST support.])],
+ [-lurcu-common -lurcu-bp -lurcu-cds -lrt -ldl]
+ )
+])
+AM_CONDITIONAL([HAVE_LIBLTTNG_UST_CTL], [test "x$lttng_ust_ctl_found" = xyes])
+AC_CHECK_FUNCS([sched_getcpu sysconf sync_file_range])
+
+# check for dlopen
+AC_CHECK_LIB([dl], [dlopen],
+[
+ have_libdl=yes
+],
+[
+ #libdl not found, check for dlopen in libc.
+ AC_CHECK_LIB([c], [dlopen],
+ [
+ have_libc_dl=yes
+ ],
+ [
+ AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
+ ])
+])
+AM_CONDITIONAL([LTTNG_TOOLS_BUILD_WITH_LIBDL], [test "x$have_libdl" = "xyes"])
+AM_CONDITIONAL([LTTNG_TOOLS_BUILD_WITH_LIBC_DL], [test "x$have_libc_dl" = "xyes"])
+
+# Check for fmemopen
+AC_CHECK_LIB([c], [fmemopen],
+[
+ AC_DEFINE_UNQUOTED([LTTNG_HAVE_FMEMOPEN], 1, [Has fmemopen support.])
+]
+)
+
+# Check for open_memstream
+AC_CHECK_LIB([c], [open_memstream],
+[
+ AC_DEFINE_UNQUOTED([LTTNG_HAVE_OPEN_MEMSTREAM], 1, [Has open_memstream support.])
+]
+)
+
+AC_ARG_ENABLE([git-version],
+ [AC_HELP_STRING([--disable-git-version],
+ [Do not use the git version for the build])],
+ [have_git_version=$enableval], [have_git_version=yes]
+)
+
+AM_CONDITIONAL([LTTNG_TOOLS_BUILD_GIT_SOURCE],
+ [test "x${have_git_version}" = "xyes"])
+
+# For Python
+# SWIG version needed or newer:
+swig_version=2.0.0
+
+AC_ARG_ENABLE([python-bindings],
+ [AC_HELP_STRING([--enable-python-bindings],
+ [compile Python bindings])],
+ [enable_python_binding=yes], [enable_python_binding=no])
+
+AM_CONDITIONAL([PYTHON_BINDING], [test "x${enable_python_binding:-yes}" = xyes])
+
+if test "x${enable_python_binding:-yes}" = xyes; then
+ AX_PKG_SWIG($swig_version, [], [ AC_MSG_ERROR([SWIG $swig_version or newer is needed]) ])
+ AM_PATH_PYTHON([3.0])
+
+ AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config])
+ AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
+ 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. Do you have python-dev installed?])])
+ ])
+ AC_MSG_CHECKING([python include flags])
+ PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`
+ AC_MSG_RESULT([$PYTHON_INCLUDE])
+ ])
+
+else
+ AC_MSG_NOTICE([You may configure with --enable-python-bindings ]dnl
+[if you want Python bindings.])
+
+fi
+
+# Epoll check. If not present, the build will fallback on poll() API
+AX_HAVE_EPOLL(
+ [AX_CONFIG_FEATURE_ENABLE(epoll)],
+ [AX_CONFIG_FEATURE_DISABLE(epoll)]
+)
+AX_CONFIG_FEATURE(
+ [epoll], [This platform supports epoll(7)],
+ [HAVE_EPOLL], [This platform supports epoll(7).],
+ [enable_epoll="yes"], [enable_epoll="no"]
+)
+AM_CONDITIONAL([COMPAT_EPOLL], [ test "$enable_epoll" = "yes" ])
+
+AM_CONDITIONAL([TEST_JAVA_JUL_AGENT], [test "x$test_java_agent_jul" = "xyes"])
+AM_CONDITIONAL([TEST_JAVA_LOG4J_AGENT], [test "x$test_java_agent_log4j" = "xyes"])
+
+if test "x$test_java_agent_jul" = "xyes" || test "x$test_java_agent_log4j" = "xyes"; then
+ AX_JAVA_OPTIONS
+ AX_PROG_JAVAC
+ AX_PROG_JAVA
+ AX_PROG_JAR
+
+ AX_CHECK_CLASSPATH
+
+ # Check for Java UST agent common class first
+ AX_CHECK_CLASS(org.lttng.ust.agent.AbstractLttngAgent)
+ if test "x$ac_cv_class_org_lttng_ust_agent_AbstractLttngAgent" = "xno"; then
+ AC_MSG_ERROR([The UST Java agent common class was not found. Please specify the location of the jar via the Java CLASSPATH e.g: export CLASSPATH="/path/to/lttng-ust-agent-common.jar"])
+ fi
+
+ if test "x$test_java_agent_jul" = "xyes"; then
+ # Check for JUL agent class
+ AX_CHECK_CLASS(org.lttng.ust.agent.jul.LttngLogHandler)
+ if test "x$ac_cv_class_org_lttng_ust_agent_jul_LttngLogHandler" = "xno"; then
+ AC_MSG_ERROR([The UST Java agent JUL class was not found. Please specify the location of the jar via the Java CLASSPATH e.g: export CLASSPATH="/path/to/lttng-ust-agent-jul.jar"])
+ fi
+ fi