Merge branch 'collectd-5.7' into collectd-5.8
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Mon, 19 Feb 2018 15:14:01 +0000 (16:14 +0100)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Mon, 19 Feb 2018 15:14:01 +0000 (16:14 +0100)
316 files changed:
.gitignore
.travis.yml
AUTHORS
CONTRIBUTING.md
ChangeLog
Makefile.am
README
bindings/Makefile.am [deleted file]
bindings/java/Makefile.am [deleted file]
bindings/java/org/collectd/java/GenericJMXConfValue.java
build.sh
clean.sh
configure.ac
contrib/README
contrib/curl_json/php-fpm.conf [new file with mode: 0644]
contrib/docker/50docker-apt-conf [new file with mode: 0644]
contrib/docker/Dockerfile [new file with mode: 0644]
contrib/docker/collectd.conf [new file with mode: 0644]
contrib/docker/collectd.conf.d/sample.conf [new file with mode: 0644]
contrib/docker/rootfs_prefix/.gitignore [new file with mode: 0644]
contrib/docker/rootfs_prefix/Makefile [new file with mode: 0644]
contrib/docker/rootfs_prefix/rootfs_prefix.c [new file with mode: 0644]
contrib/format.sh [new file with mode: 0755]
contrib/redhat/collectd.spec
contrib/systemd.collectd.service
docs/BUILD.dpdkstat.md
docs/README.virt.md [new file with mode: 0644]
docs/maintainer_guide.md [new file with mode: 0644]
m4/.gitignore [new file with mode: 0644]
m4/ax_compare_version.m4 [new file with mode: 0644]
m4/ax_compiler_vendor.m4 [new file with mode: 0644]
proto/Makefile.am [deleted file]
proto/types.proto
src/Makefile.am [deleted file]
src/aggregation.c
src/amqp.c
src/apache.c
src/apcups.c
src/apple_sensors.c
src/aquaero.c
src/ascent.c
src/battery.c
src/battery_statefs.c
src/bind.c
src/ceph.c
src/ceph_test.c
src/cgroups.c
src/chrony.c
src/collectd-nagios.c
src/collectd-python.pod
src/collectd-snmp.pod
src/collectd-tg.c
src/collectd.conf.in
src/collectd.conf.pod
src/collectd.pod
src/collectdctl.c
src/collectdmon.c
src/conntrack.c
src/contextswitch.c
src/cpu.c
src/cpufreq.c
src/cpusleep.c
src/cpython.h
src/csv.c
src/curl.c
src/curl_json.c
src/curl_json_test.c [new file with mode: 0644]
src/curl_xml.c
src/daemon/Makefile.am [deleted file]
src/daemon/collectd.c
src/daemon/collectd.h
src/daemon/common.c
src/daemon/common.h
src/daemon/common_test.c
src/daemon/configfile.c
src/daemon/filter_chain.c
src/daemon/filter_chain.h
src/daemon/globals.c [new file with mode: 0644]
src/daemon/globals.h [new file with mode: 0644]
src/daemon/meta_data.c
src/daemon/meta_data.h
src/daemon/meta_data_test.c
src/daemon/plugin.c
src/daemon/plugin.h
src/daemon/plugin_mock.c
src/daemon/types_list.c
src/daemon/utils_avltree.c
src/daemon/utils_avltree_test.c
src/daemon/utils_cache.c
src/daemon/utils_cache.h
src/daemon/utils_cache_mock.c
src/daemon/utils_complain.c
src/daemon/utils_complain.h
src/daemon/utils_heap.c
src/daemon/utils_heap.h
src/daemon/utils_heap_test.c
src/daemon/utils_ignorelist.c [deleted file]
src/daemon/utils_ignorelist.h [deleted file]
src/daemon/utils_llist.c
src/daemon/utils_random.c
src/daemon/utils_random.h
src/daemon/utils_subst.c
src/daemon/utils_subst.h
src/daemon/utils_subst_test.c
src/daemon/utils_threshold.c
src/daemon/utils_threshold.h
src/daemon/utils_time.c
src/daemon/utils_time.h
src/daemon/utils_time_test.c
src/dbi.c
src/df.c
src/disk.c
src/dns.c
src/dpdkevents.c [new file with mode: 0644]
src/dpdkstat.c
src/drbd.c
src/email.c
src/entropy.c
src/ethstat.c
src/exec.c
src/fhcount.c
src/filecount.c
src/fscache.c
src/gmond.c
src/gps.c
src/grpc.cc
src/hddtemp.c
src/hugepages.c
src/intel_pmu.c [new file with mode: 0644]
src/intel_rdt.c
src/interface.c
src/ipc.c
src/ipmi.c
src/iptables.c
src/ipvs.c
src/irq.c
src/java.c
src/libcollectdclient/Makefile.am [deleted file]
src/libcollectdclient/client.c
src/libcollectdclient/collectd/client.h
src/libcollectdclient/collectd/lcc_features.h.in
src/libcollectdclient/collectd/network.h
src/libcollectdclient/collectd/network_buffer.h
src/libcollectdclient/collectd/network_parse.h [new file with mode: 0644]
src/libcollectdclient/collectd/server.h [new file with mode: 0644]
src/libcollectdclient/collectd/types.h [new file with mode: 0644]
src/libcollectdclient/network.c
src/libcollectdclient/network_buffer.c
src/libcollectdclient/network_parse.c [new file with mode: 0644]
src/libcollectdclient/network_parse_test.c [new file with mode: 0644]
src/libcollectdclient/server.c [new file with mode: 0644]
src/liboconfig/Makefile.am [deleted file]
src/liboconfig/oconfig.c
src/liboconfig/oconfig.h
src/load.c
src/log_logstash.c
src/logfile.c
src/lpar.c
src/lua.c
src/lvm.c
src/madwifi.c
src/match_empty_counter.c
src/match_hashed.c
src/match_regex.c
src/match_timediff.c
src/match_value.c
src/mbmon.c
src/mcelog.c [new file with mode: 0644]
src/md.c
src/memcachec.c
src/memcached.c
src/memory.c
src/mic.c
src/modbus.c
src/mqtt.c
src/msr-index.h
src/multimeter.c
src/mysql.c
src/netapp.c
src/netlink.c
src/network.c
src/nfs.c
src/nginx.c
src/notify_desktop.c
src/notify_email.c
src/notify_nagios.c
src/ntpd.c
src/numa.c
src/nut.c
src/olsrd.c
src/onewire.c
src/openldap.c
src/openvpn.c
src/oracle.c
src/ovs_events.c [new file with mode: 0644]
src/ovs_stats.c [new file with mode: 0644]
src/perl.c
src/pf.c
src/pinba.c
src/ping.c
src/postgresql.c
src/powerdns.c
src/processes.c
src/protocols.c
src/python.c
src/pyvalues.c
src/redis.c
src/routeros.c
src/rrdcached.c
src/rrdtool.c
src/sensors.c
src/serial.c
src/sigrok.c
src/smart.c
src/snmp.c
src/snmp_agent.c [new file with mode: 0644]
src/statsd.c
src/swap.c
src/synproxy.c [new file with mode: 0644]
src/syslog.c
src/table.c
src/tail.c
src/tail_csv.c
src/tape.c
src/target_notification.c
src/target_replace.c
src/target_scale.c
src/target_set.c
src/target_v5upgrade.c
src/tcpconns.c
src/teamspeak2.c
src/ted.c
src/testing.h
src/thermal.c
src/threshold.c
src/tokyotyrant.c
src/turbostat.c
src/types.db
src/unixsock.c
src/uptime.c
src/users.c
src/utils_cmd_flush.c
src/utils_cmd_flush.h
src/utils_cmd_getthreshold.c
src/utils_cmd_getthreshold.h
src/utils_cmd_getval.c
src/utils_cmd_getval.h
src/utils_cmd_listval.c
src/utils_cmd_listval.h
src/utils_cmd_putnotif.c
src/utils_cmd_putnotif.h
src/utils_cmd_putval.c
src/utils_cmds.c
src/utils_cmds_test.c
src/utils_curl_stats.c
src/utils_db_query.c
src/utils_db_query.h
src/utils_dns.c
src/utils_dpdk.c [new file with mode: 0644]
src/utils_dpdk.h [new file with mode: 0644]
src/utils_fbhash.c
src/utils_fbhash.h
src/utils_format_graphite.c
src/utils_format_graphite_test.c
src/utils_format_json.c
src/utils_format_kairosdb.c
src/utils_format_kairosdb.h
src/utils_ignorelist.c [new file with mode: 0644]
src/utils_ignorelist.h [new file with mode: 0644]
src/utils_latency.c
src/utils_latency.h
src/utils_latency_config.c
src/utils_latency_config.h
src/utils_latency_test.c
src/utils_lua.c
src/utils_lua.h
src/utils_match.c
src/utils_match.h
src/utils_mount.c
src/utils_mount_test.c
src/utils_ovs.c [new file with mode: 0644]
src/utils_ovs.h [new file with mode: 0644]
src/utils_parse_option.c
src/utils_parse_option.h
src/utils_rrdcreate.c
src/utils_rrdcreate.h
src/utils_tail.c
src/utils_tail_match.c
src/utils_tail_match.h
src/utils_vl_lookup.c
src/utils_vl_lookup_test.c
src/uuid.c
src/valgrind.FreeBSD.suppress
src/varnish.c
src/virt.c
src/virt_test.c [new file with mode: 0644]
src/vmem.c
src/vserver.c
src/wireless.c
src/write_graphite.c
src/write_http.c
src/write_kafka.c
src/write_log.c
src/write_mongodb.c
src/write_prometheus.c
src/write_redis.c
src/write_riemann.c
src/write_riemann_threshold.c
src/write_sensu.c
src/write_tsdb.c
src/xencpu.c
src/xmms.c
src/zfs_arc.c
src/zone.c
src/zookeeper.c
version-gen.sh

index 8154d73..2911069 100644 (file)
@@ -4,6 +4,7 @@ Makefile.in
 /aclocal.m4
 /autom4te.cache
 /autom4te.cache
+/build-aux/
 /compile
 /config.guess
 /config.sub
@@ -12,8 +13,15 @@ Makefile.in
 /install-sh
 /libltdl/
 /ltmain.sh
+/m4/libtool.m4
+/m4/ltargz.m4
+/m4/ltdl.m4
+/m4/lt~obsolete.m4
+/m4/ltoptions.m4
+/m4/ltsugar.m4
+/m4/ltversion.m4
 /missing
-src/config.h.in
+/src/config.h.in
 
 # configure stuff:
 Makefile
@@ -29,12 +37,13 @@ src/stamp-h1
 *.la
 *.lo
 *.o
+.dirstamp
 .libs/
 .deps/
