Merge branch 'master' into collectd-4
[collectd.git] / configure.in
index 8bfd66e..4e34555 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(collectd, 3.11.4)
+AC_INIT(collectd, 4.0.0-rc9)
 AC_CONFIG_SRCDIR(src/collectd.c)
 AC_CONFIG_HEADERS(src/config.h)
 AM_INIT_AUTOMAKE(dist-bzip2)
@@ -26,7 +26,8 @@ AC_SUBST(LTDLINCL)
 AC_SUBST(LIBLTDL)
 AC_LIBTOOL_DLOPEN
 AC_PROG_LIBTOOL
-#AC_PROG_RANLIB
+AC_PROG_LEX
+AC_PROG_YACC
 AC_CONFIG_SUBDIRS(libltdl)
 
 #
@@ -46,11 +47,12 @@ AC_CHECK_HEADERS(assert.h)
 AC_CHECK_HEADERS(sys/types.h)
 AC_CHECK_HEADERS(sys/socket.h)
 AC_CHECK_HEADERS(sys/select.h)
-AC_CHECK_HEADERS(sys/poll.h)
+AC_CHECK_HEADERS(poll.h)
 AC_CHECK_HEADERS(netdb.h)
 AC_CHECK_HEADERS(arpa/inet.h)
 AC_CHECK_HEADERS(sys/resource.h)
 AC_CHECK_HEADERS(sys/param.h)
+AC_CHECK_HEADERS(kstat.h)
 
 # For ping library
 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
@@ -151,6 +153,23 @@ AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
 # include <netinet/ip6.h>
 #endif
 ])
+AC_CHECK_HEADERS(netinet/tcp.h, [], [],
+[#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+#endif
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IP_H
+# include <netinet/ip.h>
+#endif
+])
 AC_CHECK_HEADERS(netinet/udp.h, [], [],
 [#if HAVE_STDINT_H
 # include <stdint.h>
@@ -191,6 +210,7 @@ AC_CHECK_HEADERS(mach/kern_return.h)
 
 # For hddtemp module
 AC_CHECK_HEADERS(linux/major.h)
+AC_CHECK_HEADERS(libgen.h)
 
 # For the apple_sensors module
 AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h)
@@ -226,7 +246,7 @@ AC_CHECK_HEADERS(sys/swap.h)
 AC_CHECK_HEADERS(utmp.h)
 AC_CHECK_HEADERS(utmpx.h)
 
-# For traffic plugin
+# For interface plugin
 AC_CHECK_HEADERS(ifaddrs.h)
 AC_CHECK_HEADERS(net/if.h, [], [],
 [
@@ -331,6 +351,10 @@ AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
 #endif
 ])
 
+# For the multimeter plugin
+AC_CHECK_HEADERS(termios.h)
+AC_CHECK_HEADERS(sys/ioctl.h)
+
 #
 # Checking for libraries
 #
@@ -385,9 +409,104 @@ AC_CHECK_FUNCS(getutent getutxent)
 AC_CHECK_FUNCS(quotactl)
 AC_CHECK_FUNCS(getgrgid getpwuid)
 
-# For traffic module
+# For interface module
 AC_CHECK_FUNCS(getifaddrs)
 
+# Check for NAN
+nan_type="none"
+if test "x$nan_type" = "xnone"; then
+  AC_CACHE_CHECK([whether NAN is defined by default],
+    [have_nan_default],
+    AC_COMPILE_IFELSE(
+      AC_LANG_PROGRAM(
+      [[
+#include <stdlib.h>
+#include <math.h>
+static float foo = NAN;
+      ]],
+      [[
+       if (isnan (foo))
+        return 0;
+       else
+       return 1;
+      ]]),
+      [have_nan_default="yes"],
+      [have_nan_default="no"]
+    )
+  )
+  if test "x$have_nan_default" = "xyes"
+  then
+   nan_type="default"
+   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
+     [Define if NAN is defined by default and can initialize static variables.])
+  fi
+fi
+if test "x$nan_type" = "xnone"; then
+  AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
+    [have_nan_isoc],
+    AC_COMPILE_IFELSE(
+      AC_LANG_PROGRAM(
+      [[
+#include <stdlib.h>
+#define __USE_ISOC99 1
+#include <math.h>
+static float foo = NAN;
+      ]],
+      [[
+       if (isnan (foo))
+        return 0;
+       else
+       return 1;
+      ]]),
+      [have_nan_isoc="yes"],
+      [have_nan_isoc="no"]
+    )
+  )
+  if test "x$have_nan_isoc" = "xyes"
+  then
+   nan_type="isoc99"
+   AC_DEFINE(NAN_STATIC_ISOC, 1,
+     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
+  fi
+fi
+if test "x$nan_type" = "xnone"; then
+  AC_CACHE_CHECK([whether NAN can be defined by 0/0],
+    [have_nan_zero],
+    AC_RUN_IFELSE(
+      AC_LANG_PROGRAM(
+      [[
+#include <stdlib.h>
+#include <math.h>
+#ifdef NAN
+# undef NAN
+#endif
+#define NAN (0.0 / 0.0)
+#ifndef isnan
+# define isnan(f) ((f) != (f))
+#endif
+static float foo = NAN;
+      ]],
+      [[
+       if (isnan (foo))
+        return 0;
+       else
+       return 1;
+      ]]),
+      [have_nan_zero="yes"],
+      [have_nan_zero="no"]
+    )
+  )
+  if test "x$have_nan_zero" = "xyes"
+  then
+   nan_type="zero"
+   AC_DEFINE(NAN_ZERO_ZERO, 1,
+     [Define if NAN can be defined as (0.0 / 0.0)])
+  fi
+fi
+if test "x$nan_type" = "xnone"; then
+  AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
+fi
+
 # For mount interface
 #AC_CHECK_FUNCS(getfsent getvfsent)
 
@@ -533,6 +652,15 @@ AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
 #endif
 ])
 
+AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
+       [],
+       [],
+       [
+#if HAVE_KSTAT_H
+# include <kstat.h>
+#endif
+       ])
+
 AC_MSG_CHECKING([for kernel type ($host_os)])
 case $host_os in
        *linux*)
@@ -859,6 +987,53 @@ AC_DEFINE_UNQUOTED(COLLECT_LIBMYSQL, [$collect_libmysql],
        [Wether or not to use mysql library])
 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
 
+with_own_liboconfig="no"
+liboconfig_LDFLAGS="$LDFLAGS"
+liboconfig_CPPFLAGS="$CPPFLAGS"
+AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               if test -d "$withval/lib"
+               then
+                       liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
+               fi
+               if test -d "$withval/include"
+               then
+                       liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
+               fi
+       fi
+       if test "x$withval" = "xno"
+       then
+               AC_MSG_ERROR("liboconfig is required")
+       fi
+],
+[
+       with_liboconfig="yes"
+])
+
+save_LDFLAGS="$LDFLAGS"
+save_CPPFLAGS="$CPPFLAGS"
+LDFLAGS="$liboconfig_LDFLAGS"
+CPPFLAGS="$liboconfig_CPPFLAGS"
+AC_CHECK_LIB(oconfig, oconfig_parse_fh,
+[
+       with_liboconfig="yes"
+       with_own_liboconfig="no"
+],
+[
+       with_liboconfig="yes"
+       with_own_liboconfig="yes"
+       LDFLAGS="$save_LDFLAGS"
+       CPPFLAGS="$save_CPPFLAGS"
+])
+
+AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
+if test "x$with_own_liboconfig" = "xyes"
+then
+       with_liboconfig="yes (shipped version)"
+fi
+
 #with_liboping="yes"
 with_own_liboping="no"
 liboping_LDFLAGS="$LDFLAGS"
@@ -948,6 +1123,63 @@ AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
        [Wether or not to use the pcap library])
 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
 
