Code

build system: Improve detection of the libnetlink library.
authorFlorian Forster <octo@huhu.verplant.org>
Sat, 1 Sep 2007 08:57:45 +0000 (10:57 +0200)
committerFlorian Forster <octo@huhu.verplant.org>
Sat, 1 Sep 2007 08:57:45 +0000 (10:57 +0200)
configure.in
src/Makefile.am

index 5d89a97ae402b2ab7393e7c4f424c1a291302f78..522eccf8451dd9f94846cb7d9f7f3e5643576ea7 100644 (file)
@@ -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 <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>])
+
+       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
index 9f7ccad4bda3661e50d8fc7332a75c6190409597..16094f7e3f904a52cc407f3696c093165a18e088 100644 (file)
@@ -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