-src/collectd-nagios
-src/collectd-tg
-src/collectdctl
-src/collectdmon
+/collectd-nagios
+/collectd-tg
+/collectdctl
+/collectdmon
 src/*.1
 src/*.5
 src/.pod2man.tmp.*
@@ -51,26 +60,28 @@ src/liboconfig/parser.h
 src/liboconfig/scanner.c
 
 # protobuf stuff:
-src/*.pb-c.[ch]
-src/*.grpc.pb.cc
-src/*.pb.cc
-src/*.pb.h
+*.pb-c.[ch]
+*.grpc.pb.cc
+*.pb.cc
+*.pb.h
 
 # make dist stuff:
 /collectd-*.tar.gz
 /collectd-*.tar.bz2
 
 # perl stuff:
-bindings/.perl-directory-stamp
+/.perl-directory-stamp
 bindings/perl/Collectd/pm_to_blib
 bindings/perl/blib/
 bindings/perl/pm_to_blib
-bindings/buildperl
+/buildperl
 
 # java stuff
-bindings/java/java-build-stamp
-bindings/java/org/collectd/api/*.class
-bindings/java/org/collectd/java/*.class
+*.jar
+/org/collectd/api/*.class
+/org/collectd/java/*.class
+/bindings/java/java-build-stamp
+/classnoinst.stamp
 
 # python stuff
 *.pyc
@@ -94,4 +105,4 @@ src/test-suite.log
 test_*
 
 # src/daemon/...
-src/daemon/collectd
+/collectd
index 03d9dde..fc250cb 100644 (file)
@@ -16,12 +16,15 @@ before_install:
       libganglia1-dev
       libgcrypt11-dev
       libglib2.0-dev
+      libgps-dev
       libhiredis-dev
       libi2c-dev
       libldap2-dev
       libltdl-dev
+      liblua5.2-dev
       liblvm2-dev
       libmemcached-dev
+      libmicrohttpd-dev
       libmnl-dev
       libmodbus-dev
       libmosquitto0-dev
@@ -53,4 +56,4 @@ before_install:
       perl
       protobuf-c-compiler
       python-dev
-script: sh build.sh && ./configure --with-python=/usr/bin/python && make distcheck DISTCHECK_CONFIGURE_FLAGS="--with-python=/usr/bin/python"
+script: sh build.sh && ./configure && make distcheck
diff --git a/AUTHORS b/AUTHORS
index 8962e77..4df743c 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -116,6 +116,9 @@ Dan Ryder <daryder at cisco.com>
 David Bacher <drbacher at gmail.com>
  - serial plugin.
 
+Denis Pompilio <denis.pompilio at gmail.com>
+ - Improvements to the write_http plugin.
+
 Doug MacEachern <dougm at hyperic.com>
  - The `-T' option (config testing mode).
  - OpenVPN plugin.
@@ -285,6 +288,11 @@ Scott Sanders <scott at jssjr.com>
 Sebastien Pahl <sebastien.pahl at dotcloud.com>
  - AMQP plugin.
 
+Serhiy Pshyk <serhiyx.pshyk at intel.com>
+ - intel_pmu plugin
+ - intel_rdt plugin
+ - snmp_agent plugin
+
 Simon Kuhnle <simon at blarzwurst.de>
  - OpenBSD code for the cpu and memory plugins.
 
@@ -294,6 +302,9 @@ Sjoerd van der Berg <harekiet at gmail.com>
 Stefan Hacker <stefan.hacker at web.de>
  - teamspeak2 plugin.
 
+Steven Bell <stv.bell07 at gmail.com>
+ - nut plugin.
+
 Sven Trenkel <collectd at semidefinite.de>
  - netapp plugin.
  - python plugin.
index 791446a..11969de 100644 (file)
@@ -30,9 +30,11 @@ the mailing list have a tendency to fall through the cracks.
 
 *   *Focus:* Fix *one thing* in your PR. The smaller your change, the faster it
     will be reviewed and merged.
-*   *Coding style:* Please run `clang-format -style=file -i $FILE` on new files.
-    For existing files, please blend into surrounding code, i.e. mimic the
-    coding style of the code around your changes.
+*   *Coding style:* Please run `clang-format -style=file -i $FILE` after editing
+    `.c`, `.h` and `.proto` files. If you don't want to install *clang-format*
+    locally or your version produces a different result than the formatting
+    check on Github, use `contrib/format.sh` to format files using the same web
+    service used by our check.
 *   *Documentation:* New config options need to be documented in two places: the
     manpage (`src/collectd.conf.pod`) and the example config
     (`src/collectd.conf.in`). New plugins need to be added to the `README` file.
index f990dd4..5c7c42f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,179 @@
+2017-11-17, Version 5.8.0
+       * collectd: The core daemon is now completely licensed under the MIT
+         license.
+       * collectd: Added daemon option to avoid making BaseDir. Thanks to
+         Nathaniel Wesley Filardo and Florian Forster. #2422
+       * collectd: Global variables have been moved to their own module to make
+         porting collectd easier. Thanks to Sean Campbell. #2467
+       * collectd as well as Apache, memcached, OpenLDAP, Perl, RouterOS, SNMP,
+         Tail-CSV plugins: Free userdata for "plugin_register_complex_read()".
+         Thanks to Pavel Rochnyack. #2349
+       * Collectd client library: Added parsing and server code. Thanks to
+         Florian Forster. #2258
+       * Build system: Dependency on libltdl has been removed, support for
+         libtool 1 has been dropped. Thanks to Ruben Kerkhof. #1898
+       * Build system: The build system has been switched to non-recursive
+         make. Thanks to Ruben Kerkhof. #2085
+       * APC UPS plugin: The plugin's configuration is now optional. Without a
+         "<Plugin />" block reasonable defaults will be used. Thanks to Pavel
+         Rochnyack. #2351
+       * Chrony plugin: Several issues found when working with a stratum-1
+         server have been fixed. Thanks to Miroslav Lichvar. #2190
+       * Ceph plugin: Support for the Ceph version "Luminous" has been added.
+         Thanks to Aleksei Zakharov. #2464
+       * CPU plugin : Linux-specific "guest" states have been added. Thanks to
+         Xavier G. #2439
+       * cURL plugin, cURL-JSON, cURL-XML, DBI, FileCount, memcachec, Oracle,
+         PostgreSQL, Table, Tail, Tail CSV plugins: The ability to configure
+         the "plugin" field of generated metrics has been added. Thanks to
+         Pavel Rochnyack. #1944, #1681, #1558
+       * cURL-JSON plugin: Parsing of arrays has been fixed. Thanks to Florian
+         Forster. #2281
+       * DPDKEvents plugin: This new plugin reports link status and keep alive
+         events. Thanks to Maryam Tahhan, Harry van Haaren, Serhiy Pshyk,
+         Kim-Marie Jones, Krzysztof Matczak, Przemyslaw Szczerbik, Christian
+         Ehrhardt and Luca Boccassi. #2157, #2348, #2400, #2405, #2417
+       * DPDKStat plugin: The plugin has been refactored to make DPDK related
+         utility functions reusable. Thanks to Krzysztof Matczak, Przemyslaw
+         Szczerbik, Christian Ehrhardt and Luca Boccassi. #2130, #2348, #2400,
+         #2405, #2417
+       * DPDKStat plugin: The "LogLevel" and "RteDriverLibPath" config options
+         have been added. Thanks to Jiri Prokes. #2505
+       * Email plugin as well as Exec and Unixsock plugins: Use
+         "_SC_GETPW_R_SIZE_MAX". Thanks to Florian Forster. #2451
+       * FileCount plugin: Custom values for reported plugin, type and type
+         instance. Thanks to Pavel Rochnyack. #1979
+       * GenericJMX plugin: Support for "AtomicInteger" and "AtomicLong" has
+         been added. Thanks to Pierre Mauduit. #2158
+       * gRPC plugin: Support for meta data has been added. Thanks to Taylor
+         Cramer. #2378
+       * IPC plugin: Fixed failed compilation on AIX. Thanks to Pavel
+         Rochnyack. #2357
+       * Intel PMU plugin: This new plugin collects CPU performance metrics
+         using Intel's Performance Monitoring Unit (PMU). Scaling information
+         added to metadata. Thanks to Serhiy Pshyk and Roman Korynkevych.
+         #2276, #2398, #2374
+       * Intel RDT plugin: Support for collectd's logging infrastructure has
+         been added. PQoS monitoring groups are being reset on start-up to fix
+         potential previous unclean shutdowns. Thanks to Roman Korynkevych.
+         #2089.
+       * IPMI plugin: Support for System Event Log (SEL) has been added. Thanks
+         to Roman Korynkevych. #2091
+       * IPMI plugin: Support for remote IPMI controllers has been added.
+         Thanks to Pavel Rochnyack. #2024
+       * LVM plugin: A check for the "CAP_SYS_ADMIN" capability has been added.
+         This will give users an informative warning when the process is not
+         running with the required privileges for this plugin. Thanks to
+         Florian Forster. #2426, #2499
+       * mcelog plugin: This new plugin subscribes to Machine Check Exceptions
+         (MCE) and dispatches notifications. Metadata reset. Thanks to Maryam
+         Tahhan, Volodymyr Mytnyk, Taras Chornyi, Krzysztof Matczak and Roman
+         Korynkevych. #2003, #2246, #2380
+       * MQTT plugin: Add support for TLS in "Subscriber" blocks. Thanks to
+         Florian Forster. #2434
+       * memcached plugin: Persistent connections have been implemented. Fix
+         hit ratio reporting, add connections rate report. Thanks to Pavel
+         Rochnyack. #2388, #2385
+       * memcached plugin: The type of the "listen_disabled" metric has been
+         changed to "total_events". Thanks to Florian Forster. #2386, #2468
+       * Netlink plugin: The dropped packets metric has been added. Thanks to
+         Denys Fedoryshchenko. #2053
+       * NFS plugin: Support for NFS 4.2 metrics has been added. Thanks to
+         Marek Becka. #2369
+       * NFS plugin: Config options to ignore specified NFS versions have been
+         added. Thanks to Christian Bartolomäus. #2430
+       * NUT plugin: The "ConnectTimeout", "ForceSSL", "VerifyPeer" and
+         "CAPath" options have been added. Thanks to Pavel Rochnyack and Steven
+         Bell. #2145, #2354
+       * OpenLDAP plugin: A segfault after a connection failure has been fixed.
+         Thanks to Pavel Rochnyack. #2377
+       * Openvpn plugin: Added support for status files from latest OpenVPN-2.4
+         and possible from future versions. Thanks to Pavel Rochnyack. #2352
+       * OVS Events plugin: This new plugin reports link state changes from
+         Open vSwitch (OVS). Thanks to Volodymyr Mytnyk. #1971
+       * OVS Stats plugin: This new plugin reports bridge / interface
+         statistics from Open vSwitch (OVS). Thanks to Volodymyr Mytnyk and
+         Taras Chornyi. #2137
+       * Perl plugin: Bugfix, added check of proper interpreter initialization.
+         Thanks to Pavel Rochnyack. #2391
+       * PostgreSQL plugin: The plugin now sets the "application_name"
+         parameter when connecting to the database. Thanks to daniacs. #2497
+       * Processes plugin: The I/O operations reported for selected processes
+         has been fixed. The metric "ps_disk_octets" has been renamed to
+         "io_octets" because it actually contains the number of I/O operation
+         by the process, not just disk related I/O. Same for "io_ops"
+         (previously "ps_disk_ops"). The new metric "disk_octets" has been
+         added and is reporting disk I/O only. Add option to collect the count
+         of active memory maps for Linux processes. The "CollectFileDescriptor"
+         and "CollectContextSwitch" options have been added. Thanks to Pavel
+         Rochnyack and to Wilfried Goesgens. #2232, #2454, #1989
+       * Processes and TCPConns plugins: The OpenBSD implementation has been
+         changed to use "kvm_openfiles" with "KVM_NO_FILES". Thanks to Jeremie
+         Courreges-Anglas. #2061
+       * Python plugin: Extend Notification class to include metadata. Thanks
+         to Volodymyr Mytnyk. #2135
+       * Python plugin: The "CollectdException" class has been added. This
+         allows to throw an exception without a stack trace being logged.
+         Thanks to Sven Trenkel. #2330, #2346
+       * Sensors plugin: Support for (electrical) current has been added.
+         Thanks to Clemens Gruber. #2255
+       * SNMP plugin: Error handling has been improved: a potential double-free
+         is now avoided (potentially leaking memory) and handling of
+         non-failing subtrees has been fixed. Thanks to Pavel Rochnyack. #2449
+       * SNMP plugin: The "Timeout" and "Retries" config options have been
+         added. Thanks to Carlos Vicente. #1472, #2488
+       * SNMP Agent plugin: This new plugin implements an SNMP AgentX subagent
+         that receives and handles queries from SNMP master agent and returns
+         configured metrics. Thanks to Roman Korynkevych, Serhiy Pshyk and
+         Pavel Rochnyack. #2105, #2362
+       * Synproxy plugin: This new plugin provides statistics for Linux
+         SYNPROXY. Thanks to Marek Bečka. #2381
+       * Tail plugin: Allow the calculation of several distributions in one
+         "tail" instance through a "bucket" type. Thanks to Pavel Rochnyack.
+         #2442
+       * Turbostat plugin: Import "msr-index.h" header from Linux and better
+         support for mutliple packages. Thanks to Vincent Brillault. #2445,
+         #2446
+       * Uptime plugin: Changed implementation to read from "/proc/uptime"
+         instead of "/proc/stat". Update for Linux and AIX, uptime is read
+         directly using a system call. Update for BSD and Solaris, uptime is
+         calculated by subtracting boot time from current time. Thanks to Ivan
+         Kurnosov and Marcin Jurkowski. #2431, #2034
+       * UUID plugin: Support for libhal has been removed. Thanks to Ruben
+         Kerkhof. #2080
+       * Varnish plugin: Extended the varnish plugin with varnish-plus
+         counters. Fixed invalid data source type. Thanks to Denes Matetelki.
+         #2453, #2463
+       * virt plugin: The plugin has been updated to use
+         "virConnectListAllDomains()". Thanks to Denis Silakov. #2051
+       * virt plugin: Support for domain tags has been added. Thanks to
+         Francesco Romani. #2048
+       * virt plugin: Connection handling has been improved. Thanks to
+         Francesco Romani. #2100, #2101
+       * virt plugin: Many metrics have been added, including disk, hypervisor
+         CPU usage, performance monitoring events, domain state, CPU pinning
+         (affinity), file system, and job statistics. Thanks to Francesco
+         Romani and Przemyslaw Szczerbik. #2103, #2175, #2168
+       * Write Graphite plugin: Additional tests have been added. Thanks to
+         Florian Forster.
+       * Write HTTP plugin: The "Attribute" and "TTL" options for the KairosDB
+         format have been added. Implementation of "Prefix" option. Thanks to
+         jaroug, Denis Pompilio and Pavel Rochnyack. #2199, #2252, #2482
+       * Write MongoDB plugin: Memory leaks have been fixed. Thanks to
+         Saikrishna Arcot. #2307
+       * Write Prometheus plugin: Label values are now properly escaped. Thanks
+         to Florian Forster. #2035
+       * Write Redis plugin: Add "max_set_duration" to set duration for value.
+         Thanks to Tomofumi Hayashi. #2440
+       * Write Riemann plugin: Export times with microsecond resolution. Thanks
+         to mcorbin. #2315
+       * Write TSDB plugin: The options "ResolveInterval" and "ResolveJitter"
+         have been added to control DNS lookup behavior. This prevents DNS
+         flooding in case TSDB is not available. Thanks to Yves Mettier and
+         Florian Forster. #2059
+       * ZFS ARC plugin: Header lines are now ignored in the Linux
+         implementation. Thanks to YmrDtnJu. #2097
+
 2017-06-06, Version 5.7.2
        * Build system: The Notify Email plugin is no longer linked with
          indirect dependencies. Thanks to Marc Fournier.
index 03bdd39..91e4b46 100644 (file)
-ACLOCAL_AMFLAGS = -I libltdl/m4
+ACLOCAL_AMFLAGS = -I m4
+AM_YFLAGS = -d
 
-SUBDIRS =
 
-if BUILD_INCLUDED_LTDL
-SUBDIRS += libltdl
+BUILT_SOURCES = \
+       src/libcollectdclient/collectd/lcc_features.h \
+       src/liboconfig/parser.h \
+       $(dist_man_MANS)
+
+
+CLEANFILES = \
+       .perl-directory-stamp \
+       bindings/buildperl/Collectd.pm \
+       bindings/buildperl/Collectd/Plugins/OpenVZ.pm \
+       bindings/buildperl/Collectd/Unixsock.pm \
+       bindings/buildperl/Makefile.PL \
+       collectd-api.jar \
+       collectd.grpc.pb.cc \
+       collectd.grpc.pb.h \
+       collectd.pb.cc \
+       collectd.pb.h \
+       generic-jmx.jar \
+       org/collectd/api/*.class \
+       org/collectd/java/*.class \
+       prometheus.pb-c.c \
+       prometheus.pb-c.h \
+       src/pinba.pb-c.c \
+       src/pinba.pb-c.h \
+       types.pb.cc \
+       types.pb.h
+
+
+EXTRA_DIST = \
+       bindings/perl/Makefile.PL \
+       bindings/perl/lib/Collectd.pm \
+       bindings/perl/lib/Collectd/Plugins/Monitorus.pm \
+       bindings/perl/lib/Collectd/Plugins/OpenVZ.pm \
+       bindings/perl/lib/Collectd/Unixsock.pm \
+       bindings/perl/uninstall_mod.pl \
+       contrib \
+       proto/collectd.proto \
+       proto/prometheus.proto \
+       proto/types.proto \
+       src/collectd-email.pod \
+       src/collectd-exec.pod \
+       src/collectd-java.pod \
+       src/collectd-lua.pod \
+       src/collectd-nagios.pod \
+       src/collectd-perl.pod \
+       src/collectd-python.pod \
+       src/collectd-snmp.pod \
+       src/collectd-tg.pod \
+       src/collectd-threshold.pod \
+       src/collectd-unixsock.pod \
+       src/collectd.conf.pod \
+       src/collectd.pod \
+       src/collectdctl.pod \
+       src/collectdmon.pod \
+       src/pinba.proto \
+       src/postgresql_default.conf \
+       src/types.db \
+       src/types.db.pod \
+       src/valgrind.FreeBSD.suppress \
+       testwrapper.sh \
+       version-gen.sh
+
+
+dist_man_MANS = \
+       src/collectd.1 \
+       src/collectd.conf.5 \
+       src/collectd-email.5 \
+       src/collectd-exec.5 \
+       src/collectdctl.1 \
+       src/collectd-java.5 \
+       src/collectd-lua.5 \
+       src/collectdmon.1 \
+       src/collectd-nagios.1 \
+       src/collectd-perl.5 \
+       src/collectd-python.5 \
+       src/collectd-snmp.5 \
+       src/collectd-tg.1 \
+       src/collectd-threshold.5 \
+       src/collectd-unixsock.5 \
+       src/types.db.5
+
+
+nodist_pkgconfig_DATA = \
+       src/libcollectdclient/libcollectdclient.pc
+
+pkginclude_HEADERS = \
+       src/libcollectdclient/collectd/client.h \
+       src/libcollectdclient/collectd/lcc_features.h \
+       src/libcollectdclient/collectd/network_buffer.h \
+       src/libcollectdclient/collectd/network.h \
+       src/libcollectdclient/collectd/network_parse.h \
+       src/libcollectdclient/collectd/server.h \
+       src/libcollectdclient/collectd/types.h
+
+lib_LTLIBRARIES = libcollectdclient.la
+
+
+sbin_PROGRAMS = \
+       collectd \
+       collectdmon
+
+
+bin_PROGRAMS = \
+       collectd-nagios \
+       collectd-tg \
+       collectdctl
+
+
+noinst_LTLIBRARIES = \
+       libavltree.la \
+       libcmds.la \
+       libcommon.la \
+       libformat_graphite.la \
+       libformat_json.la \
+       libheap.la \
+       libignorelist.la \
+       liblatency.la \
+       liblookup.la \
+       libmetadata.la \
+       libmount.la \
+       liboconfig.la
+
+
+check_LTLIBRARIES = \
+       libplugin_mock.la
+
+
+check_PROGRAMS = \
+       test_common \
+       test_format_graphite \
+       test_meta_data \
+       test_utils_avltree \
+       test_utils_cmds \
+       test_utils_heap \
+       test_utils_latency \
+       test_utils_mount \
+       test_utils_subst \
+       test_utils_time \
+       test_utils_vl_lookup \
+       test_libcollectd_network_parse
+
+
+TESTS = $(check_PROGRAMS)
+
+LOG_COMPILER = env VALGRIND="@VALGRIND@" $(abs_srcdir)/testwrapper.sh
+
+
+jardir = $(pkgdatadir)/java
+
+pkglib_LTLIBRARIES =
+
+
+PLUGIN_LDFLAGS = \
+       -module \
+       -avoid-version \
+       -export-symbols-regex '\<module_register\>'
+
+
+AM_CPPFLAGS = \
+       -I$(top_srcdir)/src -I$(top_srcdir)/src/daemon \
+       -DPREFIX='"${prefix}"' \
+       -DCONFIGFILE='"${sysconfdir}/${PACKAGE_NAME}.conf"' \
+       -DLOCALSTATEDIR='"${localstatedir}"' \
+       -DPKGLOCALSTATEDIR='"${localstatedir}/lib/${PACKAGE_NAME}"' \
+       -DPLUGINDIR='"${pkglibdir}"' \
+       -DPKGDATADIR='"${pkgdatadir}"'
+
+
+# Link to these libraries..
+COMMON_LIBS = $(PTHREAD_LIBS)
+if BUILD_WITH_CAPABILITY
+COMMON_LIBS += -lcap
+endif
+if BUILD_WITH_LIBRT
+COMMON_LIBS += -lrt
+endif
+if BUILD_WITH_LIBPOSIX4
+COMMON_LIBS += -lposix4
+endif
+if BUILD_WITH_LIBSOCKET
+COMMON_LIBS += -lsocket
+endif
+if BUILD_WITH_LIBKSTAT
+COMMON_LIBS += -lkstat
+endif
+if BUILD_WITH_LIBDEVINFO
+COMMON_LIBS += -ldevinfo
+endif
+
+
+collectd_SOURCES = \
+       src/daemon/collectd.c \
+       src/daemon/collectd.h \
+       src/daemon/configfile.c \
+       src/daemon/configfile.h \
+       src/daemon/filter_chain.c \
+       src/daemon/filter_chain.h \
+       src/daemon/globals.c \
+       src/daemon/globals.h \
+       src/daemon/meta_data.c \
+       src/daemon/meta_data.h \
+       src/daemon/plugin.c \
+       src/daemon/plugin.h \
+       src/daemon/utils_cache.c \
+       src/daemon/utils_cache.h \
+       src/daemon/utils_complain.c \
+       src/daemon/utils_complain.h \
+       src/daemon/utils_llist.c \
+       src/daemon/utils_llist.h \
+       src/daemon/utils_random.c \
+       src/daemon/utils_random.h \
+       src/daemon/utils_subst.c \
+       src/daemon/utils_subst.h \
+       src/daemon/utils_time.c \
+       src/daemon/utils_time.h \
+       src/daemon/types_list.c \
+       src/daemon/types_list.h \
+       src/daemon/utils_threshold.c \
+       src/daemon/utils_threshold.h
+
+
+collectd_CFLAGS = $(AM_CFLAGS)
+collectd_CPPFLAGS = $(AM_CPPFLAGS)
+collectd_LDFLAGS = -export-dynamic
+collectd_LDADD = \
+       libavltree.la \
+       libcommon.la \
+       libheap.la \
+       liboconfig.la \
+       -lm \
+       $(COMMON_LIBS) \
+       $(DLOPEN_LIBS)
+
+if BUILD_FEATURE_DAEMON
+collectd_CPPFLAGS += -DPIDFILE='"${localstatedir}/run/${PACKAGE_NAME}.pid"'
+endif
+
+# The daemon needs to call sg_init, so we need to link it against libstatgrab,
+# too. -octo
+if BUILD_WITH_LIBSTATGRAB
+collectd_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+collectd_LDADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+endif
+
+
+collectdmon_SOURCES = src/collectdmon.c
+
+
+collectd_nagios_SOURCES = src/collectd-nagios.c
+collectd_nagios_CPPFLAGS = $(AM_CPPFLAGS) \
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient
+collectd_nagios_LDADD = libcollectdclient.la
+if BUILD_WITH_LIBSOCKET
+collectd_nagios_LDADD += -lsocket
+endif
+if BUILD_AIX
+collectd_nagios_LDADD += -lm
+endif
+
+
+collectdctl_SOURCES = src/collectdctl.c
+collectdctl_CPPFLAGS = $(AM_CPPFLAGS) \
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient
+collectdctl_LDADD = libcollectdclient.la
+if BUILD_WITH_LIBSOCKET
+collectdctl_LDADD += -lsocket
+endif
+if BUILD_AIX
+collectdctl_LDADD += -lm
+endif
+
+
+collectd_tg_SOURCES = src/collectd-tg.c
+collectd_tg_CPPFLAGS = $(AM_CPPFLAGS) \
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient
+collectd_tg_LDADD = \
+       $(PTHREAD_LIBS) \
+       libheap.la \
+       libcollectdclient.la
+if BUILD_WITH_LIBSOCKET
+collectd_tg_LDADD += -lsocket
+endif
+if BUILD_WITH_LIBRT
+collectd_tg_LDADD += -lrt
+endif
+if BUILD_AIX
+collectd_tg_LDADD += -lm
+endif
+
+
+test_common_SOURCES = \
+       src/daemon/common_test.c \
+       src/testing.h
+test_common_LDADD = libplugin_mock.la
+
+test_meta_data_SOURCES = \
+       src/daemon/meta_data_test.c \
+       src/testing.h
+test_meta_data_LDADD = libmetadata.la libplugin_mock.la
+
+test_utils_avltree_SOURCES = \
+       src/daemon/utils_avltree_test.c \
+       src/testing.h
+test_utils_avltree_LDADD = libavltree.la $(COMMON_LIBS)
+
+test_utils_heap_SOURCES = \
+       src/daemon/utils_heap_test.c \
+       src/testing.h
+test_utils_heap_LDADD = libheap.la $(COMMON_LIBS)
+
+test_utils_time_SOURCES = \
+       src/daemon/utils_time_test.c \
+       src/testing.h
+
+test_utils_subst_SOURCES = \
+       src/daemon/utils_subst_test.c \
+       src/testing.h \
+       src/daemon/utils_subst.c \
+       src/daemon/utils_subst.h
+test_utils_subst_LDADD = libplugin_mock.la
+
+libavltree_la_SOURCES = \
+       src/daemon/utils_avltree.c \
+       src/daemon/utils_avltree.h
+
+libcommon_la_SOURCES = \
+       src/daemon/common.c \
+       src/daemon/common.h
+libcommon_la_LIBADD = $(COMMON_LIBS)
+
+libheap_la_SOURCES = \
+       src/daemon/utils_heap.c \
+       src/daemon/utils_heap.h
+
+libignorelist_la_SOURCES = \
+       src/utils_ignorelist.c \
+       src/utils_ignorelist.h
+
+libmetadata_la_SOURCES = \
+       src/daemon/meta_data.c \
+       src/daemon/meta_data.h
+
+libplugin_mock_la_SOURCES = \
+       src/daemon/plugin_mock.c \
+       src/daemon/utils_cache_mock.c \
+       src/daemon/utils_complain.c \
+       src/daemon/utils_complain.h \
+       src/daemon/utils_time.c \
+       src/daemon/utils_time.h
+
+libplugin_mock_la_CPPFLAGS = $(AM_CPPFLAGS) -DMOCK_TIME
+libplugin_mock_la_LIBADD = libcommon.la libignorelist.la $(COMMON_LIBS)
+
+libformat_graphite_la_SOURCES = \
+       src/utils_format_graphite.c \
+       src/utils_format_graphite.h
+
+test_format_graphite_SOURCES = \
+       src/utils_format_graphite_test.c \
+       src/testing.h
+test_format_graphite_LDADD = \
+       libformat_graphite.la \
+       libmetadata.la \
+       libplugin_mock.la \
+       -lm
+
+libformat_json_la_SOURCES = \
+       src/utils_format_json.c \
+       src/utils_format_json.h
+libformat_json_la_CPPFLAGS  = $(AM_CPPFLAGS)
+libformat_json_la_LDFLAGS   = $(AM_LDFLAGS)
+libformat_json_la_LIBADD    =
+if BUILD_WITH_LIBYAJL
+libformat_json_la_CPPFLAGS += $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+libformat_json_la_LDFLAGS  += $(BUILD_WITH_LIBYAJL_LDFLAGS)
+libformat_json_la_LIBADD   += $(BUILD_WITH_LIBYAJL_LIBS)
+
+check_PROGRAMS += test_format_json
+
+test_format_json_SOURCES = \
+       src/utils_format_json_test.c \
+       src/testing.h
+test_format_json_LDADD = \
+       libformat_json.la \
+       libmetadata.la \
+       libplugin_mock.la \
+       -lm
+endif
+
+if BUILD_PLUGIN_CEPH
+test_plugin_ceph_SOURCES = src/ceph_test.c
+test_plugin_ceph_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+test_plugin_ceph_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+test_plugin_ceph_LDADD = libplugin_mock.la $(BUILD_WITH_LIBYAJL_LIBS)
+check_PROGRAMS += test_plugin_ceph
+endif
+
+liblatency_la_SOURCES = \
+       src/utils_latency.c \
+       src/utils_latency.h \
+       src/utils_latency_config.c \
+       src/utils_latency_config.h
+liblatency_la_LIBADD = \
+       libcommon.la \
+       -lm
+
+test_utils_latency_SOURCES = \
+       src/utils_latency_test.c \
+       src/testing.h
+test_utils_latency_LDADD = \
+       liblatency.la \
+       libplugin_mock.la \
+       -lm
+
+libcmds_la_SOURCES = \
+       src/utils_cmds.c \
+       src/utils_cmds.h \
+       src/utils_cmd_flush.c \
+       src/utils_cmd_flush.h \
+       src/utils_cmd_getthreshold.c \
+       src/utils_cmd_getthreshold.h \
+       src/utils_cmd_getval.c \
+       src/utils_cmd_getval.h \
+       src/utils_cmd_listval.c \
+       src/utils_cmd_listval.h \
+       src/utils_cmd_putnotif.c \
+       src/utils_cmd_putnotif.h \
+       src/utils_cmd_putval.c \
+       src/utils_cmd_putval.h \
+       src/utils_parse_option.c \
+       src/utils_parse_option.h
+libcmds_la_LIBADD = \
+       libcommon.la \
+       libmetadata.la \
+       -lm
+
+test_utils_cmds_SOURCES = \
+       src/utils_cmds_test.c \
+       src/testing.h
+test_utils_cmds_LDADD = \
+       libcmds.la \
+       libplugin_mock.la
+
+liblookup_la_SOURCES = \
+       src/utils_vl_lookup.c \
+       src/utils_vl_lookup.h
+liblookup_la_LIBADD = libavltree.la
+
+test_utils_vl_lookup_SOURCES = \
+       src/utils_vl_lookup_test.c \
+       src/testing.h
+test_utils_vl_lookup_LDADD = \
+       liblookup.la \
+       libplugin_mock.la
+if BUILD_WITH_LIBKSTAT
+test_utils_vl_lookup_LDADD += -lkstat
+endif
+
+libmount_la_SOURCES = \
+       src/utils_mount.c \
+       src/utils_mount.h
+
+test_utils_mount_SOURCES = \
+       src/utils_mount_test.c \
+       src/testing.h
+test_utils_mount_LDADD = \
+       libmount.la \
+       libplugin_mock.la
+if BUILD_WITH_LIBKSTAT
+test_utils_mount_LDADD += -lkstat
+endif
+
+
+libcollectdclient_la_SOURCES = \
+       src/libcollectdclient/client.c \
+       src/libcollectdclient/network.c \
+       src/libcollectdclient/network_buffer.c \
+       src/libcollectdclient/network_parse.c \
+       src/libcollectdclient/server.c
+libcollectdclient_la_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient \
+       -I$(srcdir)/src/daemon
+libcollectdclient_la_LDFLAGS = -version-info 2:0:1
+libcollectdclient_la_LIBADD = -lm
+if BUILD_WITH_LIBGCRYPT
+libcollectdclient_la_CPPFLAGS += $(GCRYPT_CPPFLAGS)
+libcollectdclient_la_LDFLAGS += $(GCRYPT_LDFLAGS)
+libcollectdclient_la_LIBADD += $(GCRYPT_LIBS)
+endif
+
+# network_parse_test.c includes network_parse.c, so no need to link with
+# libcollectdclient.so.
+test_libcollectd_network_parse_SOURCES = src/libcollectdclient/network_parse_test.c
+test_libcollectd_network_parse_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       -I$(srcdir)/src/libcollectdclient \
+       -I$(top_builddir)/src/libcollectdclient
+if BUILD_WITH_LIBGCRYPT
+test_libcollectd_network_parse_CPPFLAGS += $(GCRYPT_CPPFLAGS)
+test_libcollectd_network_parse_LDFLAGS = $(GCRYPT_LDFLAGS)
+test_libcollectd_network_parse_LDADD = $(GCRYPT_LIBS)
+endif
+
+liboconfig_la_SOURCES = \
+       src/liboconfig/oconfig.c \
+       src/liboconfig/oconfig.h \
+       src/liboconfig/aux_types.h \
+       src/liboconfig/scanner.l \
+       src/liboconfig/parser.y
+liboconfig_la_CPPFLAGS = -I$(srcdir)/src/liboconfig $(AM_CPPFLAGS)
+liboconfig_la_LDFLAGS = -avoid-version $(LEXLIB)
+
+
+if BUILD_PLUGIN_AGGREGATION
+pkglib_LTLIBRARIES += aggregation.la
+aggregation_la_SOURCES = \
+       src/aggregation.c \
+       src/utils_vl_lookup.c \
+       src/utils_vl_lookup.h
+aggregation_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+aggregation_la_LIBADD = -lm
+endif
+
+if BUILD_PLUGIN_AMQP
+pkglib_LTLIBRARIES += amqp.la
+amqp_la_SOURCES = src/amqp.c
+amqp_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
+amqp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
+amqp_la_LIBADD = \
+       $(BUILD_WITH_LIBRABBITMQ_LIBS) \
+       libcmds.la \
+       libformat_graphite.la \
+       libformat_json.la
+endif
+
+if BUILD_PLUGIN_APACHE
+pkglib_LTLIBRARIES += apache.la
+apache_la_SOURCES = src/apache.c
+apache_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
+apache_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+apache_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS)
+endif
+
+
+if BUILD_PLUGIN_APCUPS
+pkglib_LTLIBRARIES += apcups.la
+apcups_la_SOURCES = src/apcups.c
+apcups_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+apcups_la_LIBADD =
+if BUILD_WITH_LIBSOCKET
+apcups_la_LIBADD += -lsocket
+endif
+endif
+
+if BUILD_PLUGIN_APPLE_SENSORS
+pkglib_LTLIBRARIES += apple_sensors.la
+apple_sensors_la_SOURCES = src/apple_sensors.c
+apple_sensors_la_LDFLAGS = $(PLUGIN_LDFLAGS) -framework IOKit
+endif
+
+if BUILD_PLUGIN_AQUAERO
+pkglib_LTLIBRARIES += aquaero.la
+aquaero_la_SOURCES = src/aquaero.c
+aquaero_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBAQUAERO5_CFLAGS)
+aquaero_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBAQUAERO5_LDFLAGS)
+aquaero_la_LIBADD = -laquaero5
+endif
+
+if BUILD_PLUGIN_ASCENT
+pkglib_LTLIBRARIES += ascent.la
+ascent_la_SOURCES = src/ascent.c
+ascent_la_CFLAGS = \
+       $(AM_CFLAGS) \
+       $(BUILD_WITH_LIBCURL_CFLAGS) \
+       $(BUILD_WITH_LIBXML2_CFLAGS)
+ascent_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ascent_la_LIBADD = \
+       $(BUILD_WITH_LIBCURL_LIBS) \
+       $(BUILD_WITH_LIBXML2_LIBS)
+endif
+
+if BUILD_PLUGIN_BAROMETER
+pkglib_LTLIBRARIES += barometer.la
+barometer_la_SOURCES = src/barometer.c
+barometer_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+barometer_la_LIBADD = -lm
+endif
+
+if BUILD_PLUGIN_BATTERY
+pkglib_LTLIBRARIES += battery.la
+battery_la_SOURCES = \
+       src/battery.c \
+       src/battery_statefs.c
+battery_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+if BUILD_WITH_LIBIOKIT
+battery_la_LDFLAGS += -framework IOKit
+endif
+endif
+
+if BUILD_PLUGIN_BIND
+pkglib_LTLIBRARIES += bind.la
+bind_la_SOURCES = src/bind.c
+bind_la_CFLAGS = $(AM_CFLAGS) \
+       $(BUILD_WITH_LIBCURL_CFLAGS) $(BUILD_WITH_LIBXML2_CFLAGS)
+bind_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+bind_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS) $(BUILD_WITH_LIBXML2_LIBS)
+endif
+
+if BUILD_PLUGIN_CEPH
+pkglib_LTLIBRARIES += ceph.la
+ceph_la_SOURCES = src/ceph.c
+ceph_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+ceph_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+ceph_la_LIBADD = $(BUILD_WITH_LIBYAJL_LIBS)
+endif
+
+if BUILD_PLUGIN_CGROUPS
+pkglib_LTLIBRARIES += cgroups.la
+cgroups_la_SOURCES = src/cgroups.c
+cgroups_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+cgroups_la_LIBADD = libignorelist.la libmount.la
+endif
+
+if BUILD_PLUGIN_CHRONY
+pkglib_LTLIBRARIES += chrony.la
+chrony_la_SOURCES = src/chrony.c
+chrony_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+chrony_la_LIBADD = -lm
+endif
+
+if BUILD_PLUGIN_CONNTRACK
+pkglib_LTLIBRARIES += conntrack.la
+conntrack_la_SOURCES = src/conntrack.c
+conntrack_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_CONTEXTSWITCH
+pkglib_LTLIBRARIES += contextswitch.la
+contextswitch_la_SOURCES = src/contextswitch.c
+contextswitch_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+contextswitch_la_LIBADD =
+if BUILD_WITH_PERFSTAT
+contextswitch_la_LIBADD += -lperfstat
+endif
+endif
+
+if BUILD_PLUGIN_CPU
+pkglib_LTLIBRARIES += cpu.la
+cpu_la_SOURCES = src/cpu.c
+cpu_la_CFLAGS = $(AM_CFLAGS)
+cpu_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+cpu_la_LIBADD =
+if BUILD_WITH_LIBKSTAT
+cpu_la_LIBADD += -lkstat
+endif
+if BUILD_WITH_LIBDEVINFO
+cpu_la_LIBADD += -ldevinfo
+endif
+if BUILD_WITH_LIBSTATGRAB
+cpu_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+cpu_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+endif
+if BUILD_WITH_PERFSTAT
+cpu_la_LIBADD += -lperfstat
+endif
+endif
+
+if BUILD_PLUGIN_CPUFREQ
+pkglib_LTLIBRARIES += cpufreq.la
+cpufreq_la_SOURCES = src/cpufreq.c
+cpufreq_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_CPUSLEEP
+pkglib_LTLIBRARIES += cpusleep.la
+cpusleep_la_SOURCES = src/cpusleep.c
+cpusleep_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_CSV
+pkglib_LTLIBRARIES += csv.la
+csv_la_SOURCES = src/csv.c
+csv_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_CURL
+pkglib_LTLIBRARIES += curl.la
+curl_la_SOURCES = \
+       src/curl.c \
+       src/utils_curl_stats.c \
+       src/utils_curl_stats.h \
+       src/utils_match.c \
+       src/utils_match.h
+curl_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
+curl_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+curl_la_LIBADD = liblatency.la $(BUILD_WITH_LIBCURL_LIBS)
+endif
+
+if BUILD_PLUGIN_CURL_JSON
+pkglib_LTLIBRARIES += curl_json.la
+curl_json_la_SOURCES = \
+       src/curl_json.c \
+       src/utils_curl_stats.c \
+       src/utils_curl_stats.h
+curl_json_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
+curl_json_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+curl_json_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+curl_json_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS) $(BUILD_WITH_LIBYAJL_LIBS)
+
+test_plugin_curl_json_SOURCES = src/curl_json_test.c \
+                               src/utils_curl_stats.c \
+                               src/daemon/configfile.c \
+                               src/daemon/types_list.c
+test_plugin_curl_json_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+test_plugin_curl_json_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+test_plugin_curl_json_LDADD = libavltree.la liboconfig.la libplugin_mock.la $(BUILD_WITH_LIBCURL_LIBS) $(BUILD_WITH_LIBYAJL_LIBS)
+check_PROGRAMS += test_plugin_curl_json
+endif
+
+if BUILD_PLUGIN_CURL_XML
+pkglib_LTLIBRARIES += curl_xml.la
+curl_xml_la_SOURCES = \
+       src/curl_xml.c \
+       src/utils_curl_stats.c \
+       src/utils_curl_stats.h
+curl_xml_la_CFLAGS = $(AM_CFLAGS) \
+               $(BUILD_WITH_LIBCURL_CFLAGS) $(BUILD_WITH_LIBXML2_CFLAGS)
+curl_xml_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+curl_xml_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS) $(BUILD_WITH_LIBXML2_LIBS)
+endif
+
+if BUILD_PLUGIN_DBI
+pkglib_LTLIBRARIES += dbi.la
+dbi_la_SOURCES = \
+       src/dbi.c \
+       src/utils_db_query.c \
+       src/utils_db_query.h
+dbi_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBDBI_CPPFLAGS)
+dbi_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBDBI_LDFLAGS)
+dbi_la_LIBADD = $(BUILD_WITH_LIBDBI_LIBS)
+endif
+
+if BUILD_PLUGIN_DF
+pkglib_LTLIBRARIES += df.la
+df_la_SOURCES = src/df.c
+df_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+df_la_LIBADD = libignorelist.la libmount.la
+endif
+
+if BUILD_PLUGIN_DISK
+pkglib_LTLIBRARIES += disk.la
+disk_la_SOURCES = src/disk.c
+disk_la_CFLAGS = $(AM_CFLAGS)
+disk_la_CPPFLAGS = $(AM_CPPFLAGS)
+disk_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+disk_la_LIBADD = libignorelist.la
+if BUILD_WITH_LIBKSTAT
+disk_la_LIBADD += -lkstat
+endif
+if BUILD_WITH_LIBDEVINFO
+disk_la_LIBADD += -ldevinfo
+endif
+if BUILD_WITH_LIBIOKIT
+disk_la_LDFLAGS += -framework IOKit
+endif
+if BUILD_WITH_LIBSTATGRAB
+disk_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+disk_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+endif
+if BUILD_WITH_LIBUDEV
+disk_la_CPPFLAGS += $(BUILD_WITH_LIBUDEV_CPPFLAGS)
+disk_la_LDFLAGS += $(BUILD_WITH_LIBUDEV_LDFLAGS)
+disk_la_LIBADD += $(BUILD_WITH_LIBUDEV_LIBS)
+endif
+if BUILD_FREEBSD
+disk_la_LIBADD += -ldevstat -lgeom
+endif
+if BUILD_WITH_PERFSTAT
+disk_la_LIBADD += -lperfstat
+endif
+endif
+
+if BUILD_PLUGIN_DNS
+pkglib_LTLIBRARIES += dns.la
+dns_la_SOURCES = \
+       src/dns.c \
+       src/utils_dns.c \
+       src/utils_dns.h
+dns_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBPCAP_CPPFLAGS)
+dns_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBPCAP_LDFLAGS)
+dns_la_LIBADD = $(BUILD_WITH_LIBPCAP_LIBS)
+endif
+
+if BUILD_PLUGIN_DPDKEVENTS
+pkglib_LTLIBRARIES += dpdkevents.la
+dpdkevents_la_SOURCES = src/dpdkevents.c src/utils_dpdk.c src/utils_dpdk.h
+dpdkevents_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBDPDK_CPPFLAGS)
+dpdkevents_la_CFLAGS = $(AM_CFLAGS) $(LIBDPDK_CFLAGS)
+dpdkevents_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBDPDK_LDFLAGS)
+dpdkevents_la_LIBADD = $(LIBDPDK_LIBS)
+endif
+
+if BUILD_PLUGIN_DPDKSTAT
+pkglib_LTLIBRARIES += dpdkstat.la
+dpdkstat_la_SOURCES = src/dpdkstat.c src/utils_dpdk.c src/utils_dpdk.h
+dpdkstat_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBDPDK_CPPFLAGS)
+dpdkstat_la_CFLAGS = $(AM_CFLAGS) $(LIBDPDK_CFLAGS)
+dpdkstat_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBDPDK_LDFLAGS)
+dpdkstat_la_LIBADD = $(LIBDPDK_LIBS)
+endif
+
+if BUILD_PLUGIN_DRBD
+pkglib_LTLIBRARIES += drbd.la
+drbd_la_SOURCES = src/drbd.c
+drbd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_EMAIL
+pkglib_LTLIBRARIES += email.la
+email_la_SOURCES = src/email.c
+email_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_ENTROPY
+pkglib_LTLIBRARIES += entropy.la
+entropy_la_SOURCES = src/entropy.c
+entropy_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_EXEC
+pkglib_LTLIBRARIES += exec.la
+exec_la_SOURCES = src/exec.c
+exec_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+exec_la_LIBADD = libcmds.la
+endif
+
+if BUILD_PLUGIN_ETHSTAT
+pkglib_LTLIBRARIES += ethstat.la
+ethstat_la_SOURCES = src/ethstat.c
+ethstat_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_FHCOUNT
+pkglib_LTLIBRARIES += fhcount.la
+fhcount_la_SOURCES = src/fhcount.c
+fhcount_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_FILECOUNT
+pkglib_LTLIBRARIES += filecount.la
+filecount_la_SOURCES = src/filecount.c
+filecount_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_FSCACHE
+pkglib_LTLIBRARIES += fscache.la
+fscache_la_SOURCES = src/fscache.c
+fscache_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_GMOND
+pkglib_LTLIBRARIES += gmond.la
+gmond_la_SOURCES = src/gmond.c
+gmond_la_CPPFLAGS = $(AM_CPPFLAGS) $(GANGLIA_CPPFLAGS)
+gmond_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(GANGLIA_LDFLAGS)
+gmond_la_LIBADD = $(GANGLIA_LIBS)
+endif
+
+if BUILD_PLUGIN_GPS
+pkglib_LTLIBRARIES += gps.la
+gps_la_SOURCES = src/gps.c
+gps_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBGPS_CFLAGS)
+gps_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBGPS_LDFLAGS)
+gps_la_LIBADD = -lpthread $(BUILD_WITH_LIBGPS_LIBS)
+endif
+
+if BUILD_PLUGIN_GRPC
+pkglib_LTLIBRARIES += grpc.la
+grpc_la_SOURCES = src/grpc.cc
+nodist_grpc_la_SOURCES = \
+       collectd.grpc.pb.cc \
+       collectd.pb.cc \
+       types.pb.cc
+grpc_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBGRPCPP_CPPFLAGS) $(BUILD_WITH_LIBPROTOBUF_CPPFLAGS)
+grpc_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBGRPCPP_LDFLAGS) $(BUILD_WITH_LIBPROTOBUF_LDFLAGS)
+grpc_la_LIBADD = $(BUILD_WITH_LIBGRPCPP_LIBS) $(BUILD_WITH_LIBPROTOBUF_LIBS)
+endif
+
+if BUILD_PLUGIN_HDDTEMP
+pkglib_LTLIBRARIES += hddtemp.la
+hddtemp_la_SOURCES = src/hddtemp.c
+hddtemp_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+hddtemp_la_LIBADD =
+if BUILD_WITH_LIBSOCKET
+hddtemp_la_LIBADD += -lsocket
+endif
+endif
+
+if BUILD_PLUGIN_HUGEPAGES
+pkglib_LTLIBRARIES += hugepages.la
+hugepages_la_SOURCES = src/hugepages.c
+hugepages_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_INTEL_PMU
+pkglib_LTLIBRARIES += intel_pmu.la
+intel_pmu_la_SOURCES = src/intel_pmu.c
+intel_pmu_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBJEVENTS_CPPFLAGS)
+intel_pmu_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBJEVENTS_LDFLAGS)
+intel_pmu_la_LIBADD = $(BUILD_WITH_LIBJEVENTS_LIBS)
+endif
+
+if BUILD_PLUGIN_INTEL_RDT
+pkglib_LTLIBRARIES += intel_rdt.la
+intel_rdt_la_SOURCES = src/intel_rdt.c
+intel_rdt_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBPQOS_CPPFLAGS)
+intel_rdt_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBPQOS_LDFLAGS)
+intel_rdt_la_LIBADD = $(BUILD_WITH_LIBPQOS_LIBS)
+endif
+
+if BUILD_PLUGIN_INTERFACE
+pkglib_LTLIBRARIES += interface.la
+interface_la_SOURCES = src/interface.c
+interface_la_CFLAGS = $(AM_CFLAGS)
+interface_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+interface_la_LIBADD = libignorelist.la
+if BUILD_WITH_LIBSTATGRAB
+interface_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+interface_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+else
+if BUILD_WITH_LIBKSTAT
+interface_la_LIBADD += -lkstat
+endif
+if BUILD_WITH_LIBDEVINFO
+interface_la_LIBADD += -ldevinfo
+endif # BUILD_WITH_LIBDEVINFO
+endif # !BUILD_WITH_LIBSTATGRAB
+if BUILD_WITH_PERFSTAT
+interface_la_LIBADD += -lperfstat
+endif
+endif # BUILD_PLUGIN_INTERFACE
+
+if BUILD_PLUGIN_IPC
+pkglib_LTLIBRARIES += ipc.la
+ipc_la_SOURCES = src/ipc.c
+ipc_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_IPTABLES
+pkglib_LTLIBRARIES += iptables.la
+iptables_la_SOURCES = src/iptables.c
+iptables_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBIPTC_CPPFLAGS)
+iptables_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+iptables_la_LIBADD = $(BUILD_WITH_LIBIPTC_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_IPMI
+pkglib_LTLIBRARIES += ipmi.la
+ipmi_la_SOURCES = src/ipmi.c
+ipmi_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_OPENIPMI_CFLAGS)
+ipmi_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ipmi_la_LIBADD = libignorelist.la $(BUILD_WITH_OPENIPMI_LIBS)
+endif
+
+if BUILD_PLUGIN_IPVS
+pkglib_LTLIBRARIES += ipvs.la
+ipvs_la_SOURCES = src/ipvs.c
+ipvs_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_IRQ
+pkglib_LTLIBRARIES += irq.la
+irq_la_SOURCES = src/irq.c
+irq_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+irq_la_LIBADD = libignorelist.la
+endif
+
+if BUILD_PLUGIN_JAVA
+pkglib_LTLIBRARIES += java.la
+java_la_SOURCES = src/java.c
+java_la_CPPFLAGS = $(AM_CPPFLAGS) $(JAVA_CPPFLAGS)
+java_la_CFLAGS = $(AM_CFLAGS) $(JAVA_CFLAGS)
+java_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(JAVA_LDFLAGS)
+java_la_LIBADD = $(JAVA_LIBS)
+endif
+
+if BUILD_PLUGIN_LOAD
+pkglib_LTLIBRARIES += load.la
+load_la_SOURCES = src/load.c
+load_la_CFLAGS = $(AM_CFLAGS)
+load_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+load_la_LIBADD =
+if BUILD_WITH_LIBSTATGRAB
+load_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+load_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+endif # BUILD_WITH_LIBSTATGRAB
+if BUILD_WITH_PERFSTAT
+load_la_LIBADD += -lperfstat
+endif
+endif # BUILD_PLUGIN_LOAD
+
+if BUILD_PLUGIN_LOGFILE
+pkglib_LTLIBRARIES += logfile.la
+logfile_la_SOURCES = src/logfile.c
+logfile_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_LOG_LOGSTASH
+pkglib_LTLIBRARIES += log_logstash.la
+log_logstash_la_SOURCES = src/log_logstash.c
+log_logstash_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+log_logstash_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+log_logstash_la_LIBADD = $(BUILD_WITH_LIBYAJL_LIBS)
+endif
+
+if BUILD_PLUGIN_LPAR
+pkglib_LTLIBRARIES += lpar.la
+lpar_la_SOURCES = src/lpar.c
+lpar_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+lpar_la_LIBADD = -lperfstat
+endif
+
+if BUILD_PLUGIN_LUA
+pkglib_LTLIBRARIES += lua.la
+lua_la_SOURCES = \
+       src/lua.c \
+       src/utils_lua.c \
+       src/utils_lua.h
+lua_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBLUA_CFLAGS)
+lua_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+lua_la_LIBADD = $(BUILD_WITH_LIBLUA_LIBS)
+endif
+
+if BUILD_PLUGIN_LVM
+pkglib_LTLIBRARIES += lvm.la
+lvm_la_SOURCES = src/lvm.c
+lvm_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
+lvm_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBLVM2APP_LDFLAGS)
+lvm_la_LIBADD = $(BUILD_WITH_LIBLVM2APP_LIBS)
+endif
+
+if BUILD_PLUGIN_MADWIFI
+pkglib_LTLIBRARIES += madwifi.la
+madwifi_la_SOURCES = \
+       src/madwifi.c \
+       src/madwifi.h
+madwifi_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+madwifi_la_LIBADD = libignorelist.la
+endif
+
+if BUILD_PLUGIN_MATCH_EMPTY_COUNTER
+pkglib_LTLIBRARIES += match_empty_counter.la
+match_empty_counter_la_SOURCES = src/match_empty_counter.c
+match_empty_counter_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_MATCH_HASHED
+pkglib_LTLIBRARIES += match_hashed.la
+match_hashed_la_SOURCES = src/match_hashed.c
+match_hashed_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_MATCH_REGEX
+pkglib_LTLIBRARIES += match_regex.la
+match_regex_la_SOURCES = src/match_regex.c
+match_regex_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_MATCH_TIMEDIFF
+pkglib_LTLIBRARIES += match_timediff.la
+match_timediff_la_SOURCES = src/match_timediff.c
+match_timediff_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_MATCH_VALUE
+pkglib_LTLIBRARIES += match_value.la
+match_value_la_SOURCES = src/match_value.c
+match_value_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_MBMON
+pkglib_LTLIBRARIES += mbmon.la
+mbmon_la_SOURCES = src/mbmon.c
+mbmon_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+mbmon_la_LIBADD =
+if BUILD_WITH_LIBSOCKET
+mbmon_la_LIBADD += -lsocket
+endif
+endif
+
+if BUILD_PLUGIN_MCELOG
+pkglib_LTLIBRARIES += mcelog.la
+mcelog_la_SOURCES = src/mcelog.c
+mcelog_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_MD
+pkglib_LTLIBRARIES += md.la
+md_la_SOURCES = src/md.c
+md_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+md_la_LIBADD = libignorelist.la
+endif
+
+if BUILD_PLUGIN_MEMCACHEC
+pkglib_LTLIBRARIES += memcachec.la
+memcachec_la_SOURCES = \
+       src/memcachec.c \
+       src/utils_match.c \
+       src/utils_match.h
+memcachec_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
+memcachec_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
+memcachec_la_LIBADD = liblatency.la $(BUILD_WITH_LIBMEMCACHED_LIBS)
+endif
+
+if BUILD_PLUGIN_MEMCACHED
+pkglib_LTLIBRARIES += memcached.la
+memcached_la_SOURCES = src/memcached.c
+memcached_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+memcached_la_LIBADD =
+if BUILD_WITH_LIBSOCKET
+memcached_la_LIBADD += -lsocket
+endif
+endif
+
+if BUILD_PLUGIN_MEMORY
+pkglib_LTLIBRARIES += memory.la
+memory_la_SOURCES = src/memory.c
+memory_la_CFLAGS = $(AM_CFLAGS)
+memory_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+memory_la_LIBADD =
+if BUILD_WITH_LIBKSTAT
+memory_la_LIBADD += -lkstat
+endif
+if BUILD_WITH_LIBDEVINFO
+memory_la_LIBADD += -ldevinfo
+endif
+if BUILD_WITH_LIBSTATGRAB
+memory_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+memory_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+endif
+if BUILD_WITH_PERFSTAT
+memory_la_LIBADD += -lperfstat
+endif
+endif
+
+if BUILD_PLUGIN_MIC
+pkglib_LTLIBRARIES += mic.la
+mic_la_SOURCES = src/mic.c
+mic_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_MIC_CPPFLAGS)
+mic_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_MIC_LDFLAGS)
+mic_la_LIBADD = libignorelist.la $(BUILD_WITH_MIC_LIBS)
+endif
+
+if BUILD_PLUGIN_MODBUS
+pkglib_LTLIBRARIES += modbus.la
+modbus_la_SOURCES = src/modbus.c
+modbus_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMODBUS_CFLAGS)
+modbus_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+modbus_la_LIBADD = $(BUILD_WITH_LIBMODBUS_LIBS)
+endif
+
+if BUILD_PLUGIN_MQTT
+pkglib_LTLIBRARIES += mqtt.la
+mqtt_la_SOURCES = src/mqtt.c
+mqtt_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBMOSQUITTO_CPPFLAGS)
+mqtt_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBMOSQUITTO_LDFLAGS)
+mqtt_la_LIBADD = $(BUILD_WITH_LIBMOSQUITTO_LIBS)
+endif
+
+if BUILD_PLUGIN_MULTIMETER
+pkglib_LTLIBRARIES += multimeter.la
+multimeter_la_SOURCES = src/multimeter.c
+multimeter_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_MYSQL
+pkglib_LTLIBRARIES += mysql.la
+mysql_la_SOURCES = src/mysql.c
+mysql_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMYSQL_CFLAGS)
+mysql_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+mysql_la_LIBADD = $(BUILD_WITH_LIBMYSQL_LIBS)
+endif
+
+if BUILD_PLUGIN_NETAPP
+pkglib_LTLIBRARIES += netapp.la
+netapp_la_SOURCES = src/netapp.c
+netapp_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBNETAPP_CPPFLAGS)
+netapp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBNETAPP_LDFLAGS)
+netapp_la_LIBADD = libignorelist.la $(LIBNETAPP_LIBS)
+endif
+
+if BUILD_PLUGIN_NETLINK
+pkglib_LTLIBRARIES += netlink.la
+netlink_la_SOURCES = src/netlink.c
+netlink_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMNL_CFLAGS)
+netlink_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+netlink_la_LIBADD = $(BUILD_WITH_LIBMNL_LIBS)
+endif
+
+if BUILD_PLUGIN_NETWORK
+pkglib_LTLIBRARIES += network.la
+network_la_SOURCES = \
+       src/network.c \
+       src/network.h \
+       src/utils_fbhash.c \
+       src/utils_fbhash.h
+network_la_CPPFLAGS = $(AM_CPPFLAGS)
+network_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+network_la_LIBADD =
+if BUILD_WITH_LIBSOCKET
+network_la_LIBADD += -lsocket
+endif
+if BUILD_WITH_LIBGCRYPT
+network_la_CPPFLAGS += $(GCRYPT_CPPFLAGS)
+network_la_LDFLAGS += $(GCRYPT_LDFLAGS)
+network_la_LIBADD += $(GCRYPT_LIBS)
+endif
+endif
+
+if BUILD_PLUGIN_NFS
+pkglib_LTLIBRARIES += nfs.la
+nfs_la_SOURCES = src/nfs.c
+nfs_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_NGINX
+pkglib_LTLIBRARIES += nginx.la
+nginx_la_SOURCES = src/nginx.c
+nginx_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
+nginx_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+nginx_la_LIBADD = $(BUILD_WITH_LIBCURL_LIBS)
+endif
+
+if BUILD_PLUGIN_NOTIFY_DESKTOP
+pkglib_LTLIBRARIES += notify_desktop.la
+notify_desktop_la_SOURCES = src/notify_desktop.c
+notify_desktop_la_CFLAGS = $(AM_CFLAGS) $(LIBNOTIFY_CFLAGS)
+notify_desktop_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+notify_desktop_la_LIBADD = $(LIBNOTIFY_LIBS)
+endif
+
+if BUILD_PLUGIN_NOTIFY_EMAIL
+pkglib_LTLIBRARIES += notify_email.la
+notify_email_la_SOURCES = src/notify_email.c
+notify_email_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBESMTP_CPPFLAGS)
+notify_email_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBESMTP_LDFLAGS)
+notify_email_la_LIBADD = $(BUILD_WITH_LIBESMTP_LIBS)
+endif
+
+if BUILD_PLUGIN_NOTIFY_NAGIOS
+pkglib_LTLIBRARIES += notify_nagios.la
+notify_nagios_la_SOURCES = src/notify_nagios.c
+notify_nagios_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_NTPD
+pkglib_LTLIBRARIES += ntpd.la
+ntpd_la_SOURCES = src/ntpd.c
+ntpd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+ntpd_la_LIBADD =
+if BUILD_WITH_LIBSOCKET
+ntpd_la_LIBADD += -lsocket
+endif
+endif
+
+if BUILD_PLUGIN_NUMA
+pkglib_LTLIBRARIES += numa.la
+numa_la_SOURCES = src/numa.c
+numa_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_NUT
+pkglib_LTLIBRARIES += nut.la
+nut_la_SOURCES = src/nut.c
+nut_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
+nut_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+nut_la_LIBADD = $(BUILD_WITH_LIBUPSCLIENT_LIBS)
+endif
+
+if BUILD_PLUGIN_OLSRD
+pkglib_LTLIBRARIES += olsrd.la
+olsrd_la_SOURCES = src/olsrd.c
+olsrd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+olsrd_la_LIBADD =
+if BUILD_WITH_LIBSOCKET
+olsrd_la_LIBADD += -lsocket
+endif
+endif
+
+if BUILD_PLUGIN_ONEWIRE
+pkglib_LTLIBRARIES += onewire.la
+onewire_la_SOURCES = src/onewire.c
+onewire_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
+onewire_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBOWCAPI_LDFLAGS)
+onewire_la_LIBADD = libignorelist.la $(BUILD_WITH_LIBOWCAPI_LIBS)
+endif
+
+if BUILD_PLUGIN_OPENLDAP
+pkglib_LTLIBRARIES += openldap.la
+openldap_la_SOURCES = src/openldap.c
+openldap_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBLDAP_CPPFLAGS)
+openldap_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBLDAP_LDFLAGS)
+openldap_la_LIBADD = -lldap
+endif
+
+if BUILD_PLUGIN_OPENVPN
+pkglib_LTLIBRARIES += openvpn.la
+openvpn_la_SOURCES = src/openvpn.c
+openvpn_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_ORACLE
+pkglib_LTLIBRARIES += oracle.la
+oracle_la_SOURCES = \
+       src/oracle.c \
+       src/utils_db_query.c \
+       src/utils_db_query.h
+oracle_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_ORACLE_CPPFLAGS)
+oracle_la_LIBADD = $(BUILD_WITH_ORACLE_LIBS)
+oracle_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_OVS_EVENTS
+pkglib_LTLIBRARIES += ovs_events.la
+ovs_events_la_SOURCES = \
+       src/ovs_events.c \
+       src/utils_ovs.c \
+       src/utils_ovs.h
+ovs_events_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+ovs_events_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+ovs_events_la_LIBADD = $(BUILD_WITH_LIBYAJL_LIBS)
+endif
+
+if BUILD_PLUGIN_OVS_STATS
+pkglib_LTLIBRARIES += ovs_stats.la
+ovs_stats_la_SOURCES = \
+       src/ovs_stats.c \
+       src/utils_ovs.c \
+       src/utils_ovs.h
+ovs_stats_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBYAJL_CPPFLAGS)
+ovs_stats_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBYAJL_LDFLAGS)
+ovs_stats_la_LIBADD = $(BUILD_WITH_LIBYAJL_LIBS)
+endif
+
+if BUILD_PLUGIN_PERL
+pkglib_LTLIBRARIES += perl.la
+perl_la_SOURCES = src/perl.c
+# Despite C99 providing the "bool" type thru stdbool.h, Perl defines its own
+# version of that type if HAS_BOOL is not defined... *sigh*
+perl_la_CPPFLAGS = $(AM_CPPFLAGS) -DHAS_BOOL=1
+# Despite off_t being 64 bit wide on 64 bit platforms, Perl insist on using
+# off64_t which is only exposed when _LARGEFILE64_SOURCE is defined... *sigh*
+# On older platforms we also need _REENTRANT. _GNU_SOURCE sets both of these.
+perl_la_CPPFLAGS += -D_GNU_SOURCE
+perl_la_CFLAGS = $(AM_CFLAGS) \
+       $(PERL_CFLAGS) \
+       -DXS_VERSION=\"$(VERSION)\" -DVERSION=\"$(VERSION)\"
+perl_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(PERL_LDFLAGS)
+perl_la_LIBADD = $(PERL_LIBS)
+endif
+
+if BUILD_PLUGIN_PF
+pkglib_LTLIBRARIES += pf.la
+pf_la_SOURCES = src/pf.c
+pf_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_PINBA
+pkglib_LTLIBRARIES += pinba.la
+pinba_la_SOURCES = src/pinba.c
+nodist_pinba_la_SOURCES = \
+       src/pinba.pb-c.c \
+       src/pinba.pb-c.h
+pinba_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS)
+pinba_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBPROTOBUF_C_LDFLAGS)
+pinba_la_LIBADD = $(BUILD_WITH_LIBPROTOBUF_C_LIBS)
+endif
+
+if BUILD_PLUGIN_PING
+pkglib_LTLIBRARIES += ping.la
+ping_la_SOURCES = src/ping.c
+ping_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBOPING_CPPFLAGS)
+ping_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBOPING_LDFLAGS)
+ping_la_LIBADD = -loping -lm
+endif
+
+if BUILD_PLUGIN_POSTGRESQL
+pkglib_LTLIBRARIES += postgresql.la
+postgresql_la_SOURCES = \
+       src/postgresql.c \
+       src/utils_db_query.c \
+       src/utils_db_query.h
+postgresql_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBPQ_CPPFLAGS)
+postgresql_la_LDFLAGS = $(PLUGIN_LDFLAGS) \
+       $(BUILD_WITH_LIBPQ_LDFLAGS)
+postgresql_la_LIBADD = $(BUILD_WITH_LIBPQ_LIBS)
+endif
+
+if BUILD_PLUGIN_POWERDNS
+pkglib_LTLIBRARIES += powerdns.la
+powerdns_la_SOURCES = src/powerdns.c
+powerdns_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_PYTHON
+pkglib_LTLIBRARIES += python.la
+python_la_SOURCES = \
+       src/python.c \
+       src/pyconfig.c \
+       src/pyvalues.c \
+       src/cpython.h
+python_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBPYTHON_CPPFLAGS)
+python_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBPYTHON_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_PROCESSES
+pkglib_LTLIBRARIES += processes.la
+processes_la_SOURCES = src/processes.c
+processes_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+processes_la_LIBADD =
+if BUILD_WITH_LIBKVM_GETPROCS
+processes_la_LIBADD += -lkvm
+endif
+endif
+
+if BUILD_PLUGIN_PROTOCOLS
+pkglib_LTLIBRARIES += protocols.la
+protocols_la_SOURCES = src/protocols.c
+protocols_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+protocols_la_LIBADD = libignorelist.la
+endif
+
+if BUILD_PLUGIN_REDIS
+pkglib_LTLIBRARIES += redis.la
+redis_la_SOURCES = src/redis.c
+redis_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
+redis_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBHIREDIS_LDFLAGS)
+redis_la_LIBADD = -lhiredis
+endif
+
+if BUILD_PLUGIN_ROUTEROS
+pkglib_LTLIBRARIES += routeros.la
+routeros_la_SOURCES = src/routeros.c
+routeros_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
+routeros_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBROUTEROS_LDFLAGS)
+routeros_la_LIBADD = -lrouteros
+endif
+
+if BUILD_PLUGIN_RRDCACHED
+pkglib_LTLIBRARIES += rrdcached.la
+rrdcached_la_SOURCES = \
+       src/rrdcached.c \
+       src/utils_rrdcreate.c \
+       src/utils_rrdcreate.h
+rrdcached_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBRRD_CFLAGS)
+rrdcached_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRRD_LDFLAGS)
+rrdcached_la_LIBADD = $(BUILD_WITH_LIBRRD_LIBS)
+endif
+
+if BUILD_PLUGIN_RRDTOOL
+pkglib_LTLIBRARIES += rrdtool.la
+rrdtool_la_SOURCES = \
+       src/rrdtool.c \
+       src/utils_rrdcreate.c \
+       src/utils_rrdcreate.h
+rrdtool_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBRRD_CFLAGS)
+rrdtool_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRRD_LDFLAGS)
+rrdtool_la_LIBADD = $(BUILD_WITH_LIBRRD_LIBS)
+endif
+
+if BUILD_PLUGIN_SENSORS
+pkglib_LTLIBRARIES += sensors.la
+sensors_la_SOURCES = src/sensors.c
+sensors_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBSENSORS_CPPFLAGS)
+sensors_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBSENSORS_LDFLAGS)
+sensors_la_LIBADD = libignorelist.la $(BUILD_WITH_LIBSENSORS_LIBS)
+endif
+
+if BUILD_PLUGIN_SERIAL
+pkglib_LTLIBRARIES += serial.la
+serial_la_SOURCES = src/serial.c
+serial_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_SIGROK
+pkglib_LTLIBRARIES += sigrok.la
+sigrok_la_SOURCES = src/sigrok.c
+sigrok_la_CFLAGS = $(AM_CFLAGS) $(LIBSIGROK_CFLAGS)
+sigrok_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+sigrok_la_LIBADD = $(LIBSIGROK_LIBS)
+endif
+
+if BUILD_PLUGIN_SMART
+if BUILD_WITH_LIBUDEV
+pkglib_LTLIBRARIES += smart.la
+smart_la_SOURCES = src/smart.c
+smart_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBATASMART_CPPFLAGS) $(BUILD_WITH_LIBUDEV_CPPFLAGS)
+smart_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBATASMART_LDFLAGS) $(BUILD_WITH_LIBUDEV_LDFLAGS)
+smart_la_LIBADD = libignorelist.la $(BUILD_WITH_LIBATASMART_LIBS) $(BUILD_WITH_LIBUDEV_LIBS)
+endif
+endif
+
+if BUILD_PLUGIN_SNMP
+pkglib_LTLIBRARIES += snmp.la
+snmp_la_SOURCES = src/snmp.c
+snmp_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
+snmp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBNETSNMP_LDFLAGS)
+snmp_la_LIBADD = $(BUILD_WITH_LIBNETSNMP_LIBS)
+endif
+
+if BUILD_PLUGIN_SNMP_AGENT
+pkglib_LTLIBRARIES += snmp_agent.la
+snmp_agent_la_SOURCES = src/snmp_agent.c
+snmp_agent_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBNETSNMPAGENT_CPPFLAGS)
+snmp_agent_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBNETSNMPAGENT_LDFLAGS)
+snmp_agent_la_LIBADD = $(BUILD_WITH_LIBNETSNMPAGENT_LIBS)
+endif
+
+if BUILD_PLUGIN_STATSD
+pkglib_LTLIBRARIES += statsd.la
+statsd_la_SOURCES = src/statsd.c
+statsd_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+statsd_la_LIBADD = liblatency.la
+endif
+
+if BUILD_PLUGIN_SWAP
+pkglib_LTLIBRARIES += swap.la
+swap_la_SOURCES = src/swap.c
+swap_la_CFLAGS = $(AM_CFLAGS)
+swap_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+swap_la_LIBADD =
+if BUILD_WITH_LIBKSTAT
+swap_la_LIBADD += -lkstat
+endif
+if BUILD_WITH_LIBDEVINFO
+swap_la_LIBADD += -ldevinfo
+endif
+if BUILD_WITH_LIBKVM_GETSWAPINFO
+swap_la_LIBADD += -lkvm
+endif
+if BUILD_WITH_LIBSTATGRAB
+swap_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+swap_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+endif
+if BUILD_WITH_PERFSTAT
+swap_la_LIBADD += -lperfstat
+endif
+
+endif
+
+if BUILD_PLUGIN_SYNPROXY
+pkglib_LTLIBRARIES += synproxy.la
+synproxy_la_SOURCES = src/synproxy.c
+synproxy_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_SYSLOG
+pkglib_LTLIBRARIES += syslog.la
+syslog_la_SOURCES = src/syslog.c
+syslog_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TABLE
+pkglib_LTLIBRARIES += table.la
+table_la_SOURCES = src/table.c
+table_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TAIL
+pkglib_LTLIBRARIES += tail.la
+tail_la_SOURCES = \
+       src/tail.c \
+       src/utils_match.c \
+       src/utils_match.h \
+       src/utils_tail.c \
+       src/utils_tail.h \
+       src/utils_tail_match.c \
+       src/utils_tail_match.h
+tail_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+tail_la_LIBADD = liblatency.la
+endif
+
+if BUILD_PLUGIN_TAIL_CSV
+pkglib_LTLIBRARIES += tail_csv.la
+tail_csv_la_SOURCES = \
+       src/tail_csv.c \
+       src/utils_tail.c \
+       src/utils_tail.h
+tail_csv_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TAPE
+pkglib_LTLIBRARIES += tape.la
+tape_la_SOURCES = src/tape.c
+tape_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+tape_la_LIBADD = -lkstat -ldevinfo
+endif
+
+if BUILD_PLUGIN_TARGET_NOTIFICATION
+pkglib_LTLIBRARIES += target_notification.la
+target_notification_la_SOURCES = src/target_notification.c
+target_notification_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TARGET_REPLACE
+pkglib_LTLIBRARIES += target_replace.la
+target_replace_la_SOURCES = src/target_replace.c
+target_replace_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TARGET_SCALE
+pkglib_LTLIBRARIES += target_scale.la
+target_scale_la_SOURCES = src/target_scale.c
+target_scale_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TARGET_SET
+pkglib_LTLIBRARIES += target_set.la
+target_set_la_SOURCES = src/target_set.c
+target_set_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TARGET_V5UPGRADE
+pkglib_LTLIBRARIES += target_v5upgrade.la
+target_v5upgrade_la_SOURCES = src/target_v5upgrade.c
+target_v5upgrade_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TCPCONNS
+pkglib_LTLIBRARIES += tcpconns.la
+tcpconns_la_SOURCES = src/tcpconns.c
+tcpconns_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+tcpconns_la_LIBADD =
+if BUILD_WITH_LIBKVM_NLIST
+tcpconns_la_LIBADD += -lkvm
+endif
+endif
+
+if BUILD_PLUGIN_TEAMSPEAK2
+pkglib_LTLIBRARIES += teamspeak2.la
+teamspeak2_la_SOURCES = src/teamspeak2.c
+teamspeak2_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TED
+pkglib_LTLIBRARIES += ted.la
+ted_la_SOURCES = src/ted.c
+ted_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_THERMAL
+pkglib_LTLIBRARIES += thermal.la
+thermal_la_SOURCES = src/thermal.c
+thermal_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+thermal_la_LIBADD = libignorelist.la
+endif
+
+if BUILD_PLUGIN_THRESHOLD
+pkglib_LTLIBRARIES += threshold.la
+threshold_la_SOURCES = src/threshold.c
+threshold_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_TOKYOTYRANT
+pkglib_LTLIBRARIES += tokyotyrant.la
+tokyotyrant_la_SOURCES = src/tokyotyrant.c
+tokyotyrant_la_CPPFLAGS  = $(AM_CPPFLAGS) $(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
+tokyotyrant_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
+tokyotyrant_la_LIBADD  = $(BUILD_WITH_LIBTOKYOTYRANT_LIBS)
+if BUILD_WITH_LIBSOCKET
+tokyotyrant_la_LIBADD += -lsocket
+endif
+endif
+
+if BUILD_PLUGIN_TURBOSTAT
+pkglib_LTLIBRARIES += turbostat.la
+turbostat_la_SOURCES = \
+       src/turbostat.c \
+       src/msr-index.h
+turbostat_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_UNIXSOCK
+pkglib_LTLIBRARIES += unixsock.la
+unixsock_la_SOURCES = src/unixsock.c
+unixsock_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+unixsock_la_LIBADD = libcmds.la
+endif
+
+if BUILD_PLUGIN_UPTIME
+pkglib_LTLIBRARIES += uptime.la
+uptime_la_SOURCES = src/uptime.c
+uptime_la_CFLAGS = $(AM_CFLAGS)
+uptime_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+uptime_la_LIBADD =
+if BUILD_WITH_LIBKSTAT
+uptime_la_LIBADD += -lkstat
+endif
+if BUILD_WITH_PERFSTAT
+uptime_la_LIBADD += -lperfstat
+endif
+endif
+
+if BUILD_PLUGIN_USERS
+pkglib_LTLIBRARIES += users.la
+users_la_SOURCES = src/users.c
+users_la_CFLAGS = $(AM_CFLAGS)
+users_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+users_la_LIBADD =
+if BUILD_WITH_LIBSTATGRAB
+users_la_CFLAGS += $(BUILD_WITH_LIBSTATGRAB_CFLAGS)
+users_la_LIBADD += $(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
+endif
+endif
+
+if BUILD_PLUGIN_UUID
+pkglib_LTLIBRARIES += uuid.la
+uuid_la_SOURCES = src/uuid.c
+uuid_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_VARNISH
+pkglib_LTLIBRARIES += varnish.la
+varnish_la_SOURCES = src/varnish.c
+varnish_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBVARNISH_CFLAGS)
+varnish_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+varnish_la_LIBADD = $(BUILD_WITH_LIBVARNISH_LIBS)
+endif
+
+if BUILD_PLUGIN_VIRT
+pkglib_LTLIBRARIES += virt.la
+virt_la_SOURCES = src/virt.c
+virt_la_CFLAGS = $(AM_CFLAGS) \
+       $(BUILD_WITH_LIBVIRT_CFLAGS) $(BUILD_WITH_LIBXML2_CFLAGS)
+virt_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+virt_la_LIBADD = libignorelist.la $(BUILD_WITH_LIBVIRT_LIBS) $(BUILD_WITH_LIBXML2_LIBS)
+
+# TODO: enable once we support only modern libvirts which depends on libnl-3
+# the libvirt on wheezy is linked in libnl v1, and there is a small leak here,
+# triggered by the library initialization. There are no means to avoid it,
+# and libvirt switched to libnl3 anyway
+#test_plugin_virt_SOURCES = src/virt_test.c
+#test_plugin_virt_CPPFLAGS = $(AM_CPPFLAGS) \
+#      $(BUILD_WITH_LIBVIRT_CFLAGS) $(BUILD_WITH_LIBXML2_CFLAGS)
+#test_plugin_virt_LDFLAGS = $(PLUGIN_LDFLAGS)
+#test_plugin_virt_LDADD = libplugin_mock.la \
+#      $(BUILD_WITH_LIBVIRT_LIBS) $(BUILD_WITH_LIBXML2_LIBS)
+#check_PROGRAMS += test_plugin_virt
+#TESTS += test_plugin_virt
+endif
+
+if BUILD_PLUGIN_VMEM
+pkglib_LTLIBRARIES += vmem.la
+vmem_la_SOURCES = src/vmem.c
+vmem_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_VSERVER
+pkglib_LTLIBRARIES += vserver.la
+vserver_la_SOURCES = src/vserver.c
+vserver_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_WIRELESS
+pkglib_LTLIBRARIES += wireless.la
+wireless_la_SOURCES = src/wireless.c
+wireless_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_WRITE_GRAPHITE
+pkglib_LTLIBRARIES += write_graphite.la
+write_graphite_la_SOURCES = src/write_graphite.c
+write_graphite_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+write_graphite_la_LIBADD = libformat_graphite.la
+endif
+
+if BUILD_PLUGIN_WRITE_HTTP
+pkglib_LTLIBRARIES += write_http.la
+write_http_la_SOURCES = \
+       src/write_http.c \
+       src/utils_format_kairosdb.c \
+       src/utils_format_kairosdb.h
+write_http_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBCURL_CFLAGS)
+write_http_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+write_http_la_LIBADD = libformat_json.la $(BUILD_WITH_LIBCURL_LIBS)
+endif
+
+if BUILD_PLUGIN_WRITE_KAFKA
+pkglib_LTLIBRARIES += write_kafka.la
+write_kafka_la_SOURCES = src/write_kafka.c
+write_kafka_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBRDKAFKA_CPPFLAGS)
+write_kafka_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBRDKAFKA_LDFLAGS)
+write_kafka_la_LIBADD = \
+       libcmds.la \
+       libformat_graphite.la \
+       libformat_json.la \
+       $(BUILD_WITH_LIBRDKAFKA_LIBS)
+endif
+
+if BUILD_PLUGIN_WRITE_LOG
+pkglib_LTLIBRARIES += write_log.la
+write_log_la_SOURCES = src/write_log.c
+write_log_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+write_log_la_LIBADD = libformat_graphite.la libformat_json.la
+endif
+
+if BUILD_PLUGIN_WRITE_MONGODB
+pkglib_LTLIBRARIES += write_mongodb.la
+write_mongodb_la_SOURCES = src/write_mongodb.c
+write_mongodb_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBMONGOC_CFLAGS)
+write_mongodb_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBMONGOC_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_WRITE_PROMETHEUS
+pkglib_LTLIBRARIES += write_prometheus.la
+write_prometheus_la_SOURCES = src/write_prometheus.c
+nodist_write_prometheus_la_SOURCES = \
+       prometheus.pb-c.c \
+       prometheus.pb-c.h
+write_prometheus_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS) $(BUILD_WITH_LIBMICROHTTPD_CPPFLAGS)
+write_prometheus_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBPROTOBUF_C_LDFLAGS) $(BUILD_WITH_LIBMICROHTTPD_LDFLAGS)
+write_prometheus_la_LIBADD = $(BUILD_WITH_LIBPROTOBUF_C_LIBS) $(BUILD_WITH_LIBMICROHTTPD_LIBS)
+endif
+
+if BUILD_PLUGIN_WRITE_REDIS
+pkglib_LTLIBRARIES += write_redis.la
+write_redis_la_SOURCES = src/write_redis.c
+write_redis_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
+write_redis_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBHIREDIS_LDFLAGS)
+write_redis_la_LIBADD = -lhiredis
+endif
+
+if BUILD_PLUGIN_WRITE_RIEMANN
+pkglib_LTLIBRARIES += write_riemann.la
+write_riemann_la_SOURCES = \
+       src/write_riemann.c \
+       src/write_riemann_threshold.c \
+       src/write_riemann_threshold.h
+write_riemann_la_CFLAGS = $(AM_CFLAGS) $(LIBRIEMANN_CLIENT_CFLAGS)
+write_riemann_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBRIEMANN_CLIENT_LIBS)
+endif
+
+if BUILD_PLUGIN_WRITE_SENSU
+pkglib_LTLIBRARIES += write_sensu.la
+write_sensu_la_SOURCES = src/write_sensu.c
+write_sensu_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_WRITE_TSDB
+pkglib_LTLIBRARIES += write_tsdb.la
+write_tsdb_la_SOURCES = src/write_tsdb.c
+write_tsdb_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_XENCPU
+pkglib_LTLIBRARIES += xencpu.la
+xencpu_la_SOURCES = src/xencpu.c
+xencpu_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBXENCTL_CPPFLAGS)
+xencpu_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBXENCTL_LDFLAGS)
+xencpu_la_LIBADD = -lxenctrl
+endif
+
+if BUILD_PLUGIN_XMMS
+pkglib_LTLIBRARIES += xmms.la
+xmms_la_SOURCES = src/xmms.c
+xmms_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBXMMS_CFLAGS)
+xmms_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+xmms_la_LIBADD = $(BUILD_WITH_LIBXMMS_LIBS)
+endif
+
+if BUILD_PLUGIN_ZFS_ARC
+pkglib_LTLIBRARIES += zfs_arc.la
+zfs_arc_la_SOURCES = src/zfs_arc.c
+zfs_arc_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+if BUILD_FREEBSD
+zfs_arc_la_LIBADD = -lm
+endif
+if BUILD_SOLARIS
+zfs_arc_la_LIBADD = -lkstat
+endif
+endif
+
+if BUILD_PLUGIN_ZOOKEEPER
+pkglib_LTLIBRARIES += zookeeper.la
+zookeeper_la_SOURCES = src/zookeeper.c
+zookeeper_la_LDFLAGS = $(PLUGIN_LDFLAGS)
+endif
+
+if BUILD_PLUGIN_ZONE
+pkglib_LTLIBRARIES += zone.la
+zone_la_SOURCES = src/zone.c
+zone_la_LDFLAGS = $(PLUGIN_LDFLAGS)
 endif
 
-SUBDIRS += proto src bindings .
+AM_V_POD2MAN_C = $(am__v_POD2MAN_C_@AM_V@)
+am__v_POD2MAN_C_ = $(am__v_POD2MAN_C_@AM_DEFAULT_V@)
+am__v_POD2MAN_C_0 = @echo "  POD2MAN " $@;
+am__v_POD2MAN_C_1 =
+
+.pod.1:
+       $(AM_V_POD2MAN_C)pod2man --release=$(VERSION) --center=$(PACKAGE) $< \
+               >.pod2man.tmp.$$$$ 2>/dev/null && mv -f .pod2man.tmp.$$$$ $@ || true
+       @if grep '\<POD ERRORS\>' $@ >/dev/null 2>&1; \
+       then \
+               echo "$@ has some POD errors!"; false; \
+       fi
+
+.pod.5:
+       $(AM_V_POD2MAN_C)pod2man --section=5 --release=$(VERSION) --center=$(PACKAGE) $< \
+               >.pod2man.tmp.$$$$ 2>/dev/null && mv -f .pod2man.tmp.$$$$ $@ || true
+       @if grep '\<POD ERRORS\>' $@ >/dev/null 2>&1; \
+       then \
+               echo "$@ has some POD errors!"; false; \
+       fi
+
+V_PROTOC = $(v_protoc_@AM_V@)
+v_protoc_ = $(v_protoc_@AM_DEFAULT_V@)
+v_protoc_0 = @echo "  PROTOC  " $@;
+
+AM_V_PROTOC_C = $(am__v_PROTOC_C_@AM_V@)
+am__v_PROTOC_C_ = $(am__v_PROTOC_C_@AM_DEFAULT_V@)
+am__v_PROTOC_C_0 = @echo "  PROTOC-C" $@;
+am__v_PROTOC_C_1 =
+
+# Protocol buffer for the "pinba" plugin.
+if BUILD_PLUGIN_PINBA
+BUILT_SOURCES += src/pinba.pb-c.c src/pinba.pb-c.h
+
+src/pinba.pb-c.c src/pinba.pb-c.h: $(srcdir)/src/pinba.proto
+       $(AM_V_PROTOC_C)$(PROTOC_C) -I$(srcdir) --c_out . $(srcdir)/src/pinba.proto
+endif
 
-AM_CPPFLAGS = $(LTDLINCL)
+# Protocol buffer for the "write_prometheus" plugin.
+if BUILD_PLUGIN_WRITE_PROMETHEUS
+BUILT_SOURCES += prometheus.pb-c.c prometheus.pb-c.h
 
-EXTRA_DIST = contrib version-gen.sh testwrapper.sh
+prometheus.pb-c.c prometheus.pb-c.h: $(srcdir)/proto/prometheus.proto
+       $(AM_V_PROTOC_C)$(PROTOC_C) -I$(srcdir)/proto --c_out=$(builddir) $(srcdir)/proto/prometheus.proto
+endif
+
+if HAVE_PROTOC3
+if HAVE_GRPC_CPP
+BUILT_SOURCES += collectd.grpc.pb.cc collectd.pb.cc types.pb.cc
+
+collectd.grpc.pb.cc: $(srcdir)/proto/collectd.proto $(srcdir)/proto/types.proto
+       $(V_PROTOC)$(PROTOC) -I$(srcdir)/proto \
+               --grpc_out=$(builddir) --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN) $<
+
+collectd.pb.cc: $(srcdir)/proto/collectd.proto $(srcdir)/proto/types.proto
+       $(V_PROTOC)$(PROTOC) -I$(srcdir)/proto --cpp_out=$(builddir) $<
+
+types.pb.cc: $(srcdir)/proto/types.proto
+       $(V_PROTOC)$(PROTOC) -I$(srcdir)/proto --cpp_out=$(builddir) $<
+endif
+endif
 
 install-exec-hook:
        $(mkinstalldirs) $(DESTDIR)$(localstatedir)/run
        $(mkinstalldirs) $(DESTDIR)$(localstatedir)/lib/$(PACKAGE_NAME)
        $(mkinstalldirs) $(DESTDIR)$(localstatedir)/log
+       $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
+       if test -e $(DESTDIR)$(sysconfdir)/collectd.conf; \
+       then \
+               $(INSTALL) -m 0640 $(srcdir)/src/collectd.conf $(DESTDIR)$(sysconfdir)/collectd.conf.pkg-orig; \
+       else \
+               $(INSTALL) -m 0640 $(srcdir)/src/collectd.conf $(DESTDIR)$(sysconfdir)/collectd.conf; \
+       fi; \
+       $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
+       $(INSTALL) -m 0644 $(srcdir)/src/types.db $(DESTDIR)$(pkgdatadir)/types.db;
+       $(INSTALL) -m 0644 $(srcdir)/src/postgresql_default.conf \
+               $(DESTDIR)$(pkgdatadir)/postgresql_default.conf;
 
-maintainer-clean-local:
-       -rm -f -r libltdl
-       -rm -f INSTALL
-       -rm -f aclocal.m4
+uninstall-hook:
+       rm -f $(DESTDIR)$(pkgdatadir)/types.db;
+       rm -f $(DESTDIR)$(sysconfdir)/collectd.conf
+       rm -f $(DESTDIR)$(pkgdatadir)/postgresql_default.conf;
+
+all-local: @PERL_BINDINGS@
+
+install-exec-local:
+       [ ! -f buildperl/Makefile ] || ( cd buildperl && $(MAKE) install )
+
+# Perl 'make uninstall' does not work as well as wanted.
+# So we do the work here.
+uninstall-local:
+       @PERL@ -I$(DESTDIR)$(prefix) $(srcdir)/bindings/perl/uninstall_mod.pl Collectd
+       find $(DESTDIR)$(prefix) -name "perllocal.pod" -exec rm {} \;
+
+clean-local:
+       rm -rf buildperl
+
+perl: buildperl/Makefile
+       cd buildperl && $(MAKE)
+
+buildperl/Makefile: .perl-directory-stamp buildperl/Makefile.PL \
+       $(top_builddir)/config.status
+       @# beautify the output a bit
+       @echo 'cd buildperl && @PERL@ Makefile.PL @PERL_BINDINGS_OPTIONS@'
+       @cd buildperl && ( if ! @PERL@ Makefile.PL @PERL_BINDINGS_OPTIONS@; then \
+                       echo ""; \
+                       echo 'Check whether you have set $$PERL_MM_OPT in your environment and try using ./configure --with-perl-bindings=""'; \
+                       echo ""; \
+               fi )
+
+buildperl/Makefile.PL: .perl-directory-stamp $(top_builddir)/config.status
+
+.perl-directory-stamp:
+       if test ! -d buildperl; then \
+         mkdir -p buildperl/Collectd/Plugins; \
+         cp $(srcdir)/bindings/perl/lib/Collectd.pm buildperl/; \
+         cp $(srcdir)/bindings/perl/Makefile.PL buildperl/; \
+         cp $(srcdir)/bindings/perl/lib/Collectd/Unixsock.pm buildperl/Collectd/; \
+         cp $(srcdir)/bindings/perl/lib/Collectd/Plugins/OpenVZ.pm buildperl/Collectd/Plugins/; \
+       fi
+       touch $@
+
+.PHONY: perl
+
+
+if BUILD_WITH_JAVA
+dist_noinst_JAVA = \
+       bindings/java/org/collectd/api/Collectd.java \
+       bindings/java/org/collectd/api/CollectdConfigInterface.java \
+       bindings/java/org/collectd/api/CollectdFlushInterface.java \
+       bindings/java/org/collectd/api/CollectdInitInterface.java \
+       bindings/java/org/collectd/api/CollectdLogInterface.java \
+       bindings/java/org/collectd/api/CollectdMatchFactoryInterface.java \
+       bindings/java/org/collectd/api/CollectdMatchInterface.java \
+       bindings/java/org/collectd/api/CollectdNotificationInterface.java \
+       bindings/java/org/collectd/api/CollectdReadInterface.java \
+       bindings/java/org/collectd/api/CollectdShutdownInterface.java \
+       bindings/java/org/collectd/api/CollectdTargetFactoryInterface.java \
+       bindings/java/org/collectd/api/CollectdTargetInterface.java \
+       bindings/java/org/collectd/api/CollectdWriteInterface.java \
+       bindings/java/org/collectd/api/DataSet.java \
+       bindings/java/org/collectd/api/DataSource.java \
+       bindings/java/org/collectd/api/Notification.java \
+       bindings/java/org/collectd/api/OConfigItem.java \
+       bindings/java/org/collectd/api/OConfigValue.java \
+       bindings/java/org/collectd/api/PluginData.java \
+       bindings/java/org/collectd/api/ValueList.java \
+       bindings/java/org/collectd/java/GenericJMX.java \
+       bindings/java/org/collectd/java/GenericJMXConfConnection.java \
+       bindings/java/org/collectd/java/GenericJMXConfMBean.java \
+       bindings/java/org/collectd/java/GenericJMXConfValue.java \
+       bindings/java/org/collectd/java/JMXMemory.java
+
+collectd-api.jar: $(JAVA_TIMESTAMP_FILE)
+       $(JAR) cf $(JARFLAGS) $@ org/collectd/api/*.class
+
+generic-jmx.jar: $(JAVA_TIMESTAMP_FILE)
+       $(JAR) cf $(JARFLAGS) $@ org/collectd/java/*.class
+
+jar_DATA = collectd-api.jar generic-jmx.jar
+endif
diff --git a/README b/README
index 803fbaa..ca86c84 100644 (file)
--- a/README
+++ b/README
@@ -140,6 +140,11 @@ Features
       hugepages can be found here:
       https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt.
 
+    - intel_pmu
+      The intel_pmu plugin reads performance counters provided by the Linux
+      kernel perf interface. The plugin uses jevents library to resolve named
+      events to perf events and access perf interface.
+
     - intel_rdt
       The intel_rdt plugin collects information provided by monitoring features
       of Intel Resource Director Technology (Intel(R) RDT) like Cache Monitoring
@@ -198,14 +203,19 @@ Features
       Queries very detailed usage statistics from wireless LAN adapters and
       interfaces that use the Atheros chipset and the MadWifi driver.
 
-    - md
-      Linux software-RAID device information (number of active, failed, spare
-      and missing disks).
-
     - mbmon
       Motherboard sensors: temperature, fan speed and voltage information,
       using mbmon(1).
 
+    - mcelog
+      Monitor machine check exceptions (hardware errors detected by hardware
+      and reported to software) reported by mcelog and generate appropriate
+      notifications when machine check exceptions are detected.
+
+    - md
+      Linux software-RAID device information (number of active, failed, spare
+      and missing disks).
+
     - memcachec
       Query and parse data from a memcache daemon (memcached).
 
@@ -235,7 +245,7 @@ Features
 
     - netapp
       Plugin to query performance values from a NetApp storage system using the
-      “Manage ONTAP” SDK provided by NetApp.
+      “Manage ONTAP” SDK provided by NetApp.
 
     - netlink
       Very detailed Linux network interface and routing statistics. You can get
@@ -248,8 +258,7 @@ Features
       plugin of choice for that.
 
     - nfs
-      NFS Procedures: Which NFS command were called how often. Only NFSv2 and
-      NFSv3 right now.
+      NFS Procedures: Which NFS command were called how often.
 
     - nginx
       Collects statistics from `nginx' (speak: engine X), a HTTP and mail
@@ -283,6 +292,22 @@ Features
     - oracle
       Query data from an Oracle database.
 
+    - ovs_events
+      The plugin monitors the link status of Open vSwitch (OVS) connected
+      interfaces, dispatches the values to collectd and sends the notification
+      whenever the link state change occurs in the OVS database. It requires
+      YAJL library to be installed.
+      Detailed instructions for installing and setting up Open vSwitch, see
+      OVS documentation.
+      <http://openvswitch.org/support/dist-docs/INSTALL.rst.html>
+
+    - ovs_stats
+      The plugin collects the statistics of OVS connected bridges and
+      interfaces. It requires YAJL library to be installed.
+      Detailed instructions for installing and setting up Open vSwitch, see
+      OVS documentation.
+      <http://openvswitch.org/support/dist-docs/INSTALL.rst.html>
+
     - perl
       The perl plugin implements a Perl-interpreter into collectd. You can
       write your own plugins in Perl and return arbitrary values using this
@@ -476,6 +501,13 @@ Features
       updates to the files and write a bunch of updates at once, which lessens
       system load a lot.
 
+    - snmp_agent
+      Receives and handles queries from SNMP master agent and returns the data
+      collected by read plugins. Handles requests only for OIDs specified in
+      configuration file. To handle SNMP queries the plugin gets data from
+      collectd and translates requested values from collectd's internal format
+      to SNMP format.
+
     - unixsock
       One can query the values from the unixsock plugin whenever they're
       needed. Please read collectd-unixsock(5) for a description on how that's
@@ -750,10 +782,6 @@ Prerequisites
     Used by the `gps' plugin.
     <http://developer.berlios.de/projects/gpsd/>
 
-  * libhal (optional)
-    If present, the `uuid' plugin will check for UUID from HAL.
-    <http://hal.freedesktop.org/>
-
   * libi2c-dev (optional)
     Used for the plugin `barometer', provides just the i2c-dev.h header file
     for user space i2c development.
@@ -762,6 +790,13 @@ Prerequisites
     For querying iptables counters.
     <http://netfilter.org/>
 
+  * libjevents (optional)
+    The jevents library is used by the `intel_pmu' plugin to access the Linux
+    kernel perf interface.
+    Note: the library should be build with -fPIC flag to be linked with
+    intel_pmu shared object correctly.
+    <https://github.com/andikleen/pmu-tools>
+
   * libjvm (optional)
     Library that encapsulates the `Java Virtual Machine' (JVM). This library is
     used by the `java' plugin to execute Java bytecode.
@@ -807,7 +842,11 @@ Prerequisites
     This library is part of the “Manage ONTAP SDK” published by NetApp.
 
   * libnetsnmp (optional)
-    For the `snmp' plugin.
+    For the `snmp' and 'snmp_agent' plugins.
+    <http://www.net-snmp.org/>
+
+  * libnetsnmpagent (optional)
+    Required for the 'snmp_agent' plugin.
     <http://www.net-snmp.org/>
 
   * libnotify (optional)
@@ -925,8 +964,8 @@ Prerequisites
     <http://www.xmms.org/>
 
   * libyajl (optional)
-    Parse JSON data. This is needed for the `ceph', `curl_json' and
-    `log_logstash' plugins.
+    Parse JSON data. This is needed for the `ceph', `curl_json', 'ovs_events',
+    'ovs_stats' and `log_logstash' plugins.
     <http://github.com/lloyd/yajl>
 
   * libvarnish (optional)
@@ -981,7 +1020,6 @@ To generate the `configure` script, you'll need the following dependencies:
 - flex
 - bison
 - libtool
-- libtool-ltdl
 - pkg-config
 
 The `build.sh' script takes no arguments.
diff --git a/bindings/Makefile.am b/bindings/Makefile.am
deleted file mode 100644 (file)
index 07373e8..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-SUBDIRS =
-
-if BUILD_WITH_JAVA
-SUBDIRS += java
-endif
-
-EXTRA_DIST = perl/Makefile.PL \
-            perl/uninstall_mod.pl \
-            perl/lib/Collectd.pm \
-            perl/lib/Collectd/Unixsock.pm \
-            perl/lib/Collectd/Plugins/Monitorus.pm \
-            perl/lib/Collectd/Plugins/OpenVZ.pm
-
-CLEANFILES = \
-       buildperl/Collectd.pm \
-       buildperl/Collectd/Plugins/OpenVZ.pm \
-       buildperl/Collectd/Unixsock.pm \
-       buildperl/Makefile.PL \
-       .perl-directory-stamp
-
-DISTCLEANFILES = \
-       buildperl/Collectd.pm \
-       buildperl/Collectd/Plugins/OpenVZ.pm \
-       buildperl/Collectd/Unixsock.pm \
-       buildperl/Makefile.PL \
-       .perl-directory-stamp
-
-all-local: @PERL_BINDINGS@
-
-
-install-exec-local:
-       [ ! -f buildperl/Makefile ] || ( cd buildperl && $(MAKE) install )
-
-# Perl 'make uninstall' does not work as well as wanted.
-# So we do the work here.
-uninstall-local:
-       @PERL@ -I$(DESTDIR)$(prefix) $(srcdir)/perl/uninstall_mod.pl Collectd
-       find $(DESTDIR)$(prefix) -name "perllocal.pod" -exec rm {} \;
-
-clean-local:
-       rm -rf buildperl
-
-perl: buildperl/Makefile
-       cd buildperl && $(MAKE)
-
-buildperl/Makefile: .perl-directory-stamp buildperl/Makefile.PL \
-       $(top_builddir)/config.status
-       @# beautify the output a bit
-       @echo 'cd buildperl && @PERL@ Makefile.PL @PERL_BINDINGS_OPTIONS@'
-       @cd buildperl && ( if ! @PERL@ Makefile.PL @PERL_BINDINGS_OPTIONS@; then \
-                       echo ""; \
-                       echo 'Check whether you have set $$PERL_MM_OPT in your environment and try using ./configure --with-perl-bindings=""'; \
-                       echo ""; \
-               fi )
-
-buildperl/Makefile.PL: .perl-directory-stamp $(top_builddir)/config.status
-
-.perl-directory-stamp:
-       if test ! -d buildperl; then \
-         mkdir -p buildperl/Collectd/Plugins; \
-         cp $(srcdir)/perl/lib/Collectd.pm buildperl/; \
-         cp $(srcdir)/perl/Makefile.PL buildperl/; \
-         cp $(srcdir)/perl/lib/Collectd/Unixsock.pm buildperl/Collectd/; \
-         cp $(srcdir)/perl/lib/Collectd/Plugins/OpenVZ.pm buildperl/Collectd/Plugins/; \
-       fi
-       touch $@
-
-.PHONY: perl
-
diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am
deleted file mode 100644 (file)
index 8d2e49d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-EXTRA_DIST = org/collectd/api/CollectdConfigInterface.java \
-            org/collectd/api/CollectdFlushInterface.java \
-            org/collectd/api/CollectdInitInterface.java \
-            org/collectd/api/Collectd.java \
-            org/collectd/api/CollectdLogInterface.java \
-            org/collectd/api/CollectdMatchFactoryInterface.java \
-            org/collectd/api/CollectdMatchInterface.java \
-            org/collectd/api/CollectdNotificationInterface.java \
-            org/collectd/api/CollectdReadInterface.java \
-            org/collectd/api/CollectdShutdownInterface.java \
-            org/collectd/api/CollectdTargetFactoryInterface.java \
-            org/collectd/api/CollectdTargetInterface.java \
-            org/collectd/api/CollectdWriteInterface.java \
-            org/collectd/api/DataSet.java \
-            org/collectd/api/DataSource.java \
-            org/collectd/api/Notification.java \
-            org/collectd/api/OConfigItem.java \
-            org/collectd/api/OConfigValue.java \
-            org/collectd/api/PluginData.java \
-            org/collectd/api/ValueList.java \
-            org/collectd/java/GenericJMXConfConnection.java \
-            org/collectd/java/GenericJMXConfMBean.java \
-            org/collectd/java/GenericJMXConfValue.java \
-            org/collectd/java/GenericJMX.java \
-            org/collectd/java/JMXMemory.java
-
-java-build-stamp: $(srcdir)/org/collectd/api/*.java $(srcdir)/org/collectd/java/*.java
-       $(JAVAC) -d "." "$(srcdir)/org/collectd/api"/*.java
-       $(JAVAC) -d "." "$(srcdir)/org/collectd/java"/*.java
-       mkdir -p .libs
-       $(JAR) cf .libs/collectd-api.jar "org/collectd/api"/*.class
-       $(JAR) cf .libs/generic-jmx.jar "org/collectd/java"/*.class
-       touch "$@"
-
-all-local: java-build-stamp
-
-install-exec-local: java-build-stamp
-       mkdir -p "$(DESTDIR)$(pkgdatadir)/java"
-       $(INSTALL) -m 644 .libs/collectd-api.jar \
-               "$(DESTDIR)$(pkgdatadir)/java"
-       $(INSTALL) -m 644 .libs/generic-jmx.jar \
-               "$(DESTDIR)$(pkgdatadir)/java"
-
-uninstall-local:
-       rm -f "$(DESTDIR)$(pkgdatadir)/java/collectd-api.jar"
-       rm -f "$(DESTDIR)$(pkgdatadir)/java/generic-jmx.jar"
-       rmdir "$(DESTDIR)$(pkgdatadir)/java" || true
-
-clean-local:
-       rm -f "org/collectd/api"/*.class
-       rm -f "org/collectd/java"/*.class
-       rm -f .libs
-       rm -f "java-build-stamp"
index 63b7628..6d3d688 100644 (file)
@@ -30,6 +30,8 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Collection;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.Iterator;
 import java.util.ArrayList;
 
@@ -128,6 +130,14 @@ class GenericJMXConfValue
     {
       return (BigInteger.ZERO.add ((BigInteger) obj));
     }
+    else if (obj instanceof AtomicInteger)
+    {
+        return (new Integer(((AtomicInteger) obj).get()));
+    }
+    else if (obj instanceof AtomicLong)
+    {
+        return (new Long(((AtomicLong) obj).get()));
+    }
 
     return (null);
   } /* }}} Number genericObjectToNumber */