+perl_interpreter="perl"
+AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               LDFLAGS="$LDFLAGS -L$withval/lib"
+               CPPFLAGS="$CPPFLAGS -I$withval/include"
+               perl_interpreter="$withval/bin/perl"
+               with_libperl="yes"
+       fi
+],
+[
+       with_libperl="yes"
+])
+if test "x$with_libperl" = "xyes"
+then
+  SAVE_CFLAGS=$CFLAGS
+  SAVE_LDFLAGS=$LDFLAGS
+  PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
+  PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
+  CFLAGS="$CFLAGS $PERL_CFLAGS"
+  LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
+
+  AC_CACHE_CHECK([for libperl],
+    [have_libperl],
+    AC_LINK_IFELSE(
+      AC_LANG_PROGRAM(
+      [[
+#include <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+      ]],
+      [[
+       PerlInterpreter *perl = NULL;
+       Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
+                        newSVpv ("Collectd::Plugin::FooBar", 24),
+                        Nullsv);
+      ]]),
+      [have_libperl="yes"],
+      [have_libperl="no"]
+    )
+  )
+
+  if test "x$have_libperl" = "xyes"
+  then
+         AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
+         AC_SUBST(PERL_CFLAGS)
+         AC_SUBST(PERL_LDFLAGS)
+  else
+         with_libperl="no"
+  fi
+
+  CFLAGS=$SAVE_CFLAGS
+  LDFLAGS=$SAVE_LDFLAGS
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
+
 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
 [
        if test "x$withval" != "xno" && test "x$withval" != "xyes"
@@ -987,41 +1219,33 @@ else
 fi
 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
 
-# Define `step' and `hearbeat' values..
-declare -i collectd_step=10
-declare -i collectd_heartbeat=25
-AC_ARG_WITH(step, [AS_HELP_STRING([--with-step=SECONDS], [Interval in which plugins are queried.])],
+AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
 [
-       if test "x$withval" != "xno" -a "x$withval" != "xyes"
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
-               declare -i tmp_collectd_step="$withval"
-               if test $tmp_collectd_step -gt 0
-               then
-                       collectd_step=$tmp_collectd_step
-                       let "collectd_heartbeat=$collectd_step*2"
-               fi
+               LDFLAGS="$LDFLAGS -L$withval/lib"
+               CPPFLAGS="$CPPFLAGS -I$withval/include"
+               with_libupsclient="yes"
        fi
-], [])
-AC_ARG_WITH(heartbeat, [AS_HELP_STRING([--with-heartbeat=SECONDS], [Heartbeat of the DS in generated RRD files.])],
+],
 [
-       if test "x$withval" != "xno" -a "x$withval" != "xyes"
-       then
-               declare -i tmp_collectd_heartbeat="$withval"
-               if test $tmp_collectd_heartbeat -gt 0
-               then
-                       collectd_heartbeat=$tmp_collectd_heartbeat
-               fi
-       fi
-], [])
-
-if test $collectd_step -ne 10
+       with_libupsclient="yes"
+])
+if test "x$with_libupsclient" = "xyes"
 then
-       AC_DEFINE_UNQUOTED(COLLECTD_STEP, "$collectd_step", [Interval in which plugins are queried.])
+       AC_CHECK_LIB(upsclient, upscli_connect,
+       [
+               AC_DEFINE(HAVE_LIBUPSCLIENT, 1, [Define to 1 if you have the upsclient library (-lupsclient).])
+       ], [with_libupsclient="no (libupsclient not found)"])
 fi
-if test $collectd_heartbeat -ne 25
+if test "x$with_libupsclient" = "xyes"
 then
-       AC_DEFINE_UNQUOTED(COLLECTD_HEARTBEAT, "$collectd_heartbeat", [Interval in which plugins are queried.])
+       AC_CHECK_HEADERS(upsclient.h,
+       [
+               AC_DEFINE(HAVE_UPSCLIENT_H, 1, [Define to 1 if you have the <upsclient.h> header file.])
+       ], [with_libupsclient="no (upsclient.h not found)"])
 fi
+AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
 
 # Check for enabled/disabled features
 #
@@ -1101,11 +1325,14 @@ AC_COLLECTD([battery],   [disable], [module], [battery statistics])
 AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
 AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
 AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
+AC_COLLECTD([csv],       [disable], [module], [csv output plugin])
 AC_COLLECTD([df],        [disable], [module], [df statistics])
 AC_COLLECTD([dns],       [disable], [module], [dns statistics])
 AC_COLLECTD([email],     [disable], [module], [email statistics])
-AC_COLLECTD([quota],     [enable],  [module], [quota statistics (experimental)])
+AC_COLLECTD([entropy],   [disable], [module], [entropy statistics])
+AC_COLLECTD([exec],      [disable], [module], [exec of external programs])
 AC_COLLECTD([hddtemp],   [disable], [module], [hdd temperature statistics])
+AC_COLLECTD([interface], [disable], [module], [interface statistics])
 AC_COLLECTD([iptables],  [disable], [module], [IPtables statistics])
 AC_COLLECTD([irq],       [disable], [module], [irq statistics])
 AC_COLLECTD([load],      [disable], [module], [system load statistics])
@@ -1113,20 +1340,32 @@ AC_COLLECTD([mbmon],     [disable], [module], [motherboard monitor statistics])
 AC_COLLECTD([memory],    [disable], [module], [memory statistics])
 AC_COLLECTD([multimeter],[disable], [module], [multimeter statistics])
 AC_COLLECTD([mysql],     [disable], [module], [mysql statistics])
+AC_COLLECTD([network],   [disable], [module], [network functionality])
 AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
 AC_COLLECTD([ntpd],      [disable], [module], [ntpd statistics])
