From: Sebastian Harl Date: Mon, 9 Jan 2012 10:16:19 +0000 (+0100) Subject: build system, ipvs plugin: Check for linux/ip_vs.h as well. X-Git-Tag: collectd-4.10.6~14 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d87bf146cca2c78005cf3c915cbee3cf4a985ad9;p=collectd.git build system, ipvs plugin: Check for linux/ip_vs.h as well. Also, try to find ip_vs.h without using KERNEL_CFLAGS at first. The Linux kernel headers should not be used directly -- in current kernel versions this generates warnings leading to build failures because of -Werror. --- diff --git a/configure.in b/configure.in index 254e7fdf..5618ef84 100644 --- a/configure.in +++ b/configure.in @@ -385,18 +385,36 @@ AC_CHECK_HEADERS(linux/netdevice.h, [], [], ]) # For ipvs module +have_linux_ip_vs_h="no" have_net_ip_vs_h="no" have_ip_vs_h="no" +ip_vs_h_needs_kernel_cflags="no" if test "x$ac_system" = "xLinux" then - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $KERNEL_CFLAGS" - + AC_CHECK_HEADERS(linux/ip_vs.h, [have_linux_ip_vs_h="yes"]) AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"]) AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"]) - CFLAGS="$SAVE_CFLAGS" + if test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono" && test -d "$KERNEL_DIR" + then + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $KERNEL_CFLAGS" + + AC_MSG_NOTICE([Did not find ip_vs.h. Trying again using headers from $KERNEL_DIR.]) + + AC_CHECK_HEADERS(linux/ip_vs.h, [have_linux_ip_vs_h="yes"]) + AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"]) + AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"]) + + if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes" + then + ip_vs_h_needs_kernel_cflags="yes" + fi + + CFLAGS="$SAVE_CFLAGS" + fi fi +AM_CONDITIONAL(IP_VS_H_NEEDS_KERNEL_CFLAGS, test "x$ip_vs_h_needs_kernel_cflags" = "xyes") # For quota module AC_CHECK_HEADERS(sys/ucred.h, [], [], @@ -4031,7 +4049,7 @@ then plugin_vserver="yes" plugin_wireless="yes" - if test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes" + if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes" then plugin_ipvs="yes" fi @@ -4441,11 +4459,16 @@ AC_SUBST(LOAD_PLUGIN_CSV) dnl ip_vs.h if test "x$ac_system" = "xLinux" \ - && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono" + && test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono" then enable_ipvs="$enable_ipvs (ip_vs.h not found)" fi +if test "x$ip_vs_h_needs_kernel_cflags" = "xyes" +then + enable_ipvs="$enable_ipvs (needs $KERNEL_CFLAGS)" +fi + dnl Perl bindings AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])], [ diff --git a/src/Makefile.am b/src/Makefile.am index c6b0538d..0c427dc8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -438,7 +438,9 @@ endif if BUILD_PLUGIN_IPVS pkglib_LTLIBRARIES += ipvs.la ipvs_la_SOURCES = ipvs.c +if IP_VS_H_NEEDS_KERNEL_CFLAGS ipvs_la_CFLAGS = $(AM_CFLAGS) $(KERNEL_CFLAGS) +endif ipvs_la_LDFLAGS = -module -avoid-version collectd_LDADD += "-dlopen" ipvs.la collectd_DEPENDENCIES += ipvs.la diff --git a/src/ipvs.c b/src/ipvs.c index 87eee108..7bd8c698 100644 --- a/src/ipvs.c +++ b/src/ipvs.c @@ -45,7 +45,9 @@ #endif /* HAVE_NETINET_IN_H */ /* this can probably only be found in the kernel sources */ -#if HAVE_NET_IP_VS_H +#if HAVE_LINUX_IP_VS_H +# include +#elif HAVE_NET_IP_VS_H # include #elif HAVE_IP_VS_H # include