index 57f3d44..40f5361 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -18,12 +18,7 @@ EOF
        done
 }
 
-check_for_application lex bison autoheader aclocal automake autoconf
-
-# Actually we don't need the pkg-config executable, but we need the M4 macros.
-# We check for `pkg-config' here and hope that M4 macros will then be
-# available, too.
-check_for_application pkg-config
+check_for_application lex bison autoheader aclocal automake autoconf pkg-config
 
 libtoolize=""
 libtoolize --version >/dev/null 2>/dev/null
@@ -54,6 +49,6 @@ set -x
 
 autoheader \
 && aclocal \
-&& $libtoolize --ltdl --copy --force \
+&& $libtoolize --copy --force \
 && automake --add-missing --copy \
 && autoconf
index 6780cda..ac3c310 100755 (executable)
--- a/clean.sh
+++ b/clean.sh
@@ -15,7 +15,6 @@ true \
 && rm -f configure \
 && rm -f depcomp \
 && rm -f install-sh \
-&& rm -f -r libltdl \
 && rm -f libtool \
 && rm -f ltmain.sh \
 && rm -f Makefile \
index c4cdf4d..e869a6a 100644 (file)
@@ -3,34 +3,15 @@ AC_PREREQ([2.60])
 AC_INIT([collectd],[m4_esyscmd(./version-gen.sh)])
 AC_CONFIG_SRCDIR(src/target_set.c)
 AC_CONFIG_HEADERS(src/config.h)
