Cleanup: kmod library detection
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 11 May 2017 16:13:16 +0000 (12:13 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 1 Jun 2017 20:58:46 +0000 (16:58 -0400)
Simplify kmod detection code and use a variable to store the detected
lib instead of using the global LIBS variable.

Also remove the --with-kmod-prefix configure option since we don't offer
it for other libs and it's based on user variables which the build
system shouldn't be messing with.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
configure.ac
src/bin/lttng-sessiond/Makefile.am

index 2b61844d6927d1f15fc99ac44e464aa707e4282d..92e4a37cbae4d41011d6aa42f2b5bbd8322f6384 100644 (file)
@@ -406,31 +406,33 @@ AC_CHECK_DECL([cmm_smp_mb__before_uatomic_or], [],
         [AC_MSG_ERROR([WRONG_LIBURCU_MSG])], [[#include <urcu.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"
-               ])
-
-AC_ARG_ENABLE(kmod,
-       AS_HELP_STRING([--disable-kmod],[build without kmod support]),
-       kmod_support=$enableval, kmod_support=yes)
+# 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]
+)
 
-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)
 
 AC_ARG_WITH(lttng-ust-prefix,
   AS_HELP_STRING([--with-lttng-ust-prefix=PATH],
@@ -1121,7 +1123,7 @@ 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
index 529887b8a75ae12a6e2f4542550cca5d3aa680f2..fbbe7fe23e3bc8aee2ebf9f0f9ba47189512395e 100644 (file)
@@ -46,7 +46,7 @@ endif
 lttng_sessiond_SOURCES += lttng-sessiond.h main.c
 
 # link on liblttngctl for check if sessiond is already alive.
-lttng_sessiond_LDADD = -lurcu-common -lurcu \
+lttng_sessiond_LDADD = -lurcu-common -lurcu $(KMOD_LIBS) \
                $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la \
                $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \
                $(top_builddir)/src/common/kernel-ctl/libkernel-ctl.la \
This page took 0.028365 seconds and 4 git commands to generate.