Cleanup: merge two instances of AC_CHECK_FUNCS
[lttng-tools.git] / configure.ac
index d1fbd396bd6b7a0b3422e763ffa730a65789f23b..53d47d171bf4512c9fde65d0978ce8d2baae3a77 100644 (file)
@@ -132,6 +132,7 @@ AC_CHECK_FUNCS([ \
        mkdir munmap putenv realpath rmdir socket strchr strcspn strdup \
        strncasecmp strndup strnlen strpbrk strrchr strstr strtol strtoul \
        strtoull dirfd gethostbyname2 getipnodebyname epoll_create1 \
+       sched_getcpu sysconf sync_file_range
 ])
 
 # Check if clock_gettime, timer_create, timer_settime, and timer_delete are available in lib rt, and if so,
@@ -411,58 +412,59 @@ AC_CHECK_DECL([urcu_ref_get_unless_zero], [],
         [AC_MSG_ERROR([WRONG_LIBURCU_MSG])], [[#include <urcu/ref.h>]]
 )
 
-# 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.]),
-               [
-                       AM_CPPFLAGS="$AM_CPPFLAGS -I${withval}/include"
-                       LDFLAGS="$LDFLAGS -L${withval}/lib64 -L${withval}/lib"
-               ])
+# Check for libkmod, it will be auto-neabled if found but won't fail if it's not,
+# it can be explicitly disabled with --without-kmod
+AH_TEMPLATE([HAVE_KMOD], [Define if you have kmod support])
+AC_ARG_WITH([kmod],
+  [AS_HELP_STRING([--with-kmod], [build with lkmod support @<:@default=check@:>@])],
+  [],
+  [with_kmod=check]
+)
 
-AC_ARG_ENABLE(kmod,
-       AS_HELP_STRING([--disable-kmod],[build without kmod support]),
-       kmod_support=$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])
+AS_IF([test "x$with_kmod" != "xno"],
+  [
+    AC_CHECK_LIB([kmod], [kmod_module_probe_insert_module],
+      [
+        AC_DEFINE([HAVE_KMOD], [1])
+        KMOD_LIBS="-lkmod"
+      ],
+      [
+        if test "x$with_kmod" != xcheck; then
+          AC_MSG_FAILURE([Cannot find libkmod. Use [LDFLAGS]=-Ldir and [CPPFLAGS]=-Idir to specify its location.])
+        else
+          with_kmod=no
+        fi
+      ]
+    )
+  ]
+)
+AC_SUBST(KMOD_LIBS)
+
+# Check for liblttng-ust-ctl, fail if it's not found,
+# it can be explicitly disabled with --without-lttng-ust
+AH_TEMPLATE([HAVE_LIBLTTNG_UST_CTL], [Define if you have LTTng-UST control support])
+AC_ARG_WITH([lttng-ust],
+  [AS_HELP_STRING([--without-lttng-ust], [build without LTTng-UST (Userspace Tracing) support])],
+  [],
+  [with_lttng_ust=yes]
+)
+
+AS_IF([test "x$with_lttng_ust" = "xyes"],
+  [
+    AC_CHECK_LIB([lttng-ust-ctl], [ustctl_recv_channel_from_consumer],
+      [
+        AC_DEFINE([HAVE_LIBLTTNG_UST_CTL], [1])
+      ],
+      [
+        AC_MSG_FAILURE([Cannot find LTTng-UST >= 2.2.x. Use [LDFLAGS]=-Ldir and [CPPFLAGS]=-Idir to specify its location, or specify --without-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$with_lttng_ust" = "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.]),
-                 [
-                   AM_CPPFLAGS="$AM_CPPFLAGS -I${withval}/include"
-                   LDFLAGS="$LDFLAGS -L${withval}/lib64 -L${withval}/lib"
-                 ])
 
-# Check liblttng-ust-ctl library
-AC_ARG_WITH(lttng-ust,
-       AS_HELP_STRING([--without-lttng-ust],[build without LTTng-UST (Userspace Tracing) support]),
-       lttng_ust_support=$withval, 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 --without-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],
@@ -864,7 +866,7 @@ AS_IF([test x$build_lib_consumer = xyes],
        build_lib_hashtable=yes
        build_lib_compat=yes
        build_lib_relayd=yes
-       AS_IF([test x$lttng_ust_ctl_found = xyes],[build_lib_ust_consumer=yes])
+       AS_IF([test "x$with_lttng_ust" = "xyes"], [build_lib_ust_consumer=yes])
       ]
 )
 
@@ -1126,11 +1128,11 @@ done
 PPRINT_PROP_STRING([Target architecture], $target_arch)
 
 # kmod enabled/disabled
-test "x$kmod_found" = "xyes" && value=1 || value=0
+test "x$with_kmod" != "xno" && value=1 || value=0
 PPRINT_PROP_BOOL([libkmod support], $value)
 
 # LTTng-UST enabled/disabled
-test "x$lttng_ust_support" = "xyes" && value=1 || value=0
+test "x$with_lttng_ust" = "xyes" && value=1 || value=0
 PPRINT_PROP_BOOL([LTTng-UST support], $value)
 
 AS_ECHO
This page took 0.025727 seconds and 5 git commands to generate.