From c1406acc1770790a46fc674353154e46354afc9d Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 1 Sep 2007 10:57:45 +0200 Subject: [PATCH] build system: Improve detection of the libnetlink library. --- configure.in | 63 ++++++++++++++++++++++++++++++++++++++++++++++--- src/Makefile.am | 3 ++- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/configure.in b/configure.in index 5d89a97a..522eccf8 100644 --- a/configure.in +++ b/configure.in @@ -1389,8 +1389,65 @@ AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you ha AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes") ### END of check for libxmms ### -with_libnetlink="yes" -AC_CHECK_LIB(netlink, rtnl_open, [with_libnetlink="yes"], [with_libnetlink="no"]) +with_libnetlink_cflags="" +with_libnetlink_libs="-lnetlink" +AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])], +[ + echo "libnetlink: withval = $withval" + if test "x$withval" = "xyes" + then + with_libnetlink="yes" + else if test "x$withval" = "xno" + then + with_libnetlink="no" + else + if test -d "$withval/include" + then + with_libnetlink_cflags="-I$withval/include" + with_libnetlink_libs="-L$withval/lib -lnetlink" + with_libnetlink="yes" + else + AC_MSG_ERROR("no such directory: $withval/include") + fi + fi; fi +], +[ + if test "x$ac_system" = "xLinux" + then + with_libnetlink="yes" + else + with_libnetlink="no (Linux only library)" + fi +]) +if test "x$with_libnetlink" = "xyes" +then + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $with_libnetlink_cflags" + + AC_CHECK_HEADERS(iproute/libnetlink.h, [], [with_libnetlink="no (iproute/libnetlink.h not found)"], +[#include +#include +#include +#include +#include ]) + + CFLAGS="$SAVE_CFLAGS" +fi +if test "x$with_libnetlink" = "xyes" +then + AC_CHECK_LIB(netlink, rtnl_open, + [with_libnetlink="yes"], + [with_libnetlink="no (symbol 'rtnl_open' not found)"], + [$with_libnetlink_libs]) +fi +if test "x$with_libnetlink" = "xyes" +then + BUILD_WITH_LIBNETLINK_CFLAGS="$with_curl_cflags" + BUILD_WITH_LIBNETLINK_LIBS="$with_curl_libs" + AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS) + AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS) +fi +AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes") # Check for enabled/disabled features # @@ -1735,7 +1792,7 @@ Configuration: memory . . . . . . $enable_memory multimeter . . . . $enable_multimeter mysql . . . . . . . $enable_mysql - netlink . . . . . . $enable_network + netlink . . . . . . $enable_netlink network . . . . . . $enable_network nfs . . . . . . . . $enable_nfs ntpd . . . . . . . $enable_ntpd diff --git a/src/Makefile.am b/src/Makefile.am index 9f7ccad4..16094f7e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -353,7 +353,8 @@ if BUILD_PLUGIN_NETLINK pkglib_LTLIBRARIES += netlink.la netlink_la_SOURCES = netlink.c netlink_la_LDFLAGS = -module -avoid-version -netlink_la_LIBADD = -lnetlink +netlink_la_CFLAGS = $(BUILD_WITH_LIBNETLINK_CFLAGS) +netlink_la_LIBADD = $(BUILD_WITH_LIBNETLINK_LIBS) collectd_LDADD += "-dlopen" netlink.la collectd_DEPENDENCIES += netlink.la endif -- 2.30.2