-AC_CONFIG_AUX_DIR([libltdl/config])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
 
 dnl older automake's default of ARFLAGS=cru is noisy on newer binutils;
 dnl we don't really need the 'u' even in older toolchains.  Then there is
 dnl older libtool, which spelled it AR_FLAGS
 m4_divert_text([DEFAULTS], [: "${ARFLAGS=cr} ${AR_FLAGS=cr}"])
 
-m4_ifdef([LT_PACKAGE_VERSION],
-       # libtool >= 2.2
-       [
-        LT_CONFIG_LTDL_DIR([libltdl])
-        LT_INIT([dlopen])
-        LTDL_INIT([convenience])
-        AC_DEFINE(LIBTOOL_VERSION, 2, [Define to used libtool version.])
-       ]
-,
-       # libtool <= 1.5
-       [
-        AC_LIBLTDL_CONVENIENCE
-        AC_SUBST(LTDLINCL)
-        AC_SUBST(LIBLTDL)
-        AC_LIBTOOL_DLOPEN
-        AC_CONFIG_SUBDIRS(libltdl)
-        AC_DEFINE(LIBTOOL_VERSION, 1, [Define to used libtool version.])
-       ]
-)
-
-AM_CONDITIONAL([BUILD_INCLUDED_LTDL], [test "x$LTDLDEPS" != "x"])
+LT_INIT([dlopen disable-static])
 
 AM_INIT_AUTOMAKE([subdir-objects tar-pax dist-bzip2 no-dist-gzip foreign])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@@ -46,6 +27,9 @@ AC_SYS_LARGEFILE
 AC_PROG_CC_C99([],
   [AC_MSG_ERROR([No compiler found that supports C99])]
 )
+
+AX_COMPILER_VENDOR
+
 AC_PROG_CXX
 AC_PROG_CPP
 AC_PROG_EGREP
@@ -53,10 +37,7 @@ AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AM_PROG_CC_C_O
-AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
 
-AC_DISABLE_STATIC
-AC_PROG_LIBTOOL
 AC_PROG_LEX
 AC_PROG_YACC
 
@@ -67,78 +48,60 @@ m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-conf
 
 PKG_PROG_PKG_CONFIG
 
-AC_CACHE_CHECK([if bison is the parser generator],
-       [collectd_cv_prog_bison],
-       [AS_IF([$YACC --version 2>/dev/null | $EGREP -q '^bison '],
-               [collectd_cv_prog_bison=yes], [collectd_cv_prog_bison=no]
-       )]
+AC_CACHE_CHECK([if Bison is the parser generator],
+  [collectd_cv_prog_bison],
+  [
+    AS_IF([$YACC --version 2>/dev/null | $EGREP -q '^bison '],
+      [collectd_cv_prog_bison=yes],
+      [collectd_cv_prog_bison=no]
+    )
+  ]
 )
 
-if test "x$collectd_cv_prog_bison" = "xno" && test ! -f "${srcdir}/src/liboconfig/parser.c"
-then
-       AC_MSG_ERROR([bison is missing and you do not have ${srcdir}/src/liboconfig/parser.c. Please install bison])
+if test "x$collectd_cv_prog_bison" = "xno" && test ! -f "${srcdir}/src/liboconfig/parser.c"; then
+  AC_MSG_ERROR([bison is missing and you do not have ${srcdir}/src/liboconfig/parser.c. Please install bison])
 fi
 
-AC_ARG_VAR([PROTOC], [path to the protoc binary])
-AC_PATH_PROG([PROTOC], [protoc])
-have_protoc3="no"
-if test "x$PROTOC" != "x"; then
-       AC_MSG_CHECKING([for protoc 3.0.0+])
-       if $PROTOC --version | $EGREP libprotoc.3 >/dev/null; then
-               protoc3="yes (`$PROTOC --version`)"
-               have_protoc3="yes"
-       else
-               protoc3="no (`$PROTOC --version`)"
-       fi
-       AC_MSG_RESULT([$protoc3])
+if test "x$lt_cv_dlopen" = "xno"; then
+  AC_MSG_ERROR([Your system does not support dlopen])
 fi
-AM_CONDITIONAL(HAVE_PROTOC3, test "x$have_protoc3" = "xyes")
 
-AC_ARG_VAR([GRPC_CPP_PLUGIN], [path to the grpc_cpp_plugin binary])
-AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin])
-AM_CONDITIONAL(HAVE_GRPC_CPP, test "x$GRPC_CPP_PLUGIN" != "x")
+AC_SUBST([DLOPEN_LIBS], [$lt_cv_dlopen_libs])
 
-AC_ARG_VAR([PROTOC_C], [path to the protoc-c binary])
-AC_PATH_PROG([PROTOC_C], [protoc-c])
-if test "x$PROTOC_C" = "x"
-then
-  have_protoc_c="no (protoc-c compiler not found)"
-else
-  have_protoc_c="yes"
-fi
 
 AC_MSG_CHECKING([for kernel type ($host_os)])
 case $host_os in
-       *linux*)
-       AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
-       ac_system="Linux"
-       ;;
-       *solaris*)
-       AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
-       ac_system="Solaris"
-       ;;
-       *darwin*)
-       AC_DEFINE([KERNEL_DARWIN], 1, [True if program is to be compiled for a Darwin kernel])
-       ac_system="Darwin"
-       ;;
-       *openbsd*)
-       AC_DEFINE([KERNEL_OPENBSD], 1, [True if program is to be compiled for an OpenBSD kernel])
-       ac_system="OpenBSD"
-       ;;
-       *netbsd*)
-       AC_DEFINE([KERNEL_NETBSD], 1, [True if program is to be compiled for a NetBSD kernel])
-       ac_system="NetBSD"
-       ;;
-       *aix*)
-       AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
-       ac_system="AIX"
-       ;;
-       *freebsd*)
-       AC_DEFINE([KERNEL_FREEBSD], 1, [True if program is to be compiled for a FreeBSD kernel])
-       ac_system="FreeBSD"
-       ;;
-       *)
-       ac_system="unknown"
+  *aix*)
+    AC_DEFINE([KERNEL_AIX], [1], [True if program is to be compiled for a AIX kernel])
+    ac_system="AIX"
+    ;;
+  *darwin*)
+    AC_DEFINE([KERNEL_DARWIN], [1], [True if program is to be compiled for a Darwin kernel])
+    ac_system="Darwin"
+    ;;
+  *freebsd*)
+    AC_DEFINE([KERNEL_FREEBSD], [1], [True if program is to be compiled for a FreeBSD kernel])
+    ac_system="FreeBSD"
+    ;;
+  *linux*)
+    AC_DEFINE([KERNEL_LINUX], [1], [True if program is to be compiled for a Linux kernel])
+    ac_system="Linux"
+    ;;
+  *netbsd*)
+    AC_DEFINE([KERNEL_NETBSD], [1], [True if program is to be compiled for a NetBSD kernel])
+    ac_system="NetBSD"
+    ;;
+  *openbsd*)
+    AC_DEFINE([KERNEL_OPENBSD], [1], [True if program is to be compiled for an OpenBSD kernel])
+    ac_system="OpenBSD"
+    ;;
+  *solaris*)
+    AC_DEFINE([KERNEL_SOLARIS], [1], [True if program is to be compiled for a Solaris kernel])
+    ac_system="Solaris"
+    ;;
+  *)
+    ac_system="unknown"
+    ;;
 esac
 AC_MSG_RESULT([$ac_system])
 
@@ -149,77 +112,46 @@ AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"])
 AM_CONDITIONAL([BUILD_OPENBSD], [test "x$ac_system" = "xOpenBSD"])
 AM_CONDITIONAL([BUILD_SOLARIS], [test "x$ac_system" = "xSolaris"])
 
-if test "x$ac_system" = "xLinux"
-then
-       AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
-       if test -z "$KERNEL_DIR"
-       then
-               KERNEL_DIR="/lib/modules/`uname -r`/source"
-       fi
+if test "x$ac_system" = "xSolaris"; then
+  AC_DEFINE([_POSIX_PTHREAD_SEMANTICS], [1], [Define to enforce POSIX thread semantics under Solaris.])
+  AC_DEFINE([_REENTRANT], [1], [Define to enable reentrancy interfaces.])
 
-       KERNEL_CFLAGS="-I$KERNEL_DIR/include"
-       AC_SUBST(KERNEL_CFLAGS)
+  AC_MSG_CHECKING([whether compiler builds 64bit binaries])
+  AC_COMPILE_IFELSE(
+    [
+      AC_LANG_PROGRAM(
+        [
+          #ifndef _LP64
+          # error "Compiler not in 64bit mode."
+          #endif
+        ]
+      )
+    ],
+    [AC_MSG_RESULT([yes])],
+    [
+      AC_MSG_RESULT([no])
+      AC_MSG_NOTICE([Solaris detected. Please consider building a 64-bit binary.])
+    ]
+  )
 fi
 
-if test "x$ac_system" = "xSolaris"
-then
-       AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
-       AC_DEFINE(_REENTRANT,               1, [Define to enable reentrancy interfaces.])
-
-       AC_MSG_CHECKING([whether compiler builds 64bit binaries])
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
-                          #ifndef _LP64
-                          # error "Compiler not in 64bit mode."
-                          #endif
-                          ])],
-                          [AC_MSG_RESULT([yes])],
-                          [
-                           AC_MSG_RESULT([no])
-                           AC_MSG_NOTICE([Solaris detected. Please consider building a 64-bit binary.])
-                          ])
-fi
-
-if test "x$ac_system" = "xAIX"
-then
-       AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.])
+if test "x$ac_system" = "xAIX"; then
+  AC_DEFINE([_THREAD_SAFE_ERRNO], [1], [Define to use the thread-safe version of errno under AIX.])
 fi
 
 # Where to install .pc files.
 pkgconfigdir="${libdir}/pkgconfig"
-AC_SUBST(pkgconfigdir)
-
-# Check for standards compliance mode
-AC_ARG_ENABLE(standards,
-             AS_HELP_STRING([--enable-standards], [Enable standards compliance mode]),
-             [enable_standards="$enableval"],
-             [enable_standards="no"])
-if test "x$enable_standards" = "xyes"
-then
-       AC_DEFINE(_ISOC99_SOURCE,        1, [Define to enforce ISO C99 compliance.])
-       AC_DEFINE(_POSIX_C_SOURCE, 200809L, [Define to enforce POSIX.1-2008 compliance.])
-       AC_DEFINE(_XOPEN_SOURCE,       700, [Define to enforce X/Open 7 (XSI) compliance.])
-       AC_DEFINE(_REENTRANT,            1, [Define to enable reentrancy interfaces.])
-       if test "x$GCC" = "xyes"
-       then
-               CFLAGS="$CFLAGS -std=c99"
-       fi
-fi
-AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes")
+AC_SUBST([pkgconfigdir])
 
 #
 # Checks for header files.
 #
-AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 AC_HEADER_DIRENT
-AC_HEADER_STDBOOL
 
-AC_CHECK_HEADERS([ \
+AC_CHECK_HEADERS_ONCE([ \
   arpa/inet.h \
-  assert.h \
-  ctype.h \
   endian.h \
-  errno.h \
   fcntl.h \
   fnmatch.h \
   fs_info.h \
@@ -228,9 +160,6 @@ AC_CHECK_HEADERS([ \
   kstat.h \
   kvm.h \
   libgen.h \
-  limits.h \
-  locale.h \
-  math.h \
   mntent.h \
   mnttab.h \
   netdb.h \
@@ -239,9 +168,7 @@ AC_CHECK_HEADERS([ \
   pthread_np.h \
   pwd.h \
   regex.h \
-  signal.h \
-  stdarg.h \
-  stdio.h \
+  sys/endian.h \
   sys/fs_types.h \
   sys/fstyp.h \
   sys/ioctl.h \
@@ -260,450 +187,421 @@ AC_CHECK_HEADERS([ \
   sys/vfstab.h \
   sys/vmmeter.h \
   syslog.h \
-  wordexp.h \
+  wordexp.h
 ])
 
-# For entropy plugin on newer NetBSD
-AC_CHECK_HEADERS(sys/rndio.h, [], [],
-[#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
+if test "x$ac_system" = "xNetBSD"; then
+  # For entropy plugin on newer NetBSD
+  AC_CHECK_HEADERS([sys/rndio.h], [], [],
+    [[
+      #if HAVE_SYS_TYPES_H
+      # include <sys/types.h>
+      #endif
+      #if HAVE_SYS_IOCTL_H
+      # include <sys/ioctl.h>
+      #endif
+      #if HAVE_SYS_PARAM_H
+      # include <sys/param.h>
+      #endif
+    ]]
+  )
+fi
 
 # For ping library
-AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/in.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
-])
-AC_CHECK_HEADERS(netinet/ip.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
-])
-AC_CHECK_HEADERS(netinet/ip_icmp.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/ip_var.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/ip6.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
-])
-AC_CHECK_HEADERS(netinet/icmp6.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_IP6_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>
-#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/in_systm.h], [], [],
+  [[
+    #include <stdint.h>
+    #if HAVE_SYS_TYPES_H
+    # include <sys/types.h>
+    #endif
+  ]]
+)
 
-have_ip6_ext="no"
-AC_CHECK_TYPES([struct ip6_ext], [have_ip6_ext="yes"], [have_ip6_ext="no"],
-[#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_IP6_H
-# include <netinet/ip6.h>
-#endif
-])
+AC_CHECK_HEADERS([netinet/in.h], [], [],
+  [[
+    #include <stdint.h>
+    #if HAVE_SYS_TYPES_H
+    # include <sys/types.h>
+    #endif
+    #if HAVE_NETINET_IN_SYSTM_H
+    # include <netinet/in_systm.h>
+    #endif
+  ]]
+)
 
-if test "x$have_ip6_ext" = "xno"; then
-       SAVE_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS -DSOLARIS2=8"
-
-       AC_CHECK_TYPES([struct ip6_ext],
-                      [have_ip6_ext="yes, with -DSOLARIS2=8"],
-                      [have_ip6_ext="no"],
-[#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_IP6_H
-# include <netinet/ip6.h>
-#endif
-])
+AC_CHECK_HEADERS([netinet/ip.h], [], [],
+  [[
+    #include <stdint.h>
+    #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 test "x$have_ip6_ext" = "xno"; then
-               CFLAGS="$SAVE_CFLAGS"
-       fi
-fi
+AC_CHECK_HEADERS([netinet/ip_icmp.h], [], [],
+  [[
+    #include <stdint.h>
+    #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
+  ]]
+)
 
-# For cpu modules
-AC_CHECK_HEADERS(sys/dkstat.h)
-if test "x$ac_system" = "xDarwin"
-then
-       AC_CHECK_HEADERS(mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
-       AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
-       # For the battery plugin
-       AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
-[
-#if HAVE_IOKIT_IOKITLIB_H
-#  include <IOKit/IOKitLib.h>
-#endif
-#if HAVE_IOKIT_IOTYPES_H
-#  include <IOKit/IOTypes.h>
-#endif
-])
+AC_CHECK_HEADERS([netinet/ip_var.h], [], [],
+  [[
+    #include <stdint.h>
+    #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
+  ]]
+)
 
-fi
+AC_CHECK_HEADERS([netinet/ip6.h], [], [],
+  [[
+    #include <stdint.h>
+    #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
+  ]]
+)
 
-AC_CHECK_HEADERS(sys/sysctl.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
+AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
+  [[
+    #include <stdint.h>
+    #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_IP6_H
+    # include <netinet/ip6.h>
+    #endif
+  ]]
+)
 
-AC_MSG_CHECKING([for sysctl kern.cp_times])
-if test -x /sbin/sysctl
-then
-       /sbin/sysctl kern.cp_times >/dev/null 2>&1
-       if test $? -eq 0
-       then
-               AC_MSG_RESULT([yes])
-               AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIMES, 1,
-               [Define if sysctl supports kern.cp_times])
-       else
-               AC_MSG_RESULT([no])
-       fi
-else
-       AC_MSG_RESULT([no])
-fi
+AC_CHECK_HEADERS([netinet/tcp.h], [], [],
+  [[
+    #include <stdint.h>
+    #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_MSG_CHECKING([for sysctl kern.cp_time])
-if test -x /sbin/sysctl
-then
-       /sbin/sysctl kern.cp_time >/dev/null 2>&1
-       if test $? -eq 0
-       then
-               AC_MSG_RESULT([yes])
-               AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIME, 1,
-                       [Define if sysctl supports kern.cp_time])
-       else
-               AC_MSG_RESULT([no])
-       fi
-else
-       AC_MSG_RESULT([no])
-fi
+AC_CHECK_HEADERS([netinet/udp.h], [], [],
+  [[
+    #include <stdint.h>
+    #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
+  ]]
+)
 
-# For hddtemp module
-AC_CHECK_HEADERS(linux/major.h)
+# For cpu modules
+AC_CHECK_HEADERS([sys/dkstat.h])
+if test "x$ac_system" = "xDarwin"; then
+  AC_CHECK_HEADERS(
+    [ \
+      mach/mach_init.h \
+      mach/host_priv.h \
+      mach/mach_error.h \
+      mach/mach_host.h \
+      mach/mach_port.h \
+      mach/mach_types.h \
+      mach/message.h \
+      mach/processor_set.h \
+      mach/processor.h \
+      mach/processor_info.h \
+      mach/task.h \
+      mach/thread_act.h \
+      mach/vm_region.h \
+      mach/vm_map.h \
+      mach/vm_prot.h \
+      mach/vm_statistics.h \
+      mach/kern_return.h \
+      CoreFoundation/CoreFoundation.h \
+      IOKit/IOKitLib.h \
+      IOKit/IOTypes.h \
+      IOKit/ps/IOPSKeys.h \
+      IOKit/IOBSD.h \
+      IOKit/storage/IOBlockStorageDriver.h
+    ]
+  )
 
-# For md module (Linux only)
-if test "x$ac_system" = "xLinux"
-then
-       AC_CHECK_HEADERS(linux/raid/md_u.h,
-                        [have_linux_raid_md_u_h="yes"],
-                        [have_linux_raid_md_u_h="no"],
-[
-#include <sys/ioctl.h>
-#include <linux/major.h>
-#include <linux/types.h>
-])
-       AC_CHECK_HEADERS([sys/sysmacros.h])
-else
-       have_linux_raid_md_u_h="no"
+  # For the battery plugin
+  AC_CHECK_HEADERS([IOKit/ps/IOPowerSources.h], [], [],
+    [[
+      #if HAVE_IOKIT_IOKITLIB_H
+      #  include <IOKit/IOKitLib.h>
+      #endif
+      #if HAVE_IOKIT_IOTYPES_H
+      #  include <IOKit/IOTypes.h>
+      #endif
+    ]]
+  )
 fi
 
-# For the wireless module
-have_linux_wireless_h="no"
-if test "x$ac_system" = "xLinux"
-then
-  AC_CHECK_HEADERS(linux/wireless.h,
-                  [have_linux_wireless_h="yes"],
-                  [have_linux_wireless_h="no"],
-[
-#include <dirent.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-])
-fi
+AC_CHECK_HEADERS([sys/sysctl.h], [], [],
+  [[
+    #if HAVE_SYS_TYPES_H
+    #  include <sys/types.h>
+    #endif
+    #if HAVE_SYS_PARAM_H
+    # include <sys/param.h>
+    #endif
+  ]]
+)
 
-# For the swap module
-have_sys_swap_h="yes"
-AC_CHECK_HEADERS(sys/swap.h vm/anon.h, [], [have_sys_swap_h="no"],
-[
-#undef _FILE_OFFSET_BITS
-#undef _LARGEFILE64_SOURCE
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
+# For interface plugin
+AC_CHECK_HEADERS([ifaddrs.h])
+AC_CHECK_HEADERS([net/if.h], [], [],
+  [[
+    #if HAVE_SYS_TYPES_H
+    #  include <sys/types.h>
+    #endif
+    #if HAVE_SYS_SOCKET_H
+    #  include <sys/socket.h>
+    #endif
+  ]]
+)
 
-# For load module
-# For the processes plugin
-# For users module
-AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
+if test "x$ac_system" = "xLinux"; then
+  # For hddtemp module
+  AC_CHECK_HEADERS([linux/major.h])
+
+  # For md module (Linux only)
+  AC_CHECK_HEADERS([linux/raid/md_u.h],
+    [have_linux_raid_md_u_h="yes"],
+    [have_linux_raid_md_u_h="no"],
+    [[
+      #include <sys/ioctl.h>
+      #include <linux/major.h>
+      #include <linux/types.h>
+    ]]
+  )
+  AC_CHECK_HEADERS([sys/sysmacros.h])
+
+  AC_CHECK_HEADERS([linux/wireless.h],
+    [have_linux_wireless_h="yes"],
+    [have_linux_wireless_h="no"],
+    [[
+      #include <dirent.h>
+      #include <sys/ioctl.h>
+      #include <sys/socket.h>
+    ]]
+  )
 
-# For interface plugin
-AC_CHECK_HEADERS(ifaddrs.h)
-AC_CHECK_HEADERS(net/if.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
-])
-AC_CHECK_HEADERS(linux/if.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
-])
-AC_CHECK_HEADERS(linux/inet_diag.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
-#if HAVE_LINUX_INET_DIAG_H
-# include <linux/inet_diag.h>
-#endif
-])
-AC_CHECK_HEADERS(linux/netdevice.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-#  include <sys/socket.h>
-#endif
-#if HAVE_LINUX_IF_H
-# include <linux/if.h>
-#endif
-])
+  AC_CHECK_HEADERS([linux/if.h], [], [],
+    [[
+      #if HAVE_SYS_TYPES_H
+      #  include <sys/types.h>
+      #endif
+      #if HAVE_SYS_SOCKET_H
+      #  include <sys/socket.h>
+      #endif
+    ]]
+  )
 
-# For ethstat module
-AC_CHECK_HEADERS(linux/sockios.h,
+  AC_CHECK_HEADERS([linux/inet_diag.h], [], [],
+    [[
+      #if HAVE_SYS_TYPES_H
+      #  include <sys/types.h>
+      #endif
+      #if HAVE_SYS_SOCKET_H
+      #  include <sys/socket.h>
+      #endif
+    ]]
+  )
+
+  AC_CHECK_HEADERS([linux/netdevice.h], [], [],
+    [[
+      #if HAVE_SYS_TYPES_H
+      #  include <sys/types.h>
+      #endif
+      #if HAVE_SYS_SOCKET_H
+      #  include <sys/socket.h>
+      #endif
+      #if HAVE_LINUX_IF_H
+      # include <linux/if.h>
+      #endif
+    ]]
+  )
+
+  # For ethstat module
+  AC_CHECK_HEADERS([linux/sockios.h],
     [have_linux_sockios_h="yes"],
     [have_linux_sockios_h="no"],
-    [
-#if HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-#if HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-    ])
-AC_CHECK_HEADERS(linux/ethtool.h,
+    [[
+      #if HAVE_SYS_IOCTL_H
+      # include <sys/ioctl.h>
+      #endif
+      #if HAVE_NET_IF_H
+      # include <net/if.h>
+      #endif
+    ]]
+  )
+
+  AC_CHECK_HEADERS([linux/ethtool.h],
     [have_linux_ethtool_h="yes"],
     [have_linux_ethtool_h="no"],
-    [
-#if HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-#if HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-#if HAVE_LINUX_SOCKIOS_H
-# include <linux/sockios.h>
-#endif
-    ])
-
-# 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
-       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 HAVE_SYS_IOCTL_H
+      # include <sys/ioctl.h>
+      #endif
+      #if HAVE_NET_IF_H
+      # include <net/if.h>
+      #endif
+      #if HAVE_LINUX_SOCKIOS_H
+      # include <linux/sockios.h>
+      #endif
+    ]]
+  )
+
+  # For ipvs module
+  AC_CHECK_HEADERS_ONCE([linux/ip_vs.h])
 
-       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"
+  # For the email plugin
+  AC_CHECK_HEADERS([linux/un.h], [], [],
+    [[
+      #if HAVE_SYS_SOCKET_H
+      #  include <sys/socket.h>
+      #endif
+    ]]
+  )
+  # For the turbostat plugin
+  AC_CHECK_HEADERS([cpuid.h],
+    [have_cpuid_h="yes"],
+    [have_cpuid_h="no (cpuid.h not found)"]
+  )
+
+  AC_CHECK_HEADERS([sys/capability.h],
+    [have_capability="yes"],
+    [have_capability="no (<sys/capability.h> not found)"]
+  )
 
-               AC_MSG_NOTICE([Did not find ip_vs.h. Trying again using headers from $KERNEL_DIR.])
+  if test "x$have_capability" = "xyes"; then
+    AC_CHECK_LIB([cap], [cap_get_proc],
+      [have_capability="yes"],
+      [have_capability="no (cap_get_proc() not found)"]
+    )
+  fi
 
-               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_capability" = "xyes"; then
+    AC_CHECK_DECL([CAP_IS_SUPPORTED],
+      [have_capability="yes"],
+      [have_capability="no (CAP_IS_SUPPORTED not found)"],
+      [[#include <sys/capability.h>]]
+    )
+  fi
 
-               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
+  if test "x$have_capability" = "xyes"; then
+    AC_DEFINE([HAVE_CAPABILITY], [1], [Define to 1 if you have cap_get_proc() (-lcap).])
+  fi
 
-               CFLAGS="$SAVE_CFLAGS"
-       fi
+else
+  have_linux_raid_md_u_h="no"
+  have_linux_wireless_h="no"
 fi
-AM_CONDITIONAL(IP_VS_H_NEEDS_KERNEL_CFLAGS, test "x$ip_vs_h_needs_kernel_cflags" = "xyes")
+
+AM_CONDITIONAL([BUILD_WITH_CAPABILITY], [test "x$have_capability" = "xyes"])
+
+# For the swap module
+have_sys_swap_h="yes"
+AC_CHECK_HEADERS([sys/swap.h vm/anon.h],
+  [],
+  [have_sys_swap_h="no"],
+  [[
+    #undef _FILE_OFFSET_BITS
+    #undef _LARGEFILE64_SOURCE
+    #if HAVE_SYS_TYPES_H
+    #  include <sys/types.h>
+    #endif
+    #if HAVE_SYS_PARAM_H
+    # include <sys/param.h>
+    #endif
+  ]]
+)
+
+# For load module
+# For the processes plugin
+# For users module
+AC_CHECK_HEADERS([sys/loadavg.h linux/config.h utmp.h utmpx.h])
 
 # For quota module
-AC_CHECK_HEADERS(sys/ucred.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
+AC_CHECK_HEADERS([sys/ucred.h], [], [],
+  [[
+    #if HAVE_SYS_TYPES_H
+    #  include <sys/types.h>
+    #endif
+    #if HAVE_SYS_PARAM_H
+    # include <sys/param.h>
+    #endif
+  ]]
+)
 
 # For mount interface
-AC_CHECK_HEADERS(sys/mount.h, [], [],
-[
-#if HAVE_SYS_TYPES_H
-#  include <sys/types.h>
-#endif
-#if HAVE_SYS_PARAM_H
-# include <sys/param.h>
-#endif
-])
-
-# For the email plugin
-AC_CHECK_HEADERS(linux/un.h, [], [],
-[
-#if HAVE_SYS_SOCKET_H
-#      include <sys/socket.h>
-#endif
-])
+AC_CHECK_HEADERS([sys/mount.h], [], [],
+  [[
+    #if HAVE_SYS_TYPES_H
+    #  include <sys/types.h>
+    #endif
+    #if HAVE_SYS_PARAM_H
+    # include <sys/param.h>
+    #endif
+  ]]
+)
 
 # --enable-xfs {{{
 AC_ARG_ENABLE([xfs],
@@ -727,108 +625,95 @@ fi
 # }}}
 
 # For the dns plugin
-AC_CHECK_HEADERS(arpa/nameser.h)
-AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
-[
-#if HAVE_ARPA_NAMESER_H
-# include <arpa/nameser.h>
-#endif
-])
+AC_CHECK_HEADERS([arpa/nameser.h])
+AC_CHECK_HEADERS([arpa/nameser_compat.h], [], [],
+  [[
+    #if HAVE_ARPA_NAMESER_H
+    # include <arpa/nameser.h>
+    #endif
+  ]]
+)
 
-AC_CHECK_HEADERS(net/if_arp.h, [], [],
-[#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-])
-AC_CHECK_HEADERS(net/ppp_defs.h)
-AC_CHECK_HEADERS(net/if_ppp.h, [], [],
-[#if HAVE_NET_PPP_DEFS_H
-# include <net/ppp_defs.h>
-#endif
-])
-AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
-[#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-])
+AC_CHECK_HEADERS([net/if_arp.h], [], [],
+  [[
+    #if HAVE_SYS_SOCKET_H
+    # include <sys/socket.h>
+    #endif
+  ]]
+)
 
-have_net_pfvar_h="no"
-AC_CHECK_HEADERS(net/pfvar.h,
-               [have_net_pfvar_h="yes"],
-               [have_net_pfvar_h="no"],
-[
-#if HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
-#endif
-#if HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#if HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-#if HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-])
+AC_CHECK_HEADERS([net/ppp_defs.h])
+AC_CHECK_HEADERS([net/if_ppp.h], [], [],
+  [[
+    #if HAVE_NET_PPP_DEFS_H
+    # include <net/ppp_defs.h>
+    #endif
+  ]]
+)
+
+AC_CHECK_HEADERS([netinet/if_ether.h], [], [],
+  [[
+    #include <stdint.h>
+    #if HAVE_SYS_TYPES_H
+    # include <sys/types.h>
+    #endif
+    #if HAVE_SYS_SOCKET_H
+    # include <sys/socket.h>
+    #endif
+    #if HAVE_NET_IF_H
+    # include <net/if.h>
+    #endif
+    #if HAVE_NETINET_IN_H
+    # include <netinet/in.h>
+    #endif
+  ]]
+)
+
+AC_CHECK_HEADERS([net/pfvar.h],
+  [have_net_pfvar_h="yes"],
+  [have_net_pfvar_h="no"],
+  [[
+    #if HAVE_SYS_IOCTL_H
+    # include <sys/ioctl.h>
+    #endif
+    #if HAVE_SYS_SOCKET_H
+    # include <sys/socket.h>
+    #endif
+    #if HAVE_NET_IF_H
+    # include <net/if.h>
+    #endif
+    #if HAVE_NETINET_IN_H
+    # include <netinet/in.h>
+    #endif
+  ]]
+)
 
 # For the multimeter plugin
-have_termios_h="no"
-AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
+AC_CHECK_HEADERS([termios.h],
+  [have_termios_h="yes"],
+  [have_termios_h="no"]
+)
 
 # For cpusleep plugin
 AC_CACHE_CHECK([whether clock_boottime and clock_monotonic are supported],
-                      [c_cv_have_clock_boottime_monotonic],
-                      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[
-#include <time.h>
-]],
-[[
- struct timespec b, m;
- clock_gettime(CLOCK_BOOTTIME, &b );
- clock_gettime(CLOCK_MONOTONIC, &m );
-]]
-                      )],
-                      [c_cv_have_clock_boottime_monotonic="yes"],
-                      [c_cv_have_clock_boottime_monotonic="no"]))
-
-
-# For the turbostat plugin
-AC_CHECK_HEADERS([cpuid.h],
-  [have_cpuid_h="yes"],
-  [have_cpuid_h="no (cpuid.h not found)"]
-)
-
-have_capability="yes"
-AC_CHECK_HEADERS(sys/capability.h,
-                 [have_capability="yes"],
-                 [have_capability="no (<sys/capability.h> not found)"])
-if test "x$have_capability" = "xyes"; then
-AC_CHECK_LIB(cap, cap_get_proc,
-                 [have_capability="yes"],
-                 [have_capability="no (cap_get_proc() not found)"])
-fi
-if test "x$have_capability" = "xyes"; then
-AC_CHECK_DECL([CAP_IS_SUPPORTED],
-                 [have_capability="yes"],
-                 [have_capability="no (CAP_IS_SUPPORTED not found)"],
-                 [[#include <sys/capability.h>]])
-fi
-if test "x$have_capability" = "xyes"; then
-  AC_DEFINE(HAVE_CAPABILITY, 1, [Define to 1 if you have cap_get_proc() (-lcap).])
-fi
-AM_CONDITIONAL(BUILD_WITH_CAPABILITY, test "x$have_capability" = "xyes")
+  [c_cv_have_clock_boottime_monotonic],
+  [
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#include <time.h>]],
+        [[
+          struct timespec b, m;
+          clock_gettime(CLOCK_BOOTTIME, &b );
+          clock_gettime(CLOCK_MONOTONIC, &m );
+        ]]
+      )
+      ],
+      [c_cv_have_clock_boottime_monotonic="yes"],
+      [c_cv_have_clock_boottime_monotonic="no"]
+    )
+  ]
+)
+
 
 #
 # Checks for typedefs, structures, and compiler characteristics.
@@ -839,212 +724,264 @@ AC_TYPE_SIZE_T
 AC_TYPE_UID_T
 AC_HEADER_TIME
 
+test_cxx_flags() {
+  AC_LANG_PUSH([C++])
+  AC_LANG_CONFTEST(
+    [AC_LANG_SOURCE([[int main(void){}]]) ]
+  )
+  $CXX -c conftest.cpp $CXXFLAGS $@ > /dev/null 2> /dev/null
+  ret=$?
+  rm -f conftest.o
+  AC_LANG_POP([C++])
+  return $ret
+}
+
 #
 # Checks for library functions.
 #
-AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname setlocale asprintf)
+AC_CHECK_FUNCS_ONCE([ \
+    asprintf \
+    closelog \
+    getaddrinfo \
+    getgrnam_r \
+    getnameinfo \
+    getpwnam_r \
+    gettimeofday \
+    if_indextoname \
+    openlog \
+    regcomp \
+    regerror \
+    regexec \
+    regfree \
+    select \
+    setenv \
+    setgroups \
+    strcasecmp \
+    strdup \
+    strncasecmp \
+    sysconf
+  ]
+)
 
 AC_FUNC_STRERROR_R
 
-test_cxx_flags() {
-       AC_LANG_PUSH([C++])
-       AC_LANG_CONFTEST([
-               AC_LANG_SOURCE([[int main(void){}]])
-       ])
-       $CXX -c conftest.cpp $CXXFLAGS $@ > /dev/null 2> /dev/null
-       ret=$?
-       rm -f conftest.o
-       AC_LANG_POP([C++])
-       return $ret
-}
-
 SAVE_CFLAGS="$CFLAGS"
 # Emulate behavior of src/Makefile.am
-if test "x$GCC" = "xyes"
-then
-       CFLAGS="$CFLAGS -Wall -Werror"
+if test "x$GCC" = "xyes"; then
+  CFLAGS="$CFLAGS -Wall -Werror"
 fi
 
 AC_CACHE_CHECK([for strtok_r],
   [c_cv_have_strtok_r_default],
-  AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-]]],
-[[[
-      char buffer[] = "foo,bar,baz";
-      char *token;
-      char *dummy;
-      char *saveptr;
-
-      dummy = buffer;
-      saveptr = NULL;
-      while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
-      {
-        dummy = NULL;
-        printf ("token = %s;\n", token);
-      }
-]]]
-    )],
-    [c_cv_have_strtok_r_default="yes"],
-    [c_cv_have_strtok_r_default="no"]
-  )
+  [
+    AC_LINK_IFELSE(
+      [
+        AC_LANG_PROGRAM(
+          [[
+            #include <stdlib.h>
+            #include <stdio.h>
+            #include <string.h>
+          ]],
+          [[
+            char buffer[] = "foo,bar,baz";
+            char *token;
+            char *dummy;
+            char *saveptr;
+
+            dummy = buffer;
+            saveptr = NULL;
+            while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
+            {
+              dummy = NULL;
+              printf ("token = %s;\n", token);
+            }
+          ]]
+        )
+      ],
+      [c_cv_have_strtok_r_default="yes"],
+      [c_cv_have_strtok_r_default="no"]
+    )
+  ]
 )
 
-if test "x$c_cv_have_strtok_r_default" = "xno"
-then
+if test "x$c_cv_have_strtok_r_default" = "xno"; then
   CFLAGS="$CFLAGS -D_REENTRANT=1"
 
   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
     [c_cv_have_strtok_r_reentrant],
-    AC_LINK_IFELSE(
-      [AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-]]],
-[[[
-        char buffer[] = "foo,bar,baz";
-        char *token;
-        char *dummy;
-        char *saveptr;
-
-        dummy = buffer;
-        saveptr = NULL;
-        while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
-        {
-          dummy = NULL;
-          printf ("token = %s;\n", token);
-        }
-]]]
-      )],
-      [c_cv_have_strtok_r_reentrant="yes"],
-      [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
-    )
+    [
+      AC_LINK_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #include <stdlib.h>
+              #include <stdio.h>
+              #include <string.h>
+            ]],
+            [[
+              char buffer[] = "foo,bar,baz";
+              char *token;
+              char *dummy;
+              char *saveptr;
+
+              dummy = buffer;
+              saveptr = NULL;
+              while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
+              {
+                dummy = NULL;
+                printf ("token = %s;\n", token);
+              }
+            ]]
+          )
+        ],
+        [c_cv_have_strtok_r_reentrant="yes"],
+        [AC_MSG_FAILURE([strtok_r is not available. Please file a bugreport!])]
+      )
+    ]
   )
 fi
 
 CFLAGS="$SAVE_CFLAGS"