+AC_COLLECTD([nut],       [disable], [module], [network UPS tools statistics])
+AC_COLLECTD([perl],      [disable], [module], [embedded perl interpreter])
 AC_COLLECTD([ping],      [disable], [module], [ping statistics])
 AC_COLLECTD([processes], [disable], [module], [processes statistics])
 AC_COLLECTD([sensors],   [disable], [module], [lm_sensors statistics])
 AC_COLLECTD([serial],    [disable], [module], [serial statistics])
+AC_COLLECTD([logfile],   [disable], [module], [logfile log facility])
 AC_COLLECTD([swap],      [disable], [module], [swap statistics])
+AC_COLLECTD([syslog],    [disable], [module], [syslog log facility])
 AC_COLLECTD([tape],      [disable], [module], [tape statistics])
-AC_COLLECTD([traffic],   [disable], [module], [system traffic statistics])
+AC_COLLECTD([unixsock],  [disable], [module], [UNIX socket plugin])
 AC_COLLECTD([users],     [disable], [module], [user count statistics])
 AC_COLLECTD([vserver],   [disable], [module], [vserver statistics])
 AC_COLLECTD([wireless],  [disable], [module], [wireless link statistics])
 
-AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libconfig/Makefile src/liboping/Makefile)
+AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile)
+
+if test "x$with_libperl" = "xyes"
+then
+       with_libperl="yes (version `perl -MConfig -e 'print $Config{version};'`)"
+else
+       enable_perl="no (needs libperl)"
+fi
 
 cat <<EOF;
 
@@ -1134,21 +1373,22 @@ Configuration:
   Libraries:
     libcurl . . . . . . $with_libcurl
     libiokit  . . . . . $with_libiokit
-    liboping  . . . . . $with_liboping
-    librrd  . . . . . . $with_rrdtool
-    lm_sensors  . . . . $with_lm_sensors
-    libstatgrab . . . . $with_libstatgrab
+    libiptc . . . . . . $with_libiptc
     libkstat  . . . . . $with_kstat
     libmysql  . . . . . $with_libmysql
+    liboconfig  . . . . $with_liboconfig
+    liboping  . . . . . $with_liboping
     libpcap . . . . . . $with_libpcap
-    libiptc . . . . . . $with_libiptc
+    libperl . . . . . . $with_libperl
     libpthread  . . . . $with_libpthread
+    librrd  . . . . . . $with_rrdtool
+    libsensors  . . . . $with_lm_sensors
+    libstatgrab . . . . $with_libstatgrab
+    libupsclient  . . . $with_libupsclient
 
   Features:
-    debug . . . . . . . $enable_debug
     daemon mode . . . . $enable_daemon
-    step  . . . . . . . $collectd_step seconds
-    heartbeat . . . . . $collectd_heartbeat seconds
+    debug . . . . . . . $enable_debug
 
   Modules:
     apache  . . . . . . $enable_apache
@@ -1157,27 +1397,36 @@ Configuration:
     battery . . . . . . $enable_battery
     cpu . . . . . . . . $enable_cpu
     cpufreq . . . . . . $enable_cpufreq
+    csv . . . . . . . . $enable_csv
     df  . . . . . . . . $enable_df
     disk  . . . . . . . $enable_disk
     dns . . . . . . . . $enable_dns
     email . . . . . . . $enable_email
+    entropy . . . . . . $enable_entropy
+    exec  . . . . . . . $enable_exec
     hddtemp . . . . . . $enable_hddtemp
-    irq . . . . . . . . $enable_irq
+    interface . . . . . $enable_interface
     iptables  . . . . . $enable_iptables
+    irq . . . . . . . . $enable_irq
     load  . . . . . . . $enable_load
+    logfile . . . . . . $enable_logfile
     mbmon . . . . . . . $enable_mbmon
     memory  . . . . . . $enable_memory
     multimeter  . . . . $enable_multimeter
     mysql . . . . . . . $enable_mysql
+    network . . . . . . $enable_network
     nfs . . . . . . . . $enable_nfs
     ntpd  . . . . . . . $enable_ntpd
+    nut . . . . . . . . $enable_nut
+    perl  . . . . . . . $enable_perl
     ping  . . . . . . . $enable_ping
     processes . . . . . $enable_processes
     sensors . . . . . . $enable_sensors
     serial  . . . . . . $enable_serial
     swap  . . . . . . . $enable_swap
+    syslog  . . . . . . $enable_syslog
     tape  . . . . . . . $enable_tape
-    traffic . . . . . . $enable_traffic
+    unixsock  . . . . . $enable_unixsock
     users . . . . . . . $enable_users
     vserver . . . . . . $enable_vserver
     wireless  . . . . . $enable_wireless