[AC_MSG_ERROR([liburcu $liburcu_version or newer is needed])], [[#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.]),
+ [
+ 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.
AS_ECHO_N("Target architecture: ")
AS_ECHO($target_arch)
+# kmod enabled/disabled
+AS_ECHO_N("libkmod support: ")
+AS_IF([test "x$kmod_found" = "xyes"],[
+ AS_ECHO("Enabled")
+],[
+ AS_ECHO("Disabled")
+])
+
# LTTng-UST enabled/disabled
AS_ECHO_N("Lttng-UST support: ")
AS_IF([test "x$lttng_ust_support" = "xyes"],[
modprobe_remove_lttng_control();
}
+#if HAVE_KMOD
+#include <libkmod.h>
+static void log_kmod(void *data, int priority, const char *file, int line,
+ const char *fn, const char *format, va_list args)
+{
+ char *str;
+
+ if (vasprintf(&str, format, args) < 0) {
+ return;
+ }
+
+ DBG("libkmod: %s", str);
+ free(str);
+}
+static int modprobe_lttng(struct kern_modules_param *modules,
+ int entries, int required)
+{
+ int ret = 0, i;
+ struct kmod_ctx *ctx;
+
+ ctx = kmod_new(NULL, NULL);
+ if (!ctx) {
+ PERROR("Unable to create kmod library context");
+ ret = -ENOMEM;
+ goto error;
+ }
+
+ kmod_set_log_fn(ctx, log_kmod, NULL);
+ kmod_load_resources(ctx);
+
+ for (i = 0; i < entries; i++) {
+ struct kmod_module *mod = NULL;
+
+ ret = kmod_module_new_from_name(ctx, modules[i].name, &mod);
+ if (ret < 0) {
+ PERROR("Failed to create kmod module for %s", modules[i].name);
+ goto error;
+ }
+
+ ret = kmod_module_probe_insert_module(mod, KMOD_PROBE_IGNORE_LOADED,
+ NULL, NULL, NULL, NULL);
+ if (required && ret < 0) {
+ ERR("Unable to load module %s", modules[i].name);
+ } else {
+ DBG("Modprobe successfully %s", modules[i].name);
+ }
+
+ kmod_module_unref(mod);
+ }
+
+error:
+ if (ctx) {
+ kmod_unref(ctx);
+ }
+ return ret;
+}
+
+#else /* HAVE_KMOD */
+
static int modprobe_lttng(struct kern_modules_param *modules,
- int entries, int required)
+ int entries, int required)
{
int ret = 0, i;
char modprobe[256];
return ret;
}
+#endif /* HAVE_KMOD */
+
/*
* Load control kernel module(s).
*/