-if test "x$c_cv_have_strtok_r_reentrant" = "xyes"
-then
-       CFLAGS="$CFLAGS -D_REENTRANT=1"
+if test "x$c_cv_have_strtok_r_reentrant" = "xyes"; then
+  CFLAGS="$CFLAGS -D_REENTRANT=1"
 fi
 
-AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
-
-socket_needs_socket="no"
-AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
-AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
+AC_CHECK_FUNCS([socket],
+  [],
+  [
+    AC_CHECK_LIB([socket], [socket],
+      [socket_needs_socket="yes"],
+      [AC_MSG_ERROR([cannot find socket() in libsocket])]
+    )
+  ]
+)
+AM_CONDITIONAL([BUILD_WITH_LIBSOCKET], [test "x$socket_needs_socket" = "xyes"])
 
-clock_gettime_needs_rt="no"
 clock_gettime_needs_posix4="no"
-have_clock_gettime="no"
-AC_CHECK_FUNCS(clock_gettime, [have_clock_gettime="yes"])
-if test "x$have_clock_gettime" = "xno"
-then
-       AC_CHECK_LIB(rt, clock_gettime, [clock_gettime_needs_rt="yes"
-                                        have_clock_gettime="yes"])
+AC_CHECK_FUNCS([clock_gettime],
+  [have_clock_gettime="yes"],
+  [have_clock_gettime="no"]
+)
+
+if test "x$have_clock_gettime" = "xno"; then
+  AC_CHECK_LIB([rt], [clock_gettime],
+    [
+      clock_gettime_needs_rt="yes"
+      have_clock_gettime="yes"
+    ]
+  )
 fi
-if test "x$have_clock_gettime" = "xno"
-then
-       AC_CHECK_LIB(posix4, clock_gettime, [clock_gettime_needs_posix4="yes"
-                                            have_clock_gettime="yes"])
+
+if test "x$have_clock_gettime" = "xno"; then
+  AC_CHECK_LIB([posix4], [clock_gettime],
+    [
+      clock_gettime_needs_posix4="yes"
+      have_clock_gettime="yes"
+    ]
+  )
 fi
-if test "x$have_clock_gettime" = "xyes"
-then
-       AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
+
+if test "x$have_clock_gettime" = "xyes"; then
+  AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if the clock_gettime(2) function is available.])
 fi
 
-nanosleep_needs_rt="no"
-nanosleep_needs_posix4="no"
-AC_CHECK_FUNCS(nanosleep,
-    [],
-    AC_CHECK_LIB(rt, nanosleep,
-        [nanosleep_needs_rt="yes"],
-        AC_CHECK_LIB(posix4, nanosleep,
-            [nanosleep_needs_posix4="yes"],
-            AC_MSG_ERROR(cannot find nanosleep))))
-
-AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes")
-AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes")
-
-AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
-AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
-AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
-AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
-AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
-AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
-AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
-AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
-AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
-AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
-AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
-AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
+AC_CHECK_FUNCS([nanosleep], [],
+  AC_CHECK_LIB([rt], [nanosleep],
+    [nanosleep_needs_rt="yes"],
+    [
+      AC_CHECK_LIB([posix4], [nanosleep],
+        [nanosleep_needs_posix4="yes"],
+        [AC_MSG_ERROR([cannot find nanosleep])]
+      )
+    ]
+  )
+)
+
+AM_CONDITIONAL([BUILD_WITH_LIBRT], [test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes"])
+AM_CONDITIONAL([BUILD_WITH_LIBPOSIX4], [test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes"])
+
+AC_CHECK_FUNCS([getifaddrs], [have_getifaddrs="yes"], [have_getifaddrs="no"])
+AC_CHECK_FUNCS([getloadavg], [have_getloadavg="yes"], [have_getloadavg="no"])
+AC_CHECK_FUNCS([getutent], [have_getutent="yes"], [have_getutent="no"])
+AC_CHECK_FUNCS([getutxent], [have_getutxent="yes"], [have_getutxent="no"])
+AC_CHECK_FUNCS([host_statistics], [have_host_statistics="yes"], [have_host_statistics="no"])
+AC_CHECK_FUNCS([processor_info], [have_processor_info="yes"], [have_processor_info="no"])
+AC_CHECK_FUNCS([statfs], [have_statfs="yes"], [have_statfs="no"])
+AC_CHECK_FUNCS([statvfs], [have_statvfs="yes"], [have_statvfs="no"])
+AC_CHECK_FUNCS([sysctl], [have_sysctl="yes"], [have_sysctl="no"])
+AC_CHECK_FUNCS([sysctlbyname], [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
+AC_CHECK_FUNCS([syslog], [have_syslog="yes"], [have_syslog="no"])
+AC_CHECK_FUNCS([thread_info], [have_thread_info="yes"], [have_thread_info="no"])
 
 # Check for strptime {{{
-if test "x$GCC" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS -Wall -Wextra -Werror"
+if test "x$GCC" = "xyes"; then
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -Wall -Wextra -Werror"
 fi
 
-AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"])
-if test "x$have_strptime" = "xyes"
-then
-       AC_CACHE_CHECK([whether strptime is exported by default],
-                      [c_cv_have_strptime_default],
-                      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <time.h>
-]]],
-[[[
- struct tm stm;
- (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
-]]]
-                      )],
-                      [c_cv_have_strptime_default="yes"],
-                      [c_cv_have_strptime_default="no"]))
+AC_CHECK_FUNCS([strptime], [have_strptime="yes"], [have_strptime="no"])
+if test "x$have_strptime" = "xyes"; then
+  AC_CACHE_CHECK([whether strptime is exported by default],
+    [c_cv_have_strptime_default],
+    [
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[#include <time.h>]],
+            [[
+              struct tm stm;
+              (void)strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
+            ]]
+          )
+        ],
+        [c_cv_have_strptime_default="yes"],
+        [c_cv_have_strptime_default="no"])
+    ]
+  )
 fi
-if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"
-then
-       AC_CACHE_CHECK([whether strptime needs standards mode],
-                      [c_cv_have_strptime_standards],
-                      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#ifndef _ISOC99_SOURCE
-# define _ISOC99_SOURCE 1
-#endif
-#ifndef _POSIX_C_SOURCE
-# define _POSIX_C_SOURCE 200112L
-#endif
-#ifndef _XOPEN_SOURCE
-# define _XOPEN_SOURCE 500
-#endif
-#include <time.h>
-]]],
-[[[
- struct tm stm;
- (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
-]]]
-                      )],
-                      [c_cv_have_strptime_standards="yes"],
-                      [c_cv_have_strptime_standards="no"]))
 
-       if test "x$c_cv_have_strptime_standards" = "xyes"
-       then
-               AC_DEFINE([STRPTIME_NEEDS_STANDARDS], 1, [Set to true if strptime is only exported in X/Open mode (GNU libc).])
-       else
-               have_strptime="no"
-       fi
+if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"; then
+  AC_CACHE_CHECK([whether strptime needs standards mode],
+    [c_cv_have_strptime_standards],
+    [
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #ifndef _ISOC99_SOURCE
+              # define _ISOC99_SOURCE 1
+              #endif
+              #ifndef _POSIX_C_SOURCE
+              # define _POSIX_C_SOURCE 200112L
+              #endif
+              #ifndef _XOPEN_SOURCE
+              # define _XOPEN_SOURCE 500
+              #endif
+              #include <time.h>
+            ]],
+            [[
+              struct tm stm;
+              (void)strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
+            ]]
+          )
+        ],
+        [c_cv_have_strptime_standards="yes"],
+        [c_cv_have_strptime_standards="no"]
+      )
+    ]
+  )
+
+  if test "x$c_cv_have_strptime_standards" = "xyes"; then
+    AC_DEFINE([STRPTIME_NEEDS_STANDARDS], [1],
+      [Set to true if strptime is only exported in X/Open mode (GNU libc).]
+    )
+  else
+    have_strptime="no"
+  fi
 fi
 
-if test "x$GCC" = "xyes"
-then
-       CFLAGS="$SAVE_CFLAGS"
+if test "x$GCC" = "xyes"; then
+  CFLAGS="$SAVE_CFLAGS"
 fi
 # }}} Check for strptime
 
 CFLAGS="$SAVE_CFLAGS"
 # }}} Check for timegm
 
-AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
+AC_MSG_CHECKING([for sysctl kern.cp_times])
+if test -x /sbin/sysctl; then
+  /sbin/sysctl kern.cp_times >/dev/null 2>&1
+  if test $? -eq 0; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE([HAVE_SYSCTL_KERN_CP_TIMES], [1], [Define if sysctl supports kern.cp_times])
+  else
+    AC_MSG_RESULT([no])
+  fi
+else
+  AC_MSG_RESULT([no])
+fi
+
+AC_MSG_CHECKING([for sysctl kern.cp_time])
+if test -x /sbin/sysctl; then
+  /sbin/sysctl kern.cp_time >/dev/null 2>&1
+  if test $? -eq 0
+  then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE([HAVE_SYSCTL_KERN_CP_TIME], [1], [Define if sysctl supports kern.cp_time])
+  else
+    AC_MSG_RESULT([no])
+  fi
+else
+  AC_MSG_RESULT([no])
+fi
+
+AC_CHECK_FUNCS([swapctl], [have_swapctl="yes"], [have_swapctl="no"])
 if test "x$have_swapctl" = "xyes"; then
-        AC_CACHE_CHECK([whether swapctl takes two arguments],
-                [c_cv_have_swapctl_two_args],
-                AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
-#  undef _FILE_OFFSET_BITS
-#  undef _LARGEFILE64_SOURCE
-#endif
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/swap.h>
-#include <unistd.h>
-]]],
-[[[
-int num = swapctl(0, NULL);
-]]]
-                        )],
-                        [c_cv_have_swapctl_two_args="yes"],
-                        [c_cv_have_swapctl_two_args="no"]
-                )
-        )
-        AC_CACHE_CHECK([whether swapctl takes three arguments],
-                [c_cv_have_swapctl_three_args],
-                AC_COMPILE_IFELSE(
-                        [AC_LANG_PROGRAM(
-[[[
-#if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
-#  undef _FILE_OFFSET_BITS
-#  undef _LARGEFILE64_SOURCE
-#endif
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/swap.h>
-#include <unistd.h>
-]]],
-[[[
-int num = swapctl(0, NULL, 0);
-]]]
-                        )],
-                        [c_cv_have_swapctl_three_args="yes"],
-                        [c_cv_have_swapctl_three_args="no"]
-                )
-        )
+  AC_CACHE_CHECK([whether swapctl takes two arguments],
+    [c_cv_have_swapctl_two_args],
+    [
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
+              #  undef _FILE_OFFSET_BITS
+              #  undef _LARGEFILE64_SOURCE
+              #endif
+              #include <sys/stat.h>
+              #include <sys/param.h>
+              #include <sys/swap.h>
+              #include <unistd.h>
+            ]],
+            [[int num = swapctl(0, NULL);]]
+          )
+        ],
+        [c_cv_have_swapctl_two_args="yes"],
+        [c_cv_have_swapctl_two_args="no"]
+      )
+    ]
+  )
+
+  AC_CACHE_CHECK([whether swapctl takes three arguments],
+    [c_cv_have_swapctl_three_args],
+    [
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
+              #  undef _FILE_OFFSET_BITS
+              #  undef _LARGEFILE64_SOURCE
+              #endif
+              #include <sys/stat.h>
+              #include <sys/param.h>
+              #include <sys/swap.h>
+              #include <unistd.h>
+            ]],
+            [[int num = swapctl(0, NULL, 0);]]
+          )
+        ],
+        [c_cv_have_swapctl_three_args="yes"],
+        [c_cv_have_swapctl_three_args="no"]
+      )
+    ]
+  )
 fi
+
 # Check for different versions of `swapctl' here..
 if test "x$have_swapctl" = "xyes"; then
-        if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
-                AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1,
-                          [Define if the function swapctl exists and takes two arguments.])
-        fi
-        if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
-                AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1,
-                          [Define if the function swapctl exists and takes three arguments.])
-        fi
+  if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
+    AC_DEFINE([HAVE_SWAPCTL_TWO_ARGS], [1], [Define if the function swapctl exists and takes two arguments.])
+  fi
+
+  if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
+    AC_DEFINE([HAVE_SWAPCTL_THREE_ARGS], [1], [Define if the function swapctl exists and takes three arguments.])
+  fi
 fi
 
 # Check for NAN
-AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
-[
- if test "x$withval" = "xno"; then
-        nan_type="none"
- else if test "x$withval" = "xyes"; then
-        nan_type="zero"
- else
-        nan_type="$withval"
- fi; fi
-],
-[nan_type="none"])
+AC_ARG_WITH([nan-emulation],
+  [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
+  [
+    if test "x$withval" = "xno"; then
+      nan_type="none"
+    else if test "x$withval" = "xyes"; then
+      nan_type="zero"
+    else
+      nan_type="$withval"
+    fi; fi
+  ],
+  [nan_type="none"]
+)
+
 if test "x$nan_type" = "xnone"; then
   AC_CACHE_CHECK([whether NAN is defined by default],
     [c_cv_have_nan_default],
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <math.h>
-static double foo = NAN;
-]]],
-[[[
-       if (isnan (foo))
-        return 0;
-       else
-       return 1;
-]]]
-      )],
-      [c_cv_have_nan_default="yes"],
-      [c_cv_have_nan_default="no"]
-    )
+    [
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #include <stdlib.h>
+              #include <math.h>
+              static double foo = NAN;
+            ]],
+            [[
+              if (isnan (foo))
+                return 0;
+              return 1;
+            ]]
+          )
+        ],
+        [c_cv_have_nan_default="yes"],
+        [c_cv_have_nan_default="no"]
+      )
+    ]
   )
-  if test "x$c_cv_have_nan_default" = "xyes"
-  then
-    nan_type="default"
-  fi
 fi
+
+if test "x$c_cv_have_nan_default" = "xyes"; then
+  nan_type="default"
+fi
+
 if test "x$nan_type" = "xnone"; then
   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
     [c_cv_have_nan_isoc],
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#define __USE_ISOC99 1
-#include <math.h>
-static double foo = NAN;
-]]],
-[[[
-       if (isnan (foo))
-        return 0;
-       else
-       return 1;
-]]]
-      )],
-      [c_cv_have_nan_isoc="yes"],
-      [c_cv_have_nan_isoc="no"]
-    )
+    [
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #include <stdlib.h>
+              #define __USE_ISOC99 1
+              #include <math.h>
+              static double foo = NAN;
+            ]],
+            [[
+              if (isnan (foo))
+                return 0;
+              return 1;
+            ]]
+          )
+        ],
+        [c_cv_have_nan_isoc="yes"],
+        [c_cv_have_nan_isoc="no"]
+      )
+    ]
   )
-  if test "x$c_cv_have_nan_isoc" = "xyes"
-  then
-    nan_type="isoc99"
-  fi
 fi
+
+if test "x$c_cv_have_nan_isoc" = "xyes"; then
+  nan_type="isoc99"
+fi
+
 if test "x$nan_type" = "xnone"; then
-  SAVE_LDFLAGS=$LDFLAGS
+  SAVE_LDFLAGS="$LDFLAGS"
   LDFLAGS="$LDFLAGS -lm"
   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
     [c_cv_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 double foo = NAN;
-]]],
-[[[
-       if (isnan (foo))
-        return 0;
-       else
-       return 1;
-]]]
-      )],
-      [c_cv_have_nan_zero="yes"],
-      [c_cv_have_nan_zero="no"]
-    )
+    [
+      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 double foo = NAN;
+            ]],
+            [[
+              if (isnan (foo))
+                return 0;
+              return 1;
+            ]]
+          )
+        ],
+        [c_cv_have_nan_zero="yes"],
+        [c_cv_have_nan_zero="no"]
+      )
+    ]
   )
   LDFLAGS=$SAVE_LDFLAGS
-  if test "x$c_cv_have_nan_zero" = "xyes"
-  then
-    nan_type="zero"
-  fi
+fi
+
+if test "x$c_cv_have_nan_zero" = "xyes"; then
+  nan_type="zero"
 fi
 
 if test "x$nan_type" = "xdefault"; then
-  AC_DEFINE(NAN_STATIC_DEFAULT, 1,
-    [Define if NAN is defined by default and can initialize static variables.])
+  AC_DEFINE([NAN_STATIC_DEFAULT], [1],
+    [Define if NAN is defined by default and can initialize static variables.]
+  )
 else if test "x$nan_type" = "xisoc99"; then
-  AC_DEFINE(NAN_STATIC_ISOC, 1,
-    [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
+  AC_DEFINE([NAN_STATIC_ISOC], [1],
+    [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.]
+  )
 else if test "x$nan_type" = "xzero"; then
-  AC_DEFINE(NAN_ZERO_ZERO, 1,
-    [Define if NAN can be defined as (0.0 / 0.0)])
+  AC_DEFINE([NAN_ZERO_ZERO], [1],
+    [Define if NAN can be defined as (0.0 / 0.0)]
+  )
 else
   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
 fi; fi; fi
 
-AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
-[
- if test "x$withval" = "xnothing"; then
-       fp_layout_type="nothing"
- else if test "x$withval" = "xendianflip"; then
-       fp_layout_type="endianflip"
- else if test "x$withval" = "xintswap"; then
-       fp_layout_type="intswap"
- else
-       AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
-fi; fi; fi
-],
-[fp_layout_type="unknown"])
+AC_ARG_WITH([fp-layout],
+  [
+    AS_HELP_STRING([--with-fp-layout],
+      [set the memory layout of doubles. For crosscompiling only.]
+    )
+  ],
+  [
+    if test "x$withval" = "xnothing"; then
+      fp_layout_type="nothing"
+    else if test "x$withval" = "xendianflip"; then
+      fp_layout_type="endianflip"
+    else if test "x$withval" = "xintswap"; then
+      fp_layout_type="intswap"
+    else
+      AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
+    fi; fi; fi
+  ],
+  [fp_layout_type="unknown"]
+)
 
 if test "x$fp_layout_type" = "xunknown"; then
   AC_CACHE_CHECK([if doubles are stored in x86 representation],
     [c_cv_fp_layout_need_nothing],
-    AC_RUN_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDBOOL_H
-# include <stdbool.h>
-#endif
-]]],
-[[[
-       uint64_t i0;
-       uint64_t i1;
-       uint8_t c[8];
-       double d;
-
-       d = 8.642135e130;
-       memcpy ((void *) &i0, (void *) &d, 8);
-
-       i1 = i0;
-       memcpy ((void *) c, (void *) &i1, 8);
-
-       if ((c[0] == 0x2f) && (c[1] == 0x25)
-                       && (c[2] == 0xc0) && (c[3] == 0xc7)
-                       && (c[4] == 0x43) && (c[5] == 0x2b)
-                       && (c[6] == 0x1f) && (c[7] == 0x5b))
-               return (0);
-       else
-               return (1);
-]]]
-      )],
-      [c_cv_fp_layout_need_nothing="yes"],
-      [c_cv_fp_layout_need_nothing="no"]
-    )
+    [
+      AC_RUN_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #include <stdlib.h>
+              #include <stdio.h>
+              #include <string.h>
+              #include <stdint.h>
+              #include <inttypes.h>
+              #include <stdbool.h>
+            ]],
+            [[
+              uint64_t i0;
+              uint64_t i1;
+              uint8_t c[8];
+              double d;
+
+              d = 8.642135e130;
+              memcpy ((void *) &i0, (void *) &d, 8);
+
+              i1 = i0;
+              memcpy ((void *) c, (void *) &i1, 8);
+
+              if ((c[0] == 0x2f) && (c[1] == 0x25)
+                  && (c[2] == 0xc0) && (c[3] == 0xc7)
+                  && (c[4] == 0x43) && (c[5] == 0x2b)
+                  && (c[6] == 0x1f) && (c[7] == 0x5b))
+                return 0;
+              return 1;
+            ]]
+          )
+        ],
+        [c_cv_fp_layout_need_nothing="yes"],
+        [c_cv_fp_layout_need_nothing="no"]
+      )
+    ]
   )
-  if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
-    fp_layout_type="nothing"
-  fi
 fi
+
+if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
+  fp_layout_type="nothing"
+fi
+
 if test "x$fp_layout_type" = "xunknown"; then
   AC_CACHE_CHECK([if endianflip converts to x86 representation],
     [c_cv_fp_layout_need_endianflip],
-    AC_RUN_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDBOOL_H
-# include <stdbool.h>
-#endif
-#define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
-                       (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
-                       (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
-                       (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
-                       (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
-                       (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
-                       (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
-                       (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
-]]],
-[[[
-       uint64_t i0;
-       uint64_t i1;
-       uint8_t c[8];
-       double d;
-
-       d = 8.642135e130;
-       memcpy ((void *) &i0, (void *) &d, 8);
-
-       i1 = endianflip (i0);
-       memcpy ((void *) c, (void *) &i1, 8);
-
-       if ((c[0] == 0x2f) && (c[1] == 0x25)
-                       && (c[2] == 0xc0) && (c[3] == 0xc7)
-                       && (c[4] == 0x43) && (c[5] == 0x2b)
-                       && (c[6] == 0x1f) && (c[7] == 0x5b))
-               return (0);
-       else
-               return (1);
-]]]
-      )],
-      [c_cv_fp_layout_need_endianflip="yes"],
-      [c_cv_fp_layout_need_endianflip="no"]
+    [
+      AC_RUN_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #include <stdlib.h>
+              #include <stdio.h>
+              #include <string.h>
+              #include <stdint.h>
+              #include <inttypes.h>
+              #include <stdbool.h>
+              #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
+                                     (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
+                                     (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
+                                     (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
+                                     (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
+                                     (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
+                                     (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
+                                     (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
+            ]],
+            [[
+              uint64_t i0;
+              uint64_t i1;
+              uint8_t c[8];
+              double d;
+
+              d = 8.642135e130;
+              memcpy ((void *) &i0, (void *) &d, 8);
+
+              i1 = endianflip (i0);
+              memcpy ((void *) c, (void *) &i1, 8);
+
+              if ((c[0] == 0x2f) && (c[1] == 0x25)
+                  && (c[2] == 0xc0) && (c[3] == 0xc7)
+                  && (c[4] == 0x43) && (c[5] == 0x2b)
+                  && (c[6] == 0x1f) && (c[7] == 0x5b))
+                return 0;
+              return 1;
+            ]]
+          )
+        ],
+        [c_cv_fp_layout_need_endianflip="yes"],
+        [c_cv_fp_layout_need_endianflip="no"]
+      ]
     )
   )
-  if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
-    fp_layout_type="endianflip"
-  fi
 fi
+
+if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
+  fp_layout_type="endianflip"
+fi
+
 if test "x$fp_layout_type" = "xunknown"; then
   AC_CACHE_CHECK([if intswap converts to x86 representation],
     [c_cv_fp_layout_need_intswap],
-    AC_RUN_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#if HAVE_STDBOOL_H
-# include <stdbool.h>
-#endif
-#define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
-                       (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
-]]],
-[[[
-       uint64_t i0;
-       uint64_t i1;
-       uint8_t c[8];
-       double d;
-
-       d = 8.642135e130;
-       memcpy ((void *) &i0, (void *) &d, 8);
-
-       i1 = intswap (i0);
-       memcpy ((void *) c, (void *) &i1, 8);
-
-       if ((c[0] == 0x2f) && (c[1] == 0x25)
-                       && (c[2] == 0xc0) && (c[3] == 0xc7)
-                       && (c[4] == 0x43) && (c[5] == 0x2b)
-                       && (c[6] == 0x1f) && (c[7] == 0x5b))
-               return (0);
-       else
-               return (1);
-]]]
-      )],
-      [c_cv_fp_layout_need_intswap="yes"],
-      [c_cv_fp_layout_need_intswap="no"]
-    )
+    [
+      AC_RUN_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #include <stdlib.h>
+              #include <stdio.h>
+              #include <string.h>
+              #include <stdint.h>
+              #include <inttypes.h>
+              #include <stdbool.h>
+              #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
+                                     (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
+            ]],
+            [[
+              uint64_t i0;
+              uint64_t i1;
+              uint8_t c[8];
+              double d;
+
+              d = 8.642135e130;
+              memcpy ((void *) &i0, (void *) &d, 8);
+
+              i1 = intswap (i0);
+              memcpy ((void *) c, (void *) &i1, 8);
+
+              if ((c[0] == 0x2f) && (c[1] == 0x25)
+                  && (c[2] == 0xc0) && (c[3] == 0xc7)
+                  && (c[4] == 0x43) && (c[5] == 0x2b)
+                  && (c[6] == 0x1f) && (c[7] == 0x5b))
+                return 0;
+              return 1;
+            ]]
+          )
+        ],
+        [c_cv_fp_layout_need_intswap="yes"],
+        [c_cv_fp_layout_need_intswap="no"]
+      )
+    ]
   )
-  if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
-    fp_layout_type="intswap"
-  fi
+fi
+
+if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
+  fp_layout_type="intswap"
 fi
 
 if test "x$fp_layout_type" = "xnothing"; then
-  AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
-  [Define if doubles are stored in x86 representation.])
+  AC_DEFINE([FP_LAYOUT_NEED_NOTHING], [1],
+    [Define if doubles are stored in x86 representation.]
+  )
 else if test "x$fp_layout_type" = "xendianflip"; then
-  AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
-  [Define if endianflip is needed to convert to x86 representation.])
+  AC_DEFINE([FP_LAYOUT_NEED_ENDIANFLIP], [1],
+    [Define if endianflip is needed to convert to x86 representation.]
+  )
 else if test "x$fp_layout_type" = "xintswap"; then
-  AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
-  [Define if intswap is needed to convert to x86 representation.])
+  AC_DEFINE([FP_LAYOUT_NEED_INTSWAP], [1],
+    [Define if intswap is needed to convert to x86 representation.]
+  )
 else
   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
 fi; fi; fi
 
+# For cpusleep plugin
+AC_CACHE_CHECK([whether clock_boottime and clock_monotonic are supported],
+  [c_cv_have_clock_boottime_monotonic],
+  [
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#include <time.h>]],
+        [[
+          struct timespec b, m;
+          clock_gettime(CLOCK_BOOTTIME, &b );
+          clock_gettime(CLOCK_MONOTONIC, &m );
+        ]]
+      )
+      ],
+      [c_cv_have_clock_boottime_monotonic="yes"],
+      [c_cv_have_clock_boottime_monotonic="no"]
+    )
+  ]
+)
+
 # --with-useragent {{{
-AC_ARG_WITH(useragent, [AS_HELP_STRING([--with-useragent@<:@=AGENT@:>@], [User agent to use on http requests])],
-[
-    if test "x$withval" != "xno" && test "x$withval" != "xyes"
-    then
-        AC_DEFINE_UNQUOTED(COLLECTD_USERAGENT, ["$withval"], [User agent for http requests])
+AC_ARG_WITH([useragent],
+  [AS_HELP_STRING([--with-useragent@<:@=AGENT@:>@], [User agent to use on http requests])],
+  [
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+      AC_DEFINE_UNQUOTED([COLLECTD_USERAGENT], ["$withval"], [User agent for http requests])
     fi
-])
+  ]
+)
 
 # }}}
 
 # --with-data-max-name-len {{{
-AC_ARG_WITH(data-max-name-len, [AS_HELP_STRING([--with-data-max-name-len@<:@=VALUE@:>@], [Maximum length of data buffers])],
-[
-    if test "x$withval" != "x" && test $withval -gt 0
-    then
-        AC_DEFINE_UNQUOTED(DATA_MAX_NAME_LEN, [$withval], [Maximum length of data buffers])
+AC_ARG_WITH([data-max-name-len],
+  [AS_HELP_STRING([--with-data-max-name-len@<:@=VALUE@:>@], [Maximum length of data buffers])],
+  [
+    if test "x$withval" != "x" && test $withval -gt 0; then
+      AC_DEFINE_UNQUOTED([DATA_MAX_NAME_LEN], [$withval], [Maximum length of data buffers])
     else
-        AC_MSG_ERROR([DATA_MAX_NAME_LEN must be a positive integer -- $withval given])
+      AC_MSG_ERROR([DATA_MAX_NAME_LEN must be a positive integer -- $withval given])
     fi
-],
-[   AC_DEFINE(DATA_MAX_NAME_LEN, 128, [Maximum length of data buffers])]
+  ],
+  [AC_DEFINE([DATA_MAX_NAME_LEN], [128], [Maximum length of data buffers])]
 )
 # }}}
 
-have_getfsstat="no"
-AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
-have_getvfsstat="no"
-AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
-have_listmntent="no"
-AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
-have_getmntent_r="no"
-AC_CHECK_FUNCS(getmntent_r, [have_getmntent_r="yes"])
-
-have_getmntent="no"
-AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
+AC_CHECK_FUNCS([getfsstat], [have_getfsstat="yes"], [have_getfsstat="no"])
+AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"], [have_getvfsstat="no"])
+AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"], [have_listmntent="no"])
+AC_CHECK_FUNCS(getmntent_r, [have_getmntent_r="yes"], [have_getmntent_r="no"])
+
+AC_CHECK_FUNCS(getmntent, [have_getmntent="libc"], [have_getmntent="no"])
 if test "x$have_getmntent" = "xno"; then
-       AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
+  AC_CHECK_LIB([sun], [getmntent],
+    [have_getmntent="sun"],
+    [have_gemntent="no"]
+  )
 fi
+
 if test "x$have_getmntent" = "xno"; then
-       AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
+  AC_CHECK_LIB([seq], [getmntent],
+    [have_getmntent="seq"],
+    [have_getmntent="no"]
+  )
 fi
+
 if test "x$have_getmntent" = "xno"; then
-       AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
+  AC_CHECK_LIB([gen], [getmntent],
+    [have_getmntent="gen"],
+    [have_getmntent="no"]
+  )
 fi
 
-if test "x$have_getmntent" = "xc"; then
-       AC_CACHE_CHECK([whether getmntent takes one argument],
-               [c_cv_have_one_getmntent],
-               AC_COMPILE_IFELSE(
-                       [AC_LANG_PROGRAM(
-[[[
-#include "$srcdir/src/utils_mount.h"
-]]],
-[[[
-FILE *fh;
-struct mntent *me;
-fh = setmntent ("/etc/mtab", "r");
-me = getmntent (fh);
-return(me->mnt_passno);
-]]]
-                       )],
-                       [c_cv_have_one_getmntent="yes"],
-                       [c_cv_have_one_getmntent="no"]
-               )
-       )
-       AC_CACHE_CHECK([whether getmntent takes two arguments],
-               [c_cv_have_two_getmntent],
-               AC_COMPILE_IFELSE(
-                       [AC_LANG_PROGRAM(
-[[[
-#include "$srcdir/src/utils_mount.h"
-]]],
-[[[
-                                FILE *fh;
-                                struct mnttab mt;
-                                int status;
-                                fh = fopen ("/etc/mnttab", "r");
-                                status = getmntent (fh, &mt);
-                                return(status);
-]]]
-                       )],
-                       [c_cv_have_two_getmntent="yes"],
-                       [c_cv_have_two_getmntent="no"]
-               )
-       )
+if test "x$have_getmntent" = "xlibc"; then
+  AC_CACHE_CHECK([whether getmntent takes one argument],
+    [c_cv_have_one_getmntent],
+    [
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[#include "$srcdir/src/utils_mount.h"]],
+            [[
+              FILE *fh;
+              struct mntent *me;
+              fh = setmntent ("/etc/mtab", "r");
+              me = getmntent (fh);
+              return(me->mnt_passno);
+            ]]
+          )
+        ],
+        [c_cv_have_one_getmntent="yes"],
+        [c_cv_have_one_getmntent="no"]
+      )
+    ]
+  )
+
+  AC_CACHE_CHECK([whether getmntent takes two arguments],
+    [c_cv_have_two_getmntent],
+    [
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[#include "$srcdir/src/utils_mount.h"]],
+            [[
+              FILE *fh;
+              struct mnttab mt;
+              int status;
+              fh = fopen ("/etc/mnttab", "r");
+              status = getmntent (fh, &mt);
+              return(status);
+            ]]
+          )
+        ],
+        [c_cv_have_two_getmntent="yes"],
+        [c_cv_have_two_getmntent="no"]
+      )
+    ]
+  )
 fi
 
 # Check for different versions of `getmntent' here..
 
-if test "x$have_getmntent" = "xc"; then
-       if test "x$c_cv_have_one_getmntent" = "xyes"; then
-               AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
-                         [Define if the function getmntent exists and takes one argument.])
-       fi
-       if test "x$c_cv_have_two_getmntent" = "xyes"; then
-               AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
-                         [Define if the function getmntent exists and takes two arguments.])
-       fi
+if test "x$have_getmntent" = "xlibc"; then
+  if test "x$c_cv_have_one_getmntent" = "xyes"; then
+    AC_DEFINE([HAVE_ONE_GETMNTENT], [1],
+      [Define if the function getmntent exists and takes one argument.]
+    )
+  fi
+
+  if test "x$c_cv_have_two_getmntent" = "xyes"; then
+    AC_DEFINE([HAVE_TWO_GETMNTENT], [1],
+      [Define if the function getmntent exists and takes two arguments.]
+    )
+  fi
 fi
+
 if test "x$have_getmntent" = "xsun"; then
-       AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
-                 [Define if the function getmntent exists. It is the version from libsun.])
-fi
-if test "x$have_getmntent" = "xseq"; then
-       AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
-                 [Define if the function getmntent exists. It is the version from libseq.])
+  AC_DEFINE([HAVE_SUN_GETMNTENT], [1],
+    [Define if the function getmntent exists. It is the version from libsun.]
+  )
 fi
+
 if test "x$have_getmntent" = "xgen"; then
-       AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
-                 [Define if the function getmntent exists. It is the version from libgen.])
+  AC_DEFINE([HAVE_GEN_GETMNTENT], [1],
+    [Define if the function getmntent exists. It is the version from libgen.]
+  )
 fi
 
 # Check for htonll
-AC_CACHE_CHECK([if have htonll defined],
-                  [c_cv_have_htonll],
-                  AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[[
-#include <sys/types.h>
-#include <netinet/in.h>
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-]]],
-[[[
-          return htonll(0);
-]]]
-    )],
-    [c_cv_have_htonll="yes"],
-    [c_cv_have_htonll="no"]
-  )
+AC_CACHE_CHECK([whether htonll is defined],
+  [c_cv_have_htonll],
+  [
+    AC_LINK_IFELSE(
+      [
+        AC_LANG_PROGRAM(
+          [[
+            #include <inttypes.h>
+            #include <sys/types.h>
+            #include <netinet/in.h>
+          ]],
+          [[return htonll(0);]]
+        )
+      ],
+      [c_cv_have_htonll="yes"],
+      [c_cv_have_htonll="no"]
+    )
+  ]
 )
-if test "x$c_cv_have_htonll" = "xyes"
-then
-    AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
+
+if test "x$c_cv_have_htonll" = "xyes"; then
+  AC_DEFINE([HAVE_HTONLL], [1], [Define if the function htonll exists.])
 fi
 
 # Check for structures
 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
-       [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
-       [],
-       [
-       #include <sys/types.h>
-       #include <sys/socket.h>
-       #include <net/if.h>
-       ])
+  [AC_DEFINE([HAVE_STRUCT_IF_DATA], [1], [Define if struct if_data exists and is usable.])],
+  [],
+  [[
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <net/if.h>
+  ]]
+)
+
 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
-       [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
-       [],
-       [
-       #include <sys/types.h>
-       #include <sys/socket.h>
-       #include <linux/if.h>
-       #include <linux/netdevice.h>
-       ])
-AC_CHECK_MEMBERS([struct inet_diag_req.id, struct inet_diag_req.idiag_states],
-       [AC_DEFINE(HAVE_STRUCT_LINUX_INET_DIAG_REQ, 1, [Define if struct inet_diag_req exists and is usable.])],
-       [],
-       [
-       #include <linux/inet_diag.h>
-       ])
+  [AC_DEFINE([HAVE_STRUCT_NET_DEVICE_STATS], [1], [Define if struct net_device_stats exists and is usable.])],
+  [],
+  [[
+    #include <sys/types.h>
+    #include <sys/socket.h>
+    #include <linux/if.h>
+    #include <linux/netdevice.h>
+  ]]
+)
 
+AC_CHECK_MEMBERS([struct inet_diag_req.id, struct inet_diag_req.idiag_states],
+  [AC_DEFINE([HAVE_STRUCT_LINUX_INET_DIAG_REQ], [1], [Define if struct inet_diag_req exists and is usable.])],
+  [],
+  [[#include <linux/inet_diag.h>]]
+)
 
 AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [],
-       [],
-       [
-       #include <netinet/in.h>
-       #include <net/if.h>
-       ])
+  [],
+  [[
+    #include <netinet/in.h>
+    #include <net/if.h>
+  ]]
+)
 
 AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
-       [
-               AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
-                       [Define if struct kinfo_proc exists in the FreeBSD variant.])
-               have_struct_kinfo_proc_freebsd="yes"
-       ],
-       [
-               have_struct_kinfo_proc_freebsd="no"
-       ],
-       [
-#include <kvm.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/user.h>
-       ])
+  [
+    AC_DEFINE([HAVE_STRUCT_KINFO_PROC_FREEBSD], [1], [Define if struct kinfo_proc exists in the FreeBSD variant.])
+    have_struct_kinfo_proc_freebsd="yes"
+  ],
+  [],
+  [[
+    #include <kvm.h>
+    #include <sys/param.h>
+    #include <sys/sysctl.h>
+    #include <sys/user.h>
+  ]]
+)
 
 AC_CHECK_MEMBERS([struct kinfo_proc.p_pid, struct kinfo_proc.p_vm_rssize],
-       [
-               AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
-                       [Define if struct kinfo_proc exists in the OpenBSD variant.])
-               have_struct_kinfo_proc_openbsd="yes"
-       ],
-       [
-               have_struct_kinfo_proc_openbsd="no"
-       ],
-       [
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <kvm.h>
-       ])
-
+  [
+    AC_DEFINE([HAVE_STRUCT_KINFO_PROC_OPENBSD], [1], [Define if struct kinfo_proc exists in the OpenBSD variant.])
+    have_struct_kinfo_proc_openbsd="yes"
+  ],
+  [],
+  [[
+    #include <sys/param.h>
+    #include <sys/sysctl.h>
+    #include <kvm.h>
+  ]]
+)
 
 AC_CHECK_MEMBERS([struct kinfo_proc2.p_pid, struct kinfo_proc2.p_uru_maxrss],
-       [
-               AC_DEFINE(HAVE_STRUCT_KINFO_PROC2_NETBSD, 1,
-                       [Define if struct kinfo_proc2 exists in the NetBSD variant.])
-               have_struct_kinfo_proc2_netbsd="yes"
-       ],
-       [
-               have_struct_kinfo_proc2_netbsd="no"
-       ],
-       [
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <kvm.h>
-       ])
-
-
-
-AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
-[#define _BSD_SOURCE
-#define _DEFAULT_SOURCE
-#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
-#if HAVE_NETINET_UDP_H
-# include <netinet/udp.h>
-#endif
-])
-AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
-[#define _BSD_SOURCE
-#define _DEFAULT_SOURCE
-#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
-#if HAVE_NETINET_UDP_H
-# include <netinet/udp.h>
-#endif
-])
+  [
+    AC_DEFINE([HAVE_STRUCT_KINFO_PROC2_NETBSD], [1], [Define if struct kinfo_proc2 exists in the NetBSD variant.])
+    have_struct_kinfo_proc2_netbsd="yes"
+  ],
+  [],
+  [[
+    #include <sys/param.h>
+    #include <sys/sysctl.h>
+    #include <kvm.h>
+  ]]
+)
+
+AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport],
+  [],
+  [],
+  [[
+    #define _BSD_SOURCE
+    #define _DEFAULT_SOURCE
+    #include <stdint.h>
+    #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
+    #if HAVE_NETINET_UDP_H
+    # include <netinet/udp.h>
+    #endif
+  ]]
+)
+
+AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source],
+  [],
+  [],
+  [[
+    #define _BSD_SOURCE
+    #define _DEFAULT_SOURCE
+    #include <stdint.h>
+    #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
+    #if HAVE_NETINET_UDP_H
+    # include <netinet/udp.h>
+    #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
-       ])
+  [],
+  [],
+  [[# include <kstat.h>]]
+)
 
 # check for pthread_setname_np
 SAVE_LDFLAGS="$LDFLAGS"
 LDFLAGS="$LDFLAGS -lpthread"
 
 AC_MSG_CHECKING([for pthread_setname_np])
-       have_pthread_setname_np="no"
-       AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[
-#define _GNU_SOURCE
-#include <pthread.h>
-]],
-[[
-        pthread_setname_np((pthread_t) {0}, "conftest");
-]]
-       )], [
-               have_pthread_setname_np="yes"
-               AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [pthread_setname_np() is available.])
-       ])
+have_pthread_setname_np="no"
+AC_LINK_IFELSE(
+  [
+    AC_LANG_PROGRAM(
+      [[
+        #define _GNU_SOURCE
+        #include <pthread.h>
+      ]],
+      [[pthread_setname_np((pthread_t) {0}, "conftest");]]
+    )
+  ],
+  [
+    have_pthread_setname_np="yes"
+    AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [pthread_setname_np() is available.])
+  ]
+)
 
 AC_MSG_RESULT([$have_pthread_setname_np])
 
 # check for pthread_set_name_np(3) (FreeBSD)
 AC_MSG_CHECKING([for pthread_set_name_np])
-       have_pthread_set_name_np="no"
-       AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[
-#include <pthread_np.h>
-]],
-[[
-        pthread_set_name_np((pthread_t) {0}, "conftest");
-]]
-       )], [
-               have_pthread_set_name_np="yes"
-               AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [pthread_set_name_np() is available.])
-       ])
+have_pthread_set_name_np="no"
+AC_LINK_IFELSE(
+  [
+    AC_LANG_PROGRAM(
+      [[#include <pthread_np.h>]],
+      [[pthread_set_name_np((pthread_t) {0}, "conftest");]]
+    )
+   ],
+  [
+    have_pthread_set_name_np="yes"
+    AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [pthread_set_name_np() is available.])
+  ]
+)
 AC_MSG_RESULT([$have_pthread_set_name_np])
 
 LDFLAGS="$SAVE_LDFLAGS"
 
-#
-# Checks for libraries begin here
-#
+AC_CHECK_TYPES([struct ip6_ext],
+  [have_ip6_ext="yes"],
+  [have_ip6_ext="no"],
+  [[
+    #include <stdint.h>
+    #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_IP6_H
+    # include <netinet/ip6.h>
+    #endif
+  ]]
+)
 
-with_libresolv="yes"
-AC_CHECK_LIB(resolv, res_search,
-[
-       AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
-],
-[with_libresolv="no"])
-AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
+if test "x$have_ip6_ext" = "xno"; then
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -DSOLARIS2=8"
+  AC_CHECK_TYPES([struct ip6_ext],
+    [have_ip6_ext="yes, with -DSOLARIS2=8"],
+    [have_ip6_ext="no"],
+    [[
+      #include <stdint.h>
+      #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_IP6_H
+      # include <netinet/ip6.h>
+      #endif
+    ]]
+  )
+  if test "x$have_ip6_ext" = "xno"; then
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+fi
 
-dnl Check for HAL (hardware abstraction library)
-with_libhal="no"
-PKG_CHECK_MODULES([HAL], [hal],
-  [
-    SAVE_LIBS="$LIBS"
-    LIBS="$HAL_LIBS $LIBS"
-    AC_CHECK_LIB([hal], [libhal_device_property_exists],
-      [
-        SAVE_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="$HAL_CFLAGS $CPPFLAGS"
-        AC_CHECK_HEADERS([libhal.h],
-        [
-          with_libhal="yes"
-          BUILD_WITH_LIBHAL_CFLAGS="$HAL_CFLAGS"
-          BUILD_WITH_LIBHAL_LIBS="$HAL_LIBS"
-        ])
-        CPPFLAGS="$SAVE_CPPFLAGS"
-      ],
-      [ : ]
-    )
-    LIBS="$SAVE_LIBS"
-  ],
-  [ : ]
-)
-AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
-AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
+# libi2c-dev
+if test "x$ac_system" = "xLinux"; then
+  AC_CHECK_DECL([i2c_smbus_read_i2c_block_data],
+    [with_libi2c="yes"],
+    [with_libi2c="no (symbol i2c_smbus_read_i2c_block_data not found - have you installed libi2c-dev ?)"],
+    [[
+      #include <stdlib.h>
+      #include <linux/i2c-dev.h>
+    ]]
+  )
+else
+  with_libi2c="no (Linux only)"
+fi
 
+#
+# Checks for libraries begin here
+#
 
+# Check for libpthread
 SAVE_LIBS="$LIBS"
 AC_CHECK_LIB([pthread],
   [pthread_create],
   [],
-  [AC_MSG_ERROR([Symbol 'pthread_create' not found in libpthread"])],
+  [AC_MSG_ERROR([Symbol 'pthread_create' not found in libpthread])],
   []
 )
 PTHREAD_LIBS="$LIBS"
 LIBS="$SAVE_LIBS"
+AC_SUBST([PTHREAD_LIBS])
 
 AC_CHECK_HEADERS([pthread.h],
   [],
   [AC_MSG_ERROR([pthread.h not found])]
 )
-AC_SUBST([PTHREAD_LIBS])
 
 m4_divert_once([HELP_WITH], [
-collectd additional packages:])
+Collectd additional packages:])
 
-if test "x$ac_system" = "xAIX"
-then
-       with_perfstat="yes"
-       with_procinfo="yes"
+if test "x$ac_system" = "xAIX"; then
+  with_perfstat="yes"
+  with_procinfo="yes"
 else
-       with_perfstat="no (AIX only)"
-       with_procinfo="no (AIX only)"
+  with_perfstat="no (AIX only)"
+  with_procinfo="no (AIX only)"
 fi
 
-if test "x$with_perfstat" = "xyes"
-then
-       AC_CHECK_LIB(perfstat, perfstat_reset, [with_perfstat="yes"], [with_perfstat="no (perfstat not found)"], [])
-#      AC_CHECK_HEADERS(sys/protosw.h libperfstat.h,, [with_perfstat="no (perfstat not found)"])
+if test "x$with_perfstat" = "xyes"; then
+  AC_CHECK_LIB([perfstat], [perfstat_reset],
+    [with_perfstat="yes"],
+    [with_perfstat="no (perfstat not found)"]
+  )
 fi
-if test "x$with_perfstat" = "xyes"
-then
-        AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
-        # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
-        AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled], [], [], [[#include <libperfstat.h]])
-        if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"
-        then
-               AC_DEFINE(PERFSTAT_SUPPORTS_DONATION, 1, [Define to 1 if your version of the 'perfstat' library supports donation])
-        fi
+
+if test "x$with_perfstat" = "xyes"; then
+  AC_DEFINE([HAVE_PERFSTAT], [1], [Define to 1 if you have the 'perfstat' library (-lperfstat)])
+  # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
+  AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled],
+    [],
+    [],
+    [[#include <libperfstat.h]]
+  )
+  if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"; then
+    AC_DEFINE([PERFSTAT_SUPPORTS_DONATION], [1], [Define to 1 if your version of the 'perfstat' library supports donation])
+  fi
 fi
-AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")
+AM_CONDITIONAL([BUILD_WITH_PERFSTAT], [test "x$with_perfstat" = "xyes"])
 
 # Processes plugin under AIX.
-if test "x$with_procinfo" = "xyes"
-then
-       AC_CHECK_HEADERS(procinfo.h,, [with_procinfo="no (procinfo.h not found)"])
-fi
-if test "x$with_procinfo" = "xyes"
-then
-        AC_DEFINE(HAVE_PROCINFO_H, 1, [Define to 1 if you have the procinfo.h])
+if test "x$with_procinfo" = "xyes"; then
+  AC_CHECK_HEADERS([procinfo.h],
+    [AC_DEFINE([HAVE_PROCINFO_H], [1], [Define to 1 if you have the procinfo.h])],
+    [with_procinfo="no (procinfo.h not found)"]
+  )
 fi
 
-if test "x$ac_system" = "xSolaris"
-then
-       with_kstat="yes"
-       with_devinfo="yes"
+if test "x$ac_system" = "xSolaris"; then
+  with_kstat="yes"
+  with_devinfo="yes"
 else
-       with_kstat="no (Solaris only)"
-       with_devinfo="no (Solaris only)"
+  with_kstat="no (Solaris only)"
+  with_devinfo="no (Solaris only)"
 fi
 
-if test "x$with_kstat" = "xyes"
-then
-       AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
-fi
-if test "x$with_kstat" = "xyes"
-then
-       AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
-       AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
+if test "x$with_kstat" = "xyes"; then
+  AC_CHECK_LIB([kstat], [kstat_open],
+    [with_kstat="yes"],
+    [with_kstat="no (libkstat not found)"]
+  )
 fi
-if test "x$with_kstat" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBKSTAT, 1,
-                 [Define to 1 if you have the 'kstat' library (-lkstat)])
+
+if test "x$with_kstat" = "xyes"; then
+  AC_CHECK_LIB([devinfo], [di_init],
+    [with_devinfo="yes"],
+    [with_devinfo="no (not found)"]
+  )
+  AC_CHECK_HEADERS([kstat.h],
+    [AC_DEFINE(HAVE_LIBKSTAT, [1], [Define to 1 if you have the 'kstat' library (-lkstat)])],
+    [with_kstat="no (kstat.h not found)"]
+  )
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
-AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
 
-with_libiokit="no"
-if test "x$ac_system" = "xDarwin"
-then
-       with_libiokit="yes"
+AM_CONDITIONAL([BUILD_WITH_LIBDEVINFO], [test "x$with_devinfo" = "xyes"])
+AM_CONDITIONAL([BUILD_WITH_LIBKSTAT], [test "x$with_kstat" = "xyes"])
+
+if test "x$ac_system" = "xDarwin"; then
+  with_libiokit="yes"
 else
-       with_libiokit="no"
+  with_libiokit="no"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
+AM_CONDITIONAL([BUILD_WITH_LIBIOKIT], [test "x$with_libiokit" = "xyes"])
 
 with_libkvm="no"
-AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
-if test "x$with_kvm_getprocs" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
-                 [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
-       with_libkvm="yes"
+AC_CHECK_LIB([kvm], [kvm_getprocs],
+  [with_kvm_getprocs="yes"],
+  [with_kvm_getprocs="no"]
+)
+
+if test "x$with_kvm_getprocs" = "xyes"; then
+  AC_DEFINE([HAVE_LIBKVM_GETPROCS], [1],
+    [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)]
+  )
+  with_libkvm="yes"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
 
-AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
-if test "x$with_kvm_getswapinfo" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
-                 [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
-       with_libkvm="yes"
+AM_CONDITIONAL([BUILD_WITH_LIBKVM_GETPROCS], [test "x$with_kvm_getprocs" = "xyes"])
+
+AC_CHECK_LIB([kvm], [kvm_getswapinfo],
+  [with_kvm_getswapinfo="yes"],
+  [with_kvm_getswapinfo="no"]
+)
+
+if test "x$with_kvm_getswapinfo" = "xyes"; then
+  AC_DEFINE([HAVE_LIBKVM_GETSWAPINFO], [1],
+    [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)]
+  )
+  with_libkvm="yes"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
 
-AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
-if test "x$with_kvm_nlist" = "xyes"
-then
-       AC_CHECK_HEADERS(bsd/nlist.h nlist.h)
-       AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
-                 [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
-       with_libkvm="yes"
+AM_CONDITIONAL([BUILD_WITH_LIBKVM_GETSWAPINFO], [test "x$with_kvm_getswapinfo" = "xyes"])
+
+AC_CHECK_LIB([kvm], [kvm_nlist],
+  [with_kvm_nlist="yes"],
+  [with_kvm_nlist="no"]
+)
+
+if test "x$with_kvm_nlist" = "xyes"; then
+  AC_CHECK_HEADERS([bsd/nlist.h nlist.h])
+  AC_DEFINE([HAVE_LIBKVM_NLIST], [1],
+    [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)]
+  )
+  with_libkvm="yes"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
 
-AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
-if test "x$with_kvm_openfiles" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
-                 [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
-       with_libkvm="yes"
+AM_CONDITIONAL([BUILD_WITH_LIBKVM_NLIST], [test "x$with_kvm_nlist" = "xyes"])
+
+AC_CHECK_LIB([kvm], [kvm_openfiles],
+  [with_kvm_openfiles="yes"],
+  [with_kvm_openfiles="no"]
+)
+
+if test "x$with_kvm_openfiles" = "xyes"; then
+  AC_DEFINE([HAVE_LIBKVM_NLIST], [1],
+    [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)]
+  )
+  with_libkvm="yes"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
 
 # --with-libaquaero5 {{{
-AC_ARG_WITH(libaquaero5, [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_libaquaero5="yes"
- else if test "x$withval" = "xno"
- then
-        with_libaquaero5="no"
- else
-        with_libaquaero5="yes"
-        LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS -I$withval/src"
-        LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS -L$withval/obj"
- fi; fi
-],
-[with_libaquaero5="yes"])
+AC_ARG_WITH([libaquaero5],
+  [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
+  [
   if test "x$withval" = "xyes"; then
+      with_libaquaero5="yes"
+    else if test "x$withval" = "xno"; then
+      with_libaquaero5="no"
+    else
+      with_libaquaero5="yes"
+      LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS -I$withval/src"
+      LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS -L$withval/obj"
+    fi; fi
+  ],
+  [with_libaquaero5="yes"]
+)
 
 SAVE_CPPFLAGS="$CPPFLAGS"
 SAVE_LDFLAGS="$LDFLAGS"
-
 CPPFLAGS="$CPPFLAGS $LIBAQUAERO5_CFLAGS"
 LDFLAGS="$LDFLAGS $LIBAQUAERO5_LDFLAGS"
 
-if test "x$with_libaquaero5" = "xyes"
-then
-       if test "x$LIBAQUAERO5_CFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libaquaero5 CPPFLAGS: $LIBAQUAERO5_CFLAGS])
-       fi
-       AC_CHECK_HEADERS(libaquaero5.h,
-       [with_libaquaero5="yes"],
-       [with_libaquaero5="no (libaquaero5.h not found)"])
-fi
-if test "x$with_libaquaero5" = "xyes"
-then
-       if test "x$LIBAQUAERO5_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libaquaero5 LDFLAGS: $LIBAQUAERO5_LDFLAGS])
-       fi
-       AC_CHECK_LIB(aquaero5, libaquaero5_poll,
-       [with_libaquaero5="yes"],
-       [with_libaquaero5="no (symbol 'libaquaero5_poll' not found)"])
+if test "x$with_libaquaero5" = "xyes"; then
+  if test "x$LIBAQUAERO5_CFLAGS" != "x"; then
+    AC_MSG_NOTICE([libaquaero5 CPPFLAGS: $LIBAQUAERO5_CFLAGS])
+  fi
+  AC_CHECK_HEADERS([libaquaero5.h],
+    [with_libaquaero5="yes"],
+    [with_libaquaero5="no (libaquaero5.h not found)"]
+  )
+fi
+
+if test "x$with_libaquaero5" = "xyes"; then
+  if test "x$LIBAQUAERO5_LDFLAGS" != "x"; then
+    AC_MSG_NOTICE([libaquaero5 LDFLAGS: $LIBAQUAERO5_LDFLAGS])
+  fi
+  AC_CHECK_LIB([aquaero5], libaquaero5_poll,
+    [with_libaquaero5="yes"],
+    [with_libaquaero5="no (symbol 'libaquaero5_poll' not found)"]
+  )
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
 LDFLAGS="$SAVE_LDFLAGS"
 
-if test "x$with_libaquaero5" = "xyes"
-then
-       BUILD_WITH_LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS"
-       BUILD_WITH_LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBAQUAERO5_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBAQUAERO5_LDFLAGS)
+if test "x$with_libaquaero5" = "xyes"; then
+  BUILD_WITH_LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS"
+  BUILD_WITH_LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBAQUAERO5, test "x$with_libaquaero5" = "xyes")
+AC_SUBST([BUILD_WITH_LIBAQUAERO5_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBAQUAERO5_LDFLAGS])
 # }}}
 
 # --with-libhiredis {{{
-AC_ARG_WITH(libhiredis, [AS_HELP_STRING([--with-libhiredis@<:@=PREFIX@:>@],
-      [Path to libhiredis.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_libhiredis="yes"
- else if test "x$withval" = "xno"
- then
-        with_libhiredis="no"
- else
-        with_libhiredis="yes"
-        LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS -I$withval/include"
-        LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS -L$withval/lib"
- fi; fi
-],
-[with_libhiredis="yes"])
+AC_ARG_WITH([libhiredis],
+  [AS_HELP_STRING([--with-libhiredis@<:@=PREFIX@:>@], [Path to libhiredis.])],
+  [
+    if test "x$withval" = "xyes"; then
+      with_libhiredis="yes"
+    else if test "x$withval" = "xno"; then
+      with_libhiredis="no"
+    else
+      with_libhiredis="yes"
+      LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS -I$withval/include"
+      LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS -L$withval/lib"
+    fi; fi
+  ],
+  [with_libhiredis="yes"]
+)
 
 SAVE_CPPFLAGS="$CPPFLAGS"
 SAVE_LDFLAGS="$LDFLAGS"
-
 CPPFLAGS="$CPPFLAGS $LIBHIREDIS_CPPFLAGS"
 LDFLAGS="$LDFLAGS $LIBHIREDIS_LDFLAGS"
 
-if test "x$with_libhiredis" = "xyes"
-then
-       if test "x$LIBHIREDIS_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libhiredis CPPFLAGS: $LIBHIREDIS_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(hiredis/hiredis.h,
-       [with_libhiredis="yes"],
-       [with_libhiredis="no (hiredis.h not found)"])
-fi
-if test "x$with_libhiredis" = "xyes"
-then
-       if test "x$LIBHIREDIS_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libhiredis LDFLAGS: $LIBHIREDIS_LDFLAGS])
-       fi
-       AC_CHECK_LIB(hiredis, redisCommand,
-       [with_libhiredis="yes"],
-       [with_libhiredis="no (symbol 'redisCommand' not found)"])
+if test "x$with_libhiredis" = "xyes"; then
+  if test "x$LIBHIREDIS_CPPFLAGS" != "x"; then
+    AC_MSG_NOTICE([libhiredis CPPFLAGS: $LIBHIREDIS_CPPFLAGS])
+  fi
+  AC_CHECK_HEADERS([hiredis/hiredis.h],
+    [with_libhiredis="yes"],
+    [with_libhiredis="no (hiredis.h not found)"]
+  )
+fi
 
+if test "x$with_libhiredis" = "xyes"; then
+  if test "x$LIBHIREDIS_LDFLAGS" != "x"; then
+    AC_MSG_NOTICE([libhiredis LDFLAGS: $LIBHIREDIS_LDFLAGS])
+  fi
+  AC_CHECK_LIB([hiredis], [redisCommand],
+    [with_libhiredis="yes"],
+    [with_libhiredis="no (symbol 'redisCommand' not found)"]
+  )
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
 LDFLAGS="$SAVE_LDFLAGS"
 
-if test "x$with_libhiredis" = "xyes"
-then
-       BUILD_WITH_LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS"
-       BUILD_WITH_LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBHIREDIS_LDFLAGS)
+if test "x$with_libhiredis" = "xyes"; then
+  BUILD_WITH_LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS"
+  BUILD_WITH_LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBHIREDIS, test "x$with_libhiredis" = "xyes")
+
+AC_SUBST([BUILD_WITH_LIBHIREDIS_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBHIREDIS_LDFLAGS])
 # }}}
 
 # --with-libcurl {{{
 with_curl_config="curl-config"
 with_curl_cflags=""
 with_curl_libs=""
-AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libcurl="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libcurl="yes"
-       else
-               if test -f "$withval" && test -x "$withval"
-               then
-                       with_curl_config="$withval"
-                       with_libcurl="yes"
-               else if test -x "$withval/bin/curl-config"
-               then
-                       with_curl_config="$withval/bin/curl-config"
-                       with_libcurl="yes"
-               fi; fi
-               with_libcurl="yes"
-       fi; fi
-],
-[
-       with_libcurl="yes"
-])
-if test "x$with_libcurl" = "xyes"
-then
-       with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
-       curl_config_status=$?
+AC_ARG_WITH(libcurl,
+  [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
+  [
+    if test "x$withval" = "xno"; then
+      with_libcurl="no"
+    else if test "x$withval" = "xyes"; then
+      with_libcurl="yes"
+    else
+      if test -f "$withval" && test -x "$withval"; then
+        with_curl_config="$withval"
+        with_libcurl="yes"
+      else if test -x "$withval/bin/curl-config"; then
+        with_curl_config="$withval/bin/curl-config"
+        with_libcurl="yes"
+      fi; fi
+      with_libcurl="yes"
+    fi; fi
+  ],
+  [with_libcurl="yes"]
+)
 
-       if test $curl_config_status -ne 0
-       then
-               with_libcurl="no ($with_curl_config failed)"
-       else
-               SAVE_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS $with_curl_cflags"
+if test "x$with_libcurl" = "xyes"; then
+  with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
+  curl_config_status=$?
+
+  if test $curl_config_status -ne 0; then
+    with_libcurl="no ($with_curl_config failed)"
+  else
+    SAVE_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $with_curl_cflags"
 
-               AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
+    AC_CHECK_HEADERS([curl/curl.h],
+      [with_libcurl="yes"],
+      [with_libcurl="no (curl/curl.h not found)"]
+    )
 
-               CPPFLAGS="$SAVE_CPPFLAGS"
-       fi
+    CPPFLAGS="$SAVE_CPPFLAGS"
+  fi
 fi
-if test "x$with_libcurl" = "xyes"
-then
-       with_curl_libs=`$with_curl_config --libs 2>/dev/null`
-       curl_config_status=$?
-
-       if test $curl_config_status -ne 0
-       then
-               with_libcurl="no ($with_curl_config failed)"
-       else
-               AC_CHECK_LIB(curl, curl_easy_init,
-                [with_libcurl="yes"],
-                [with_libcurl="no (symbol 'curl_easy_init' not found)"],
-                [$with_curl_libs])
-               AC_CHECK_DECL(CURLOPT_USERNAME,
-                [have_curlopt_username="yes"],
-                [have_curlopt_username="no"],
-                [[#include <curl/curl.h>]])
-               AC_CHECK_DECL(CURLOPT_TIMEOUT_MS,
-                [have_curlopt_timeout="yes"],
-                [have_curlopt_timeout="no"],
-                [[#include <curl/curl.h>]])
-       fi
-fi
-if test "x$with_libcurl" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_curl_cflags"
-       LDFLAGS="$LDFLAGS $with_curl_libs"
-       AC_CACHE_CHECK([for CURLINFO_APPCONNECT_TIME],
-               [c_cv_have_curlinfo_appconnect_time],
-               AC_LINK_IFELSE([AC_LANG_PROGRAM(
-[[
-#include <curl/curl.h>
-]],
-[[
-int val = CURLINFO_APPCONNECT_TIME;
-return val;
-]]
-                       )],
-                       [c_cv_have_curlinfo_appconnect_time="yes"],
-                       [c_cv_have_curlinfo_appconnect_time="no"]
-               )
-       )
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
-if test "x$c_cv_have_curlinfo_appconnect_time" = "xyes"
-then
-       AC_DEFINE(HAVE_CURLINFO_APPCONNECT_TIME, 1, [Define if curl.h defines CURLINFO_APPCONNECT_TIME.])
+
+if test "x$with_libcurl" = "xyes"; then
+  with_curl_libs=`$with_curl_config --libs 2>/dev/null`
+  curl_config_status=$?
+
+  if test $curl_config_status -ne 0; then
+    with_libcurl="no ($with_curl_config failed)"
+  else
+    AC_CHECK_LIB([curl], [curl_easy_init],
+      [with_libcurl="yes"],
+      [with_libcurl="no (symbol 'curl_easy_init' not found)"],
+      [$with_curl_libs]
+    )
+
+    AC_CHECK_DECL([CURLOPT_USERNAME],
+      [have_curlopt_username="yes"],
+      [have_curlopt_username="no"],
+      [[#include <curl/curl.h>]]
+    )
+
+    AC_CHECK_DECL(CURLOPT_TIMEOUT_MS,
+      [have_curlopt_timeout="yes"],
+      [have_curlopt_timeout="no"],
+      [[#include <curl/curl.h>]]
+    )
+  fi
 fi
 
-if test "x$with_libcurl" = "xyes"
-then
-       BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
-       BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
-       AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
+if test "x$with_libcurl" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  SAVE_LDFLAGS="$LDFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_curl_cflags"
+  LDFLAGS="$LDFLAGS $with_curl_libs"
+  AC_CACHE_CHECK([for CURLINFO_APPCONNECT_TIME],
+    [c_cv_have_curlinfo_appconnect_time],
+    [
+      AC_LINK_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[#include <curl/curl.h>]],
+            [[
+              int val = CURLINFO_APPCONNECT_TIME;
+              return val;
+            ]]
+          )
+        ],
+        [c_cv_have_curlinfo_appconnect_time="yes"],
+        [c_cv_have_curlinfo_appconnect_time="no"]
+      )
+    ]
+  )
+  CPPFLAGS="$SAVE_CPPFLAGS"
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$c_cv_have_curlinfo_appconnect_time" = "xyes"; then
+  AC_DEFINE([HAVE_CURLINFO_APPCONNECT_TIME], [1],
+    [Define if curl.h defines CURLINFO_APPCONNECT_TIME.]
+  )
+fi
 
-       if test "x$have_curlopt_username" = "xyes"
-       then
-               AC_DEFINE(HAVE_CURLOPT_USERNAME, 1, [Define if libcurl supports CURLOPT_USERNAME option.])
-       fi
+if test "x$with_libcurl" = "xyes"; then
+  BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
+  BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
 
-       if test "x$have_curlopt_timeout" = "xyes"
-       then
-               AC_DEFINE(HAVE_CURLOPT_TIMEOUT_MS, 1, [Define if libcurl supports CURLOPT_TIMEOUT_MS option.])
-       fi
+  if test "x$have_curlopt_username" = "xyes"; then
+    AC_DEFINE([HAVE_CURLOPT_USERNAME], [1],
+      [Define if libcurl supports CURLOPT_USERNAME option.]
+    )
+  fi
+
+  if test "x$have_curlopt_timeout" = "xyes"; then
+    AC_DEFINE([HAVE_CURLOPT_TIMEOUT_MS], [1],
+      [Define if libcurl supports CURLOPT_TIMEOUT_MS option.]
+    )
+  fi
 fi
+
+AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
+AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
 # }}}
 
 # --with-libdbi {{{
-with_libdbi_cppflags=""
-with_libdbi_ldflags=""
-AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libdbi_cppflags="-I$withval/include"
-               with_libdbi_ldflags="-L$withval/lib"
-               with_libdbi="yes"
-       else
-               with_libdbi="$withval"
-       fi
-],
-[
-       with_libdbi="yes"
-])
-if test "x$with_libdbi" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
+AC_ARG_WITH([libdbi],
+  [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
+  [
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+      with_libdbi_cppflags="-I$withval/include"
+      with_libdbi_ldflags="-L$withval/lib"
+      with_libdbi="yes"
+    else
+      with_libdbi="$withval"
+    fi
+  ],
+  [with_libdbi="yes"]
+)
+
+if test "x$with_libdbi" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
+
+  AC_CHECK_HEADERS([dbi/dbi.h],
+    [with_libdbi="yes"],
+    [with_libdbi="no (dbi/dbi.h not found)"]
+  )
 
-       AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
+  CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libdbi" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
+  AC_CHECK_LIB([dbi], [dbi_initialize],
+    [with_libdbi="yes"],
+    [with_libdbi="no (Symbol 'dbi_initialize' not found)"]
+  )
+
+  LDFLAGS="$SAVE_LDFLAGS"
 fi
-if test "x$with_libdbi" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
-       LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
 
-       AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
+BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
+BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
+BUILD_WITH_LIBDBI_LIBS="-ldbi"
+AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
+AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
+AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
+# }}}
+
+# --with-libdpdk {{{
+AC_ARG_VAR([LIBDPDK_CPPFLAGS], [Preprocessor flags for libdpdk])
+AC_ARG_VAR([LIBDPDK_CFLAGS], [Compiler flags for libdpdk])
+AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
+AC_ARG_VAR([LIBDPDK_LIBS], [Libraries to link for libdpdk])
+
+AC_ARG_WITH([libdpdk],
+  [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])],
+  [with_libdpdk="$withval"],
+  [with_libdpdk="yes"]
+)
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
+if test "x$with_libdpdk" != "xno"; then
+  PKG_CHECK_MODULES([DPDK], [libdpdk], [],
+    [AC_MSG_NOTICE([no DPDK pkg-config, using defaults])])
+  if test "x$LIBDPDK_CPPFLAGS" = "x"; then
+    LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
+  fi
+  if test "x$LIBDPDK_CFLAGS" = "x"; then
+    LIBDPDK_CFLAGS="$DPDK_CFLAGS"
+    LIBDPDK_CPPFLAGS="$LIBDPDK_CPPFLAGS $DPDK_CFLAGS"
+  fi
+  if test "x$LIBDPDK_LIBS" = "x"; then
+    if test "x$DPDK_LIBS" != "x"; then
+      LIBDPDK_LIBS="$DPDK_LIBS"
+    else
+      LIBDPDK_LIBS="-ldpdk"
+    fi
+  fi
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$LIBDPDK_CFLAGS $CFLAGS"
+  AC_CHECK_HEADERS([rte_config.h],
+    [
+      with_libdpdk="yes"
+      AC_PREPROC_IFELSE(
+        [
+          AC_LANG_SOURCE(
+            [[
+              #include <rte_version.h>
+              #if RTE_VERSION < RTE_VERSION_NUM(16,7,0,0)
+              #error "required DPDK >= 16.07"
+              #endif
+            ]]
+          )
+        ],
+        [dpdk_keepalive="yes"],
+        [dpdk_keepalive="no (DPDK version < 16.07)"]
+      )
+    ],
+    [with_libdpdk="no (rte_config.h not found)"]
+  )
+  CPPFLAGS="$SAVE_CPPFLAGS"
+  CFLAGS="$SAVE_CFLAGS"
 fi
-if test "x$with_libdbi" = "xyes"
-then
-       BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
-       BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
-       BUILD_WITH_LIBDBI_LIBS="-ldbi"
-       AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
+
+if test "x$with_libdpdk" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
+  AC_CHECK_LIB([dpdk], [rte_eal_init],
+    [with_libdpdk="yes"],
+    [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
+  )
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
+
 # }}}
 
 # --with-libesmtp {{{
-AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
-               with_libesmtp="yes"
-       else
-               with_libesmtp="$withval"
-       fi
-],
-[
-       with_libesmtp="yes"
-])
-if test "x$with_libesmtp" = "xyes"
-then
-       AC_CHECK_LIB(esmtp, smtp_create_session,
-       [
-               AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
-       ], [with_libesmtp="no (libesmtp not found)"])
-fi
-if test "x$with_libesmtp" = "xyes"
-then
-       AC_CHECK_HEADERS(libesmtp.h,
-       [
-               AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
-       ], [with_libesmtp="no (libesmtp.h not found)"])
+AC_ARG_WITH([libesmtp],
+  [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
+  [
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+      with_libesmtp_cppflags="-I$withval/include"
+      with_libesmtp_ldflags="-L$withval/lib"
+      with_libesmtp="yes"
+    else
+      with_libesmtp="$withval"
+    fi
+  ],
+  [with_libesmtp="yes"]
+)
+
+if test "x$with_libesmtp" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libesmtp_cppflags"
+
+  AC_CHECK_HEADERS([libesmtp.h],
+    [with_libesmtp="yes"],
+    [with_libesmtp="no (libesmtp.h not found)"]
+  )
+
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libesmtp" = "xyes"
-then
-       collect_libesmtp=1
-else
-       collect_libesmtp=0
+
+if test "x$with_libesmtp" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_esmtp_ldflags"
+
+  AC_CHECK_LIB([esmtp], [smtp_create_session],
+    [with_libesmtp="yes"],
+    [with_libesmtp="no (Symbol 'smtp_create_session' not found)"]
+  )
+
+  LDFLAGS="$SAVE_LDFLAGS"
 fi
-AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
-       [Wether or not to use the esmtp library])
-AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
+
+BUILD_WITH_LIBESMTP_CPPFLAGS="$with_libesmtp_cppflags"
+BUILD_WITH_LIBESMTP_LDFLAGS="$with_libesmtp_ldflags"
+BUILD_WITH_LIBESMTP_LIBS="-lesmtp"
+AC_SUBST(BUILD_WITH_LIBESMTP_CPPFLAGS)
+AC_SUBST(BUILD_WITH_LIBESMTP_LDFLAGS)
+AC_SUBST(BUILD_WITH_LIBESMTP_LIBS)
 # }}}
 
 # --with-libganglia {{{
-AC_ARG_WITH(libganglia, [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
-[
- if test -f "$withval" && test -x "$withval"
- then
-        with_libganglia_config="$withval"
-        with_libganglia="yes"
- else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"
- then
-        with_libganglia_config="$withval/bin/ganglia-config"
-        with_libganglia="yes"
- else if test -d "$withval"
- then
-        GANGLIA_CPPFLAGS="-I$withval/include"
-        GANGLIA_LDFLAGS="-L$withval/lib"
-        with_libganglia="yes"
- else
-        with_libganglia="$withval"
- fi; fi; fi
-],
-[
- with_libganglia="yes"
-])
+AC_ARG_WITH([libganglia],
+  [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
+  [
+    if test -f "$withval" && test -x "$withval"; then
+      with_libganglia_config="$withval"
+      with_libganglia="yes"
+    else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"; then
+      with_libganglia_config="$withval/bin/ganglia-config"
+      with_libganglia="yes"
+    else if test -d "$withval"; then
+      GANGLIA_CPPFLAGS="-I$withval/include"
+      GANGLIA_LDFLAGS="-L$withval/lib"
+      with_libganglia="yes"
+    else
+      with_libganglia="$withval"
+    fi; fi; fi
+  ],
+  [with_libganglia="yes"]
+)
 
-if test "x$with_libganglia" = "xyes"
-then
-       if test "x$with_libganglia_config" != "x"
-       then
-               if test "x$GANGLIA_CPPFLAGS" = "x"
-               then
-                       GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
-               fi
-
-               if test "x$GANGLIA_LDFLAGS" = "x"
-               then
-                       GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
-               fi
-
-               if test "x$GANGLIA_LIBS" = "x"
-               then
-                       GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
-               fi
-       else
-               GANGLIA_LIBS="-lganglia"
-       fi
+if test "x$with_libganglia" = "xyes"; then
+  if test "x$with_libganglia_config" != "x"; then
+    if test "x$GANGLIA_CPPFLAGS" = "x"; then
+      GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
+    fi
+
+    if test "x$GANGLIA_LDFLAGS" = "x"; then
+      GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
+    fi
+
+    if test "x$GANGLIA_LIBS" = "x"; then
+      GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
+    fi
+  else
+    GANGLIA_LIBS="-lganglia"
+  fi
 fi
 
 SAVE_CPPFLAGS="$CPPFLAGS"
@@ -2338,22 +2482,18 @@ SAVE_LDFLAGS="$LDFLAGS"
 CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
 LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
 
-if test "x$with_libganglia" = "xyes"
-then
-       AC_CHECK_HEADERS(gm_protocol.h,
-       [
-               AC_DEFINE(HAVE_GM_PROTOCOL_H, 1,
-                         [Define to 1 if you have the <gm_protocol.h> header file.])
-       ], [with_libganglia="no (gm_protocol.h not found)"])
+if test "x$with_libganglia" = "xyes"; then
+  AC_CHECK_HEADERS([gm_protocol.h],
+    [with_libganglia="yes"],
+    [with_libganglia="no (gm_protocol.h not found)"]
+  )
 fi
 
-if test "x$with_libganglia" = "xyes"
-then
-       AC_CHECK_LIB(ganglia, xdr_Ganglia_value_msg,
-       [
-               AC_DEFINE(HAVE_LIBGANGLIA, 1,
-                         [Define to 1 if you have the ganglia library (-lganglia).])
-       ], [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"])
+if test "x$with_libganglia" = "xyes"; then
+  AC_CHECK_LIB([ganglia], [xdr_Ganglia_value_msg],
+    [with_libganglia="yes"],
+    [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"]
+  )
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
@@ -2362,49 +2502,44 @@ LDFLAGS="$SAVE_LDFLAGS"
 AC_SUBST(GANGLIA_CPPFLAGS)
 AC_SUBST(GANGLIA_LDFLAGS)
 AC_SUBST(GANGLIA_LIBS)
-AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
 # }}}
 
 # --with-libgcrypt {{{
 GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
 GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
 GCRYPT_LIBS="$GCRYPT_LIBS"
-AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
-[
- if test -f "$withval" && test -x "$withval"
- then
-        with_libgcrypt_config="$withval"
-        with_libgcrypt="yes"
- else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
- then
-        with_libgcrypt_config="$withval/bin/gcrypt-config"
-        with_libgcrypt="yes"
- else if test -d "$withval"
- then
-        GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
-        GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
-        with_libgcrypt="yes"
- else
-        with_libgcrypt_config="gcrypt-config"
-        with_libgcrypt="$withval"
- fi; fi; fi
-],
-[
- with_libgcrypt_config="libgcrypt-config"
- with_libgcrypt="yes"
-])
+AC_ARG_WITH([libgcrypt],
+  [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
+  [
+    if test -f "$withval" && test -x "$withval"; then
+      with_libgcrypt_config="$withval"
+      with_libgcrypt="yes"
+    else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"; then
+      with_libgcrypt_config="$withval/bin/gcrypt-config"
+      with_libgcrypt="yes"
+    else if test -d "$withval"; then
+      GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
+      GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
+      with_libgcrypt="yes"
+    else
+      with_libgcrypt_config="gcrypt-config"
+      with_libgcrypt="$withval"
+    fi; fi; fi
+  ],
+  [
+    with_libgcrypt_config="libgcrypt-config"
+    with_libgcrypt="yes"
+  ]
+)
 
-if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
-then
-       if test "x$GCRYPT_CPPFLAGS" = "x"
-       then
-               GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
-       fi
+if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"; then
+  if test "x$GCRYPT_CPPFLAGS" = "x"; then
+    GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
+  fi
 
-       if test "x$GCRYPT_LIBS" = "x"
-       then
-               GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
-       fi
+  if test "x$GCRYPT_LIBS" = "x"; then
+    GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
+  fi
 fi
 
 SAVE_CPPFLAGS="$CPPFLAGS"
@@ -2414,118 +2549,108 @@ CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
 LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
 LIBS="$LIBS $GCRYPT_LIBS"
 
-if test "x$with_libgcrypt" = "xyes"
-then
-       if test "x$GCRYPT_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(gcrypt.h,
-               [with_libgcrypt="yes"],
-               [with_libgcrypt="no (gcrypt.h not found)"])
+if test "x$with_libgcrypt" = "xyes"; then
+  if test "x$GCRYPT_CPPFLAGS" != "x"; then
+    AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
+  fi
+  AC_CHECK_HEADERS([gcrypt.h],
+    [with_libgcrypt="yes"],
+    [with_libgcrypt="no (gcrypt.h not found)"]
+  )
 fi
 
-if test "x$with_libgcrypt" = "xyes"
-then
-       AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
-               [with_libgcrypt="yes"],
-               [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
+if test "x$with_libgcrypt" = "xyes"; then
+  AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
+    [with_libgcrypt="yes"],
+    [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"]
+  )
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
 LDFLAGS="$SAVE_LDFLAGS"
 LIBS="$SAVE_LIBS"
 
-if test "x$with_libgcrypt" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to 1 if you have the gcrypt library (-lgcrypt).])
-fi
-
-AC_SUBST(GCRYPT_CPPFLAGS)
-AC_SUBST(GCRYPT_LDFLAGS)
-AC_SUBST(GCRYPT_LIBS)
-AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
+AC_SUBST([GCRYPT_CPPFLAGS])
+AC_SUBST([GCRYPT_LDFLAGS])
+AC_SUBST([GCRYPT_LIBS])
+AM_CONDITIONAL([BUILD_WITH_LIBGCRYPT], [test "x$with_libgcrypt" = "xyes"])
 # }}}
 
 # --with-libgps {{{
-with_libgps_cflags=""
-with_libgps_ldflags=""
-AC_ARG_WITH(libgps, [AS_HELP_STRING([--with-libgps@<:@=PREFIX@:>@], [Path to libgps.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libgps_cflags="-I$withval/include"
-               with_libgps_ldflags="-L$withval/lib"
-               with_libgps="yes"
-       else
-               with_libgps="$withval"
-       fi
-],
-[
-       with_libgps="yes"
-])
-if test "x$with_libgps" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       CFLAGS="$CFLAGS $with_libgps_cflags"
+AC_ARG_WITH([libgps],
+  [AS_HELP_STRING([--with-libgps@<:@=PREFIX@:>@], [Path to libgps.])],
+  [
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+      with_libgps_cflags="-I$withval/include"
+      with_libgps_ldflags="-L$withval/lib"
+      with_libgps="yes"
+    else
+      with_libgps="$withval"
+    fi
+  ],
+  [with_libgps="yes"]
+)
 
-       AC_CHECK_HEADERS(gps.h, [with_libgps="yes"], [with_libgps="no (gps.h not found)"])
+if test "x$with_libgps" = "xyes"; then
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS $with_libgps_cflags"
+
+  AC_CHECK_HEADERS([gps.h],
+    [with_libgps="yes"],
+    [with_libgps="no (gps.h not found)"]
+  )
 
-       CFLAGS="$SAVE_CFLAGS"
+  CFLAGS="$SAVE_CFLAGS"
 fi
-if test "x$with_libgps" = "xyes"
-then
-       SAVE_CFLAGS="$CFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CFLAGS="$CFLAGS $with_libgps_cflags"
-       LDFLAGS="$LDFLAGS $with_libgps_ldflags"
 
-       AC_CHECK_LIB(gps, gps_open, [with_libgps="yes"], [with_libgps="no (symbol gps_open not found)"])
+if test "x$with_libgps" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_libgps_ldflags"
+
+  AC_CHECK_LIB([gps], [gps_open],
+    [with_libgps="yes"],
+    [with_libgps="no (symbol gps_open not found)"]
+  )
+
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
 
-       CFLAGS="$SAVE_CFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
+if test "x$with_libgps" = "xyes"; then
+  BUILD_WITH_LIBGPS_CFLAGS="$with_libgps_cflags"
+  BUILD_WITH_LIBGPS_LDFLAGS="$with_libgps_ldflags"
+  BUILD_WITH_LIBGPS_LIBS="-lgps"
 fi
-if test "x$with_libgps" = "xyes"
-then
-       BUILD_WITH_LIBGPS_CFLAGS="$with_libgps_cflags"
-       BUILD_WITH_LIBGPS_LDFLAGS="$with_libgps_ldflags"
-       BUILD_WITH_LIBGPS_LIBS="-lgps"
-       AC_SUBST(BUILD_WITH_LIBGPS_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBGPS_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBGPS_LIBS)
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBGPS, test "x$with_libgps" = "xyes")
+
+AC_SUBST([BUILD_WITH_LIBGPS_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBGPS_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBGPS_LIBS])
+
 # }}}
 
 # --with-libgrpc++ {{{
-with_libgrpcpp_cppflags=""
-with_libgrpcpp_ldflags=""
-AC_ARG_WITH([libgrpc++], [AS_HELP_STRING([--with-libgrpc++@<:@=PREFIX@:>@], [Path to libgrpc++.])],
+AC_ARG_WITH([libgrpc++],
+  [AS_HELP_STRING([--with-libgrpc++@<:@=PREFIX@:>@], [Path to libgrpc++.])],
   [
     with_grpcpp="$withval"
-    if test "x$withval" != "xno" && test "x$withval" != "xyes"
-    then
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
       with_libgrpcpp_cppflags="-I$withval/include"
       with_libgrpcpp_ldflags="-L$withval/lib"
       with_libgrpcpp="yes"
     fi
-    if test "x$withval" = "xno"
-    then
+    if test "x$withval" = "xno"; then
       with_libgrpcpp="no (disabled on command line)"
     fi
   ],
   [withval="yes"]
 )
-if test "x$withval" = "xyes"
-then
+if test "x$withval" = "xyes"; then
 PKG_CHECK_MODULES([GRPCPP], [grpc++],
   [with_libgrpcpp="yes"],
   [with_libgrpcpp="no (pkg-config could not find libgrpc++)"]
 )
 fi
 
-if test "x$withval" != "xno"
-then
+if test "x$withval" != "xno"; then
   AC_MSG_CHECKING([whether $CXX accepts -std=c++11])
   if test_cxx_flags -std=c++11; then
     AC_MSG_RESULT([yes])
@@ -2535,40 +2660,40 @@ then
   fi
 fi
 
-if test "x$with_libgrpcpp" = "xyes"
-then
+if test "x$with_libgrpcpp" = "xyes"; then
   AC_LANG_PUSH(C++)
   SAVE_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS"
-  AC_CHECK_HEADERS([grpc++/grpc++.h], [],
+  AC_CHECK_HEADERS([grpc++/grpc++.h],
+    [with_libgrpcpp="yes"],
     [with_libgrpcpp="no (<grpc++/grpc++.h> not found)"]
   )
   CPPFLAGS="$SAVE_CPPFLAGS"
   AC_LANG_POP(C++)
 fi
-if test "x$with_libgrpcpp" = "xyes"
-then
+
+if test "x$with_libgrpcpp" = "xyes"; then
   AC_LANG_PUSH(C++)
   SAVE_CPPFLAGS="$CPPFLAGS"
   SAVE_LDFLAGS="$LDFLAGS"
   SAVE_LIBS="$LIBS"
   CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS"
   LDFLAGS="$with_libgrpcpp_ldflags"
-  if test "x$GRPCPP_LIBS" = "x"
-  then
+  if test "x$GRPCPP_LIBS" = "x"; then
     LIBS="-lgrpc++"
   else
     LIBS="$GRPCPP_LIBS"
   fi
   AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM(
-      [[#include <grpc++/grpc++.h>]],
-      [[grpc::ServerBuilder sb;]]
-    )],
+    [
+      AC_LANG_PROGRAM(
+        [[#include <grpc++/grpc++.h>]],
+        [[grpc::ServerBuilder sb;]]
+      )
+    ],
     [
       with_libgrpcpp="yes"
-      if test "x$GRPCPP_LIBS" = "x"
-      then
+      if test "x$GRPCPP_LIBS" = "x"; then
         GRPCPP_LIBS="-lgrpc++"
       fi
     ],
@@ -2579,6 +2704,7 @@ then
   LIBS="$SAVE_LIBS"
   AC_LANG_POP(C++)
 fi
+
 BUILD_WITH_LIBGRPCPP_CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS"
 BUILD_WITH_LIBGRPCPP_LDFLAGS="$with_libgrpcpp_ldflags"
 BUILD_WITH_LIBGRPCPP_LIBS="$GRPCPP_LIBS"
@@ -2587,302 +2713,219 @@ AC_SUBST([BUILD_WITH_LIBGRPCPP_LDFLAGS])
 AC_SUBST([BUILD_WITH_LIBGRPCPP_LIBS])
 # }}}
 
+AC_ARG_VAR([GRPC_CPP_PLUGIN], [path to the grpc_cpp_plugin binary])
+AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin])
+AM_CONDITIONAL([HAVE_GRPC_CPP], [test "x$GRPC_CPP_PLUGIN" != "x"])
+
 # --with-libiptc {{{
-AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
-[
-       if test "x$withval" = "xyes"
-       then
-               with_libiptc="pkgconfig"
-       else if test "x$withval" = "xno"
-       then
-               with_libiptc="no"
-       else
-               with_libiptc="yes"
-               with_libiptc_cflags="-I$withval/include"
-               with_libiptc_libs="-L$withval/lib"
-       fi; fi
-],
-[
-       if test "x$ac_system" = "xLinux"
-       then
-               with_libiptc="pkgconfig"
-       else
-               with_libiptc="no (Linux only)"
-       fi
-])
+AC_ARG_WITH([libiptc],
+  [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
+  [
+    if test "x$withval" = "xyes"; then
+      with_libiptc="pkgconfig"
+    else if test "x$withval" = "xno"; then
+      with_libiptc="no"
+    else
+      with_libiptc="yes"
+      with_libiptc_cflags="-I$withval/include"
+      with_libiptc_libs="-L$withval/lib"
+    fi; fi
+  ],
+  [
+    if test "x$ac_system" = "xLinux"; then
+      with_libiptc="pkgconfig"
+    else
+      with_libiptc="no (Linux only)"
+    fi
+  ]
+)
 
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       $PKG_CONFIG --exists 'libiptc' 2>/dev/null
-       if test $? -ne 0
-       then
-               with_libiptc="no (pkg-config doesn't know libiptc)"
-       fi
+if test "x$with_libiptc" = "xpkgconfig"; then
+  $PKG_CONFIG --exists 'libiptc' 2>/dev/null
+  if test $? -ne 0; then
+    with_libiptc="no (pkg-config doesn't know libiptc)"
+  fi
 fi
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
-       if test $? -ne 0
-       then
-               with_libiptc="no ($PKG_CONFIG failed)"
-       fi
-       with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
-       if test $? -ne 0
-       then
-               with_libiptc="no ($PKG_CONFIG failed)"
-       fi
+
+if test "x$with_libiptc" = "xpkgconfig"; then
+  with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
+  if test $? -ne 0; then
+    with_libiptc="no ($PKG_CONFIG failed)"
+  fi
+
+  with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
+  if test $? -ne 0; then
+    with_libiptc="no ($PKG_CONFIG failed)"
+  fi
 fi
 
 SAVE_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS $with_libiptc_cflags"
 
 # check whether the header file for libiptc is available.
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       AC_CHECK_HEADERS(libiptc/libiptc.h libiptc/libip6tc.h, ,
-                       [with_libiptc="no (header file missing)"])
+if test "x$with_libiptc" = "xpkgconfig"; then
+  AC_CHECK_HEADERS([libiptc/libiptc.h libiptc/libip6tc.h],
+    [],
+    [with_libiptc="no (header file missing)"]
+  )
 fi
+
 # If the header file is available, check for the required type declaractions.
 # They may be missing in old versions of libiptc. In that case, they will be
 # declared in the iptables plugin.
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
+if test "x$with_libiptc" = "xpkgconfig"; then
+  AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
 fi
+
 # Check for the iptc_init symbol in the library.
 # This could be in iptc or ip4tc
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       SAVE_LIBS="$LIBS"
-       AC_SEARCH_LIBS(iptc_init, [iptc ip4tc],
-                       [with_libiptc="pkgconfig"],
-                       [with_libiptc="no"],
-                       [$with_libiptc_libs])
-       LIBS="$SAVE_LIBS"
-fi
-if test "x$with_libiptc" = "xpkgconfig"
-then
-       with_libiptc="yes"
+if test "x$with_libiptc" = "xpkgconfig"; then
+  SAVE_LIBS="$LIBS"
+  AC_SEARCH_LIBS([iptc_init], [iptc ip4tc],
+    [with_libiptc="pkgconfig"],
+    [with_libiptc="no"],
+    [$with_libiptc_libs]
+  )
+  LIBS="$SAVE_LIBS"
+fi
+
+if test "x$with_libiptc" = "xpkgconfig"; then
+  with_libiptc="yes"
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
 
-AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
-if test "x$with_libiptc" = "xyes"
-then
-       BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
-       BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
-       AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
+if test "x$with_libiptc" = "xyes"; then
+  BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
+  BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
 fi
+AC_SUBST([BUILD_WITH_LIBIPTC_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBIPTC_LDFLAGS])
 # }}}
 
-# --with-libdpdk {{{
-AC_ARG_VAR([LIBDPDK_CPPFLAGS], [Preprocessor flags for libdpdk])
-AC_ARG_VAR([LIBDPDK_CFLAGS], [Compiler flags for libdpdk])
-AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
-AC_ARG_VAR([LIBDPDK_LIBS], [Libraries to link for libdpdk])
+# --with-java {{{
+with_java_home="$JAVA_HOME"
+if test "x$with_java_home" = "x"; then
+  with_java_home="/usr/lib/jvm"
+fi
 
-AC_ARG_WITH([libdpdk],
-  [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])],
-  [with_libdpdk="$withval"],
-  [with_libdpdk="yes"]
+JAVAC="$JAVAC"
+JAR="$JAR"
+AC_ARG_WITH([java],
+  [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
+  [
+    if test "x$withval" = "xno"; then
+      with_java="no"
+    else if test "x$withval" = "xyes"; then
+      with_java="yes"
+    else
+      with_java_home="$withval"
+      with_java="yes"
+    fi; fi
+  ],
+  [with_java="yes"]
 )
 
-if test "x$with_libdpdk" != "xno"; then
-  PKG_CHECK_MODULES([DPDK], [libdpdk], [],
-                   [AC_MSG_NOTICE([no DPDK pkg-config, using defaults])])
-  if test "x$LIBDPDK_CPPFLAGS" = "x"; then
-    LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
-  fi
-  if test "x$LIBDPDK_CFLAGS" = "x"; then
-      LIBDPDK_CFLAGS="$DPDK_CFLAGS"
-      LIBDPDK_CPPFLAGS="$LIBDPDK_CPPFLAGS $DPDK_CFLAGS"
-  fi
-  if test "x$LIBDPDK_LIBS" = "x"; then
-      if test "x$DPDK_LIBS" != "x"; then
-          LIBDPDK_LIBS="$DPDK_LIBS"
+AX_COMPARE_VERSION([$am__api_version],[lt],[1.12],
+  [JAVA_TIMESTAMP_FILE="classdist_noinst.stamp"],
+  [JAVA_TIMESTAMP_FILE="classnoinst.stamp"])
+if test "x$with_java" = "xyes"; then
+  if test -d "$with_java_home"; then
+    AC_MSG_CHECKING([for jni.h])
+    TMPVAR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
+    if test "x$TMPVAR" != "x"; then
+      AC_MSG_RESULT([found in $TMPVAR])
+      JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
+    else
+      AC_MSG_RESULT([not found])
+    fi
+
+    AC_MSG_CHECKING([for jni_md.h])
+    TMPVAR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
+    if test "x$TMPVAR" != "x"; then
+      AC_MSG_RESULT([found in $TMPVAR])
+      JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
+    else
+      AC_MSG_RESULT([not found])
+    fi
+
+    AC_MSG_CHECKING([for libjvm.so])
+    TMPVAR=`find -L "$with_java_home" -type f \( -name libjvm.so -o -name libjvm.dylib \) -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
+    if test "x$TMPVAR" != "x"; then
+      AC_MSG_RESULT([found in $TMPVAR])
+      JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
+    else
+      AC_MSG_RESULT([not found])
+    fi
+
+    if test "x$JAVAC" = "x"; then
+      AC_MSG_CHECKING([for javac])
+      TMPVAR=`find -L "$with_java_home" -name javac -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
+      if test "x$TMPVAR" != "x"; then
+        JAVAC="$TMPVAR"
+        AC_MSG_RESULT([$JAVAC])
       else
-          LIBDPDK_LIBS="-ldpdk"
+        AC_MSG_RESULT([not found])
       fi
-  fi
-  SAVE_CPPFLAGS="$CPPFLAGS"
-  CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
-  SAVE_CFLAGS="$CFLAGS"
-  CFLAGS="$LIBDPDK_CFLAGS $CFLAGS"
-  AC_CHECK_HEADERS([rte_config.h],
-    [
-      with_libdpdk="yes"
-      AC_PREPROC_IFELSE(
-        [
-          AC_LANG_SOURCE(
-            [[
-              #include <rte_version.h>
-              #if RTE_VERSION < RTE_VERSION_NUM(16,7,0,0)
-              #error "required DPDK >= 16.07"
-              #endif
-            ]]
-          )
-        ],
-        [dpdk_keepalive="yes"],
-        [dpdk_keepalive="no (DPDK version < 16.07)"]
-      )
-    ],
-    [with_libdpdk="no (rte_config.h not found)"]
-  )
-  CPPFLAGS="$SAVE_CPPFLAGS"
-  CFLAGS="$SAVE_CFLAGS"
-fi
+    fi
 
-if test "x$with_libdpdk" = "xyes"; then
-  SAVE_LDFLAGS="$LDFLAGS"
-  LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
-  AC_CHECK_LIB([dpdk], [rte_eal_init],
-    [with_libdpdk="yes"],
-    [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
-  )
-  LDFLAGS="$SAVE_LDFLAGS"
+    if test "x$JAR" = "x"; then
+      AC_MSG_CHECKING([for jar])
+      TMPVAR=`find -L "$with_java_home" -name jar -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
+      if test "x$TMPVAR" != "x"; then
+        JAR="$TMPVAR"
+        AC_MSG_RESULT([$JAR])
+      else
+        AC_MSG_RESULT([not found])
+      fi
+    fi
+  else if test "x$with_java_home" != "x"; then
+    AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
+  fi; fi
 fi
 
-# }}}
-
-# --with-java {{{
-with_java_home="$JAVA_HOME"
-if test "x$with_java_home" = "x"
-then
-       with_java_home="/usr/lib/jvm"
+if test "x$JAVA_CPPFLAGS" != "x"; then
+  AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
 fi
-JAVAC="$JAVAC"
-JAR="$JAR"
-AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_java="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_java="yes"
-       else
-               with_java_home="$withval"
-               with_java="yes"
-       fi; fi
-],
-[with_java="yes"])
-if test "x$with_java" = "xyes"
-then
-       if test -d "$with_java_home"
-       then
-               AC_MSG_CHECKING([for jni.h])
-               TMPVAR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
-               if test "x$TMPVAR" != "x"
-               then
-                       AC_MSG_RESULT([found in $TMPVAR])
-                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
-               else
-                       AC_MSG_RESULT([not found])
-               fi
-
-               AC_MSG_CHECKING([for jni_md.h])
-               TMPVAR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
-               if test "x$TMPVAR" != "x"
-               then
-                       AC_MSG_RESULT([found in $TMPVAR])
-                       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
-               else
-                       AC_MSG_RESULT([not found])
-               fi
-
-               AC_MSG_CHECKING([for libjvm.so])
-               TMPVAR=`find -L "$with_java_home" -type f \( -name libjvm.so -o -name libjvm.dylib \) -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
-               if test "x$TMPVAR" != "x"
-               then
-                       AC_MSG_RESULT([found in $TMPVAR])
-                       JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
-               else
-                       AC_MSG_RESULT([not found])
-               fi
-
-               if test "x$JAVAC" = "x"
-               then
-                       AC_MSG_CHECKING([for javac])
-                       TMPVAR=`find -L "$with_java_home" -name javac -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
-                       if test "x$TMPVAR" != "x"
-                       then
-                               JAVAC="$TMPVAR"
-                               AC_MSG_RESULT([$JAVAC])
-                       else
-                               AC_MSG_RESULT([not found])
-                       fi
-               fi
-               if test "x$JAR" = "x"
-               then
-                       AC_MSG_CHECKING([for jar])
-                       TMPVAR=`find -L "$with_java_home" -name jar -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
-                       if test "x$TMPVAR" != "x"
-                       then
-                               JAR="$TMPVAR"
-                               AC_MSG_RESULT([$JAR])
-                       else
-                               AC_MSG_RESULT([not found])
-                       fi
-               fi
-       else if test "x$with_java_home" != "x"
-       then
-               AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
-       fi; fi
-fi
-
-if test "x$JAVA_CPPFLAGS" != "x"
-then
-       AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
+if test "x$JAVA_CFLAGS" != "x"; then
+  AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
 fi
-if test "x$JAVA_CFLAGS" != "x"
-then
-       AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
+if test "x$JAVA_LDFLAGS" != "x"; then
+  AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
 fi
-if test "x$JAVA_LDFLAGS" != "x"
-then
-       AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
+if test "x$JAVA_LIBS" != "x"; then
+  AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
 fi
-if test "x$JAVA_LIBS" != "x"
-then
-       AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
+if test "x$JAVAC" = "x"; then
+  with_javac_path="$PATH"
+  if test "x$with_java_home" != "x"; then
+    with_javac_path="$with_java_home:with_javac_path"
+    if test -d "$with_java_home/bin"; then
+      with_javac_path="$with_java_home/bin:with_javac_path"
+    fi
+  fi
+
+  AC_PATH_PROG([JAVAC], [javac], [], "$with_javac_path")
 fi
-if test "x$JAVAC" = "x"
-then
-       with_javac_path="$PATH"
-       if test "x$with_java_home" != "x"
-       then
-               with_javac_path="$with_java_home:with_javac_path"
-               if test -d "$with_java_home/bin"
-               then
-                       with_javac_path="$with_java_home/bin:with_javac_path"
-               fi
-       fi
-
-       AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
-fi
-if test "x$JAVAC" = "x"
-then
-       with_java="no (javac not found)"
+
+if test "x$JAVAC" = "x"; then
+  with_java="no (javac not found)"
 fi
-if test "x$JAR" = "x"
-then
-       with_jar_path="$PATH"
-       if test "x$with_java_home" != "x"
-       then
-               with_jar_path="$with_java_home:$with_jar_path"
-               if test -d "$with_java_home/bin"
-               then
-                       with_jar_path="$with_java_home/bin:$with_jar_path"
-               fi
-       fi
-
-       AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
-fi
-if test "x$JAR" = "x"
-then
-       with_java="no (jar not found)"
+
+if test "x$JAR" = "x"; then
+  with_jar_path="$PATH"
+  if test "x$with_java_home" != "x"; then
+    with_jar_path="$with_java_home:$with_jar_path"
+    if test -d "$with_java_home/bin"; then
+      with_jar_path="$with_java_home/bin:$with_jar_path"
+    fi
+  fi
+
+  AC_PATH_PROG([JAR], [jar], [], "$with_jar_path")
+fi
+
+if test "x$JAR" = "x"; then
+  with_java="no (jar not found)"
 fi
 
 SAVE_CPPFLAGS="$CPPFLAGS"
@@ -2894,21 +2937,23 @@ CFLAGS="$CFLAGS $JAVA_CFLAGS"
 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
 LIBS="$LIBS $JAVA_LIBS"
 
-if test "x$with_java" = "xyes"
-then
-       AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
+if test "x$with_java" = "xyes"; then
+  AC_CHECK_HEADERS([jni.h],
+    [with_jave="yes"],
+    [with_java="no (jni.h not found)"])
 fi
-if test "x$with_java" = "xyes"
-then
-       AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
-       [with_java="yes"],
-       [with_java="no (Symbol 'JNI_CreateJavaVM' not found)"],
-       [$JAVA_LIBS $PTHREAD_LIBS])
+
+if test "x$with_java" = "xyes"; then
+  AC_CHECK_LIB([jvm], [JNI_CreateJavaVM],
+    [with_java="yes"],
+    [with_java="no (Symbol 'JNI_CreateJavaVM' not found)"],
+    [$JAVA_LIBS $PTHREAD_LIBS]
+  )
 fi
-if test "x$with_java" = "xyes"
-then
-       JAVA_LIBS="$JAVA_LIBS -ljvm"
-       AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
+
+if test "x$with_java" = "xyes"; then
+  JAVA_LIBS="$JAVA_LIBS -ljvm"
+  AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
@@ -2916,29 +2961,30 @@ CFLAGS="$SAVE_CFLAGS"
 LDFLAGS="$SAVE_LDFLAGS"
 LIBS="$SAVE_LIBS"
 
-AC_SUBST(JAVA_CPPFLAGS)
-AC_SUBST(JAVA_CFLAGS)
-AC_SUBST(JAVA_LDFLAGS)
-AC_SUBST(JAVA_LIBS)
-AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
+AC_SUBST([JAVA_CPPFLAGS])
+AC_SUBST([JAVA_CFLAGS])
+AC_SUBST([JAVA_LDFLAGS])
+AC_SUBST([JAVA_LIBS])
+AC_SUBST([JAVA_TIMESTAMP_FILE])
+AM_CONDITIONAL([BUILD_WITH_JAVA], [test "x$with_java" = "xyes"])
 # }}}
 
 # --with-libldap {{{
-AC_ARG_WITH(libldap, [AS_HELP_STRING([--with-libldap@<:@=PREFIX@:>@], [Path to libldap.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_libldap="yes"
- else if test "x$withval" = "xno"
- then
-        with_libldap="no"
- else
-        with_libldap="yes"
-        LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS -I$withval/include"
-        LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS -L$withval/lib"
- fi; fi
-],
-[with_libldap="yes"])
+AC_ARG_WITH([libldap],
+  [AS_HELP_STRING([--with-libldap@<:@=PREFIX@:>@], [Path to libldap.])],
+  [
   if test "x$withval" = "xyes"; then
+      with_libldap="yes"
+    else if test "x$withval" = "xno"; then
+      with_libldap="no"
+    else
+      with_libldap="yes"
+      LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS -I$withval/include"
+      LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS -L$withval/lib"
+    fi; fi
+  ],
+  [with_libldap="yes"]
+)
 
 SAVE_CPPFLAGS="$CPPFLAGS"
 SAVE_LDFLAGS="$LDFLAGS"
@@ -2946,26 +2992,26 @@ SAVE_LDFLAGS="$LDFLAGS"
 CPPFLAGS="$CPPFLAGS $LIBLDAP_CPPFLAGS"
 LDFLAGS="$LDFLAGS $LIBLDAP_LDFLAGS"
 
-if test "x$with_libldap" = "xyes"
-then
-       if test "x$LIBLDAP_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libldap CPPFLAGS: $LIBLDAP_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(ldap.h,
-       [with_libldap="yes"],
-       [with_libldap="no ('ldap.h' not found)"])
+if test "x$with_libldap" = "xyes"; then
+  if test "x$LIBLDAP_CPPFLAGS" != "x"; then
+    AC_MSG_NOTICE([libldap CPPFLAGS: $LIBLDAP_CPPFLAGS])
+  fi
+
+  AC_CHECK_HEADERS([ldap.h],
+    [with_libldap="yes"],
+    [with_libldap="no ('ldap.h' not found)"]
+  )
 fi
-if test "x$with_libldap" = "xyes"
-then
-       if test "x$LIBLDAP_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libldap LDFLAGS: $LIBLDAP_LDFLAGS])
-       fi
-       AC_CHECK_LIB(ldap, ldap_initialize,
-       [with_libldap="yes"],
-       [with_libldap="no (symbol 'ldap_initialize' not found)"])
 
+if test "x$with_libldap" = "xyes"; then
+  if test "x$LIBLDAP_LDFLAGS" != "x"; then
+    AC_MSG_NOTICE([libldap LDFLAGS: $LIBLDAP_LDFLAGS])
+  fi
+
+  AC_CHECK_LIB([ldap], [ldap_initialize],
+    [with_libldap="yes"],
+    [with_libldap="no (symbol 'ldap_initialize' not found)"]
+  )
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
@@ -2973,12 +3019,11 @@ LDFLAGS="$SAVE_LDFLAGS"
 
 if test "x$with_libldap" = "xyes"
 then
-       BUILD_WITH_LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS"
-       BUILD_WITH_LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBLDAP_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBLDAP_LDFLAGS)
+  BUILD_WITH_LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS"
+  BUILD_WITH_LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBLDAP, test "x$with_libldap" = "xyes")
+AC_SUBST([BUILD_WITH_LIBLDAP_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBLDAP_LDFLAGS])
 # }}}
 
 # --with-liblua {{{
@@ -2996,7 +3041,7 @@ else
       PKG_CHECK_MODULES([LUA], [lua-5.3],
         [with_liblua="yes"],
         [
-         PKG_CHECK_MODULES([LUA], [lua5.3],
+          PKG_CHECK_MODULES([LUA], [lua5.3],
             [with_liblua="yes"],
             [
               PKG_CHECK_MODULES([LUA], [lua-5.2],
@@ -3062,114 +3107,117 @@ AC_SUBST(BUILD_WITH_LIBLUA_LIBS)
 # }}}
 
 # --with-liblvm2app {{{
-with_liblvm2app_cppflags=""
-with_liblvm2app_ldflags=""
-AC_ARG_WITH(liblvm2app, [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_liblvm2app="no"
-       else
-               with_liblvm2app="yes"
-               if test "x$withval" != "xyes"
-               then
-                       with_liblvm2app_cppflags="-I$withval/include"
-                       with_liblvm2app_ldflags="-L$withval/lib"
-               fi
-        fi
-],
-[
-       if test "x$ac_system" = "xLinux"
-       then
-               with_liblvm2app="yes"
-       else
-               with_liblvm2app="no (Linux only library)"
-       fi
-])
-if test "x$with_liblvm2app" = "xyes"
-then
-        SAVE_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
+AC_ARG_WITH([liblvm2app],
+  [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
+  [
+    if test "x$withval" = "xno"; then
+      with_liblvm2app="no"
+    else
+      with_liblvm2app="yes"
+      if test "x$withval" != "xyes"; then
+        with_liblvm2app_cppflags="-I$withval/include"
+        with_liblvm2app_ldflags="-L$withval/lib"
+      fi
+    fi
+  ],
+  [
+    if test "x$ac_system" = "xLinux"; then
+      with_liblvm2app="yes"
+    else
+      with_liblvm2app="no (Linux only library)"
+    fi
+  ]
+)
+
+if test "x$with_liblvm2app" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
 
-        AC_CHECK_HEADERS(lvm2app.h, [with_liblvm2app="yes"], [with_liblvm2app="no (lvm2app.h not found)"])
+  AC_CHECK_HEADERS([lvm2app.h],
+    [with_liblvm2app="yes"],
+    [with_liblvm2app="no (lvm2app.h not found)"]
+  )
 
-        CPPFLAGS="$SAVE_CPPFLAGS"
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
 
-if test "x$with_liblvm2app" = "xyes"
-then
-        SAVE_CPPFLAGS="$CPPFLAGS"
-        SAVE_LDFLAGS="$LDFLAGS"
-        CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
-        LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
+if test "x$with_liblvm2app" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  SAVE_LDFLAGS="$LDFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
+  LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
+
+  AC_CHECK_LIB([lvm2app], [lvm_lv_get_property],
+    [with_liblvm2app="yes"],
+    [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"]
+  )
 
-        AC_CHECK_LIB(lvm2app, lvm_lv_get_property, [with_liblvm2app="yes"], [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"])
+  CPPFLAGS="$SAVE_CPPFLAGS"
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
 
-        CPPFLAGS="$SAVE_CPPFLAGS"
-        LDFLAGS="$SAVE_LDFLAGS"
+if test "x$with_liblvm2app" = "xyes"; then
+  BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
+  BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
+  BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
 fi
-if test "x$with_liblvm2app" = "xyes"
-then
-        BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
-        BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
-        BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
-        AC_SUBST(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
-        AC_SUBST(BUILD_WITH_LIBLVM2APP_LDFLAGS)
-        AC_SUBST(BUILD_WITH_LIBLVM2APP_LIBS)
-        AC_DEFINE(HAVE_LIBLVM2APP, 1, [Define if liblvm2app is present and usable.])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBLVM2APP, test "x$with_liblvm2app" = "xyes")
+
+AC_SUBST([BUILD_WITH_LIBLVM2APP_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBLVM2APP_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBLVM2APP_LIBS])
 # }}}
 
 # --with-libmemcached {{{
-with_libmemcached_cppflags=""
-with_libmemcached_ldflags=""
-AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libmemcached_cppflags="-I$withval/include"
-               with_libmemcached_ldflags="-L$withval/lib"
-               with_libmemcached="yes"
-       else
-               with_libmemcached="$withval"
-       fi
-],
-[
-       with_libmemcached="yes"
-])
-if test "x$with_libmemcached" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
+AC_ARG_WITH([libmemcached],
+  [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
+  [
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+      with_libmemcached_cppflags="-I$withval/include"
+      with_libmemcached_ldflags="-L$withval/lib"
+      with_libmemcached="yes"
+    else
+      with_libmemcached="$withval"
+    fi
+  ],
+  [with_libmemcached="yes"]
+)
+
+if test "x$with_libmemcached" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
 
-       AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
+  AC_CHECK_HEADERS([libmemcached/memcached.h],
+    [with_libmemcached="yes"],
+    [with_libmemcached="no (libmemcached/memcached.h not found)"]
+  )
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libmemcached" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
-       LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
 
-       AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
+if test "x$with_libmemcached" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  SAVE_LDFLAGS="$LDFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
+  LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
+
+  AC_CHECK_LIB([memcached], [memcached_create],
+    [with_libmemcached="yes"],
+    [with_libmemcached="no (Symbol 'memcached_create' not found)"]
+  )
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
+  CPPFLAGS="$SAVE_CPPFLAGS"
+  LDFLAGS="$SAVE_LDFLAGS"
 fi
-if test "x$with_libmemcached" = "xyes"
-then
-       BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
-       BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
-       BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
-       AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
-       AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
+
+if test "x$with_libmemcached" = "xyes"; then
+  BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
+  BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
+  BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
+fi
+
+AC_SUBST([BUILD_WITH_LIBMEMCACHED_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBMEMCACHED_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBMEMCACHED_LIBS])
 # }}}
 
 # --with-libmicrohttpd {{{
@@ -3177,29 +3225,25 @@ with_libmicrohttpd_cppflags=""
 with_libmicrohttpd_ldflags=""
 AC_ARG_WITH([libmicrohttpd], [AS_HELP_STRING([--with-libmicrohttpd@<:@=PREFIX@:>@], [Path to libmicrohttpd.])],
   [
-    if test "x$withval" != "xno" && test "x$withval" != "xyes"
-    then
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
       with_libmicrohttpd_cppflags="-I$withval/include"
       with_libmicrohttpd_ldflags="-L$withval/lib"
       with_libmicrohttpd="yes"
     fi
-    if test "x$withval" = "xno"
-    then
+    if test "x$withval" = "xno"; then
       with_libmicrohttpd="no (disabled on command line)"
     fi
   ],
   [withval="yes"]
 )
-if test "x$withval" = "xyes"
-then
-PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd],
-  [with_libmicrohttpd="yes"],
-  [with_libmicrohttpd="no (pkg-config could not find libmicrohttpd)"]
-)
+if test "x$withval" = "xyes"; then
+  PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd],
+    [with_libmicrohttpd="yes"],
+    [with_libmicrohttpd="no (pkg-config could not find libmicrohttpd)"]
+  )
 fi
 
-if test "x$MICROHTTPD_LIBS" = "x"
-then
+if test "x$MICROHTTPD_LIBS" = "x"; then
   MICROHTTPD_LIBS="-lmicrohttpd"
 fi
 
@@ -3210,18 +3254,18 @@ CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
 LDFLAGS="$with_libmicrohttpd_ldflags $LDFLAGS"
 LIBS="$LIBS $MICROHTTPD_LIBS"
 
-if test "x$with_libmicrohttpd" = "xyes"
-then
+if test "x$with_libmicrohttpd" = "xyes"; then
   AC_CHECK_HEADERS([microhttpd.h],
-                   [with_libmicrohttpd="yes"],
-                   [with_libmicrohttpd="no (<microhttpd.h> not found)"])
+   [with_libmicrohttpd="yes"],
+   [with_libmicrohttpd="no (<microhttpd.h> not found)"]
+  )
 fi
 
-if test "x$with_libmicrohttpd" = "xyes"
-then
+if test "x$with_libmicrohttpd" = "xyes"; then
   AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
-               [with_libmicrohttpd="yes"],
-               [with_libmicrohttpd="no (libmicrohttpd not found)"])
+    [with_libmicrohttpd="yes"],
+    [with_libmicrohttpd="no (libmicrohttpd not found)"]
+  )
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
@@ -3237,1158 +3281,1216 @@ AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LIBS])
 # }}}
 
 # --with-libmodbus {{{
-with_libmodbus_config=""
-with_libmodbus_cflags=""
-with_libmodbus_libs=""
-AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libmodbus="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libmodbus="use_pkgconfig"
-       else if test -d "$with_libmodbus/lib"
-       then
-               AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
-               with_libmodbus_cflags="-I$withval/include"
-               with_libmodbus_libs="-L$withval/lib -lmodbus"
-               with_libmodbus="yes"
-       fi; fi; fi
-],
-[with_libmodbus="use_pkgconfig"])
+AC_ARG_WITH([libmodbus],
+  [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
+  [
+    if test "x$withval" = "xno"; then
+      with_libmodbus="no"
+    else if test "x$withval" = "xyes"; then
+      with_libmodbus="use_pkgconfig"
+    else if test -d "$with_libmodbus/lib"; then
+      AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
+      with_libmodbus_cflags="-I$withval/include"
+      with_libmodbus_libs="-L$withval/lib -lmodbus"
+      with_libmodbus="yes"
+    fi; fi; fi
+  ],
+  [with_libmodbus="use_pkgconfig"]
+)
 
 # configure using pkg-config
-if test "x$with_libmodbus" = "xuse_pkgconfig"
-then
-       AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
-       $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
-       if test $? -ne 0
-       then
-               with_libmodbus="no (pkg-config doesn't know libmodbus)"
-       fi
-fi
-if test "x$with_libmodbus" = "xuse_pkgconfig"
-then
-       with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
-       if test $? -ne 0
-       then
-               with_libmodbus="no ($PKG_CONFIG failed)"
-       fi
-       with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
-       if test $? -ne 0
-       then
-               with_libmodbus="no ($PKG_CONFIG failed)"
-       fi
-fi
-if test "x$with_libmodbus" = "xuse_pkgconfig"
-then
-       with_libmodbus="yes"
+if test "x$with_libmodbus" = "xuse_pkgconfig"; then
+  AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
+  $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
+  if test $? -ne 0; then
+    with_libmodbus="no (pkg-config doesn't know libmodbus)"
+  fi
 fi
 
-# with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do
-# the actual checks.
-if test "x$with_libmodbus" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
+if test "x$with_libmodbus" = "xuse_pkgconfig"; then
+  with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
+  if test $? -ne 0; then
+    with_libmodbus="no ($PKG_CONFIG failed)"
+  fi
 
-       AC_CHECK_HEADERS(modbus.h, [], [with_libmodbus="no (modbus.h not found)"])
+  with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
+  if test $? -ne 0; then
+    with_libmodbus="no ($PKG_CONFIG failed)"
+  fi
+fi
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
+if test "x$with_libmodbus" = "xuse_pkgconfig"; then
+  with_libmodbus="yes"
 fi
-if test "x$with_libmodbus" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       SAVE_LDFLAGS="$LDFLAGS"
 
-       CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
-       LDFLAGS="$LDFLAGS $with_libmodbus_libs"
+if test "x$with_libmodbus" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
 
-       AC_CHECK_LIB(modbus, modbus_connect,
-                    [with_libmodbus="yes"],
-                    [with_libmodbus="no (symbol modbus_connect not found)"])
+  AC_CHECK_HEADERS([modbus.h],
+    [with_libmodbus="yes"],
+    [with_libmodbus="no (modbus.h not found)"]
+  )
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
-       LDFLAGS="$SAVE_LDFLAGS"
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libmodbus" = "xyes"
-then
-       BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
-       BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
-       AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS)
+
+if test "x$with_libmodbus" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_libmodbus_libs"
+
+  AC_CHECK_LIB([modbus], [modbus_connect],
+    [with_libmodbus="yes"],
+    [with_libmodbus="no (symbol modbus_connect not found)"]
+  )
+
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libmodbus" = "xyes"; then
+  BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
+  BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
 fi
+
+AC_SUBST([BUILD_WITH_LIBMODBUS_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBMODBUS_LIBS])
 # }}}
 
 # --with-libmongoc {{{
-AC_ARG_WITH(libmongoc, [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
-[
- if test "x$withval" = "xyes"
- then
-        with_libmongoc="yes"
- else if test "x$withval" = "xno"
- then
-        with_libmongoc="no"
- else
-        with_libmongoc="yes"
-        LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
-        LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
- fi; fi
-],
-[with_libmongoc="yes"])
+AC_ARG_WITH([libmongoc],
+  [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
+  [
+    if test "x$withval" = "xyes"; then
+      with_libmongoc="yes"
+    else if test "x$withval" = "xno"; then
+      with_libmongoc="no"
+    else
+      with_libmongoc="no"
+    fi; fi
+  ],
+  [with_libmongoc="yes"]
+)
 
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
+if test "x$with_libmongoc" = "xyes"; then
+  PKG_CHECK_MODULES([LIBMONGOC], [libmongoc-1.0],
+    [with_libmongoc="yes"],
+    [with_libmongoc="no (pkg-config could not find libmongoc)"]
+  )
+fi
 
-CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
-LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
+if test "x$with_libmongoc" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
 
-if test "x$with_libmongoc" = "xyes"
-then
-       if test "x$LIBMONGOC_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(mongo.h,
-       [with_libmongoc="yes"],
-       [with_libmongoc="no ('mongo.h' not found)"],
-[#if HAVE_STDINT_H
-# define MONGO_HAVE_STDINT 1
-#else
-# define MONGO_USE_LONG_LONG_INT 1
-#endif
-])
-fi
-if test "x$with_libmongoc" = "xyes"
-then
-       if test "x$LIBMONGOC_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
-       fi
-       AC_CHECK_LIB(mongoc, mongo_run_command,
-       [with_libmongoc="yes"],
-       [with_libmongoc="no (symbol 'mongo_run_command' not found)"])
+  CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
+
+  if test "x$CPPFLAGS" != "x"; then
+    AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CFLAGS])
+  fi
+
+  AC_CHECK_HEADERS([mongoc.h],
+    [with_libmongoc="yes"],
+    [with_libmongoc="no ('mongoc.h' not found)"]
+  )
+
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
 
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
+if test "x$with_libmongoc" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  SAVE_LDFLAGS="$LDFLAGS"
 
-if test "x$with_libmongoc" = "xyes"
-then
-       BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
-       BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
-       AC_SUBST(BUILD_WITH_LIBMONGOC_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMONGOC_LDFLAGS)
+  CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
+  LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
+
+  if test "x$LIBMONGOC_LDFLAGS" != "x"; then
+    AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
+  fi
+
+  AC_CHECK_LIB([mongoc-1.0], [mongoc_init],
+    [with_libmongoc="yes"],
+    [with_libmongoc="no (symbol 'mongoc_init' not found)"]
+  )
+
+  CPPFLAGS="$SAVE_CPPFLAGS"
+  LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libmongoc" = "xyes"; then
+  BUILD_WITH_LIBMONGOC_CFLAGS="$LIBMONGOC_CFLAGS"
+  BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
+
+AC_SUBST([BUILD_WITH_LIBMONGOC_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBMONGOC_LDFLAGS])
 # }}}
 
 # --with-libmosquitto {{{
-with_libmosquitto_cppflags=""
-with_libmosquitto_ldflags=""
-AC_ARG_WITH(libmosquitto, [AS_HELP_STRING([--with-libmosquitto@<:@=PREFIX@:>@], [Path to libmosquitto.])],
-[
-       if test "x$withval" != "xno" && test "x$withval" != "xyes"
-       then
-               with_libmosquitto_cppflags="-I$withval/include"
-               with_libmosquitto_ldflags="-L$withval/lib"
-               with_libmosquitto="yes"
-       else
-               with_libmosquitto="$withval"
-       fi
-],
-[
-       with_libmosquitto="yes"
-])
-if test "x$with_libmosquitto" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
+AC_ARG_WITH([libmosquitto],
+  [AS_HELP_STRING([--with-libmosquitto@<:@=PREFIX@:>@], [Path to libmosquitto.])],
+  [
+    if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+      with_libmosquitto_cppflags="-I$withval/include"
+      with_libmosquitto_ldflags="-L$withval/lib"
+      with_libmosquitto="yes"
+    else
+      with_libmosquitto="$withval"
+    fi
+  ],
+  [with_libmosquitto="yes"]
+)
+
+if test "x$with_libmosquitto" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
 
-       AC_CHECK_HEADERS(mosquitto.h, [with_libmosquitto="yes"], [with_libmosquitto="no (mosquitto.h not found)"])
+  AC_CHECK_HEADERS([mosquitto.h],
+    [with_libmosquitto="yes"],
+    [with_libmosquitto="no (mosquitto.h not found)"]
+  )
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libmosquitto" = "xyes"
-then
-       SAVE_LDFLAGS="$LDFLAGS"
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       LDFLAGS="$LDFLAGS $with_libmosquitto_ldflags"
-       CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
 
-       AC_CHECK_LIB(mosquitto, mosquitto_connect, [with_libmosquitto="yes"], [with_libmosquitto="no (libmosquitto not found)"])
+if test "x$with_libmosquitto" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_libmosquitto_ldflags"
+
+  AC_CHECK_LIB([mosquitto], [mosquitto_connect],
+    [with_libmosquitto="yes"],
+    [with_libmosquitto="no (libmosquitto not found)"]
+  )
 
-       LDFLAGS="$SAVE_LDFLAGS"
-       CPPFLAGS="$SAVE_CPPFLAGS"
+  LDFLAGS="$SAVE_LDFLAGS"
 fi
-if test "x$with_libmosquitto" = "xyes"
-then
-       BUILD_WITH_LIBMOSQUITTO_CPPFLAGS="$with_libmosquitto_cppflags"
-       BUILD_WITH_LIBMOSQUITTO_LDFLAGS="$with_libmosquitto_ldflags"
-       BUILD_WITH_LIBMOSQUITTO_LIBS="-lmosquitto"
-       AC_SUBST(BUILD_WITH_LIBMOSQUITTO_CPPFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMOSQUITTO_LDFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMOSQUITTO_LIBS)
+
+if test "x$with_libmosquitto" = "xyes"; then
+  BUILD_WITH_LIBMOSQUITTO_CPPFLAGS="$with_libmosquitto_cppflags"
+  BUILD_WITH_LIBMOSQUITTO_LDFLAGS="$with_libmosquitto_ldflags"
+  BUILD_WITH_LIBMOSQUITTO_LIBS="-lmosquitto"
 fi
+
+AC_SUBST([BUILD_WITH_LIBMOSQUITTO_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBMOSQUITTO_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBMOSQUITTO_LIBS])
 # }}}
 
 # --with-libmysql {{{
 with_mysql_config="mysql_config"
-with_mysql_cflags=""
-with_mysql_libs=""
-AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libmysql="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libmysql="yes"
-       else
-               if test -f "$withval" && test -x "$withval";
-               then
-                       with_mysql_config="$withval"
-               else if test -x "$withval/bin/mysql_config"
-               then
-                       with_mysql_config="$withval/bin/mysql_config"
-               fi; fi
-               with_libmysql="yes"
-       fi; fi
-],
-[
-       with_libmysql="yes"
-])
-if test "x$with_libmysql" = "xyes"
-then
-       with_mysql_cflags=`$with_mysql_config --include 2>/dev/null`
-       mysql_config_status=$?
-
-       if test $mysql_config_status -ne 0
-       then
-               with_libmysql="no ($with_mysql_config failed)"
-       else
-               SAVE_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
-
-               have_mysql_h="no"
-               have_mysql_mysql_h="no"
-               AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
-
-               if test "x$have_mysql_h" = "xno"
-               then
-                       AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
-               fi
-
-               if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
-               then
-                       with_libmysql="no (mysql.h not found)"
-               fi
-
-               CPPFLAGS="$SAVE_CPPFLAGS"
-       fi
-fi
-if test "x$with_libmysql" = "xyes"
-then
-       with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
-       mysql_config_status=$?
-
-       if test $mysql_config_status -ne 0
-       then
-               with_libmysql="no ($with_mysql_config failed)"
-       else
-               SAVE_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
-               SAVE_LIBS="$LIBS"
-               LIBS="$with_mysql_libs"
-               AC_SEARCH_LIBS([mysql_get_server_version],
-                [],
-                [with_libmysql="yes"],
-                [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
-                [])
-               CPPFLAGS="$SAVE_CPPFLAGS"
-               LIBS="$SAVE_LIBS"
-       fi
-fi
-if test "x$with_libmysql" = "xyes"
-then
-       BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
-       BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
-       AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
+AC_ARG_WITH([libmysql],
+  [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
+  [
+    if test "x$withval" = "xno"; then
+      with_libmysql="no"
+    else if test "x$withval" = "xyes"; then
+      with_libmysql="yes"
+    else
+      if test -f "$withval" && test -x "$withval"; then
+        with_mysql_config="$withval"
+      else if test -x "$withval/bin/mysql_config"; then
+        with_mysql_config="$withval/bin/mysql_config"
+      fi; fi
+      with_libmysql="yes"
+    fi; fi
+  ],
+  [with_libmysql="yes"]
+)
+
+if test "x$with_libmysql" = "xyes"; then
+  with_mysql_cflags=`$with_mysql_config --include 2>/dev/null`
+  if test $? -ne 0; then
+    with_libmysql="no ($with_mysql_config failed)"
+  else
+    SAVE_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
+
+    AC_CHECK_HEADERS([mysql.h],
+      [have_mysql_h="yes"],
+      [have_mysql_h="no"]
+    )
+
+    if test "x$have_mysql_h" != "xyes"; then
+      AC_CHECK_HEADERS([mysql/mysql.h],
+        [have_mysql_mysql_h="yes"],
+        [],
+      )
+    fi
+
+    if test "x$have_mysql_h" != "xyes" && test "x$have_mysql_mysql_h" != "xyes"; then
+      with_libmysql="no (mysql.h not found)"
+    fi
+
+    CPPFLAGS="$SAVE_CPPFLAGS"
+  fi
+fi
+
+if test "x$with_libmysql" = "xyes"; then
+  with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
+  if test $? -ne 0; then
+    with_libmysql="no ($with_mysql_config failed)"
+  else
+    SAVE_LIBS="$LIBS"
+    LIBS="$with_mysql_libs"
+
+    AC_SEARCH_LIBS([mysql_get_server_version],
+      [],
+      [with_libmysql="yes"],
+      [with_libmysql="no (symbol 'mysql_get_server_version' not found in ${LIBS})"],
+      []
+    )
+    LIBS="$SAVE_LIBS"
+  fi
+fi
+
+if test "x$with_libmysql" = "xyes"; then
+  BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
+  BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
+
+AC_SUBST([BUILD_WITH_LIBMYSQL_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBMYSQL_LIBS])
 # }}}
 
 # --with-libmnl {{{
-with_libmnl_cflags=""
-with_libmnl_libs=""
-AC_ARG_WITH(libmnl, [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
-[
- echo "libmnl: withval = $withval"
- if test "x$withval" = "xyes"
- then
-        with_libmnl="yes"
- else if test "x$withval" = "xno"
- then
-        with_libmnl="no"
- else
-        if test -d "$withval/include"
-        then
-                with_libmnl_cflags="-I$withval/include"
-                with_libmnl_libs="-L$withval/lib -lmnl"
-                with_libmnl="yes"
-        else
-                AC_MSG_ERROR("no such directory: $withval/include")
-        fi
- fi; fi
-],
-[
- if test "x$ac_system" = "xLinux"
- then
-        with_libmnl="yes"
- else
-        with_libmnl="no (Linux only library)"
- fi
-])
-if test "x$with_libmnl" = "xyes"
-then
-       if $PKG_CONFIG --exists libmnl 2>/dev/null; then
-         with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
-         with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
-       fi
-
-       AC_CHECK_HEADERS(libmnl.h libmnl/libmnl.h,
-       [
-        with_libmnl="yes"
-        break
-       ], [],
-[#include <stdio.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>])
-       AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
-[#include <stdio.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/socket.h>])
-
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[
-#include <stdio.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-]],
-[[
-int retval = TCA_STATS2;
-return (retval);
-]]
-       )],
-       [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])])
-
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-[[
-#include <stdio.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-]],
-[[
-int retval = TCA_STATS;
-return (retval);
-]]
-       )],
-       [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])])
-fi
-if test "x$with_libmnl" = "xyes"
-then
-       AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
-       [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
-       [],
-       [
-       #include <linux/if_link.h>
-       ])
-fi
-if test "x$with_libmnl" = "xyes"
-then
-       AC_CHECK_LIB(mnl, mnl_nlmsg_get_payload,
-                    [with_libmnl="yes"],
-                    [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
-                    [$with_libmnl_libs])
+AC_ARG_WITH([libmnl],
+  [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
+  [
+    if test "x$withval" = "xyes"; then
+      with_libmnl="yes"
+     else if test "x$withval" = "xno"; then
+       with_libmnl="no"
+     else
+       if test -d "$withval/include"; then
+         with_libmnl_cflags="-I$withval/include"
+         with_libmnl_libs="-L$withval/lib -lmnl"
+         with_libmnl="yes"
+       else
+         AC_MSG_ERROR("no such directory: $withval/include")
+       fi
+     fi; fi
+  ],
+  [
+    if test "x$ac_system" = "xLinux"; then
+      with_libmnl="yes"
+    else
+      with_libmnl="no (Linux only library)"
+    fi
+  ]
+)
+
+if test "x$with_libmnl" = "xyes"; then
+  if $PKG_CONFIG --exists libmnl 2>/dev/null; then
+    with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
+    with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
+  fi
+
+  AC_CHECK_HEADERS([libmnl.h libmnl/libmnl.h],
+    [
+      with_libmnl="yes"
+      break
+    ],
+    [],
+    [[
+      #include <stdio.h>
+      #include <sys/types.h>
+      #include <asm/types.h>
+      #include <sys/socket.h>
+      #include <linux/netlink.h>
+      #include <linux/rtnetlink.h>]]
+  )
+
+  AC_CHECK_HEADERS([linux/gen_stats.h linux/pkt_sched.h],
+    [],
+    [],
+    [[
+      #include <stdio.h>
+      #include <sys/types.h>
+      #include <asm/types.h>
+      #include <sys/socket.h>
+    ]]
+  )
+
+  AC_COMPILE_IFELSE(
+    [
+      AC_LANG_PROGRAM(
+        [[
+          #include <stdio.h>
+          #include <sys/types.h>
+          #include <asm/types.h>
+          #include <sys/socket.h>
+          #include <linux/netlink.h>
+          #include <linux/rtnetlink.h>
+        ]],
+        [[
+          int retval = TCA_STATS2;
+          return retval;
+        ]]
+      )
+    ],
+    [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])]
+  )
+
+  AC_COMPILE_IFELSE(
+    [
+      AC_LANG_PROGRAM(
+        [[
+          #include <stdio.h>
+          #include <sys/types.h>
+          #include <asm/types.h>
+          #include <sys/socket.h>
+          #include <linux/netlink.h>
+          #include <linux/rtnetlink.h>
+        ]],
+        [[
+          int retval = TCA_STATS;
+          return retval;
+        ]]
+      )
+    ],
+    [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
+  )
+
+  AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
+    [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
+    [],
+    [[#include <linux/if_link.h>]]
+  )
+
+  AC_CHECK_LIB([mnl], [mnl_nlmsg_get_payload],
+    [with_libmnl="yes"],
+    [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
+    [$with_libmnl_libs]
+  )
 fi
-if test "x$with_libmnl" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBMNL, 1, [Define if libmnl is present and usable.])
-       BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
-       BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
-       AC_SUBST(BUILD_WITH_LIBMNL_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBMNL_LIBS)
+
+if test "x$with_libmnl" = "xyes"; then
+  BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
+  BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBMNL, test "x$with_libmnl" = "xyes")
+AC_SUBST([BUILD_WITH_LIBMNL_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBMNL_LIBS])
 # }}}
 
 # --with-libnetapp {{{
 AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
 AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
 AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
-LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS"
-LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS"
-LIBNETAPP_LIBS="$LIBNETAPP_LIBS"
-AC_ARG_WITH(libnetapp, [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
-[
- if test -d "$withval"
- then
-        LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
-        LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
-        with_libnetapp="yes"
- else
-        with_libnetapp="$withval"
- fi
-],
-[
- with_libnetapp="yes"
-])
+AC_ARG_WITH([libnetapp],
+  [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
+  [
+   if test -d "$withval"; then
+     LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
+     LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
+     with_libnetapp="yes"
+   else
+     with_libnetapp="$withval"
+   fi
+  ],
+  [with_libnetapp="yes"]
+)
 
 SAVE_CPPFLAGS="$CPPFLAGS"
 SAVE_LDFLAGS="$LDFLAGS"
 CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
 LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
 
-if test "x$with_libnetapp" = "xyes"
-then
-       if test "x$LIBNETAPP_CPPFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
-       fi
-       AC_CHECK_HEADERS(netapp_api.h,
-               [with_libnetapp="yes"],
-               [with_libnetapp="no (netapp_api.h not found)"])
+if test "x$with_libnetapp" = "xyes"; then
+  if test "x$LIBNETAPP_CPPFLAGS" != "x"; then
+    AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
+  fi
+  AC_CHECK_HEADERS([netapp_api.h],
+    [with_libnetapp="yes"],
+    [with_libnetapp="no (netapp_api.h not found)"]
+  )
 fi
 
-if test "x$with_libnetapp" = "xyes"
-then
-       if test "x$LIBNETAPP_LDFLAGS" != "x"
-       then
-               AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
-       fi
+if test "x$with_libnetapp" = "xyes"; then
+  if test "x$LIBNETAPP_LDFLAGS" != "x"; then
+    AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
+  fi
 
-       if test "x$LIBNETAPP_LIBS" = "x"
-       then
-               LIBNETAPP_LIBS="$PTHREAD_LIBS -lxml -ladt -lssl -lm -lcrypto -lz"
-       fi
-       AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
+  if test "x$LIBNETAPP_LIBS" = "x"; then
+    LIBNETAPP_LIBS="$PTHREAD_LIBS -lxml -ladt -lssl -lm -lcrypto -lz"
+  fi
+
+  AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
+
+  AC_CHECK_LIB([netapp], [na_server_invoke_elem],
+    [with_libnetapp="yes"],
+    [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
+    [$LIBNETAPP_LIBS]
+  )
 
-       AC_CHECK_LIB(netapp, na_server_invoke_elem,
-               [with_libnetapp="yes"],
-               [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
-               [$LIBNETAPP_LIBS])
-       LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
+  LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
 fi
 
 CPPFLAGS="$SAVE_CPPFLAGS"
 LDFLAGS="$SAVE_LDFLAGS"
 
-if test "x$with_libnetapp" = "xyes"
-then
-       AC_DEFINE(HAVE_LIBNETAPP, 1, [Define to 1 if you have the netapp library (-lnetapp).])
-fi
-
-AC_SUBST(LIBNETAPP_CPPFLAGS)
-AC_SUBST(LIBNETAPP_LDFLAGS)
-AC_SUBST(LIBNETAPP_LIBS)
-AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
+AC_SUBST([LIBNETAPP_CPPFLAGS])
+AC_SUBST([LIBNETAPP_LDFLAGS])
+AC_SUBST([LIBNETAPP_LIBS])
 # }}}
 
 # --with-libnetsnmp {{{
-AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
-[
-       if test "x$withval" = "xno"
-       then
-               with_libnetsnmp="no"
-       else if test "x$withval" = "xyes"
-       then
-               with_libnetsnmp="yes"
-       else
-               with_libnetsnmp_cppflags="-I$withval/include"
-               with_libnetsnmp_ldflags="-I$withval/lib"
-               with_libnetsnmp="yes"
-       fi; fi
-],
-[with_libnetsnmp="yes"])
-if test "x$with_libnetsnmp" = "xyes"
-then
-       SAVE_CPPFLAGS="$CPPFLAGS"
-       CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
+AC_ARG_WITH([libnetsnmp],
+  [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to libnetsnmp.])],
+  [
+    if test "x$withval" = "xno"; then
+     with_libnetsnmp="no"
+    else if test "x$withval" = "xyes"; then
+     with_libnetsnmp="yes"
+    else
+      with_libnetsnmp_cppflags="-I$withval/include"
+      with_libnetsnmp_ldflags="-I$withval/lib"
+      with_libnetsnmp="yes"
+    fi; fi
+  ],
+  [with_libnetsnmp="yes"]
+)
+
+if test "x$with_libnetsnmp" = "xyes"; then
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
 
-       AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
+  AC_CHECK_HEADERS([net-snmp/net-snmp-config.h],
+    [with_libnetsnmp="yes"],
+    [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"]
+  )
+
+  AC_CHECK_HEADERS([net-snmp/net-snmp-includes.h],
+    [with_libnetsnmp="yes"],
+    [with_libnetsnmp="no (net-snmp/net-snmp-includes.h not found)"],
+    [[
+      #if HAVE_NET_SNMP_NET_SNMP_CONFIG_H
+      # include <net-snmp/net-snmp-config.h>
+      #endif
+    ]]
+  )
 
-       CPPFLAGS="$SAVE_CPPFLAGS"
+  CPPFLAGS="$SAVE_CPPFLAGS"
 fi
-if test "x$with_libnetsnmp" = "xyes"
-then
-       SAVE_LDFLAGS="$LDFLAGS"
-       LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
 
-       AC_CHECK_LIB(netsnmp, init_snmp,
-               [with_libnetsnmp="yes"],
-               [with_libnetsnmp="no (libnetsnmp not found)"],
-               [$with_snmp_libs])
+if test "x$with_libnetsnmp" = "xyes"; then
+  SAVE_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"