Add daemon option to avoid making BaseDir
[collectd.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ([2.60])
3 AC_INIT([collectd],[m4_esyscmd(./version-gen.sh)])
4 AC_CONFIG_SRCDIR(src/target_set.c)
5 AC_CONFIG_HEADERS(src/config.h)
6 AC_CONFIG_AUX_DIR([build-aux])
7 AC_CONFIG_MACRO_DIR([m4])
8
9 dnl older automake's default of ARFLAGS=cru is noisy on newer binutils;
10 dnl we don't really need the 'u' even in older toolchains.  Then there is
11 dnl older libtool, which spelled it AR_FLAGS
12 m4_divert_text([DEFAULTS], [: "${ARFLAGS=cr} ${AR_FLAGS=cr}"])
13
14 LT_INIT([dlopen disable-static])
15
16 AM_INIT_AUTOMAKE([subdir-objects tar-pax dist-bzip2 no-dist-gzip foreign])
17 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
18 AC_LANG(C)
19
20 AC_PREFIX_DEFAULT("/opt/collectd")
21
22 AC_SYS_LARGEFILE
23
24 #
25 # Checks for programs.
26 #
27 AC_PROG_CC_C99([],
28   [AC_MSG_ERROR([No compiler found that supports C99])]
29 )
30
31 AX_COMPILER_VENDOR
32
33 AC_PROG_CXX
34 AC_PROG_CPP
35 AC_PROG_EGREP
36 AC_PROG_INSTALL
37 AC_PROG_LN_S
38 AC_PROG_MAKE_SET
39 AM_PROG_CC_C_O
40
41 AC_PROG_LEX
42 AC_PROG_YACC
43
44 AC_PATH_PROG([VALGRIND], [valgrind])
45
46 # Warn when pkg.m4 is missing
47 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
48
49 PKG_PROG_PKG_CONFIG
50
51 AC_CACHE_CHECK([if Bison is the parser generator],
52   [collectd_cv_prog_bison],
53   [
54     AS_IF([$YACC --version 2>/dev/null | $EGREP -q '^bison '],
55       [collectd_cv_prog_bison=yes],
56       [collectd_cv_prog_bison=no]
57     )
58   ]
59 )
60
61 if test "x$collectd_cv_prog_bison" = "xno" && test ! -f "${srcdir}/src/liboconfig/parser.c"; then
62   AC_MSG_ERROR([bison is missing and you do not have ${srcdir}/src/liboconfig/parser.c. Please install bison])
63 fi
64
65 if test "x$lt_cv_dlopen" = "xno"; then
66   AC_MSG_ERROR([Your system does not support dlopen])
67 fi
68
69 AC_SUBST([DLOPEN_LIBS], [$lt_cv_dlopen_libs])
70
71
72 AC_MSG_CHECKING([for kernel type ($host_os)])
73 case $host_os in
74   *aix*)
75     AC_DEFINE([KERNEL_AIX], [1], [True if program is to be compiled for a AIX kernel])
76     ac_system="AIX"
77     ;;
78   *darwin*)
79     AC_DEFINE([KERNEL_DARWIN], [1], [True if program is to be compiled for a Darwin kernel])
80     ac_system="Darwin"
81     ;;
82   *freebsd*)
83     AC_DEFINE([KERNEL_FREEBSD], [1], [True if program is to be compiled for a FreeBSD kernel])
84     ac_system="FreeBSD"
85     ;;
86   *linux*)
87     AC_DEFINE([KERNEL_LINUX], [1], [True if program is to be compiled for a Linux kernel])
88     ac_system="Linux"
89     ;;
90   *netbsd*)
91     AC_DEFINE([KERNEL_NETBSD], [1], [True if program is to be compiled for a NetBSD kernel])
92     ac_system="NetBSD"
93     ;;
94   *openbsd*)
95     AC_DEFINE([KERNEL_OPENBSD], [1], [True if program is to be compiled for an OpenBSD kernel])
96     ac_system="OpenBSD"
97     ;;
98   *solaris*)
99     AC_DEFINE([KERNEL_SOLARIS], [1], [True if program is to be compiled for a Solaris kernel])
100     ac_system="Solaris"
101     ;;
102   *)
103     ac_system="unknown"
104     ;;
105 esac
106 AC_MSG_RESULT([$ac_system])
107
108 AM_CONDITIONAL([BUILD_AIX], [test "x$ac_system" = "xAIX"])
109 AM_CONDITIONAL([BUILD_DARWIN], [test "x$ac_system" = "xDarwin"])
110 AM_CONDITIONAL([BUILD_FREEBSD], [test "x$ac_system" = "xFreeBSD"])
111 AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"])
112 AM_CONDITIONAL([BUILD_OPENBSD], [test "x$ac_system" = "xOpenBSD"])
113 AM_CONDITIONAL([BUILD_SOLARIS], [test "x$ac_system" = "xSolaris"])
114
115 if test "x$ac_system" = "xSolaris"; then
116   AC_DEFINE([_POSIX_PTHREAD_SEMANTICS], [1], [Define to enforce POSIX thread semantics under Solaris.])
117   AC_DEFINE([_REENTRANT], [1], [Define to enable reentrancy interfaces.])
118
119   AC_MSG_CHECKING([whether compiler builds 64bit binaries])
120   AC_COMPILE_IFELSE(
121     [
122       AC_LANG_PROGRAM(
123         [
124           #ifndef _LP64
125           # error "Compiler not in 64bit mode."
126           #endif
127         ]
128       )
129     ],
130     [AC_MSG_RESULT([yes])],
131     [
132       AC_MSG_RESULT([no])
133       AC_MSG_NOTICE([Solaris detected. Please consider building a 64-bit binary.])
134     ]
135   )
136 fi
137
138 if test "x$ac_system" = "xAIX"; then
139   AC_DEFINE([_THREAD_SAFE_ERRNO], [1], [Define to use the thread-safe version of errno under AIX.])
140 fi
141
142 # Where to install .pc files.
143 pkgconfigdir="${libdir}/pkgconfig"
144 AC_SUBST([pkgconfigdir])
145
146 #
147 # Checks for header files.
148 #
149 AC_HEADER_SYS_WAIT
150 AC_HEADER_DIRENT
151
152 AC_CHECK_HEADERS_ONCE([ \
153   arpa/inet.h \
154   endian.h \
155   fcntl.h \
156   fnmatch.h \
157   fs_info.h \
158   fshelp.h \
159   grp.h \
160   kstat.h \
161   kvm.h \
162   libgen.h \
163   mntent.h \
164   mnttab.h \
165   netdb.h \
166   paths.h \
167   poll.h \
168   pthread_np.h \
169   pwd.h \
170   regex.h \
171   sys/endian.h \
172   sys/fs_types.h \
173   sys/fstyp.h \
174   sys/ioctl.h \
175   sys/isa_defs.h \
176   sys/mntent.h \
177   sys/mnttab.h \
178   sys/param.h \
179   sys/resource.h \
180   sys/select.h \
181   sys/socket.h \
182   sys/statfs.h \
183   sys/statvfs.h \
184   sys/types.h \
185   sys/un.h \
186   sys/vfs.h \
187   sys/vfstab.h \
188   sys/vmmeter.h \
189   syslog.h \
190   wordexp.h
191 ])
192
193 if test "x$ac_system" = "xNetBSD"; then
194   # For entropy plugin on newer NetBSD
195   AC_CHECK_HEADERS([sys/rndio.h], [], [],
196     [[
197       #if HAVE_SYS_TYPES_H
198       # include <sys/types.h>
199       #endif
200       #if HAVE_SYS_IOCTL_H
201       # include <sys/ioctl.h>
202       #endif
203       #if HAVE_SYS_PARAM_H
204       # include <sys/param.h>
205       #endif
206     ]]
207   )
208 fi
209
210 # For ping library
211 AC_CHECK_HEADERS([netinet/in_systm.h], [], [],
212   [[
213     #include <stdint.h>
214     #if HAVE_SYS_TYPES_H
215     # include <sys/types.h>
216     #endif
217   ]]
218 )
219
220 AC_CHECK_HEADERS([netinet/in.h], [], [],
221   [[
222     #include <stdint.h>
223     #if HAVE_SYS_TYPES_H
224     # include <sys/types.h>
225     #endif
226     #if HAVE_NETINET_IN_SYSTM_H
227     # include <netinet/in_systm.h>
228     #endif
229   ]]
230 )
231
232 AC_CHECK_HEADERS([netinet/ip.h], [], [],
233   [[
234     #include <stdint.h>
235     #if HAVE_SYS_TYPES_H
236     # include <sys/types.h>
237     #endif
238     #if HAVE_NETINET_IN_SYSTM_H
239     # include <netinet/in_systm.h>
240     #endif
241     #if HAVE_NETINET_IN_H
242     # include <netinet/in.h>
243     #endif
244   ]]
245 )
246
247 AC_CHECK_HEADERS([netinet/ip_icmp.h], [], [],
248   [[
249     #include <stdint.h>
250     #if HAVE_SYS_TYPES_H
251     # include <sys/types.h>
252     #endif
253     #if HAVE_NETINET_IN_SYSTM_H
254     # include <netinet/in_systm.h>
255     #endif
256     #if HAVE_NETINET_IN_H
257     # include <netinet/in.h>
258     #endif
259     #if HAVE_NETINET_IP_H
260     # include <netinet/ip.h>
261     #endif
262   ]]
263 )
264
265 AC_CHECK_HEADERS([netinet/ip_var.h], [], [],
266   [[
267     #include <stdint.h>
268     #if HAVE_SYS_TYPES_H
269     # include <sys/types.h>
270     #endif
271     #if HAVE_NETINET_IN_SYSTM_H
272     # include <netinet/in_systm.h>
273     #endif
274     #if HAVE_NETINET_IN_H
275     # include <netinet/in.h>
276     #endif
277     #if HAVE_NETINET_IP_H
278     # include <netinet/ip.h>
279     #endif
280   ]]
281 )
282
283 AC_CHECK_HEADERS([netinet/ip6.h], [], [],
284   [[
285     #include <stdint.h>
286     #if HAVE_SYS_TYPES_H
287     # include <sys/types.h>
288     #endif
289     #if HAVE_NETINET_IN_SYSTM_H
290     # include <netinet/in_systm.h>
291     #endif
292     #if HAVE_NETINET_IN_H
293     # include <netinet/in.h>
294     #endif
295   ]]
296 )
297
298 AC_CHECK_HEADERS([netinet/icmp6.h], [], [],
299   [[
300     #include <stdint.h>
301     #if HAVE_SYS_TYPES_H
302     # include <sys/types.h>
303     #endif
304     #if HAVE_NETINET_IN_SYSTM_H
305     # include <netinet/in_systm.h>
306     #endif
307     #if HAVE_NETINET_IN_H
308     # include <netinet/in.h>
309     #endif
310     #if HAVE_NETINET_IP6_H
311     # include <netinet/ip6.h>
312     #endif
313   ]]
314 )
315
316 AC_CHECK_HEADERS([netinet/tcp.h], [], [],
317   [[
318     #include <stdint.h>
319     #if HAVE_SYS_TYPES_H
320     # include <sys/types.h>
321     #endif
322     #if HAVE_NETINET_IN_SYSTM_H
323     # include <netinet/in_systm.h>
324     #endif
325     #if HAVE_NETINET_IN_H
326     # include <netinet/in.h>
327     #endif
328     #if HAVE_NETINET_IP_H
329     # include <netinet/ip.h>
330     #endif
331   ]]
332 )
333
334 AC_CHECK_HEADERS([netinet/udp.h], [], [],
335   [[
336     #include <stdint.h>
337     #if HAVE_SYS_TYPES_H
338     # include <sys/types.h>
339     #endif
340     #if HAVE_NETINET_IN_SYSTM_H
341     # include <netinet/in_systm.h>
342     #endif
343     #if HAVE_NETINET_IN_H
344     # include <netinet/in.h>
345     #endif
346     #if HAVE_NETINET_IP_H
347     # include <netinet/ip.h>
348     #endif
349   ]]
350 )
351
352 # For cpu modules
353 AC_CHECK_HEADERS([sys/dkstat.h])
354 if test "x$ac_system" = "xDarwin"; then
355   AC_CHECK_HEADERS(
356     [ \
357       mach/mach_init.h \
358       mach/host_priv.h \
359       mach/mach_error.h \
360       mach/mach_host.h \
361       mach/mach_port.h \
362       mach/mach_types.h \
363       mach/message.h \
364       mach/processor_set.h \
365       mach/processor.h \
366       mach/processor_info.h \
367       mach/task.h \
368       mach/thread_act.h \
369       mach/vm_region.h \
370       mach/vm_map.h \
371       mach/vm_prot.h \
372       mach/vm_statistics.h \
373       mach/kern_return.h \
374       CoreFoundation/CoreFoundation.h \
375       IOKit/IOKitLib.h \
376       IOKit/IOTypes.h \
377       IOKit/ps/IOPSKeys.h \
378       IOKit/IOBSD.h \
379       IOKit/storage/IOBlockStorageDriver.h
380     ]
381   )
382
383   # For the battery plugin
384   AC_CHECK_HEADERS([IOKit/ps/IOPowerSources.h], [], [],
385     [[
386       #if HAVE_IOKIT_IOKITLIB_H
387       #  include <IOKit/IOKitLib.h>
388       #endif
389       #if HAVE_IOKIT_IOTYPES_H
390       #  include <IOKit/IOTypes.h>
391       #endif
392     ]]
393   )
394 fi
395
396 AC_CHECK_HEADERS([sys/sysctl.h], [], [],
397   [[
398     #if HAVE_SYS_TYPES_H
399     #  include <sys/types.h>
400     #endif
401     #if HAVE_SYS_PARAM_H
402     # include <sys/param.h>
403     #endif
404   ]]
405 )
406
407 # For interface plugin
408 AC_CHECK_HEADERS([ifaddrs.h])
409 AC_CHECK_HEADERS([net/if.h], [], [],
410   [[
411     #if HAVE_SYS_TYPES_H
412     #  include <sys/types.h>
413     #endif
414     #if HAVE_SYS_SOCKET_H
415     #  include <sys/socket.h>
416     #endif
417   ]]
418 )
419
420 if test "x$ac_system" = "xLinux"; then
421   # For hddtemp module
422   AC_CHECK_HEADERS([linux/major.h])
423
424   # For md module (Linux only)
425   AC_CHECK_HEADERS([linux/raid/md_u.h],
426     [have_linux_raid_md_u_h="yes"],
427     [have_linux_raid_md_u_h="no"],
428     [[
429       #include <sys/ioctl.h>
430       #include <linux/major.h>
431       #include <linux/types.h>
432     ]]
433   )
434   AC_CHECK_HEADERS([sys/sysmacros.h])
435
436   AC_CHECK_HEADERS([linux/wireless.h],
437     [have_linux_wireless_h="yes"],
438     [have_linux_wireless_h="no"],
439     [[
440       #include <dirent.h>
441       #include <sys/ioctl.h>
442       #include <sys/socket.h>
443     ]]
444   )
445
446   AC_CHECK_HEADERS([linux/if.h], [], [],
447     [[
448       #if HAVE_SYS_TYPES_H
449       #  include <sys/types.h>
450       #endif
451       #if HAVE_SYS_SOCKET_H
452       #  include <sys/socket.h>
453       #endif
454     ]]
455   )
456
457   AC_CHECK_HEADERS([linux/inet_diag.h], [], [],
458     [[
459       #if HAVE_SYS_TYPES_H
460       #  include <sys/types.h>
461       #endif
462       #if HAVE_SYS_SOCKET_H
463       #  include <sys/socket.h>
464       #endif
465     ]]
466   )
467
468   AC_CHECK_HEADERS([linux/netdevice.h], [], [],
469     [[
470       #if HAVE_SYS_TYPES_H
471       #  include <sys/types.h>
472       #endif
473       #if HAVE_SYS_SOCKET_H
474       #  include <sys/socket.h>
475       #endif
476       #if HAVE_LINUX_IF_H
477       # include <linux/if.h>
478       #endif
479     ]]
480   )
481
482   # For ethstat module
483   AC_CHECK_HEADERS([linux/sockios.h],
484     [have_linux_sockios_h="yes"],
485     [have_linux_sockios_h="no"],
486     [[
487       #if HAVE_SYS_IOCTL_H
488       # include <sys/ioctl.h>
489       #endif
490       #if HAVE_NET_IF_H
491       # include <net/if.h>
492       #endif
493     ]]
494   )
495
496   AC_CHECK_HEADERS([linux/ethtool.h],
497     [have_linux_ethtool_h="yes"],
498     [have_linux_ethtool_h="no"],
499     [[
500       #if HAVE_SYS_IOCTL_H
501       # include <sys/ioctl.h>
502       #endif
503       #if HAVE_NET_IF_H
504       # include <net/if.h>
505       #endif
506       #if HAVE_LINUX_SOCKIOS_H
507       # include <linux/sockios.h>
508       #endif
509     ]]
510   )
511
512   # For ipvs module
513   AC_CHECK_HEADERS_ONCE([linux/ip_vs.h])
514
515   # For the email plugin
516   AC_CHECK_HEADERS([linux/un.h], [], [],
517     [[
518       #if HAVE_SYS_SOCKET_H
519       #  include <sys/socket.h>
520       #endif
521     ]]
522   )
523   # For the turbostat plugin
524   AC_CHECK_HEADERS([asm/msr-index.h],
525     [have_asm_msrindex_h="yes"],
526     [have_asm_msrindex_h="no"]
527   )
528
529   if test "x$have_asm_msrindex_h" = "xyes"; then
530     AC_CACHE_CHECK([whether asm/msr-index.h has MSR_PKG_C10_RESIDENCY],
531       [c_cv_have_usable_asm_msrindex_h],
532       [
533         AC_COMPILE_IFELSE(
534           [
535             AC_LANG_PROGRAM(
536               [[#include<asm/msr-index.h>]],
537               [[
538                 int y = MSR_PKG_C10_RESIDENCY;
539                 return(y);
540               ]]
541             )
542           ],
543           [c_cv_have_usable_asm_msrindex_h="yes"],
544           [c_cv_have_usable_asm_msrindex_h="no"],
545         )
546       ]
547     )
548   fi
549
550   AC_CHECK_HEADERS([cpuid.h],
551     [have_cpuid_h="yes"],
552     [have_cpuid_h="no (cpuid.h not found)"]
553   )
554
555   AC_CHECK_HEADERS([sys/capability.h],
556     [have_capability="yes"],
557     [have_capability="no (<sys/capability.h> not found)"]
558   )
559
560   if test "x$have_capability" = "xyes"; then
561     AC_CHECK_LIB([cap], [cap_get_proc],
562       [have_capability="yes"],
563       [have_capability="no (cap_get_proc() not found)"]
564     )
565   fi
566
567   if test "x$have_capability" = "xyes"; then
568     AC_CHECK_DECL([CAP_IS_SUPPORTED],
569       [have_capability="yes"],
570       [have_capability="no (CAP_IS_SUPPORTED not found)"],
571       [[#include <sys/capability.h>]]
572     )
573   fi
574
575   if test "x$have_capability" = "xyes"; then
576     AC_DEFINE([HAVE_CAPABILITY], [1], [Define to 1 if you have cap_get_proc() (-lcap).])
577   fi
578
579 else
580   have_linux_raid_md_u_h="no"
581   have_linux_wireless_h="no"
582 fi
583
584 AM_CONDITIONAL([BUILD_WITH_CAPABILITY], [test "x$have_capability" = "xyes"])
585
586 # For the swap module
587 have_sys_swap_h="yes"
588 AC_CHECK_HEADERS([sys/swap.h vm/anon.h],
589   [],
590   [have_sys_swap_h="no"],
591   [[
592     #undef _FILE_OFFSET_BITS
593     #undef _LARGEFILE64_SOURCE
594     #if HAVE_SYS_TYPES_H
595     #  include <sys/types.h>
596     #endif
597     #if HAVE_SYS_PARAM_H
598     # include <sys/param.h>
599     #endif
600   ]]
601 )
602
603 # For load module
604 # For the processes plugin
605 # For users module
606 AC_CHECK_HEADERS([sys/loadavg.h linux/config.h utmp.h utmpx.h])
607
608 # For quota module
609 AC_CHECK_HEADERS([sys/ucred.h], [], [],
610   [[
611     #if HAVE_SYS_TYPES_H
612     #  include <sys/types.h>
613     #endif
614     #if HAVE_SYS_PARAM_H
615     # include <sys/param.h>
616     #endif
617   ]]
618 )
619
620 # For mount interface
621 AC_CHECK_HEADERS([sys/mount.h], [], [],
622   [[
623     #if HAVE_SYS_TYPES_H
624     #  include <sys/types.h>
625     #endif
626     #if HAVE_SYS_PARAM_H
627     # include <sys/param.h>
628     #endif
629   ]]
630 )
631
632 # --enable-xfs {{{
633 AC_ARG_ENABLE([xfs],
634   [AS_HELP_STRING([--enable-xfs], [xfs support in df plugin @<:@default=yes@:>@])],
635   [],
636   [enable_xfs="auto"]
637 )
638
639 if test "x$enable_xfs" != "xno"; then
640   AC_CHECK_HEADERS([xfs/xqm.h],
641     [],
642     [
643       if test "x$enable_xfs" = "xyes"; then
644         AC_MSG_ERROR([xfs/xqm.h not found])
645       fi
646     ],
647     [[#define _GNU_SOURCE]]
648   )
649 fi
650
651 # }}}
652
653 # For the dns plugin
654 AC_CHECK_HEADERS([arpa/nameser.h])
655 AC_CHECK_HEADERS([arpa/nameser_compat.h], [], [],
656   [[
657     #if HAVE_ARPA_NAMESER_H
658     # include <arpa/nameser.h>
659     #endif
660   ]]
661 )
662
663 AC_CHECK_HEADERS([net/if_arp.h], [], [],
664   [[
665     #if HAVE_SYS_SOCKET_H
666     # include <sys/socket.h>
667     #endif
668   ]]
669 )
670
671 AC_CHECK_HEADERS([net/ppp_defs.h])
672 AC_CHECK_HEADERS([net/if_ppp.h], [], [],
673   [[
674     #if HAVE_NET_PPP_DEFS_H
675     # include <net/ppp_defs.h>
676     #endif
677   ]]
678 )
679
680 AC_CHECK_HEADERS([netinet/if_ether.h], [], [],
681   [[
682     #include <stdint.h>
683     #if HAVE_SYS_TYPES_H
684     # include <sys/types.h>
685     #endif
686     #if HAVE_SYS_SOCKET_H
687     # include <sys/socket.h>
688     #endif
689     #if HAVE_NET_IF_H
690     # include <net/if.h>
691     #endif
692     #if HAVE_NETINET_IN_H
693     # include <netinet/in.h>
694     #endif
695   ]]
696 )
697
698 AC_CHECK_HEADERS([net/pfvar.h],
699   [have_net_pfvar_h="yes"],
700   [have_net_pfvar_h="no"],
701   [[
702     #if HAVE_SYS_IOCTL_H
703     # include <sys/ioctl.h>
704     #endif
705     #if HAVE_SYS_SOCKET_H
706     # include <sys/socket.h>
707     #endif
708     #if HAVE_NET_IF_H
709     # include <net/if.h>
710     #endif
711     #if HAVE_NETINET_IN_H
712     # include <netinet/in.h>
713     #endif
714   ]]
715 )
716
717 # For the multimeter plugin
718 AC_CHECK_HEADERS([termios.h],
719   [have_termios_h="yes"],
720   [have_termios_h="no"]
721 )
722
723 # For cpusleep plugin
724 AC_CACHE_CHECK([whether clock_boottime and clock_monotonic are supported],
725   [c_cv_have_clock_boottime_monotonic],
726   [
727     AC_COMPILE_IFELSE(
728       [AC_LANG_PROGRAM(
729         [[#include <time.h>]],
730         [[
731           struct timespec b, m;
732           clock_gettime(CLOCK_BOOTTIME, &b );
733           clock_gettime(CLOCK_MONOTONIC, &m );
734         ]]
735       )
736       ],
737       [c_cv_have_clock_boottime_monotonic="yes"],
738       [c_cv_have_clock_boottime_monotonic="no"]
739     )
740   ]
741 )
742
743
744 #
745 # Checks for typedefs, structures, and compiler characteristics.
746 #
747 AC_C_CONST
748 AC_TYPE_PID_T
749 AC_TYPE_SIZE_T
750 AC_TYPE_UID_T
751 AC_HEADER_TIME
752
753 test_cxx_flags() {
754   AC_LANG_PUSH([C++])
755   AC_LANG_CONFTEST(
756     [AC_LANG_SOURCE([[int main(void){}]]) ]
757   )
758   $CXX -c conftest.cpp $CXXFLAGS $@ > /dev/null 2> /dev/null
759   ret=$?
760   rm -f conftest.o
761   AC_LANG_POP([C++])
762   return $ret
763 }
764
765 #
766 # Checks for library functions.
767 #
768 AC_CHECK_FUNCS_ONCE([ \
769     asprintf \
770     closelog \
771     getaddrinfo \
772     getgrnam_r \
773     getnameinfo \
774     getpwnam_r \
775     gettimeofday \
776     if_indextoname \
777     openlog \
778     regcomp \
779     regerror \
780     regexec \
781     regfree \
782     select \
783     setenv \
784     setgroups \
785     strcasecmp \
786     strdup \
787     strncasecmp \
788     sysconf
789   ]
790 )
791
792 AC_FUNC_STRERROR_R
793
794 SAVE_CFLAGS="$CFLAGS"
795 # Emulate behavior of src/Makefile.am
796 if test "x$GCC" = "xyes"; then
797   CFLAGS="$CFLAGS -Wall -Werror"
798 fi
799
800 AC_CACHE_CHECK([for strtok_r],
801   [c_cv_have_strtok_r_default],
802   [
803     AC_LINK_IFELSE(
804       [
805         AC_LANG_PROGRAM(
806           [[
807             #include <stdlib.h>
808             #include <stdio.h>
809             #include <string.h>
810           ]],
811           [[
812             char buffer[] = "foo,bar,baz";
813             char *token;
814             char *dummy;
815             char *saveptr;
816
817             dummy = buffer;
818             saveptr = NULL;
819             while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
820             {
821               dummy = NULL;
822               printf ("token = %s;\n", token);
823             }
824           ]]
825         )
826       ],
827       [c_cv_have_strtok_r_default="yes"],
828       [c_cv_have_strtok_r_default="no"]
829     )
830   ]
831 )
832
833 if test "x$c_cv_have_strtok_r_default" = "xno"; then
834   CFLAGS="$CFLAGS -D_REENTRANT=1"
835
836   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
837     [c_cv_have_strtok_r_reentrant],
838     [
839       AC_LINK_IFELSE(
840         [
841           AC_LANG_PROGRAM(
842             [[
843               #include <stdlib.h>
844               #include <stdio.h>
845               #include <string.h>
846             ]],
847             [[
848               char buffer[] = "foo,bar,baz";
849               char *token;
850               char *dummy;
851               char *saveptr;
852
853               dummy = buffer;
854               saveptr = NULL;
855               while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
856               {
857                 dummy = NULL;
858                 printf ("token = %s;\n", token);
859               }
860             ]]
861           )
862         ],
863         [c_cv_have_strtok_r_reentrant="yes"],
864         [AC_MSG_FAILURE([strtok_r is not available. Please file a bugreport!])]
865       )
866     ]
867   )
868 fi
869
870 CFLAGS="$SAVE_CFLAGS"
871 if test "x$c_cv_have_strtok_r_reentrant" = "xyes"; then
872   CFLAGS="$CFLAGS -D_REENTRANT=1"
873 fi
874
875 AC_CHECK_FUNCS([socket],
876   [],
877   [
878     AC_CHECK_LIB([socket], [socket],
879       [socket_needs_socket="yes"],
880       [AC_MSG_ERROR([cannot find socket() in libsocket])]
881     )
882   ]
883 )
884 AM_CONDITIONAL([BUILD_WITH_LIBSOCKET], [test "x$socket_needs_socket" = "xyes"])
885
886 clock_gettime_needs_posix4="no"
887 AC_CHECK_FUNCS([clock_gettime],
888   [have_clock_gettime="yes"],
889   [have_clock_gettime="no"]
890 )
891
892 if test "x$have_clock_gettime" = "xno"; then
893   AC_CHECK_LIB([rt], [clock_gettime],
894     [
895       clock_gettime_needs_rt="yes"
896       have_clock_gettime="yes"
897     ]
898   )
899 fi
900
901 if test "x$have_clock_gettime" = "xno"; then
902   AC_CHECK_LIB([posix4], [clock_gettime],
903     [
904       clock_gettime_needs_posix4="yes"
905       have_clock_gettime="yes"
906     ]
907   )
908 fi
909
910 if test "x$have_clock_gettime" = "xyes"; then
911   AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Define if the clock_gettime(2) function is available.])
912 fi
913
914 AC_CHECK_FUNCS([nanosleep], [],
915   AC_CHECK_LIB([rt], [nanosleep],
916     [nanosleep_needs_rt="yes"],
917     [
918       AC_CHECK_LIB([posix4], [nanosleep],
919         [nanosleep_needs_posix4="yes"],
920         [AC_MSG_ERROR([cannot find nanosleep])]
921       )
922     ]
923   )
924 )
925
926 AM_CONDITIONAL([BUILD_WITH_LIBRT], [test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes"])
927 AM_CONDITIONAL([BUILD_WITH_LIBPOSIX4], [test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes"])
928
929 AC_CHECK_FUNCS([getifaddrs], [have_getifaddrs="yes"], [have_getifaddrs="no"])
930 AC_CHECK_FUNCS([getloadavg], [have_getloadavg="yes"], [have_getloadavg="no"])
931 AC_CHECK_FUNCS([getutent], [have_getutent="yes"], [have_getutent="no"])
932 AC_CHECK_FUNCS([getutxent], [have_getutxent="yes"], [have_getutxent="no"])
933 AC_CHECK_FUNCS([host_statistics], [have_host_statistics="yes"], [have_host_statistics="no"])
934 AC_CHECK_FUNCS([processor_info], [have_processor_info="yes"], [have_processor_info="no"])
935 AC_CHECK_FUNCS([statfs], [have_statfs="yes"], [have_statfs="no"])
936 AC_CHECK_FUNCS([statvfs], [have_statvfs="yes"], [have_statvfs="no"])
937 AC_CHECK_FUNCS([sysctl], [have_sysctl="yes"], [have_sysctl="no"])
938 AC_CHECK_FUNCS([sysctlbyname], [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
939 AC_CHECK_FUNCS([syslog], [have_syslog="yes"], [have_syslog="no"])
940 AC_CHECK_FUNCS([thread_info], [have_thread_info="yes"], [have_thread_info="no"])
941
942 # Check for strptime {{{
943 if test "x$GCC" = "xyes"; then
944   SAVE_CFLAGS="$CFLAGS"
945   CFLAGS="$CFLAGS -Wall -Wextra -Werror"
946 fi
947
948 AC_CHECK_FUNCS([strptime], [have_strptime="yes"], [have_strptime="no"])
949 if test "x$have_strptime" = "xyes"; then
950   AC_CACHE_CHECK([whether strptime is exported by default],
951     [c_cv_have_strptime_default],
952     [
953       AC_COMPILE_IFELSE(
954         [
955           AC_LANG_PROGRAM(
956             [[#include <time.h>]],
957             [[
958               struct tm stm;
959               (void)strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
960             ]]
961           )
962         ],
963         [c_cv_have_strptime_default="yes"],
964         [c_cv_have_strptime_default="no"])
965     ]
966   )
967 fi
968
969 if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"; then
970   AC_CACHE_CHECK([whether strptime needs standards mode],
971     [c_cv_have_strptime_standards],
972     [
973       AC_COMPILE_IFELSE(
974         [
975           AC_LANG_PROGRAM(
976             [[
977               #ifndef _ISOC99_SOURCE
978               # define _ISOC99_SOURCE 1
979               #endif
980               #ifndef _POSIX_C_SOURCE
981               # define _POSIX_C_SOURCE 200112L
982               #endif
983               #ifndef _XOPEN_SOURCE
984               # define _XOPEN_SOURCE 500
985               #endif
986               #include <time.h>
987             ]],
988             [[
989               struct tm stm;
990               (void)strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
991             ]]
992           )
993         ],
994         [c_cv_have_strptime_standards="yes"],
995         [c_cv_have_strptime_standards="no"]
996       )
997     ]
998   )
999
1000   if test "x$c_cv_have_strptime_standards" = "xyes"; then
1001     AC_DEFINE([STRPTIME_NEEDS_STANDARDS], [1],
1002       [Set to true if strptime is only exported in X/Open mode (GNU libc).]
1003     )
1004   else
1005     have_strptime="no"
1006   fi
1007 fi
1008
1009 if test "x$GCC" = "xyes"; then
1010   CFLAGS="$SAVE_CFLAGS"
1011 fi
1012 # }}} Check for strptime
1013
1014 # Check for timegm {{{
1015
1016 # These checks need -Werror because implicit function declarations are only a
1017 # warning ...
1018 SAVE_CFLAGS="$CFLAGS"
1019 CFLAGS="$CFLAGS -Werror"
1020
1021 AC_CACHE_CHECK([for timegm],
1022   [c_cv_have_timegm],
1023   AC_LINK_IFELSE(
1024     [AC_LANG_PROGRAM(
1025 [[[
1026 #if STRPTIME_NEEDS_STANDARDS
1027 # ifndef _ISOC99_SOURCE
1028 #  define _ISOC99_SOURCE 1
1029 # endif
1030 # ifndef _POSIX_C_SOURCE
1031 #  define _POSIX_C_SOURCE 200112L
1032 # endif
1033 # ifndef _XOPEN_SOURCE
1034 #  define _XOPEN_SOURCE 500
1035 # endif
1036 #endif
1037 #include <time.h>
1038 ]]],
1039 [[[
1040  time_t t = timegm(&(struct tm){0});
1041  if (t == ((time_t) -1)) {
1042    return 1;
1043  }
1044 ]]]
1045     )],
1046     [c_cv_have_timegm="yes"],
1047     [c_cv_have_timegm="no"]
1048   )
1049 )
1050
1051 if test "x$c_cv_have_timegm" != "xyes"
1052 then
1053   AC_CACHE_CHECK([for timegm with _BSD_SOURCE],
1054     [c_cv_have_timegm_bsd],
1055     AC_LINK_IFELSE(
1056       [AC_LANG_PROGRAM(
1057 [[[
1058 #if STRPTIME_NEEDS_STANDARDS
1059 # ifndef _ISOC99_SOURCE
1060 #  define _ISOC99_SOURCE 1
1061 # endif
1062 # ifndef _POSIX_C_SOURCE
1063 #  define _POSIX_C_SOURCE 200112L
1064 # endif
1065 # ifndef _XOPEN_SOURCE
1066 #  define _XOPEN_SOURCE 500
1067 # endif
1068 #endif
1069 #ifndef _BSD_SOURCE
1070 # define _BSD_SOURCE 1
1071 #endif
1072 #include <time.h>
1073 ]]],
1074 [[[
1075  time_t t = timegm(&(struct tm){0});
1076  if (t == ((time_t) -1)) {
1077    return 1;
1078  }
1079 ]]]
1080       )],
1081       [c_cv_have_timegm_bsd="yes"
1082        c_cv_have_timegm="yes"],
1083       [c_cv_have_timegm_bsd="no"]
1084     )
1085   )
1086 fi
1087
1088 if test "x$c_cv_have_timegm" = "xyes"
1089 then
1090   AC_DEFINE(HAVE_TIMEGM, 1, [Define if the timegm(3) function is available.])
1091   if test "x$c_cv_have_timegm_bsd" = "xyes"
1092   then
1093     AC_DEFINE(TIMEGM_NEEDS_BSD, 1, [Set to true if timegm is only exported in BSD mode.])
1094   fi
1095 fi
1096
1097 CFLAGS="$SAVE_CFLAGS"
1098 # }}} Check for timegm
1099
1100 AC_MSG_CHECKING([for sysctl kern.cp_times])
1101 if test -x /sbin/sysctl; then
1102   /sbin/sysctl kern.cp_times >/dev/null 2>&1
1103   if test $? -eq 0; then
1104     AC_MSG_RESULT([yes])
1105     AC_DEFINE([HAVE_SYSCTL_KERN_CP_TIMES], [1], [Define if sysctl supports kern.cp_times])
1106   else
1107     AC_MSG_RESULT([no])
1108   fi
1109 else
1110   AC_MSG_RESULT([no])
1111 fi
1112
1113 AC_MSG_CHECKING([for sysctl kern.cp_time])
1114 if test -x /sbin/sysctl; then
1115   /sbin/sysctl kern.cp_time >/dev/null 2>&1
1116   if test $? -eq 0
1117   then
1118     AC_MSG_RESULT([yes])
1119     AC_DEFINE([HAVE_SYSCTL_KERN_CP_TIME], [1], [Define if sysctl supports kern.cp_time])
1120   else
1121     AC_MSG_RESULT([no])
1122   fi
1123 else
1124   AC_MSG_RESULT([no])
1125 fi
1126
1127 AC_CHECK_FUNCS([swapctl], [have_swapctl="yes"], [have_swapctl="no"])
1128 if test "x$have_swapctl" = "xyes"; then
1129   AC_CACHE_CHECK([whether swapctl takes two arguments],
1130     [c_cv_have_swapctl_two_args],
1131     [
1132       AC_COMPILE_IFELSE(
1133         [
1134           AC_LANG_PROGRAM(
1135             [[
1136               #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
1137               #  undef _FILE_OFFSET_BITS
1138               #  undef _LARGEFILE64_SOURCE
1139               #endif
1140               #include <sys/stat.h>
1141               #include <sys/param.h>
1142               #include <sys/swap.h>
1143               #include <unistd.h>
1144             ]],
1145             [[int num = swapctl(0, NULL);]]
1146           )
1147         ],
1148         [c_cv_have_swapctl_two_args="yes"],
1149         [c_cv_have_swapctl_two_args="no"]
1150       )
1151     ]
1152   )
1153
1154   AC_CACHE_CHECK([whether swapctl takes three arguments],
1155     [c_cv_have_swapctl_three_args],
1156     [
1157       AC_COMPILE_IFELSE(
1158         [
1159           AC_LANG_PROGRAM(
1160             [[
1161               #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
1162               #  undef _FILE_OFFSET_BITS
1163               #  undef _LARGEFILE64_SOURCE
1164               #endif
1165               #include <sys/stat.h>
1166               #include <sys/param.h>
1167               #include <sys/swap.h>
1168               #include <unistd.h>
1169             ]],
1170             [[int num = swapctl(0, NULL, 0);]]
1171           )
1172         ],
1173         [c_cv_have_swapctl_three_args="yes"],
1174         [c_cv_have_swapctl_three_args="no"]
1175       )
1176     ]
1177   )
1178 fi
1179
1180 # Check for different versions of `swapctl' here..
1181 if test "x$have_swapctl" = "xyes"; then
1182   if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
1183     AC_DEFINE([HAVE_SWAPCTL_TWO_ARGS], [1], [Define if the function swapctl exists and takes two arguments.])
1184   fi
1185
1186   if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
1187     AC_DEFINE([HAVE_SWAPCTL_THREE_ARGS], [1], [Define if the function swapctl exists and takes three arguments.])
1188   fi
1189 fi
1190
1191 # Check for NAN
1192 AC_ARG_WITH([nan-emulation],
1193   [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
1194   [
1195     if test "x$withval" = "xno"; then
1196       nan_type="none"
1197     else if test "x$withval" = "xyes"; then
1198       nan_type="zero"
1199     else
1200       nan_type="$withval"
1201     fi; fi
1202   ],
1203   [nan_type="none"]
1204 )
1205
1206 if test "x$nan_type" = "xnone"; then
1207   AC_CACHE_CHECK([whether NAN is defined by default],
1208     [c_cv_have_nan_default],
1209     [
1210       AC_COMPILE_IFELSE(
1211         [
1212           AC_LANG_PROGRAM(
1213             [[
1214               #include <stdlib.h>
1215               #include <math.h>
1216               static double foo = NAN;
1217             ]],
1218             [[
1219               if (isnan (foo))
1220                 return 0;
1221               return 1;
1222             ]]
1223           )
1224         ],
1225         [c_cv_have_nan_default="yes"],
1226         [c_cv_have_nan_default="no"]
1227       )
1228     ]
1229   )
1230 fi
1231
1232 if test "x$c_cv_have_nan_default" = "xyes"; then
1233   nan_type="default"
1234 fi
1235
1236 if test "x$nan_type" = "xnone"; then
1237   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
1238     [c_cv_have_nan_isoc],
1239     [
1240       AC_COMPILE_IFELSE(
1241         [
1242           AC_LANG_PROGRAM(
1243             [[
1244               #include <stdlib.h>
1245               #define __USE_ISOC99 1
1246               #include <math.h>
1247               static double foo = NAN;
1248             ]],
1249             [[
1250               if (isnan (foo))
1251                 return 0;
1252               return 1;
1253             ]]
1254           )
1255         ],
1256         [c_cv_have_nan_isoc="yes"],
1257         [c_cv_have_nan_isoc="no"]
1258       )
1259     ]
1260   )
1261 fi
1262
1263 if test "x$c_cv_have_nan_isoc" = "xyes"; then
1264   nan_type="isoc99"
1265 fi
1266
1267 if test "x$nan_type" = "xnone"; then
1268   SAVE_LDFLAGS="$LDFLAGS"
1269   LDFLAGS="$LDFLAGS -lm"
1270   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
1271     [c_cv_have_nan_zero],
1272     [
1273       AC_RUN_IFELSE(
1274         [
1275           AC_LANG_PROGRAM(
1276             [[
1277               #include <stdlib.h>
1278               #include <math.h>
1279               #ifdef NAN
1280               # undef NAN
1281               #endif
1282               #define NAN (0.0 / 0.0)
1283               #ifndef isnan
1284               # define isnan(f) ((f) != (f))
1285               #endif
1286               static double foo = NAN;
1287             ]],
1288             [[
1289               if (isnan (foo))
1290                 return 0;
1291               return 1;
1292             ]]
1293           )
1294         ],
1295         [c_cv_have_nan_zero="yes"],
1296         [c_cv_have_nan_zero="no"]
1297       )
1298     ]
1299   )
1300   LDFLAGS=$SAVE_LDFLAGS
1301 fi
1302
1303 if test "x$c_cv_have_nan_zero" = "xyes"; then
1304   nan_type="zero"
1305 fi
1306
1307 if test "x$nan_type" = "xdefault"; then
1308   AC_DEFINE([NAN_STATIC_DEFAULT], [1],
1309     [Define if NAN is defined by default and can initialize static variables.]
1310   )
1311 else if test "x$nan_type" = "xisoc99"; then
1312   AC_DEFINE([NAN_STATIC_ISOC], [1],
1313     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.]
1314   )
1315 else if test "x$nan_type" = "xzero"; then
1316   AC_DEFINE([NAN_ZERO_ZERO], [1],
1317     [Define if NAN can be defined as (0.0 / 0.0)]
1318   )
1319 else
1320   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
1321 fi; fi; fi
1322
1323 AC_ARG_WITH([fp-layout],
1324   [
1325     AS_HELP_STRING([--with-fp-layout],
1326       [set the memory layout of doubles. For crosscompiling only.]
1327     )
1328   ],
1329   [
1330     if test "x$withval" = "xnothing"; then
1331       fp_layout_type="nothing"
1332     else if test "x$withval" = "xendianflip"; then
1333       fp_layout_type="endianflip"
1334     else if test "x$withval" = "xintswap"; then
1335       fp_layout_type="intswap"
1336     else
1337       AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
1338     fi; fi; fi
1339   ],
1340   [fp_layout_type="unknown"]
1341 )
1342
1343 if test "x$fp_layout_type" = "xunknown"; then
1344   AC_CACHE_CHECK([if doubles are stored in x86 representation],
1345     [c_cv_fp_layout_need_nothing],
1346     [
1347       AC_RUN_IFELSE(
1348         [
1349           AC_LANG_PROGRAM(
1350             [[
1351               #include <stdlib.h>
1352               #include <stdio.h>
1353               #include <string.h>
1354               #include <stdint.h>
1355               #include <inttypes.h>
1356               #include <stdbool.h>
1357             ]],
1358             [[
1359               uint64_t i0;
1360               uint64_t i1;
1361               uint8_t c[8];
1362               double d;
1363
1364               d = 8.642135e130;
1365               memcpy ((void *) &i0, (void *) &d, 8);
1366
1367               i1 = i0;
1368               memcpy ((void *) c, (void *) &i1, 8);
1369
1370               if ((c[0] == 0x2f) && (c[1] == 0x25)
1371                   && (c[2] == 0xc0) && (c[3] == 0xc7)
1372                   && (c[4] == 0x43) && (c[5] == 0x2b)
1373                   && (c[6] == 0x1f) && (c[7] == 0x5b))
1374                 return 0;
1375               return 1;
1376             ]]
1377           )
1378         ],
1379         [c_cv_fp_layout_need_nothing="yes"],
1380         [c_cv_fp_layout_need_nothing="no"]
1381       )
1382     ]
1383   )
1384 fi
1385
1386 if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
1387   fp_layout_type="nothing"
1388 fi
1389
1390 if test "x$fp_layout_type" = "xunknown"; then
1391   AC_CACHE_CHECK([if endianflip converts to x86 representation],
1392     [c_cv_fp_layout_need_endianflip],
1393     [
1394       AC_RUN_IFELSE(
1395         [
1396           AC_LANG_PROGRAM(
1397             [[
1398               #include <stdlib.h>
1399               #include <stdio.h>
1400               #include <string.h>
1401               #include <stdint.h>
1402               #include <inttypes.h>
1403               #include <stdbool.h>
1404               #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
1405                                      (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
1406                                      (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
1407                                      (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
1408                                      (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
1409                                      (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
1410                                      (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
1411                                      (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
1412             ]],
1413             [[
1414               uint64_t i0;
1415               uint64_t i1;
1416               uint8_t c[8];
1417               double d;
1418
1419               d = 8.642135e130;
1420               memcpy ((void *) &i0, (void *) &d, 8);
1421
1422               i1 = endianflip (i0);
1423               memcpy ((void *) c, (void *) &i1, 8);
1424
1425               if ((c[0] == 0x2f) && (c[1] == 0x25)
1426                   && (c[2] == 0xc0) && (c[3] == 0xc7)
1427                   && (c[4] == 0x43) && (c[5] == 0x2b)
1428                   && (c[6] == 0x1f) && (c[7] == 0x5b))
1429                 return 0;
1430               return 1;
1431             ]]
1432           )
1433         ],
1434         [c_cv_fp_layout_need_endianflip="yes"],
1435         [c_cv_fp_layout_need_endianflip="no"]
1436       ]
1437     )
1438   )
1439 fi
1440
1441 if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
1442   fp_layout_type="endianflip"
1443 fi
1444
1445 if test "x$fp_layout_type" = "xunknown"; then
1446   AC_CACHE_CHECK([if intswap converts to x86 representation],
1447     [c_cv_fp_layout_need_intswap],
1448     [
1449       AC_RUN_IFELSE(
1450         [
1451           AC_LANG_PROGRAM(
1452             [[
1453               #include <stdlib.h>
1454               #include <stdio.h>
1455               #include <string.h>
1456               #include <stdint.h>
1457               #include <inttypes.h>
1458               #include <stdbool.h>
1459               #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
1460                                      (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
1461             ]],
1462             [[
1463               uint64_t i0;
1464               uint64_t i1;
1465               uint8_t c[8];
1466               double d;
1467
1468               d = 8.642135e130;
1469               memcpy ((void *) &i0, (void *) &d, 8);
1470
1471               i1 = intswap (i0);
1472               memcpy ((void *) c, (void *) &i1, 8);
1473
1474               if ((c[0] == 0x2f) && (c[1] == 0x25)
1475                   && (c[2] == 0xc0) && (c[3] == 0xc7)
1476                   && (c[4] == 0x43) && (c[5] == 0x2b)
1477                   && (c[6] == 0x1f) && (c[7] == 0x5b))
1478                 return 0;
1479               return 1;
1480             ]]
1481           )
1482         ],
1483         [c_cv_fp_layout_need_intswap="yes"],
1484         [c_cv_fp_layout_need_intswap="no"]
1485       )
1486     ]
1487   )
1488 fi
1489
1490 if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
1491   fp_layout_type="intswap"
1492 fi
1493
1494 if test "x$fp_layout_type" = "xnothing"; then
1495   AC_DEFINE([FP_LAYOUT_NEED_NOTHING], [1],
1496     [Define if doubles are stored in x86 representation.]
1497   )
1498 else if test "x$fp_layout_type" = "xendianflip"; then
1499   AC_DEFINE([FP_LAYOUT_NEED_ENDIANFLIP], [1],
1500     [Define if endianflip is needed to convert to x86 representation.]
1501   )
1502 else if test "x$fp_layout_type" = "xintswap"; then
1503   AC_DEFINE([FP_LAYOUT_NEED_INTSWAP], [1],
1504     [Define if intswap is needed to convert to x86 representation.]
1505   )
1506 else
1507   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
1508 fi; fi; fi
1509
1510 # For cpusleep plugin
1511 AC_CACHE_CHECK([whether clock_boottime and clock_monotonic are supported],
1512   [c_cv_have_clock_boottime_monotonic],
1513   [
1514     AC_COMPILE_IFELSE(
1515       [AC_LANG_PROGRAM(
1516         [[#include <time.h>]],
1517         [[
1518           struct timespec b, m;
1519           clock_gettime(CLOCK_BOOTTIME, &b );
1520           clock_gettime(CLOCK_MONOTONIC, &m );
1521         ]]
1522       )
1523       ],
1524       [c_cv_have_clock_boottime_monotonic="yes"],
1525       [c_cv_have_clock_boottime_monotonic="no"]
1526     )
1527   ]
1528 )
1529
1530 # --with-useragent {{{
1531 AC_ARG_WITH([useragent],
1532   [AS_HELP_STRING([--with-useragent@<:@=AGENT@:>@], [User agent to use on http requests])],
1533   [
1534     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
1535       AC_DEFINE_UNQUOTED([COLLECTD_USERAGENT], ["$withval"], [User agent for http requests])
1536     fi
1537   ]
1538 )
1539
1540 # }}}
1541
1542 # --with-data-max-name-len {{{
1543 AC_ARG_WITH([data-max-name-len],
1544   [AS_HELP_STRING([--with-data-max-name-len@<:@=VALUE@:>@], [Maximum length of data buffers])],
1545   [
1546     if test "x$withval" != "x" && test $withval -gt 0; then
1547       AC_DEFINE_UNQUOTED([DATA_MAX_NAME_LEN], [$withval], [Maximum length of data buffers])
1548     else
1549       AC_MSG_ERROR([DATA_MAX_NAME_LEN must be a positive integer -- $withval given])
1550     fi
1551   ],
1552   [AC_DEFINE([DATA_MAX_NAME_LEN], [128], [Maximum length of data buffers])]
1553 )
1554 # }}}
1555
1556 AC_CHECK_FUNCS([getfsstat], [have_getfsstat="yes"], [have_getfsstat="no"])
1557 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"], [have_getvfsstat="no"])
1558 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"], [have_listmntent="no"])
1559 AC_CHECK_FUNCS(getmntent_r, [have_getmntent_r="yes"], [have_getmntent_r="no"])
1560
1561 AC_CHECK_FUNCS(getmntent, [have_getmntent="libc"], [have_getmntent="no"])
1562 if test "x$have_getmntent" = "xno"; then
1563   AC_CHECK_LIB([sun], [getmntent],
1564     [have_getmntent="sun"],
1565     [have_gemntent="no"]
1566   )
1567 fi
1568
1569 if test "x$have_getmntent" = "xno"; then
1570   AC_CHECK_LIB([seq], [getmntent],
1571     [have_getmntent="seq"],
1572     [have_getmntent="no"]
1573   )
1574 fi
1575
1576 if test "x$have_getmntent" = "xno"; then
1577   AC_CHECK_LIB([gen], [getmntent],
1578     [have_getmntent="gen"],
1579     [have_getmntent="no"]
1580   )
1581 fi
1582
1583 if test "x$have_getmntent" = "xlibc"; then
1584   AC_CACHE_CHECK([whether getmntent takes one argument],
1585     [c_cv_have_one_getmntent],
1586     [
1587       AC_COMPILE_IFELSE(
1588         [
1589           AC_LANG_PROGRAM(
1590             [[#include "$srcdir/src/utils_mount.h"]],
1591             [[
1592               FILE *fh;
1593               struct mntent *me;
1594               fh = setmntent ("/etc/mtab", "r");
1595               me = getmntent (fh);
1596               return(me->mnt_passno);
1597             ]]
1598           )
1599         ],
1600         [c_cv_have_one_getmntent="yes"],
1601         [c_cv_have_one_getmntent="no"]
1602       )
1603     ]
1604   )
1605
1606   AC_CACHE_CHECK([whether getmntent takes two arguments],
1607     [c_cv_have_two_getmntent],
1608     [
1609       AC_COMPILE_IFELSE(
1610         [
1611           AC_LANG_PROGRAM(
1612             [[#include "$srcdir/src/utils_mount.h"]],
1613             [[
1614               FILE *fh;
1615               struct mnttab mt;
1616               int status;
1617               fh = fopen ("/etc/mnttab", "r");
1618               status = getmntent (fh, &mt);
1619               return(status);
1620             ]]
1621           )
1622         ],
1623         [c_cv_have_two_getmntent="yes"],
1624         [c_cv_have_two_getmntent="no"]
1625       )
1626     ]
1627   )
1628 fi
1629
1630 # Check for different versions of `getmntent' here..
1631
1632 if test "x$have_getmntent" = "xlibc"; then
1633   if test "x$c_cv_have_one_getmntent" = "xyes"; then
1634     AC_DEFINE([HAVE_ONE_GETMNTENT], [1],
1635       [Define if the function getmntent exists and takes one argument.]
1636     )
1637   fi
1638
1639   if test "x$c_cv_have_two_getmntent" = "xyes"; then
1640     AC_DEFINE([HAVE_TWO_GETMNTENT], [1],
1641       [Define if the function getmntent exists and takes two arguments.]
1642     )
1643   fi
1644 fi
1645
1646 if test "x$have_getmntent" = "xsun"; then
1647   AC_DEFINE([HAVE_SUN_GETMNTENT], [1],
1648     [Define if the function getmntent exists. It is the version from libsun.]
1649   )
1650 fi
1651
1652 if test "x$have_getmntent" = "xgen"; then
1653   AC_DEFINE([HAVE_GEN_GETMNTENT], [1],
1654     [Define if the function getmntent exists. It is the version from libgen.]
1655   )
1656 fi
1657
1658 # Check for htonll
1659 AC_CACHE_CHECK([whether htonll is defined],
1660   [c_cv_have_htonll],
1661   [
1662     AC_LINK_IFELSE(
1663       [
1664         AC_LANG_PROGRAM(
1665           [[
1666             #include <inttypes.h>
1667             #include <sys/types.h>
1668             #include <netinet/in.h>
1669           ]],
1670           [[return htonll(0);]]
1671         )
1672       ],
1673       [c_cv_have_htonll="yes"],
1674       [c_cv_have_htonll="no"]
1675     )
1676   ]
1677 )
1678
1679 if test "x$c_cv_have_htonll" = "xyes"; then
1680   AC_DEFINE([HAVE_HTONLL], [1], [Define if the function htonll exists.])
1681 fi
1682
1683 # Check for structures
1684 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
1685   [AC_DEFINE([HAVE_STRUCT_IF_DATA], [1], [Define if struct if_data exists and is usable.])],
1686   [],
1687   [[
1688     #include <sys/types.h>
1689     #include <sys/socket.h>
1690     #include <net/if.h>
1691   ]]
1692 )
1693
1694 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
1695   [AC_DEFINE([HAVE_STRUCT_NET_DEVICE_STATS], [1], [Define if struct net_device_stats exists and is usable.])],
1696   [],
1697   [[
1698     #include <sys/types.h>
1699     #include <sys/socket.h>
1700     #include <linux/if.h>
1701     #include <linux/netdevice.h>
1702   ]]
1703 )
1704
1705 AC_CHECK_MEMBERS([struct inet_diag_req.id, struct inet_diag_req.idiag_states],
1706   [AC_DEFINE([HAVE_STRUCT_LINUX_INET_DIAG_REQ], [1], [Define if struct inet_diag_req exists and is usable.])],
1707   [],
1708   [[#include <linux/inet_diag.h>]]
1709 )
1710
1711 AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [],
1712   [],
1713   [[
1714     #include <netinet/in.h>
1715     #include <net/if.h>
1716   ]]
1717 )
1718
1719 AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
1720   [
1721     AC_DEFINE([HAVE_STRUCT_KINFO_PROC_FREEBSD], [1], [Define if struct kinfo_proc exists in the FreeBSD variant.])
1722     have_struct_kinfo_proc_freebsd="yes"
1723   ],
1724   [],
1725   [[
1726     #include <kvm.h>
1727     #include <sys/param.h>
1728     #include <sys/sysctl.h>
1729     #include <sys/user.h>
1730   ]]
1731 )
1732
1733 AC_CHECK_MEMBERS([struct kinfo_proc.p_pid, struct kinfo_proc.p_vm_rssize],
1734   [
1735     AC_DEFINE([HAVE_STRUCT_KINFO_PROC_OPENBSD], [1], [Define if struct kinfo_proc exists in the OpenBSD variant.])
1736     have_struct_kinfo_proc_openbsd="yes"
1737   ],
1738   [],
1739   [[
1740     #include <sys/param.h>
1741     #include <sys/sysctl.h>
1742     #include <kvm.h>
1743   ]]
1744 )
1745
1746 AC_CHECK_MEMBERS([struct kinfo_proc2.p_pid, struct kinfo_proc2.p_uru_maxrss],
1747   [
1748     AC_DEFINE([HAVE_STRUCT_KINFO_PROC2_NETBSD], [1], [Define if struct kinfo_proc2 exists in the NetBSD variant.])
1749     have_struct_kinfo_proc2_netbsd="yes"
1750   ],
1751   [],
1752   [[
1753     #include <sys/param.h>
1754     #include <sys/sysctl.h>
1755     #include <kvm.h>
1756   ]]
1757 )
1758
1759 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport],
1760   [],
1761   [],
1762   [[
1763     #define _BSD_SOURCE
1764     #define _DEFAULT_SOURCE
1765     #include <stdint.h>
1766     #if HAVE_SYS_TYPES_H
1767     # include <sys/types.h>
1768     #endif
1769     #if HAVE_NETINET_IN_SYSTM_H
1770     # include <netinet/in_systm.h>
1771     #endif
1772     #if HAVE_NETINET_IN_H
1773     # include <netinet/in.h>
1774     #endif
1775     #if HAVE_NETINET_IP_H
1776     # include <netinet/ip.h>
1777     #endif
1778     #if HAVE_NETINET_UDP_H
1779     # include <netinet/udp.h>
1780     #endif
1781   ]]
1782 )
1783
1784 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source],
1785   [],
1786   [],
1787   [[
1788     #define _BSD_SOURCE
1789     #define _DEFAULT_SOURCE
1790     #include <stdint.h>
1791     #if HAVE_SYS_TYPES_H
1792     # include <sys/types.h>
1793     #endif
1794     #if HAVE_NETINET_IN_SYSTM_H
1795     # include <netinet/in_systm.h>
1796     #endif
1797     #if HAVE_NETINET_IN_H
1798     # include <netinet/in.h>
1799     #endif
1800     #if HAVE_NETINET_IP_H
1801     # include <netinet/ip.h>
1802     #endif
1803     #if HAVE_NETINET_UDP_H
1804     # include <netinet/udp.h>
1805     #endif
1806   ]]
1807 )
1808
1809 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
1810   [],
1811   [],
1812   [[# include <kstat.h>]]
1813 )
1814
1815 # check for pthread_setname_np
1816 SAVE_LDFLAGS="$LDFLAGS"
1817 LDFLAGS="$LDFLAGS -lpthread"
1818
1819 AC_MSG_CHECKING([for pthread_setname_np])
1820 have_pthread_setname_np="no"
1821 AC_LINK_IFELSE(
1822   [
1823     AC_LANG_PROGRAM(
1824       [[
1825         #define _GNU_SOURCE
1826         #include <pthread.h>
1827       ]],
1828       [[pthread_setname_np((pthread_t) {0}, "conftest");]]
1829     )
1830   ],
1831   [
1832     have_pthread_setname_np="yes"
1833     AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [pthread_setname_np() is available.])
1834   ]
1835 )
1836
1837 AC_MSG_RESULT([$have_pthread_setname_np])
1838
1839 # check for pthread_set_name_np(3) (FreeBSD)
1840 AC_MSG_CHECKING([for pthread_set_name_np])
1841 have_pthread_set_name_np="no"
1842 AC_LINK_IFELSE(
1843   [
1844     AC_LANG_PROGRAM(
1845       [[#include <pthread_np.h>]],
1846       [[pthread_set_name_np((pthread_t) {0}, "conftest");]]
1847     )
1848    ],
1849   [
1850     have_pthread_set_name_np="yes"
1851     AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [pthread_set_name_np() is available.])
1852   ]
1853 )
1854 AC_MSG_RESULT([$have_pthread_set_name_np])
1855
1856 LDFLAGS="$SAVE_LDFLAGS"
1857
1858 AC_CHECK_TYPES([struct ip6_ext],
1859   [have_ip6_ext="yes"],
1860   [have_ip6_ext="no"],
1861   [[
1862     #include <stdint.h>
1863     #if HAVE_SYS_TYPES_H
1864     # include <sys/types.h>
1865     #endif
1866     #if HAVE_NETINET_IN_SYSTM_H
1867     # include <netinet/in_systm.h>
1868     #endif
1869     #if HAVE_NETINET_IN_H
1870     # include <netinet/in.h>
1871     #endif
1872     #if HAVE_NETINET_IP6_H
1873     # include <netinet/ip6.h>
1874     #endif
1875   ]]
1876 )
1877
1878 if test "x$have_ip6_ext" = "xno"; then
1879   SAVE_CFLAGS="$CFLAGS"
1880   CFLAGS="$CFLAGS -DSOLARIS2=8"
1881   AC_CHECK_TYPES([struct ip6_ext],
1882     [have_ip6_ext="yes, with -DSOLARIS2=8"],
1883     [have_ip6_ext="no"],
1884     [[
1885       #include <stdint.h>
1886       #if HAVE_SYS_TYPES_H
1887       # include <sys/types.h>
1888       #endif
1889       #if HAVE_NETINET_IN_SYSTM_H
1890       # include <netinet/in_systm.h>
1891       #endif
1892       #if HAVE_NETINET_IN_H
1893       # include <netinet/in.h>
1894       #endif
1895       #if HAVE_NETINET_IP6_H
1896       # include <netinet/ip6.h>
1897       #endif
1898     ]]
1899   )
1900   if test "x$have_ip6_ext" = "xno"; then
1901     CFLAGS="$SAVE_CFLAGS"
1902   fi
1903 fi
1904
1905 # libi2c-dev
1906 if test "x$ac_system" = "xLinux"; then
1907   AC_CHECK_DECL([i2c_smbus_read_i2c_block_data],
1908     [with_libi2c="yes"],
1909     [with_libi2c="no (symbol i2c_smbus_read_i2c_block_data not found - have you installed libi2c-dev ?)"],
1910     [[
1911       #include <stdlib.h>
1912       #include <linux/i2c-dev.h>
1913     ]]
1914   )
1915 else
1916   with_libi2c="no (Linux only)"
1917 fi
1918
1919 #
1920 # Checks for libraries begin here
1921 #
1922
1923 # Check for libpthread
1924 SAVE_LIBS="$LIBS"
1925 AC_CHECK_LIB([pthread],
1926   [pthread_create],
1927   [],
1928   [AC_MSG_ERROR([Symbol 'pthread_create' not found in libpthread])],
1929   []
1930 )
1931 PTHREAD_LIBS="$LIBS"
1932 LIBS="$SAVE_LIBS"
1933 AC_SUBST([PTHREAD_LIBS])
1934
1935 AC_CHECK_HEADERS([pthread.h],
1936   [],
1937   [AC_MSG_ERROR([pthread.h not found])]
1938 )
1939
1940 m4_divert_once([HELP_WITH], [
1941 Collectd additional packages:])
1942
1943 if test "x$ac_system" = "xAIX"; then
1944   with_perfstat="yes"
1945   with_procinfo="yes"
1946 else
1947   with_perfstat="no (AIX only)"
1948   with_procinfo="no (AIX only)"
1949 fi
1950
1951 if test "x$with_perfstat" = "xyes"; then
1952   AC_CHECK_LIB([perfstat], [perfstat_reset],
1953     [with_perfstat="yes"],
1954     [with_perfstat="no (perfstat not found)"]
1955   )
1956 fi
1957
1958 if test "x$with_perfstat" = "xyes"; then
1959   AC_DEFINE([HAVE_PERFSTAT], [1], [Define to 1 if you have the 'perfstat' library (-lperfstat)])
1960   # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
1961   AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled],
1962     [],
1963     [],
1964     [[#include <libperfstat.h]]
1965   )
1966   if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"; then
1967     AC_DEFINE([PERFSTAT_SUPPORTS_DONATION], [1], [Define to 1 if your version of the 'perfstat' library supports donation])
1968   fi
1969 fi
1970 AM_CONDITIONAL([BUILD_WITH_PERFSTAT], [test "x$with_perfstat" = "xyes"])
1971
1972 # Processes plugin under AIX.
1973 if test "x$with_procinfo" = "xyes"; then
1974   AC_CHECK_HEADERS([procinfo.h],
1975     [AC_DEFINE([HAVE_PROCINFO_H], [1], [Define to 1 if you have the procinfo.h])],
1976     [with_procinfo="no (procinfo.h not found)"]
1977   )
1978 fi
1979
1980 if test "x$ac_system" = "xSolaris"; then
1981   with_kstat="yes"
1982   with_devinfo="yes"
1983 else
1984   with_kstat="no (Solaris only)"
1985   with_devinfo="no (Solaris only)"
1986 fi
1987
1988 if test "x$with_kstat" = "xyes"; then
1989   AC_CHECK_LIB([kstat], [kstat_open],
1990     [with_kstat="yes"],
1991     [with_kstat="no (libkstat not found)"]
1992   )
1993 fi
1994
1995 if test "x$with_kstat" = "xyes"; then
1996   AC_CHECK_LIB([devinfo], [di_init],
1997     [with_devinfo="yes"],
1998     [with_devinfo="no (not found)"]
1999   )
2000   AC_CHECK_HEADERS([kstat.h],
2001     [AC_DEFINE(HAVE_LIBKSTAT, [1], [Define to 1 if you have the 'kstat' library (-lkstat)])],
2002     [with_kstat="no (kstat.h not found)"]
2003   )
2004 fi
2005
2006 AM_CONDITIONAL([BUILD_WITH_LIBDEVINFO], [test "x$with_devinfo" = "xyes"])
2007 AM_CONDITIONAL([BUILD_WITH_LIBKSTAT], [test "x$with_kstat" = "xyes"])
2008
2009 if test "x$ac_system" = "xDarwin"; then
2010   with_libiokit="yes"
2011 else
2012   with_libiokit="no"
2013 fi
2014 AM_CONDITIONAL([BUILD_WITH_LIBIOKIT], [test "x$with_libiokit" = "xyes"])
2015
2016 with_libkvm="no"
2017 AC_CHECK_LIB([kvm], [kvm_getprocs],
2018   [with_kvm_getprocs="yes"],
2019   [with_kvm_getprocs="no"]
2020 )
2021
2022 if test "x$with_kvm_getprocs" = "xyes"; then
2023   AC_DEFINE([HAVE_LIBKVM_GETPROCS], [1],
2024     [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)]
2025   )
2026   with_libkvm="yes"
2027 fi
2028
2029 AM_CONDITIONAL([BUILD_WITH_LIBKVM_GETPROCS], [test "x$with_kvm_getprocs" = "xyes"])
2030
2031 AC_CHECK_LIB([kvm], [kvm_getswapinfo],
2032   [with_kvm_getswapinfo="yes"],
2033   [with_kvm_getswapinfo="no"]
2034 )
2035
2036 if test "x$with_kvm_getswapinfo" = "xyes"; then
2037   AC_DEFINE([HAVE_LIBKVM_GETSWAPINFO], [1],
2038     [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)]
2039   )
2040   with_libkvm="yes"
2041 fi
2042
2043 AM_CONDITIONAL([BUILD_WITH_LIBKVM_GETSWAPINFO], [test "x$with_kvm_getswapinfo" = "xyes"])
2044
2045 AC_CHECK_LIB([kvm], [kvm_nlist],
2046   [with_kvm_nlist="yes"],
2047   [with_kvm_nlist="no"]
2048 )
2049
2050 if test "x$with_kvm_nlist" = "xyes"; then
2051   AC_CHECK_HEADERS([bsd/nlist.h nlist.h])
2052   AC_DEFINE([HAVE_LIBKVM_NLIST], [1],
2053     [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)]
2054   )
2055   with_libkvm="yes"
2056 fi
2057
2058 AM_CONDITIONAL([BUILD_WITH_LIBKVM_NLIST], [test "x$with_kvm_nlist" = "xyes"])
2059
2060 AC_CHECK_LIB([kvm], [kvm_openfiles],
2061   [with_kvm_openfiles="yes"],
2062   [with_kvm_openfiles="no"]
2063 )
2064
2065 if test "x$with_kvm_openfiles" = "xyes"; then
2066   AC_DEFINE([HAVE_LIBKVM_NLIST], [1],
2067     [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)]
2068   )
2069   with_libkvm="yes"
2070 fi
2071
2072 # --with-libaquaero5 {{{
2073 AC_ARG_WITH([libaquaero5],
2074   [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
2075   [
2076     if test "x$withval" = "xyes"; then
2077       with_libaquaero5="yes"
2078     else if test "x$withval" = "xno"; then
2079       with_libaquaero5="no"
2080     else
2081       with_libaquaero5="yes"
2082       LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS -I$withval/src"
2083       LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS -L$withval/obj"
2084     fi; fi
2085   ],
2086   [with_libaquaero5="yes"]
2087 )
2088
2089 SAVE_CPPFLAGS="$CPPFLAGS"
2090 SAVE_LDFLAGS="$LDFLAGS"
2091 CPPFLAGS="$CPPFLAGS $LIBAQUAERO5_CFLAGS"
2092 LDFLAGS="$LDFLAGS $LIBAQUAERO5_LDFLAGS"
2093
2094 if test "x$with_libaquaero5" = "xyes"; then
2095   if test "x$LIBAQUAERO5_CFLAGS" != "x"; then
2096     AC_MSG_NOTICE([libaquaero5 CPPFLAGS: $LIBAQUAERO5_CFLAGS])
2097   fi
2098   AC_CHECK_HEADERS([libaquaero5.h],
2099     [with_libaquaero5="yes"],
2100     [with_libaquaero5="no (libaquaero5.h not found)"]
2101   )
2102 fi
2103
2104 if test "x$with_libaquaero5" = "xyes"; then
2105   if test "x$LIBAQUAERO5_LDFLAGS" != "x"; then
2106     AC_MSG_NOTICE([libaquaero5 LDFLAGS: $LIBAQUAERO5_LDFLAGS])
2107   fi
2108   AC_CHECK_LIB([aquaero5], libaquaero5_poll,
2109     [with_libaquaero5="yes"],
2110     [with_libaquaero5="no (symbol 'libaquaero5_poll' not found)"]
2111   )
2112 fi
2113
2114 CPPFLAGS="$SAVE_CPPFLAGS"
2115 LDFLAGS="$SAVE_LDFLAGS"
2116
2117 if test "x$with_libaquaero5" = "xyes"; then
2118   BUILD_WITH_LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS"
2119   BUILD_WITH_LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS"
2120 fi
2121 AC_SUBST([BUILD_WITH_LIBAQUAERO5_CFLAGS])
2122 AC_SUBST([BUILD_WITH_LIBAQUAERO5_LDFLAGS])
2123 # }}}
2124
2125 # --with-libhiredis {{{
2126 AC_ARG_WITH([libhiredis],
2127   [AS_HELP_STRING([--with-libhiredis@<:@=PREFIX@:>@], [Path to libhiredis.])],
2128   [
2129     if test "x$withval" = "xyes"; then
2130       with_libhiredis="yes"
2131     else if test "x$withval" = "xno"; then
2132       with_libhiredis="no"
2133     else
2134       with_libhiredis="yes"
2135       LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS -I$withval/include"
2136       LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS -L$withval/lib"
2137     fi; fi
2138   ],
2139   [with_libhiredis="yes"]
2140 )
2141
2142 SAVE_CPPFLAGS="$CPPFLAGS"
2143 SAVE_LDFLAGS="$LDFLAGS"
2144 CPPFLAGS="$CPPFLAGS $LIBHIREDIS_CPPFLAGS"
2145 LDFLAGS="$LDFLAGS $LIBHIREDIS_LDFLAGS"
2146
2147 if test "x$with_libhiredis" = "xyes"; then
2148   if test "x$LIBHIREDIS_CPPFLAGS" != "x"; then
2149     AC_MSG_NOTICE([libhiredis CPPFLAGS: $LIBHIREDIS_CPPFLAGS])
2150   fi
2151   AC_CHECK_HEADERS([hiredis/hiredis.h],
2152     [with_libhiredis="yes"],
2153     [with_libhiredis="no (hiredis.h not found)"]
2154   )
2155 fi
2156
2157 if test "x$with_libhiredis" = "xyes"; then
2158   if test "x$LIBHIREDIS_LDFLAGS" != "x"; then
2159     AC_MSG_NOTICE([libhiredis LDFLAGS: $LIBHIREDIS_LDFLAGS])
2160   fi
2161   AC_CHECK_LIB([hiredis], [redisCommand],
2162     [with_libhiredis="yes"],
2163     [with_libhiredis="no (symbol 'redisCommand' not found)"]
2164   )
2165 fi
2166
2167 CPPFLAGS="$SAVE_CPPFLAGS"
2168 LDFLAGS="$SAVE_LDFLAGS"
2169
2170 if test "x$with_libhiredis" = "xyes"; then
2171   BUILD_WITH_LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS"
2172   BUILD_WITH_LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS"
2173 fi
2174
2175 AC_SUBST([BUILD_WITH_LIBHIREDIS_CPPFLAGS])
2176 AC_SUBST([BUILD_WITH_LIBHIREDIS_LDFLAGS])
2177 # }}}
2178
2179 # --with-libcurl {{{
2180 with_curl_config="curl-config"
2181 with_curl_cflags=""
2182 with_curl_libs=""
2183 AC_ARG_WITH(libcurl,
2184   [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
2185   [
2186     if test "x$withval" = "xno"; then
2187       with_libcurl="no"
2188     else if test "x$withval" = "xyes"; then
2189       with_libcurl="yes"
2190     else
2191       if test -f "$withval" && test -x "$withval"; then
2192         with_curl_config="$withval"
2193         with_libcurl="yes"
2194       else if test -x "$withval/bin/curl-config"; then
2195         with_curl_config="$withval/bin/curl-config"
2196         with_libcurl="yes"
2197       fi; fi
2198       with_libcurl="yes"
2199     fi; fi
2200   ],
2201   [with_libcurl="yes"]
2202 )
2203
2204 if test "x$with_libcurl" = "xyes"; then
2205   with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
2206   curl_config_status=$?
2207
2208   if test $curl_config_status -ne 0; then
2209     with_libcurl="no ($with_curl_config failed)"
2210   else
2211     SAVE_CPPFLAGS="$CPPFLAGS"
2212     CPPFLAGS="$CPPFLAGS $with_curl_cflags"
2213
2214     AC_CHECK_HEADERS([curl/curl.h],
2215       [with_libcurl="yes"],
2216       [with_libcurl="no (curl/curl.h not found)"]
2217     )
2218
2219     CPPFLAGS="$SAVE_CPPFLAGS"
2220   fi
2221 fi
2222
2223 if test "x$with_libcurl" = "xyes"; then
2224   with_curl_libs=`$with_curl_config --libs 2>/dev/null`
2225   curl_config_status=$?
2226
2227   if test $curl_config_status -ne 0; then
2228     with_libcurl="no ($with_curl_config failed)"
2229   else
2230     AC_CHECK_LIB([curl], [curl_easy_init],
2231       [with_libcurl="yes"],
2232       [with_libcurl="no (symbol 'curl_easy_init' not found)"],
2233       [$with_curl_libs]
2234     )
2235
2236     AC_CHECK_DECL([CURLOPT_USERNAME],
2237       [have_curlopt_username="yes"],
2238       [have_curlopt_username="no"],
2239       [[#include <curl/curl.h>]]
2240     )
2241
2242     AC_CHECK_DECL(CURLOPT_TIMEOUT_MS,
2243       [have_curlopt_timeout="yes"],
2244       [have_curlopt_timeout="no"],
2245       [[#include <curl/curl.h>]]
2246     )
2247   fi
2248 fi
2249
2250 if test "x$with_libcurl" = "xyes"; then
2251   SAVE_CPPFLAGS="$CPPFLAGS"
2252   SAVE_LDFLAGS="$LDFLAGS"
2253   CPPFLAGS="$CPPFLAGS $with_curl_cflags"
2254   LDFLAGS="$LDFLAGS $with_curl_libs"
2255   AC_CACHE_CHECK([for CURLINFO_APPCONNECT_TIME],
2256     [c_cv_have_curlinfo_appconnect_time],
2257     [
2258       AC_LINK_IFELSE(
2259         [
2260           AC_LANG_PROGRAM(
2261             [[#include <curl/curl.h>]],
2262             [[
2263               int val = CURLINFO_APPCONNECT_TIME;
2264               return val;
2265             ]]
2266           )
2267         ],
2268         [c_cv_have_curlinfo_appconnect_time="yes"],
2269         [c_cv_have_curlinfo_appconnect_time="no"]
2270       )
2271     ]
2272   )
2273   CPPFLAGS="$SAVE_CPPFLAGS"
2274   LDFLAGS="$SAVE_LDFLAGS"
2275 fi
2276
2277 if test "x$c_cv_have_curlinfo_appconnect_time" = "xyes"; then
2278   AC_DEFINE([HAVE_CURLINFO_APPCONNECT_TIME], [1],
2279     [Define if curl.h defines CURLINFO_APPCONNECT_TIME.]
2280   )
2281 fi
2282
2283 if test "x$with_libcurl" = "xyes"; then
2284   BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
2285   BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
2286
2287   if test "x$have_curlopt_username" = "xyes"; then
2288     AC_DEFINE([HAVE_CURLOPT_USERNAME], [1],
2289       [Define if libcurl supports CURLOPT_USERNAME option.]
2290     )
2291   fi
2292
2293   if test "x$have_curlopt_timeout" = "xyes"; then
2294     AC_DEFINE([HAVE_CURLOPT_TIMEOUT_MS], [1],
2295       [Define if libcurl supports CURLOPT_TIMEOUT_MS option.]
2296     )
2297   fi
2298 fi
2299
2300 AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
2301 AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
2302 # }}}
2303
2304 # --with-libdbi {{{
2305 AC_ARG_WITH([libdbi],
2306   [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
2307   [
2308     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2309       with_libdbi_cppflags="-I$withval/include"
2310       with_libdbi_ldflags="-L$withval/lib"
2311       with_libdbi="yes"
2312     else
2313       with_libdbi="$withval"
2314     fi
2315   ],
2316   [with_libdbi="yes"]
2317 )
2318
2319 if test "x$with_libdbi" = "xyes"; then
2320   SAVE_CPPFLAGS="$CPPFLAGS"
2321   CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
2322
2323   AC_CHECK_HEADERS([dbi/dbi.h],
2324     [with_libdbi="yes"],
2325     [with_libdbi="no (dbi/dbi.h not found)"]
2326   )
2327
2328   CPPFLAGS="$SAVE_CPPFLAGS"
2329 fi
2330
2331 if test "x$with_libdbi" = "xyes"; then
2332   SAVE_LDFLAGS="$LDFLAGS"
2333   LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
2334
2335   AC_CHECK_LIB([dbi], [dbi_initialize],
2336     [with_libdbi="yes"],
2337     [with_libdbi="no (Symbol 'dbi_initialize' not found)"]
2338   )
2339
2340   LDFLAGS="$SAVE_LDFLAGS"
2341 fi
2342
2343 BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
2344 BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
2345 BUILD_WITH_LIBDBI_LIBS="-ldbi"
2346 AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
2347 AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
2348 AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
2349 # }}}
2350
2351 # --with-libdpdk {{{
2352 AC_ARG_VAR([LIBDPDK_CPPFLAGS], [Preprocessor flags for libdpdk])
2353 AC_ARG_VAR([LIBDPDK_CFLAGS], [Compiler flags for libdpdk])
2354 AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
2355 AC_ARG_VAR([LIBDPDK_LIBS], [Libraries to link for libdpdk])
2356
2357 AC_ARG_WITH([libdpdk],
2358   [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])],
2359   [with_libdpdk="$withval"],
2360   [with_libdpdk="yes"]
2361 )
2362
2363 if test "x$with_libdpdk" != "xno"; then
2364   PKG_CHECK_MODULES([DPDK], [libdpdk], [],
2365     [AC_MSG_NOTICE([no DPDK pkg-config, using defaults])])
2366   if test "x$LIBDPDK_CPPFLAGS" = "x"; then
2367     LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
2368   fi
2369   if test "x$LIBDPDK_CFLAGS" = "x"; then
2370     LIBDPDK_CFLAGS="$DPDK_CFLAGS"
2371     LIBDPDK_CPPFLAGS="$LIBDPDK_CPPFLAGS $DPDK_CFLAGS"
2372   fi
2373   if test "x$LIBDPDK_LIBS" = "x"; then
2374     if test "x$DPDK_LIBS" != "x"; then
2375       LIBDPDK_LIBS="$DPDK_LIBS"
2376     else
2377       LIBDPDK_LIBS="-ldpdk"
2378     fi
2379   fi
2380   SAVE_CPPFLAGS="$CPPFLAGS"
2381   CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
2382   SAVE_CFLAGS="$CFLAGS"
2383   CFLAGS="$LIBDPDK_CFLAGS $CFLAGS"
2384   AC_CHECK_HEADERS([rte_config.h],
2385     [
2386       with_libdpdk="yes"
2387       AC_PREPROC_IFELSE(
2388         [
2389           AC_LANG_SOURCE(
2390             [[
2391               #include <rte_version.h>
2392               #if RTE_VERSION < RTE_VERSION_NUM(16,7,0,0)
2393               #error "required DPDK >= 16.07"
2394               #endif
2395             ]]
2396           )
2397         ],
2398         [dpdk_keepalive="yes"],
2399         [dpdk_keepalive="no (DPDK version < 16.07)"]
2400       )
2401     ],
2402     [with_libdpdk="no (rte_config.h not found)"]
2403   )
2404   CPPFLAGS="$SAVE_CPPFLAGS"
2405   CFLAGS="$SAVE_CFLAGS"
2406 fi
2407
2408 if test "x$with_libdpdk" = "xyes"; then
2409   SAVE_LDFLAGS="$LDFLAGS"
2410   LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
2411   AC_CHECK_LIB([dpdk], [rte_eal_init],
2412     [with_libdpdk="yes"],
2413     [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
2414   )
2415   LDFLAGS="$SAVE_LDFLAGS"
2416 fi
2417
2418 # }}}
2419
2420 # --with-libesmtp {{{
2421 AC_ARG_WITH([libesmtp],
2422   [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
2423   [
2424     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2425       with_libesmtp_cppflags="-I$withval/include"
2426       with_libesmtp_ldflags="-L$withval/lib"
2427       with_libesmtp="yes"
2428     else
2429       with_libesmtp="$withval"
2430     fi
2431   ],
2432   [with_libesmtp="yes"]
2433 )
2434
2435 if test "x$with_libesmtp" = "xyes"; then
2436   SAVE_CPPFLAGS="$CPPFLAGS"
2437   CPPFLAGS="$CPPFLAGS $with_libesmtp_cppflags"
2438
2439   AC_CHECK_HEADERS([libesmtp.h],
2440     [with_libesmtp="yes"],
2441     [with_libesmtp="no (libesmtp.h not found)"]
2442   )
2443
2444   CPPFLAGS="$SAVE_CPPFLAGS"
2445 fi
2446
2447 if test "x$with_libesmtp" = "xyes"; then
2448   SAVE_LDFLAGS="$LDFLAGS"
2449   LDFLAGS="$LDFLAGS $with_esmtp_ldflags"
2450
2451   AC_CHECK_LIB([esmtp], [smtp_create_session],
2452     [with_libesmtp="yes"],
2453     [with_libesmtp="no (Symbol 'smtp_create_session' not found)"]
2454   )
2455
2456   LDFLAGS="$SAVE_LDFLAGS"
2457 fi
2458
2459 BUILD_WITH_LIBESMTP_CPPFLAGS="$with_libesmtp_cppflags"
2460 BUILD_WITH_LIBESMTP_LDFLAGS="$with_libesmtp_ldflags"
2461 BUILD_WITH_LIBESMTP_LIBS="-lesmtp"
2462 AC_SUBST(BUILD_WITH_LIBESMTP_CPPFLAGS)
2463 AC_SUBST(BUILD_WITH_LIBESMTP_LDFLAGS)
2464 AC_SUBST(BUILD_WITH_LIBESMTP_LIBS)
2465 # }}}
2466
2467 # --with-libganglia {{{
2468 AC_ARG_WITH([libganglia],
2469   [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
2470   [
2471     if test -f "$withval" && test -x "$withval"; then
2472       with_libganglia_config="$withval"
2473       with_libganglia="yes"
2474     else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"; then
2475       with_libganglia_config="$withval/bin/ganglia-config"
2476       with_libganglia="yes"
2477     else if test -d "$withval"; then
2478       GANGLIA_CPPFLAGS="-I$withval/include"
2479       GANGLIA_LDFLAGS="-L$withval/lib"
2480       with_libganglia="yes"
2481     else
2482       with_libganglia="$withval"
2483     fi; fi; fi
2484   ],
2485   [with_libganglia="yes"]
2486 )
2487
2488 if test "x$with_libganglia" = "xyes"; then
2489   if test "x$with_libganglia_config" != "x"; then
2490     if test "x$GANGLIA_CPPFLAGS" = "x"; then
2491       GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
2492     fi
2493
2494     if test "x$GANGLIA_LDFLAGS" = "x"; then
2495       GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
2496     fi
2497
2498     if test "x$GANGLIA_LIBS" = "x"; then
2499       GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
2500     fi
2501   else
2502     GANGLIA_LIBS="-lganglia"
2503   fi
2504 fi
2505
2506 SAVE_CPPFLAGS="$CPPFLAGS"
2507 SAVE_LDFLAGS="$LDFLAGS"
2508 CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
2509 LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
2510
2511 if test "x$with_libganglia" = "xyes"; then
2512   AC_CHECK_HEADERS([gm_protocol.h],
2513     [with_libganglia="yes"],
2514     [with_libganglia="no (gm_protocol.h not found)"]
2515   )
2516 fi
2517
2518 if test "x$with_libganglia" = "xyes"; then
2519   AC_CHECK_LIB([ganglia], [xdr_Ganglia_value_msg],
2520     [with_libganglia="yes"],
2521     [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"]
2522   )
2523 fi
2524
2525 CPPFLAGS="$SAVE_CPPFLAGS"
2526 LDFLAGS="$SAVE_LDFLAGS"
2527
2528 AC_SUBST(GANGLIA_CPPFLAGS)
2529 AC_SUBST(GANGLIA_LDFLAGS)
2530 AC_SUBST(GANGLIA_LIBS)
2531 # }}}
2532
2533 # --with-libgcrypt {{{
2534 GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
2535 GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
2536 GCRYPT_LIBS="$GCRYPT_LIBS"
2537 AC_ARG_WITH([libgcrypt],
2538   [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
2539   [
2540     if test -f "$withval" && test -x "$withval"; then
2541       with_libgcrypt_config="$withval"
2542       with_libgcrypt="yes"
2543     else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"; then
2544       with_libgcrypt_config="$withval/bin/gcrypt-config"
2545       with_libgcrypt="yes"
2546     else if test -d "$withval"; then
2547       GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
2548       GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
2549       with_libgcrypt="yes"
2550     else
2551       with_libgcrypt_config="gcrypt-config"
2552       with_libgcrypt="$withval"
2553     fi; fi; fi
2554   ],
2555   [
2556     with_libgcrypt_config="libgcrypt-config"
2557     with_libgcrypt="yes"
2558   ]
2559 )
2560
2561 if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"; then
2562   if test "x$GCRYPT_CPPFLAGS" = "x"; then
2563     GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
2564   fi
2565
2566   if test "x$GCRYPT_LIBS" = "x"; then
2567     GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
2568   fi
2569 fi
2570
2571 SAVE_CPPFLAGS="$CPPFLAGS"
2572 SAVE_LDFLAGS="$LDFLAGS"
2573 SAVE_LIBS="$LIBS"
2574 CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
2575 LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
2576 LIBS="$LIBS $GCRYPT_LIBS"
2577
2578 if test "x$with_libgcrypt" = "xyes"; then
2579   if test "x$GCRYPT_CPPFLAGS" != "x"; then
2580     AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
2581   fi
2582   AC_CHECK_HEADERS([gcrypt.h],
2583     [with_libgcrypt="yes"],
2584     [with_libgcrypt="no (gcrypt.h not found)"]
2585   )
2586 fi
2587
2588 if test "x$with_libgcrypt" = "xyes"; then
2589   AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
2590     [with_libgcrypt="yes"],
2591     [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"]
2592   )
2593 fi
2594
2595 CPPFLAGS="$SAVE_CPPFLAGS"
2596 LDFLAGS="$SAVE_LDFLAGS"
2597 LIBS="$SAVE_LIBS"
2598
2599 AC_SUBST([GCRYPT_CPPFLAGS])
2600 AC_SUBST([GCRYPT_LDFLAGS])
2601 AC_SUBST([GCRYPT_LIBS])
2602 AM_CONDITIONAL([BUILD_WITH_LIBGCRYPT], [test "x$with_libgcrypt" = "xyes"])
2603 # }}}
2604
2605 # --with-libgps {{{
2606 AC_ARG_WITH([libgps],
2607   [AS_HELP_STRING([--with-libgps@<:@=PREFIX@:>@], [Path to libgps.])],
2608   [
2609     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2610       with_libgps_cflags="-I$withval/include"
2611       with_libgps_ldflags="-L$withval/lib"
2612       with_libgps="yes"
2613     else
2614       with_libgps="$withval"
2615     fi
2616   ],
2617   [with_libgps="yes"]
2618 )
2619
2620 if test "x$with_libgps" = "xyes"; then
2621   SAVE_CFLAGS="$CFLAGS"
2622   CFLAGS="$CFLAGS $with_libgps_cflags"
2623
2624   AC_CHECK_HEADERS([gps.h],
2625     [with_libgps="yes"],
2626     [with_libgps="no (gps.h not found)"]
2627   )
2628
2629   CFLAGS="$SAVE_CFLAGS"
2630 fi
2631
2632 if test "x$with_libgps" = "xyes"; then
2633   SAVE_LDFLAGS="$LDFLAGS"
2634   LDFLAGS="$LDFLAGS $with_libgps_ldflags"
2635
2636   AC_CHECK_LIB([gps], [gps_open],
2637     [with_libgps="yes"],
2638     [with_libgps="no (symbol gps_open not found)"]
2639   )
2640
2641   LDFLAGS="$SAVE_LDFLAGS"
2642 fi
2643
2644 if test "x$with_libgps" = "xyes"; then
2645   BUILD_WITH_LIBGPS_CFLAGS="$with_libgps_cflags"
2646   BUILD_WITH_LIBGPS_LDFLAGS="$with_libgps_ldflags"
2647   BUILD_WITH_LIBGPS_LIBS="-lgps"
2648 fi
2649
2650 AC_SUBST([BUILD_WITH_LIBGPS_CFLAGS])
2651 AC_SUBST([BUILD_WITH_LIBGPS_LDFLAGS])
2652 AC_SUBST([BUILD_WITH_LIBGPS_LIBS])
2653
2654 # }}}
2655
2656 # --with-libgrpc++ {{{
2657 AC_ARG_WITH([libgrpc++],
2658   [AS_HELP_STRING([--with-libgrpc++@<:@=PREFIX@:>@], [Path to libgrpc++.])],
2659   [
2660     with_grpcpp="$withval"
2661     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
2662       with_libgrpcpp_cppflags="-I$withval/include"
2663       with_libgrpcpp_ldflags="-L$withval/lib"
2664       with_libgrpcpp="yes"
2665     fi
2666     if test "x$withval" = "xno"; then
2667       with_libgrpcpp="no (disabled on command line)"
2668     fi
2669   ],
2670   [withval="yes"]
2671 )
2672 if test "x$withval" = "xyes"; then
2673 PKG_CHECK_MODULES([GRPCPP], [grpc++],
2674   [with_libgrpcpp="yes"],
2675   [with_libgrpcpp="no (pkg-config could not find libgrpc++)"]
2676 )
2677 fi
2678
2679 if test "x$withval" != "xno"; then
2680   AC_MSG_CHECKING([whether $CXX accepts -std=c++11])
2681   if test_cxx_flags -std=c++11; then
2682     AC_MSG_RESULT([yes])
2683   else
2684     AC_MSG_RESULT([no])
2685     with_libgrpcpp="no (requires C++11 support)"
2686   fi
2687 fi
2688
2689 if test "x$with_libgrpcpp" = "xyes"; then
2690   AC_LANG_PUSH(C++)
2691   SAVE_CPPFLAGS="$CPPFLAGS"
2692   CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS"
2693   AC_CHECK_HEADERS([grpc++/grpc++.h],
2694     [with_libgrpcpp="yes"],
2695     [with_libgrpcpp="no (<grpc++/grpc++.h> not found)"]
2696   )
2697   CPPFLAGS="$SAVE_CPPFLAGS"
2698   AC_LANG_POP(C++)
2699 fi
2700
2701 if test "x$with_libgrpcpp" = "xyes"; then
2702   AC_LANG_PUSH(C++)
2703   SAVE_CPPFLAGS="$CPPFLAGS"
2704   SAVE_LDFLAGS="$LDFLAGS"
2705   SAVE_LIBS="$LIBS"
2706   CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS"
2707   LDFLAGS="$with_libgrpcpp_ldflags"
2708   if test "x$GRPCPP_LIBS" = "x"; then
2709     LIBS="-lgrpc++"
2710   else
2711     LIBS="$GRPCPP_LIBS"
2712   fi
2713   AC_LINK_IFELSE(
2714     [
2715       AC_LANG_PROGRAM(
2716         [[#include <grpc++/grpc++.h>]],
2717         [[grpc::ServerBuilder sb;]]
2718       )
2719     ],
2720     [
2721       with_libgrpcpp="yes"
2722       if test "x$GRPCPP_LIBS" = "x"; then
2723         GRPCPP_LIBS="-lgrpc++"
2724       fi
2725     ],
2726     [with_libgrpcpp="no (libgrpc++ not found)"]
2727   )
2728   CPPFLAGS="$SAVE_CPPFLAGS"
2729   LDFLAGS="$SAVE_LDFLAGS"
2730   LIBS="$SAVE_LIBS"
2731   AC_LANG_POP(C++)
2732 fi
2733
2734 BUILD_WITH_LIBGRPCPP_CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS"
2735 BUILD_WITH_LIBGRPCPP_LDFLAGS="$with_libgrpcpp_ldflags"
2736 BUILD_WITH_LIBGRPCPP_LIBS="$GRPCPP_LIBS"
2737 AC_SUBST([BUILD_WITH_LIBGRPCPP_CPPFLAGS])
2738 AC_SUBST([BUILD_WITH_LIBGRPCPP_LDFLAGS])
2739 AC_SUBST([BUILD_WITH_LIBGRPCPP_LIBS])
2740 # }}}
2741
2742 AC_ARG_VAR([GRPC_CPP_PLUGIN], [path to the grpc_cpp_plugin binary])
2743 AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin])
2744 AM_CONDITIONAL([HAVE_GRPC_CPP], [test "x$GRPC_CPP_PLUGIN" != "x"])
2745
2746 # --with-libiptc {{{
2747 AC_ARG_WITH([libiptc],
2748   [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
2749   [
2750     if test "x$withval" = "xyes"; then
2751       with_libiptc="pkgconfig"
2752     else if test "x$withval" = "xno"; then
2753       with_libiptc="no"
2754     else
2755       with_libiptc="yes"
2756       with_libiptc_cflags="-I$withval/include"
2757       with_libiptc_libs="-L$withval/lib"
2758     fi; fi
2759   ],
2760   [
2761     if test "x$ac_system" = "xLinux"; then
2762       with_libiptc="pkgconfig"
2763     else
2764       with_libiptc="no (Linux only)"
2765     fi
2766   ]
2767 )
2768
2769 if test "x$with_libiptc" = "xpkgconfig"; then
2770   $PKG_CONFIG --exists 'libiptc' 2>/dev/null
2771   if test $? -ne 0; then
2772     with_libiptc="no (pkg-config doesn't know libiptc)"
2773   fi
2774 fi
2775
2776 if test "x$with_libiptc" = "xpkgconfig"; then
2777   with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
2778   if test $? -ne 0; then
2779     with_libiptc="no ($PKG_CONFIG failed)"
2780   fi
2781
2782   with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
2783   if test $? -ne 0; then
2784     with_libiptc="no ($PKG_CONFIG failed)"
2785   fi
2786 fi
2787
2788 SAVE_CPPFLAGS="$CPPFLAGS"
2789 CPPFLAGS="$CPPFLAGS $with_libiptc_cflags"
2790
2791 # check whether the header file for libiptc is available.
2792 if test "x$with_libiptc" = "xpkgconfig"; then
2793   AC_CHECK_HEADERS([libiptc/libiptc.h libiptc/libip6tc.h],
2794     [],
2795     [with_libiptc="no (header file missing)"]
2796   )
2797 fi
2798
2799 # If the header file is available, check for the required type declaractions.
2800 # They may be missing in old versions of libiptc. In that case, they will be
2801 # declared in the iptables plugin.
2802 if test "x$with_libiptc" = "xpkgconfig"; then
2803   AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
2804 fi
2805
2806 # Check for the iptc_init symbol in the library.
2807 # This could be in iptc or ip4tc
2808 if test "x$with_libiptc" = "xpkgconfig"; then
2809   SAVE_LIBS="$LIBS"
2810   AC_SEARCH_LIBS([iptc_init], [iptc ip4tc],
2811     [with_libiptc="pkgconfig"],
2812     [with_libiptc="no"],
2813     [$with_libiptc_libs]
2814   )
2815   LIBS="$SAVE_LIBS"
2816 fi
2817
2818 if test "x$with_libiptc" = "xpkgconfig"; then
2819   with_libiptc="yes"
2820 fi
2821
2822 CPPFLAGS="$SAVE_CPPFLAGS"
2823
2824 if test "x$with_libiptc" = "xyes"; then
2825   BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
2826   BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
2827 fi
2828 AC_SUBST([BUILD_WITH_LIBIPTC_CPPFLAGS])
2829 AC_SUBST([BUILD_WITH_LIBIPTC_LDFLAGS])
2830 # }}}
2831
2832 # --with-java {{{
2833 with_java_home="$JAVA_HOME"
2834 if test "x$with_java_home" = "x"; then
2835   with_java_home="/usr/lib/jvm"
2836 fi
2837
2838 JAVAC="$JAVAC"
2839 JAR="$JAR"
2840 AC_ARG_WITH([java],
2841   [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
2842   [
2843     if test "x$withval" = "xno"; then
2844       with_java="no"
2845     else if test "x$withval" = "xyes"; then
2846       with_java="yes"
2847     else
2848       with_java_home="$withval"
2849       with_java="yes"
2850     fi; fi
2851   ],
2852   [with_java="yes"]
2853 )
2854
2855 AX_COMPARE_VERSION([$am__api_version],[lt],[1.12],
2856   [JAVA_TIMESTAMP_FILE="classdist_noinst.stamp"],
2857   [JAVA_TIMESTAMP_FILE="classnoinst.stamp"])
2858 if test "x$with_java" = "xyes"; then
2859   if test -d "$with_java_home"; then
2860     AC_MSG_CHECKING([for jni.h])
2861     TMPVAR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2862     if test "x$TMPVAR" != "x"; then
2863       AC_MSG_RESULT([found in $TMPVAR])
2864       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
2865     else
2866       AC_MSG_RESULT([not found])
2867     fi
2868
2869     AC_MSG_CHECKING([for jni_md.h])
2870     TMPVAR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2871     if test "x$TMPVAR" != "x"; then
2872       AC_MSG_RESULT([found in $TMPVAR])
2873       JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
2874     else
2875       AC_MSG_RESULT([not found])
2876     fi
2877
2878     AC_MSG_CHECKING([for libjvm.so])
2879     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`
2880     if test "x$TMPVAR" != "x"; then
2881       AC_MSG_RESULT([found in $TMPVAR])
2882       JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
2883     else
2884       AC_MSG_RESULT([not found])
2885     fi
2886
2887     if test "x$JAVAC" = "x"; then
2888       AC_MSG_CHECKING([for javac])
2889       TMPVAR=`find -L "$with_java_home" -name javac -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
2890       if test "x$TMPVAR" != "x"; then
2891         JAVAC="$TMPVAR"
2892         AC_MSG_RESULT([$JAVAC])
2893       else
2894         AC_MSG_RESULT([not found])
2895       fi
2896     fi
2897
2898     if test "x$JAR" = "x"; then
2899       AC_MSG_CHECKING([for jar])
2900       TMPVAR=`find -L "$with_java_home" -name jar -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
2901       if test "x$TMPVAR" != "x"; then
2902         JAR="$TMPVAR"
2903         AC_MSG_RESULT([$JAR])
2904       else
2905         AC_MSG_RESULT([not found])
2906       fi
2907     fi
2908   else if test "x$with_java_home" != "x"; then
2909     AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
2910   fi; fi
2911 fi
2912
2913 if test "x$JAVA_CPPFLAGS" != "x"; then
2914   AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
2915 fi
2916 if test "x$JAVA_CFLAGS" != "x"; then
2917   AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
2918 fi
2919 if test "x$JAVA_LDFLAGS" != "x"; then
2920   AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
2921 fi
2922 if test "x$JAVA_LIBS" != "x"; then
2923   AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
2924 fi
2925 if test "x$JAVAC" = "x"; then
2926   with_javac_path="$PATH"
2927   if test "x$with_java_home" != "x"; then
2928     with_javac_path="$with_java_home:with_javac_path"
2929     if test -d "$with_java_home/bin"; then
2930       with_javac_path="$with_java_home/bin:with_javac_path"
2931     fi
2932   fi
2933
2934   AC_PATH_PROG([JAVAC], [javac], [], "$with_javac_path")
2935 fi
2936
2937 if test "x$JAVAC" = "x"; then
2938   with_java="no (javac not found)"
2939 fi
2940
2941 if test "x$JAR" = "x"; then
2942   with_jar_path="$PATH"
2943   if test "x$with_java_home" != "x"; then
2944     with_jar_path="$with_java_home:$with_jar_path"
2945     if test -d "$with_java_home/bin"; then
2946       with_jar_path="$with_java_home/bin:$with_jar_path"
2947     fi
2948   fi
2949
2950   AC_PATH_PROG([JAR], [jar], [], "$with_jar_path")
2951 fi
2952
2953 if test "x$JAR" = "x"; then
2954   with_java="no (jar not found)"
2955 fi
2956
2957 SAVE_CPPFLAGS="$CPPFLAGS"
2958 SAVE_CFLAGS="$CFLAGS"
2959 SAVE_LDFLAGS="$LDFLAGS"
2960 SAVE_LIBS="$LIBS"
2961 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
2962 CFLAGS="$CFLAGS $JAVA_CFLAGS"
2963 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
2964 LIBS="$LIBS $JAVA_LIBS"
2965
2966 if test "x$with_java" = "xyes"; then
2967   AC_CHECK_HEADERS([jni.h],
2968     [with_jave="yes"],
2969     [with_java="no (jni.h not found)"])
2970 fi
2971
2972 if test "x$with_java" = "xyes"; then
2973   AC_CHECK_LIB([jvm], [JNI_CreateJavaVM],
2974     [with_java="yes"],
2975     [with_java="no (Symbol 'JNI_CreateJavaVM' not found)"],
2976     [$JAVA_LIBS $PTHREAD_LIBS]
2977   )
2978 fi
2979
2980 if test "x$with_java" = "xyes"; then
2981   JAVA_LIBS="$JAVA_LIBS -ljvm"
2982   AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
2983 fi
2984
2985 CPPFLAGS="$SAVE_CPPFLAGS"
2986 CFLAGS="$SAVE_CFLAGS"
2987 LDFLAGS="$SAVE_LDFLAGS"
2988 LIBS="$SAVE_LIBS"
2989
2990 AC_SUBST([JAVA_CPPFLAGS])
2991 AC_SUBST([JAVA_CFLAGS])
2992 AC_SUBST([JAVA_LDFLAGS])
2993 AC_SUBST([JAVA_LIBS])
2994 AC_SUBST([JAVA_TIMESTAMP_FILE])
2995 AM_CONDITIONAL([BUILD_WITH_JAVA], [test "x$with_java" = "xyes"])
2996 # }}}
2997
2998 # --with-libldap {{{
2999 AC_ARG_WITH([libldap],
3000   [AS_HELP_STRING([--with-libldap@<:@=PREFIX@:>@], [Path to libldap.])],
3001   [
3002     if test "x$withval" = "xyes"; then
3003       with_libldap="yes"
3004     else if test "x$withval" = "xno"; then
3005       with_libldap="no"
3006     else
3007       with_libldap="yes"
3008       LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS -I$withval/include"
3009       LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS -L$withval/lib"
3010     fi; fi
3011   ],
3012   [with_libldap="yes"]
3013 )
3014
3015 SAVE_CPPFLAGS="$CPPFLAGS"
3016 SAVE_LDFLAGS="$LDFLAGS"
3017
3018 CPPFLAGS="$CPPFLAGS $LIBLDAP_CPPFLAGS"
3019 LDFLAGS="$LDFLAGS $LIBLDAP_LDFLAGS"
3020
3021 if test "x$with_libldap" = "xyes"; then
3022   if test "x$LIBLDAP_CPPFLAGS" != "x"; then
3023     AC_MSG_NOTICE([libldap CPPFLAGS: $LIBLDAP_CPPFLAGS])
3024   fi
3025
3026   AC_CHECK_HEADERS([ldap.h],
3027     [with_libldap="yes"],
3028     [with_libldap="no ('ldap.h' not found)"]
3029   )
3030 fi
3031
3032 if test "x$with_libldap" = "xyes"; then
3033   if test "x$LIBLDAP_LDFLAGS" != "x"; then
3034     AC_MSG_NOTICE([libldap LDFLAGS: $LIBLDAP_LDFLAGS])
3035   fi
3036
3037   AC_CHECK_LIB([ldap], [ldap_initialize],
3038     [with_libldap="yes"],
3039     [with_libldap="no (symbol 'ldap_initialize' not found)"]
3040   )
3041 fi
3042
3043 CPPFLAGS="$SAVE_CPPFLAGS"
3044 LDFLAGS="$SAVE_LDFLAGS"
3045
3046 if test "x$with_libldap" = "xyes"
3047 then
3048   BUILD_WITH_LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS"
3049   BUILD_WITH_LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS"
3050 fi
3051 AC_SUBST([BUILD_WITH_LIBLDAP_CPPFLAGS])
3052 AC_SUBST([BUILD_WITH_LIBLDAP_LDFLAGS])
3053 # }}}
3054
3055 # --with-liblua {{{
3056 AC_ARG_VAR([LIBLUA_PKG_CONFIG_NAME], [Name of liblua used by pkg-config])
3057 if test "x$LIBLUA_PKG_CONFIG_NAME" != "x"
3058 then
3059   PKG_CHECK_MODULES([LUA], [$LIBLUA_PKG_CONFIG_NAME],
3060     [with_liblua="yes"],
3061     [with_liblua="no"]
3062   )
3063 else
3064   PKG_CHECK_MODULES([LUA], [lua],
3065     [with_liblua="yes"],
3066     [
3067       PKG_CHECK_MODULES([LUA], [lua-5.3],
3068         [with_liblua="yes"],
3069         [
3070           PKG_CHECK_MODULES([LUA], [lua5.3],
3071             [with_liblua="yes"],
3072             [
3073               PKG_CHECK_MODULES([LUA], [lua-5.2],
3074                 [with_liblua="yes"],
3075                 [
3076                   PKG_CHECK_MODULES([LUA], [lua5.2],
3077                     [with_liblua="yes"],
3078                     [
3079                       PKG_CHECK_MODULES([LUA], [lua-5.1],
3080                         [with_liblua="yes"],
3081                         [
3082                           PKG_CHECK_MODULES([LUA], [lua5.1],
3083                             [with_liblua="yes"],
3084                             [with_liblua="no (pkg-config cannot find liblua)"]
3085                           )
3086                         ]
3087                       )
3088                     ]
3089                   )
3090                 ]
3091               )
3092             ]
3093           )
3094         ]
3095       )
3096     ]
3097   )
3098 fi
3099
3100 if test "x$with_liblua" = "xyes"
3101 then
3102   SAVE_CPPFLAGS="$CPPFLAGS"
3103   CPPFLAGS="$CPPFLAGS $LUA_CFLAGS"
3104
3105   AC_CHECK_HEADERS([lua.h lauxlib.h lualib.h],
3106     [with_liblua="yes"],
3107     [with_liblua="no (header not found)"]
3108   )
3109
3110   CPPFLAGS="$SAVE_CPPFLAGS"
3111 fi
3112
3113 if test "x$with_liblua" = "xyes"
3114 then
3115   SAVE_LIBS="$LIBS"
3116   LIBS="$LIBS $LUA_LIBS"
3117
3118   AC_CHECK_FUNC([lua_settop],
3119     [with_liblua="yes"],
3120     [with_liblua="no (symbol 'lua_settop' not found)"]
3121   )
3122
3123   LIBS="$SAVE_LIBS"
3124 fi
3125
3126 if test "x$with_liblua" = "xyes"
3127 then
3128     BUILD_WITH_LIBLUA_CFLAGS="$LUA_CFLAGS"
3129     BUILD_WITH_LIBLUA_LIBS="$LUA_LIBS"
3130 fi
3131 AC_SUBST(BUILD_WITH_LIBLUA_CFLAGS)
3132 AC_SUBST(BUILD_WITH_LIBLUA_LIBS)
3133 # }}}
3134
3135 # --with-liblvm2app {{{
3136 AC_ARG_WITH([liblvm2app],
3137   [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
3138   [
3139     if test "x$withval" = "xno"; then
3140       with_liblvm2app="no"
3141     else
3142       with_liblvm2app="yes"
3143       if test "x$withval" != "xyes"; then
3144         with_liblvm2app_cppflags="-I$withval/include"
3145         with_liblvm2app_ldflags="-L$withval/lib"
3146       fi
3147     fi
3148   ],
3149   [
3150     if test "x$ac_system" = "xLinux"; then
3151       with_liblvm2app="yes"
3152     else
3153       with_liblvm2app="no (Linux only library)"
3154     fi
3155   ]
3156 )
3157
3158 if test "x$with_liblvm2app" = "xyes"; then
3159   SAVE_CPPFLAGS="$CPPFLAGS"
3160   CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
3161
3162   AC_CHECK_HEADERS([lvm2app.h],
3163     [with_liblvm2app="yes"],
3164     [with_liblvm2app="no (lvm2app.h not found)"]
3165   )
3166
3167   CPPFLAGS="$SAVE_CPPFLAGS"
3168 fi
3169
3170 if test "x$with_liblvm2app" = "xyes"; then
3171   SAVE_CPPFLAGS="$CPPFLAGS"
3172   SAVE_LDFLAGS="$LDFLAGS"
3173   CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
3174   LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
3175
3176   AC_CHECK_LIB([lvm2app], [lvm_lv_get_property],
3177     [with_liblvm2app="yes"],
3178     [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"]
3179   )
3180
3181   CPPFLAGS="$SAVE_CPPFLAGS"
3182   LDFLAGS="$SAVE_LDFLAGS"
3183 fi
3184
3185 if test "x$with_liblvm2app" = "xyes"; then
3186   BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
3187   BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
3188   BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
3189 fi
3190
3191 AC_SUBST([BUILD_WITH_LIBLVM2APP_CPPFLAGS])
3192 AC_SUBST([BUILD_WITH_LIBLVM2APP_LDFLAGS])
3193 AC_SUBST([BUILD_WITH_LIBLVM2APP_LIBS])
3194 # }}}
3195
3196 # --with-libmemcached {{{
3197 AC_ARG_WITH([libmemcached],
3198   [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
3199   [
3200     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
3201       with_libmemcached_cppflags="-I$withval/include"
3202       with_libmemcached_ldflags="-L$withval/lib"
3203       with_libmemcached="yes"
3204     else
3205       with_libmemcached="$withval"
3206     fi
3207   ],
3208   [with_libmemcached="yes"]
3209 )
3210
3211 if test "x$with_libmemcached" = "xyes"; then
3212   SAVE_CPPFLAGS="$CPPFLAGS"
3213   CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
3214
3215   AC_CHECK_HEADERS([libmemcached/memcached.h],
3216     [with_libmemcached="yes"],
3217     [with_libmemcached="no (libmemcached/memcached.h not found)"]
3218   )
3219
3220   CPPFLAGS="$SAVE_CPPFLAGS"
3221 fi
3222
3223 if test "x$with_libmemcached" = "xyes"; then
3224   SAVE_CPPFLAGS="$CPPFLAGS"
3225   SAVE_LDFLAGS="$LDFLAGS"
3226   CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
3227   LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
3228
3229   AC_CHECK_LIB([memcached], [memcached_create],
3230     [with_libmemcached="yes"],
3231     [with_libmemcached="no (Symbol 'memcached_create' not found)"]
3232   )
3233
3234   CPPFLAGS="$SAVE_CPPFLAGS"
3235   LDFLAGS="$SAVE_LDFLAGS"
3236 fi
3237
3238 if test "x$with_libmemcached" = "xyes"; then
3239   BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
3240   BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
3241   BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
3242 fi
3243
3244 AC_SUBST([BUILD_WITH_LIBMEMCACHED_CPPFLAGS])
3245 AC_SUBST([BUILD_WITH_LIBMEMCACHED_LDFLAGS])
3246 AC_SUBST([BUILD_WITH_LIBMEMCACHED_LIBS])
3247 # }}}
3248
3249 # --with-libmicrohttpd {{{
3250 with_libmicrohttpd_cppflags=""
3251 with_libmicrohttpd_ldflags=""
3252 AC_ARG_WITH([libmicrohttpd], [AS_HELP_STRING([--with-libmicrohttpd@<:@=PREFIX@:>@], [Path to libmicrohttpd.])],
3253   [
3254     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
3255       with_libmicrohttpd_cppflags="-I$withval/include"
3256       with_libmicrohttpd_ldflags="-L$withval/lib"
3257       with_libmicrohttpd="yes"
3258     fi
3259     if test "x$withval" = "xno"; then
3260       with_libmicrohttpd="no (disabled on command line)"
3261     fi
3262   ],
3263   [withval="yes"]
3264 )
3265 if test "x$withval" = "xyes"; then
3266   PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd],
3267     [with_libmicrohttpd="yes"],
3268     [with_libmicrohttpd="no (pkg-config could not find libmicrohttpd)"]
3269   )
3270 fi
3271
3272 if test "x$MICROHTTPD_LIBS" = "x"; then
3273   MICROHTTPD_LIBS="-lmicrohttpd"
3274 fi
3275
3276 SAVE_CPPFLAGS="$CPPFLAGS"
3277 SAVE_LDFLAGS="$LDFLAGS"
3278 SAVE_LIBS="$LIBS"
3279 CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
3280 LDFLAGS="$with_libmicrohttpd_ldflags $LDFLAGS"
3281 LIBS="$LIBS $MICROHTTPD_LIBS"
3282
3283 if test "x$with_libmicrohttpd" = "xyes"; then
3284   AC_CHECK_HEADERS([microhttpd.h],
3285    [with_libmicrohttpd="yes"],
3286    [with_libmicrohttpd="no (<microhttpd.h> not found)"]
3287   )
3288 fi
3289
3290 if test "x$with_libmicrohttpd" = "xyes"; then
3291   AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
3292     [with_libmicrohttpd="yes"],
3293     [with_libmicrohttpd="no (libmicrohttpd not found)"]
3294   )
3295 fi
3296
3297 CPPFLAGS="$SAVE_CPPFLAGS"
3298 LDFLAGS="$SAVE_LDFLAGS"
3299 LIBS="$SAVE_LIBS"
3300
3301 BUILD_WITH_LIBMICROHTTPD_CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
3302 BUILD_WITH_LIBMICROHTTPD_LDFLAGS="$with_libmicrohttpd_ldflags"
3303 BUILD_WITH_LIBMICROHTTPD_LIBS="$MICROHTTPD_LIBS"
3304 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_CPPFLAGS])
3305 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LDFLAGS])
3306 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LIBS])
3307 # }}}
3308
3309 # --with-libmodbus {{{
3310 AC_ARG_WITH([libmodbus],
3311   [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
3312   [
3313     if test "x$withval" = "xno"; then
3314       with_libmodbus="no"
3315     else if test "x$withval" = "xyes"; then
3316       with_libmodbus="use_pkgconfig"
3317     else if test -d "$with_libmodbus/lib"; then
3318       AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
3319       with_libmodbus_cflags="-I$withval/include"
3320       with_libmodbus_libs="-L$withval/lib -lmodbus"
3321       with_libmodbus="yes"
3322     fi; fi; fi
3323   ],
3324   [with_libmodbus="use_pkgconfig"]
3325 )
3326
3327 # configure using pkg-config
3328 if test "x$with_libmodbus" = "xuse_pkgconfig"; then
3329   AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
3330   $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
3331   if test $? -ne 0; then
3332     with_libmodbus="no (pkg-config doesn't know libmodbus)"
3333   fi
3334 fi
3335
3336 if test "x$with_libmodbus" = "xuse_pkgconfig"; then
3337   with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
3338   if test $? -ne 0; then
3339     with_libmodbus="no ($PKG_CONFIG failed)"
3340   fi
3341
3342   with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
3343   if test $? -ne 0; then
3344     with_libmodbus="no ($PKG_CONFIG failed)"
3345   fi
3346 fi
3347
3348 if test "x$with_libmodbus" = "xuse_pkgconfig"; then
3349   with_libmodbus="yes"
3350 fi
3351
3352 if test "x$with_libmodbus" = "xyes"; then
3353   SAVE_CPPFLAGS="$CPPFLAGS"
3354   CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
3355
3356   AC_CHECK_HEADERS([modbus.h],
3357     [with_libmodbus="yes"],
3358     [with_libmodbus="no (modbus.h not found)"]
3359   )
3360
3361   CPPFLAGS="$SAVE_CPPFLAGS"
3362 fi
3363
3364 if test "x$with_libmodbus" = "xyes"; then
3365   SAVE_LDFLAGS="$LDFLAGS"
3366   LDFLAGS="$LDFLAGS $with_libmodbus_libs"
3367
3368   AC_CHECK_LIB([modbus], [modbus_connect],
3369     [with_libmodbus="yes"],
3370     [with_libmodbus="no (symbol modbus_connect not found)"]
3371   )
3372
3373   LDFLAGS="$SAVE_LDFLAGS"
3374 fi
3375
3376 if test "x$with_libmodbus" = "xyes"; then
3377   BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
3378   BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
3379 fi
3380
3381 AC_SUBST([BUILD_WITH_LIBMODBUS_CFLAGS])
3382 AC_SUBST([BUILD_WITH_LIBMODBUS_LIBS])
3383 # }}}
3384
3385 # --with-libmongoc {{{
3386 AC_ARG_WITH([libmongoc],
3387   [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
3388   [
3389     if test "x$withval" = "xyes"; then
3390       with_libmongoc="yes"
3391     else if test "x$withval" = "xno"; then
3392       with_libmongoc="no"
3393     else
3394       with_libmongoc="no"
3395     fi; fi
3396   ],
3397   [with_libmongoc="yes"]
3398 )
3399
3400 if test "x$with_libmongoc" = "xyes"; then
3401   PKG_CHECK_MODULES([LIBMONGOC], [libmongoc-1.0],
3402     [with_libmongoc="yes"],
3403     [with_libmongoc="no (pkg-config could not find libmongoc)"]
3404   )
3405 fi
3406
3407 if test "x$with_libmongoc" = "xyes"; then
3408   SAVE_CPPFLAGS="$CPPFLAGS"
3409
3410   CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
3411
3412   if test "x$CPPFLAGS" != "x"; then
3413     AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CFLAGS])
3414   fi
3415
3416   AC_CHECK_HEADERS([mongoc.h],
3417     [with_libmongoc="yes"],
3418     [with_libmongoc="no ('mongoc.h' not found)"]
3419   )
3420
3421   CPPFLAGS="$SAVE_CPPFLAGS"
3422 fi
3423
3424 if test "x$with_libmongoc" = "xyes"; then
3425   SAVE_CPPFLAGS="$CPPFLAGS"
3426   SAVE_LDFLAGS="$LDFLAGS"
3427
3428   CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
3429   LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
3430
3431   if test "x$LIBMONGOC_LDFLAGS" != "x"; then
3432     AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
3433   fi
3434
3435   AC_CHECK_LIB([mongoc-1.0], [mongoc_init],
3436     [with_libmongoc="yes"],
3437     [with_libmongoc="no (symbol 'mongoc_init' not found)"]
3438   )
3439
3440   CPPFLAGS="$SAVE_CPPFLAGS"
3441   LDFLAGS="$SAVE_LDFLAGS"
3442 fi
3443
3444 if test "x$with_libmongoc" = "xyes"; then
3445   BUILD_WITH_LIBMONGOC_CFLAGS="$LIBMONGOC_CFLAGS"
3446   BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
3447 fi
3448
3449 AC_SUBST([BUILD_WITH_LIBMONGOC_CFLAGS])
3450 AC_SUBST([BUILD_WITH_LIBMONGOC_LDFLAGS])
3451 # }}}
3452
3453 # --with-libmosquitto {{{
3454 AC_ARG_WITH([libmosquitto],
3455   [AS_HELP_STRING([--with-libmosquitto@<:@=PREFIX@:>@], [Path to libmosquitto.])],
3456   [
3457     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
3458       with_libmosquitto_cppflags="-I$withval/include"
3459       with_libmosquitto_ldflags="-L$withval/lib"
3460       with_libmosquitto="yes"
3461     else
3462       with_libmosquitto="$withval"
3463     fi
3464   ],
3465   [with_libmosquitto="yes"]
3466 )
3467
3468 if test "x$with_libmosquitto" = "xyes"; then
3469   SAVE_CPPFLAGS="$CPPFLAGS"
3470   CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
3471
3472   AC_CHECK_HEADERS([mosquitto.h],
3473     [with_libmosquitto="yes"],
3474     [with_libmosquitto="no (mosquitto.h not found)"]
3475   )
3476
3477   CPPFLAGS="$SAVE_CPPFLAGS"
3478 fi
3479
3480 if test "x$with_libmosquitto" = "xyes"; then
3481   SAVE_LDFLAGS="$LDFLAGS"
3482   LDFLAGS="$LDFLAGS $with_libmosquitto_ldflags"
3483
3484   AC_CHECK_LIB([mosquitto], [mosquitto_connect],
3485     [with_libmosquitto="yes"],
3486     [with_libmosquitto="no (libmosquitto not found)"]
3487   )
3488
3489   LDFLAGS="$SAVE_LDFLAGS"
3490 fi
3491
3492 if test "x$with_libmosquitto" = "xyes"; then
3493   BUILD_WITH_LIBMOSQUITTO_CPPFLAGS="$with_libmosquitto_cppflags"
3494   BUILD_WITH_LIBMOSQUITTO_LDFLAGS="$with_libmosquitto_ldflags"
3495   BUILD_WITH_LIBMOSQUITTO_LIBS="-lmosquitto"
3496 fi
3497
3498 AC_SUBST([BUILD_WITH_LIBMOSQUITTO_CPPFLAGS])
3499 AC_SUBST([BUILD_WITH_LIBMOSQUITTO_LDFLAGS])
3500 AC_SUBST([BUILD_WITH_LIBMOSQUITTO_LIBS])
3501 # }}}
3502
3503 # --with-libmysql {{{
3504 with_mysql_config="mysql_config"
3505 AC_ARG_WITH([libmysql],
3506   [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
3507   [
3508     if test "x$withval" = "xno"; then
3509       with_libmysql="no"
3510     else if test "x$withval" = "xyes"; then
3511       with_libmysql="yes"
3512     else
3513       if test -f "$withval" && test -x "$withval"; then
3514         with_mysql_config="$withval"
3515       else if test -x "$withval/bin/mysql_config"; then
3516         with_mysql_config="$withval/bin/mysql_config"
3517       fi; fi
3518       with_libmysql="yes"
3519     fi; fi
3520   ],
3521   [with_libmysql="yes"]
3522 )
3523
3524 if test "x$with_libmysql" = "xyes"; then
3525   with_mysql_cflags=`$with_mysql_config --include 2>/dev/null`
3526   if test $? -ne 0; then
3527     with_libmysql="no ($with_mysql_config failed)"
3528   else
3529     SAVE_CPPFLAGS="$CPPFLAGS"
3530     CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
3531
3532     AC_CHECK_HEADERS([mysql.h],
3533       [have_mysql_h="yes"],
3534       [have_mysql_h="no"]
3535     )
3536
3537     if test "x$have_mysql_h" != "xyes"; then
3538       AC_CHECK_HEADERS([mysql/mysql.h],
3539         [have_mysql_mysql_h="yes"],
3540         [],
3541       )
3542     fi
3543
3544     if test "x$have_mysql_h" != "xyes" && test "x$have_mysql_mysql_h" != "xyes"; then
3545       with_libmysql="no (mysql.h not found)"
3546     fi
3547
3548     CPPFLAGS="$SAVE_CPPFLAGS"
3549   fi
3550 fi
3551
3552 if test "x$with_libmysql" = "xyes"; then
3553   with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
3554   if test $? -ne 0; then
3555     with_libmysql="no ($with_mysql_config failed)"
3556   else
3557     SAVE_LIBS="$LIBS"
3558     LIBS="$with_mysql_libs"
3559
3560     AC_SEARCH_LIBS([mysql_get_server_version],
3561       [],
3562       [with_libmysql="yes"],
3563       [with_libmysql="no (symbol 'mysql_get_server_version' not found in ${LIBS})"],
3564       []
3565     )
3566     LIBS="$SAVE_LIBS"
3567   fi
3568 fi
3569
3570 if test "x$with_libmysql" = "xyes"; then
3571   BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
3572   BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
3573 fi
3574
3575 AC_SUBST([BUILD_WITH_LIBMYSQL_CFLAGS])
3576 AC_SUBST([BUILD_WITH_LIBMYSQL_LIBS])
3577 # }}}
3578
3579 # --with-libmnl {{{
3580 AC_ARG_WITH([libmnl],
3581   [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
3582   [
3583     if test "x$withval" = "xyes"; then
3584       with_libmnl="yes"
3585      else if test "x$withval" = "xno"; then
3586        with_libmnl="no"
3587      else
3588        if test -d "$withval/include"; then
3589          with_libmnl_cflags="-I$withval/include"
3590          with_libmnl_libs="-L$withval/lib -lmnl"
3591          with_libmnl="yes"
3592        else
3593          AC_MSG_ERROR("no such directory: $withval/include")
3594        fi
3595      fi; fi
3596   ],
3597   [
3598     if test "x$ac_system" = "xLinux"; then
3599       with_libmnl="yes"
3600     else
3601       with_libmnl="no (Linux only library)"
3602     fi
3603   ]
3604 )
3605
3606 if test "x$with_libmnl" = "xyes"; then
3607   if $PKG_CONFIG --exists libmnl 2>/dev/null; then
3608     with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
3609     with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
3610   fi
3611
3612   AC_CHECK_HEADERS([libmnl.h libmnl/libmnl.h],
3613     [
3614       with_libmnl="yes"
3615       break
3616     ],
3617     [],
3618     [[
3619       #include <stdio.h>
3620       #include <sys/types.h>
3621       #include <asm/types.h>
3622       #include <sys/socket.h>
3623       #include <linux/netlink.h>
3624       #include <linux/rtnetlink.h>]]
3625   )
3626
3627   AC_CHECK_HEADERS([linux/gen_stats.h linux/pkt_sched.h],
3628     [],
3629     [],
3630     [[
3631       #include <stdio.h>
3632       #include <sys/types.h>
3633       #include <asm/types.h>
3634       #include <sys/socket.h>
3635     ]]
3636   )
3637
3638   AC_COMPILE_IFELSE(
3639     [
3640       AC_LANG_PROGRAM(
3641         [[
3642           #include <stdio.h>
3643           #include <sys/types.h>
3644           #include <asm/types.h>
3645           #include <sys/socket.h>
3646           #include <linux/netlink.h>
3647           #include <linux/rtnetlink.h>
3648         ]],
3649         [[
3650           int retval = TCA_STATS2;
3651           return retval;
3652         ]]
3653       )
3654     ],
3655     [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])]
3656   )
3657
3658   AC_COMPILE_IFELSE(
3659     [
3660       AC_LANG_PROGRAM(
3661         [[
3662           #include <stdio.h>
3663           #include <sys/types.h>
3664           #include <asm/types.h>
3665           #include <sys/socket.h>
3666           #include <linux/netlink.h>
3667           #include <linux/rtnetlink.h>
3668         ]],
3669         [[
3670           int retval = TCA_STATS;
3671           return retval;
3672         ]]
3673       )
3674     ],
3675     [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
3676   )
3677
3678   AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
3679     [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
3680     [],
3681     [[#include <linux/if_link.h>]]
3682   )
3683
3684   AC_CHECK_LIB([mnl], [mnl_nlmsg_get_payload],
3685     [with_libmnl="yes"],
3686     [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
3687     [$with_libmnl_libs]
3688   )
3689 fi
3690
3691 if test "x$with_libmnl" = "xyes"; then
3692   BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
3693   BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
3694 fi
3695 AC_SUBST([BUILD_WITH_LIBMNL_CFLAGS])
3696 AC_SUBST([BUILD_WITH_LIBMNL_LIBS])
3697 # }}}
3698
3699 # --with-libnetapp {{{
3700 AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
3701 AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
3702 AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
3703 AC_ARG_WITH([libnetapp],
3704   [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
3705   [
3706    if test -d "$withval"; then
3707      LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
3708      LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
3709      with_libnetapp="yes"
3710    else
3711      with_libnetapp="$withval"
3712    fi
3713   ],
3714   [with_libnetapp="yes"]
3715 )
3716
3717 SAVE_CPPFLAGS="$CPPFLAGS"
3718 SAVE_LDFLAGS="$LDFLAGS"
3719 CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
3720 LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
3721
3722 if test "x$with_libnetapp" = "xyes"; then
3723   if test "x$LIBNETAPP_CPPFLAGS" != "x"; then
3724     AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
3725   fi
3726   AC_CHECK_HEADERS([netapp_api.h],
3727     [with_libnetapp="yes"],
3728     [with_libnetapp="no (netapp_api.h not found)"]
3729   )
3730 fi
3731
3732 if test "x$with_libnetapp" = "xyes"; then
3733   if test "x$LIBNETAPP_LDFLAGS" != "x"; then
3734     AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
3735   fi
3736
3737   if test "x$LIBNETAPP_LIBS" = "x"; then
3738     LIBNETAPP_LIBS="$PTHREAD_LIBS -lxml -ladt -lssl -lm -lcrypto -lz"
3739   fi
3740
3741   AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
3742
3743   AC_CHECK_LIB([netapp], [na_server_invoke_elem],
3744     [with_libnetapp="yes"],
3745     [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
3746     [$LIBNETAPP_LIBS]
3747   )
3748
3749   LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
3750 fi
3751
3752 CPPFLAGS="$SAVE_CPPFLAGS"
3753 LDFLAGS="$SAVE_LDFLAGS"
3754
3755 AC_SUBST([LIBNETAPP_CPPFLAGS])
3756 AC_SUBST([LIBNETAPP_LDFLAGS])
3757 AC_SUBST([LIBNETAPP_LIBS])
3758 # }}}
3759
3760 # --with-libnetsnmp {{{
3761 AC_ARG_WITH([libnetsnmp],
3762   [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to libnetsnmp.])],
3763   [
3764     if test "x$withval" = "xno"; then
3765      with_libnetsnmp="no"
3766     else if test "x$withval" = "xyes"; then
3767      with_libnetsnmp="yes"
3768     else
3769       with_libnetsnmp_cppflags="-I$withval/include"
3770       with_libnetsnmp_ldflags="-I$withval/lib"
3771       with_libnetsnmp="yes"
3772     fi; fi
3773   ],
3774   [with_libnetsnmp="yes"]
3775 )
3776
3777 if test "x$with_libnetsnmp" = "xyes"; then
3778   SAVE_CPPFLAGS="$CPPFLAGS"
3779   CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
3780
3781   AC_CHECK_HEADERS([net-snmp/net-snmp-config.h],
3782     [with_libnetsnmp="yes"],
3783     [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"]
3784   )
3785
3786   AC_CHECK_HEADERS([net-snmp/net-snmp-includes.h],
3787     [with_libnetsnmp="yes"],
3788     [with_libnetsnmp="no (net-snmp/net-snmp-includes.h not found)"],
3789     [[
3790       #if HAVE_NET_SNMP_NET_SNMP_CONFIG_H
3791       # include <net-snmp/net-snmp-config.h>
3792       #endif
3793     ]]
3794   )
3795
3796   CPPFLAGS="$SAVE_CPPFLAGS"
3797 fi
3798
3799 if test "x$with_libnetsnmp" = "xyes"; then
3800   SAVE_LDFLAGS="$LDFLAGS"
3801   LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
3802
3803   AC_CHECK_LIB([netsnmp], [init_snmp],
3804     [with_libnetsmp="yes"],
3805     [with_libnetsnmp="no (libnetsnmp not found)"]
3806   )
3807
3808   LDFLAGS="$SAVE_LDFLAGS"
3809 fi
3810
3811 if test "x$with_libnetsnmp" = "xyes"; then
3812   BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
3813   BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
3814   BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
3815 fi
3816
3817 AC_SUBST([BUILD_WITH_LIBNETSNMP_CPPFLAGS])
3818 AC_SUBST([BUILD_WITH_LIBNETSNMP_LDFLAGS])
3819 AC_SUBST([BUILD_WITH_LIBNETSNMP_LIBS])
3820 # }}}
3821
3822 # --with-libnetsmpagent {{{
3823 AC_ARG_WITH([libnetsnmpagent],
3824   [AS_HELP_STRING([--with-libnetsnmpagent@<:@=PREFIX@:>@], [Path to libnetsnmpagent.])],
3825   [
3826     if test "x$withval" = "xno"; then
3827       with_libnetsnmpagent="no"
3828     else if test "x$withval" = "xyes"; then
3829       with_libnetsnmpagent="yes"
3830     else
3831       with_libnetsnmpagent_cppflags="-I$withval/include"
3832       with_libnetsnmpagent_ldflags="-I$withval/lib"
3833       with_libnetsnmpagent="yes"
3834     fi; fi
3835   ],
3836   [with_libnetsnmpagent="yes"]
3837 )
3838
3839 if test "x$with_libnetsnmpagent" = "xyes"; then
3840   SAVE_CPPFLAGS="$CPPFLAGS"
3841   CPPFLAGS="$CPPFLAGS $with_libnetsnmpagent_cppflags"
3842
3843   AC_CHECK_HEADERS([net-snmp/agent/net-snmp-agent-includes.h],
3844     [],
3845     [with_libnetsnmpagent="no (net-snmp/agent/net-snmp-agent-includes.h not found)"],
3846     [[
3847       #if HAVE_NET_SNMP_NET_SNMP_CONFIG_H
3848       # include <net-snmp/net-snmp-config.h>
3849       #endif
3850       #if HAVE_NET_SNMP_NET_SNMP_INCLUDES_H
3851       # include <net-snmp/net-snmp-includes.h>
3852       #endif
3853     ]]
3854   )
3855
3856   CPPFLAGS="$SAVE_CPPFLAGS"
3857 fi
3858
3859 if test "x$with_libnetsnmpagent" = "xyes"; then
3860   SAVE_LDFLAGS="$LDFLAGS"
3861   LDFLAGS="$LDFLAGS $with_libnetsnmpagent_ldflags"
3862
3863   # older versions of libnetsnmpagent fail to link
3864   # against the helpers library, so do that explicitly
3865   AC_CHECK_LIB([netsnmphelpers], [netsnmp_init_helpers],
3866     [libnetsnmphelpers="-lnetsnmphelpers"],
3867     [libnetsnmphelpers=""]
3868   )
3869
3870   AC_CHECK_LIB([netsnmpagent], [init_agent],
3871     [with_libnetsnmpagent="yes"],
3872     [with_libnetsnmpagent="no (libnetsnmpagent not found)"],
3873     [$libnetsnmphelpers]
3874   )
3875
3876   LDFLAGS="$SAVE_LDFLAGS"
3877 fi
3878
3879 if test "x$with_libnetsnmpagent" = "xyes"; then
3880   BUILD_WITH_LIBNETSNMPAGENT_LIBS="-lnetsnmpagent $libnetsnmphelpers"
3881 fi
3882
3883 AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_CPPFLAGS])
3884 AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LDFLAGS])
3885 AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LIBS])
3886 # }}}
3887
3888 # --with-liboping {{{
3889 AC_ARG_WITH([liboping],
3890   [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
3891   [
3892     if test "x$withval" = "xyes"; then
3893       with_liboping="yes"
3894     else if test "x$withval" = "xno"; then
3895       with_liboping="no"
3896     else
3897       with_liboping="yes"
3898       LIBOPING_CPPFLAGS="-I$withval/include"
3899       LIBOPING_LDFLAGS="-L$withval/lib"
3900     fi; fi
3901   ],
3902   [with_liboping="yes"]
3903 )
3904
3905 SAVE_CPPFLAGS="$CPPFLAGS"
3906 SAVE_LDFLAGS="$LDFLAGS"
3907 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
3908 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
3909
3910 if test "x$with_liboping" = "xyes"; then
3911   AC_CHECK_HEADERS([oping.h],
3912     [with_liboping="yes"],
3913     [with_liboping="no (oping.h not found)"]
3914   )
3915 fi
3916
3917 if test "x$with_liboping" = "xyes"; then
3918   AC_CHECK_LIB([oping], [ping_construct],
3919     [with_liboping="yes"],
3920     [with_liboping="no (symbol 'ping_construct' not found)"]
3921   )
3922 fi
3923
3924 CPPFLAGS="$SAVE_CPPFLAGS"
3925 LDFLAGS="$SAVE_LDFLAGS"
3926
3927 if test "x$with_liboping" = "xyes"; then
3928   BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
3929   BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
3930 fi
3931
3932 AC_SUBST([BUILD_WITH_LIBOPING_CPPFLAGS])
3933 AC_SUBST([BUILD_WITH_LIBOPING_LDFLAGS])
3934 # }}}
3935
3936 # --with-oracle {{{
3937 AC_ARG_WITH([oracle],
3938   [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
3939   [
3940     if test "x$withval" = "xyes"; then
3941       if test "x$ORACLE_HOME" = "x"; then
3942         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
3943       fi
3944       with_oracle="yes"
3945     else if test "x$withval" = "xno"; then
3946       with_oracle="no"
3947     else
3948       with_oracle="yes"
3949       ORACLE_HOME="$withval"
3950     fi; fi
3951   ],
3952   [
3953     if test "x$ORACLE_HOME" = "x"; then
3954       with_oracle="no (ORACLE_HOME is not set)"
3955     else
3956       with_oracle="yes"
3957     fi
3958   ]
3959 )
3960
3961 if test "x$ORACLE_HOME" != "x"; then
3962   with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
3963   if test -e "$ORACLE_HOME/lib/ldflags"; then
3964     with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
3965   fi
3966   with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
3967 fi
3968
3969 if test "x$with_oracle" = "xyes"; then
3970   SAVE_CPPFLAGS="$CPPFLAGS"
3971   CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
3972
3973   AC_CHECK_HEADERS([oci.h],
3974     [with_oracle="yes"],
3975     [with_oracle="no (oci.h not found)"]
3976   )
3977
3978   CPPFLAGS="$SAVE_CPPFLAGS"
3979 fi
3980
3981 if test "x$with_oracle" = "xyes"; then
3982   SAVE_CPPFLAGS="$CPPFLAGS"
3983   SAVE_LIBS="$LIBS"
3984   CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
3985   LIBS="$LIBS $with_oracle_libs"
3986
3987   AC_CHECK_FUNC([OCIEnvCreate],
3988     [with_oracle="yes"],
3989     [with_oracle="no (Symbol 'OCIEnvCreate' not found)"]
3990   )
3991
3992   CPPFLAGS="$SAVE_CPPFLAGS"
3993   LIBS="$SAVE_LIBS"
3994 fi
3995
3996 if test "x$with_oracle" = "xyes"; then
3997   BUILD_WITH_ORACLE_CPPFLAGS="$with_oracle_cppflags"
3998   BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
3999 fi
4000
4001 AC_SUBST([BUILD_WITH_ORACLE_CPPFLAGS])
4002 AC_SUBST([BUILD_WITH_ORACLE_LIBS])
4003 # }}}
4004
4005 # --with-libowcapi {{{
4006 AC_ARG_WITH([libowcapi],
4007   [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
4008   [
4009     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4010       with_libowcapi_cppflags="-I$withval/include"
4011       with_libowcapi_ldflags="-L$withval/lib"
4012       with_libowcapi="yes"
4013     else
4014       with_libowcapi="$withval"
4015     fi
4016   ],
4017   [with_libowcapi="yes"]
4018 )
4019
4020 if test "x$with_libowcapi" = "xyes"; then
4021   SAVE_CPPFLAGS="$CPPFLAGS"
4022   CPPFLAGS="$CPPFLAGS $with_libowcapi_cppflags"
4023
4024   AC_CHECK_HEADERS([owcapi.h],
4025     [with_libowcapi="yes"],
4026     [with_libowcapi="no (owcapi.h not found)"]
4027   )
4028
4029   CPPFLAGS="$SAVE_CPPFLAGS"
4030 fi
4031
4032 if test "x$with_libowcapi" = "xyes"; then
4033   SAVE_LDFLAGS="$LDFLAGS"
4034   LDFLAGS="$LDFLAGS $with_libowcapi_ldflags"
4035
4036   AC_CHECK_LIB([owcapi], [OW_get],
4037     [with_libowcapi="yes"],
4038     [with_libowcapi="no (libowcapi not found)"]
4039   )
4040
4041   LDFLAGS="$SAVE_LDFLAGS"
4042 fi
4043
4044 if test "x$with_libowcapi" = "xyes"; then
4045   BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
4046   BUILD_WITH_LIBOWCAPI_LDFLAGS="$with_libowcapi_ldflags"
4047   BUILD_WITH_LIBOWCAPI_LIBS="-lowcapi"
4048 fi
4049
4050 AC_SUBST([BUILD_WITH_LIBOWCAPI_CPPFLAGS])
4051 AC_SUBST([BUILD_WITH_LIBOWCAPI_LDFLAGS])
4052 AC_SUBST([BUILD_WITH_LIBOWCAPI_LIBS])
4053 # }}}
4054
4055 # --with-libpcap {{{
4056 AC_ARG_WITH([libpcap],
4057   [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
4058   [
4059     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4060       with_libpcap_cppflags="-I$withval/include"
4061       with_libpcap_ldflags="$LDFLAGS -L$withval/lib"
4062       with_libpcap="yes"
4063     else
4064       with_libpcap="$withval"
4065     fi
4066   ],
4067   [with_libpcap="yes"]
4068 )
4069
4070 if test "x$with_libpcap" = "xyes"; then
4071   SAVE_CPPFLAGS="$CPPFLAGS"
4072   CPPFLAGS="$CPPFLAGS $with_libpcap_cppflags"
4073
4074   AC_CHECK_HEADERS([pcap.h],
4075     [with_libpcap="yes"],
4076     [with_libpcap="no (pcap.h not found)"]
4077   )
4078
4079   CPPFLAGS="$SAVE_CPPFLAGS"
4080 fi
4081
4082 if test "x$with_libpcap" = "xyes"; then
4083   SAVE_LDFLAGS="$LDFLAGS"
4084   LDFLAGS="$LDFLAGS $with_libpcap_ldflags"
4085
4086   AC_CHECK_LIB([pcap], [pcap_open_live],
4087     [with_libpcap="yes"],
4088     [with_libpcap="no (libpcap not found)"]
4089   )
4090
4091   LDFLAGS="$SAVE_LDFLAGS"
4092 fi
4093
4094 if test "x$with_libpcap" = "xyes"; then
4095   AC_CACHE_CHECK([whether libpcap has PCAP_ERROR_IFACE_NOT_UP],
4096     [c_cv_libpcap_have_pcap_error_iface_not_up],
4097     [
4098       AC_COMPILE_IFELSE(
4099         [
4100           AC_LANG_PROGRAM(
4101             [[#include <pcap.h>]],
4102             [[
4103               int val = PCAP_ERROR_IFACE_NOT_UP;
4104               return(val);
4105             ]]
4106           )
4107         ],
4108         [c_cv_libpcap_have_pcap_error_iface_not_up="yes"],
4109         [c_cv_libpcap_have_pcap_error_iface_not_up="no"]
4110       )
4111     ]
4112   )
4113 fi
4114
4115 if test "x$c_cv_libpcap_have_pcap_error_iface_not_up" != "xyes"; then
4116   with_libpcap="no (pcap.h misses PCAP_ERROR_IFACE_NOT_UP)"
4117 fi
4118
4119 if test "x$with_libpcap" = "xyes"; then
4120   BUILD_WITH_LIBPCAP_CPPFLAGS="$with_libpcap_cppflags"
4121   BUILD_WITH_LIBPCAP_LDFLAGS="$with_libpcap_ldflags"
4122   BUILD_WITH_LIBPCAP_LIBS="-lpcap"
4123 fi
4124
4125 AC_SUBST([BUILD_WITH_LIBPCAP_CPPFLAGS])
4126 AC_SUBST([BUILD_WITH_LIBPCAP_LDFLAGS])
4127 AC_SUBST([BUILD_WITH_LIBPCAP_LIBS])
4128 # }}}
4129
4130 # --with-libperl {{{
4131 AC_ARG_WITH([libperl],
4132   [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
4133   [
4134     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4135       LDFLAGS="$LDFLAGS -L$withval/lib"
4136       CPPFLAGS="$CPPFLAGS -I$withval/include"
4137       with_libperl="yes"
4138     else
4139       with_libperl="$withval"
4140     fi
4141   ],
4142   [with_libperl="yes"]
4143 )
4144
4145 AC_ARG_VAR([PERL], [path to Perl interpreter])
4146 AC_PATH_PROG([PERL], [perl])
4147
4148 if test "x$PERL" = "x"; then
4149   with_libperl="no (no Perl interpreter found)"
4150 fi
4151
4152 if test "x$with_libperl" = "xyes"; then
4153   SAVE_CFLAGS="$CFLAGS"
4154   SAVE_LIBS="$LIBS"
4155   dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
4156   PERL_CFLAGS=`ARCHFLAGS="" $PERL -MExtUtils::Embed -e perl_inc`
4157   PERL_LIBS=`ARCHFLAGS="" $PERL -MExtUtils::Embed -e ldopts`
4158   CFLAGS="$CFLAGS $PERL_CFLAGS"
4159   LIBS="$LIBS $PERL_LIBS"
4160
4161   AC_CACHE_CHECK([for libperl],
4162     [c_cv_have_libperl],
4163     [
4164       AC_LINK_IFELSE(
4165         [
4166           AC_LANG_PROGRAM(
4167             [[
4168               #define PERL_NO_GET_CONTEXT
4169               #include <EXTERN.h>
4170               #include <perl.h>
4171               #include <XSUB.h>
4172             ]],
4173             [[
4174               dTHX;
4175               load_module (PERL_LOADMOD_NOIMPORT,
4176                 newSVpv ("Collectd::Plugin::FooBar", 24),
4177                 Nullsv);
4178             ]]
4179           )
4180         ],
4181         [c_cv_have_libperl="yes"],
4182         [c_cv_have_libperl="no"]
4183       )
4184     ]
4185   )
4186
4187   CFLAGS="$SAVE_CFLAGS"
4188   LIBS="$SAVE_LIBS"
4189
4190   if test "x$c_cv_have_libperl" = "xno"; then
4191     with_libperl="no"
4192   fi
4193 fi
4194
4195 if test "x$with_libperl" = "xyes"; then
4196   SAVE_CFLAGS="$CFLAGS"
4197   SAVE_LIBS="$LIBS"
4198   CFLAGS="$CFLAGS $PERL_CFLAGS"
4199   LIBS="$LIBS $PERL_LIBS"
4200
4201   AC_CACHE_CHECK([if Perl supports ithreads],
4202     [c_cv_have_perl_ithreads],
4203     [
4204       AC_LINK_IFELSE(
4205         [
4206           AC_LANG_PROGRAM(
4207             [[
4208               #include <EXTERN.h>
4209               #include <perl.h>
4210               #include <XSUB.h>
4211
4212               #if !defined(USE_ITHREADS)
4213               # error "Perl does not support ithreads!"
4214               #endif /* !defined(USE_ITHREADS) */
4215             ]],
4216             []
4217           )
4218         ],
4219         [c_cv_have_perl_ithreads="yes"],
4220         [c_cv_have_perl_ithreads="no"]
4221       )
4222     ]
4223   )
4224
4225   CFLAGS="$SAVE_CFLAGS"
4226   LIBS="$SAVE_LIBS"
4227 fi
4228
4229 if test "x$with_libperl" = "xyes"; then
4230   # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
4231   # (see issues #41 and #42)
4232   SAVE_CFLAGS="$CFLAGS"
4233   SAVE_LIBS="$LIBS"
4234   CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
4235   LIBS="$LIBS $PERL_LIBS"
4236
4237   AC_CACHE_CHECK([for broken Perl_load_module()],
4238     [c_cv_have_broken_perl_load_module],
4239     [
4240       AC_LINK_IFELSE(
4241         [
4242           AC_LANG_PROGRAM(
4243             [[
4244               #define PERL_NO_GET_CONTEXT
4245               #include <EXTERN.h>
4246               #include <perl.h>
4247               #include <XSUB.h>
4248             ]],
4249             [[
4250               dTHX;
4251               load_module (PERL_LOADMOD_NOIMPORT,
4252                 newSVpv ("Collectd::Plugin::FooBar", 24),
4253                 Nullsv);
4254             ]]
4255           )
4256         ],
4257         [c_cv_have_broken_perl_load_module="no"],
4258         [c_cv_have_broken_perl_load_module="yes"]
4259       )
4260     ]
4261   )
4262
4263   CFLAGS="$SAVE_CFLAGS"
4264   LIBS="$SAVE_LIBS"
4265 fi
4266
4267 if test "x$c_cv_have_broken_perl_load_module" = "xyes"; then
4268   PERL_CFLAGS="$PERL_CFLAGS -Wno-nonnull"
4269 fi
4270
4271 if test "x$with_libperl" = "xyes"; then
4272   SAVE_CFLAGS="$CFLAGS"
4273   SAVE_LIBS="$LIBS"
4274   CFLAGS="$CFLAGS $PERL_CFLAGS"
4275   LIBS="$LIBS $PERL_LIBS"
4276
4277   AC_CHECK_MEMBER(
4278     [struct mgvtbl.svt_local],
4279     [have_struct_mgvtbl_svt_local="yes"],
4280     [have_struct_mgvtbl_svt_local="no"],
4281     [[
4282       #include <EXTERN.h>
4283       #include <perl.h>
4284       #include <XSUB.h>
4285     ]]
4286   )
4287
4288   if test "x$have_struct_mgvtbl_svt_local" = "xyes"; then
4289     AC_DEFINE([HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL], [1], [Define if Perls struct mgvtbl has member svt_local.])
4290   fi
4291
4292   CFLAGS="$SAVE_CFLAGS"
4293   LIBS="$SAVE_LIBS"
4294 fi
4295 AC_SUBST([PERL_CFLAGS])
4296 AC_SUBST([PERL_LIBS])
4297
4298 # }}}
4299
4300 # --with-libpq {{{
4301 with_pg_config="pg_config"
4302 AC_ARG_WITH([libpq],
4303   [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@], [Path to libpq.])],
4304   [
4305     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
4306       with_libpq="$withval"
4307     else
4308       if test -f "$withval" && test -x "$withval"; then
4309         with_pg_config="$withval"
4310       else if test -x "$withval/bin/pg_config"; then
4311         with_pg_config="$withval/bin/pg_config"
4312       fi; fi
4313       with_libpq="yes"
4314     fi
4315   ],
4316   [with_libpq="yes"]
4317 )
4318
4319 if test "x$with_libpq" = "xyes"; then
4320   with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
4321   pg_config_status=$?
4322
4323   if test $pg_config_status -eq 0; then
4324     if test -n "$with_libpq_includedir"; then
4325       for dir in $with_libpq_includedir; do
4326         with_libpq_cppflags="$with_libpq_cppflags -I$dir"
4327       done
4328     fi
4329   else
4330     AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
4331   fi
4332
4333   SAVE_CPPFLAGS="$CPPFLAGS"
4334   CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
4335
4336   AC_CHECK_HEADERS([libpq-fe.h],
4337     [with_libpq="yes"],
4338     [with_libpq="no (libpq-fe.h not found)"]
4339   )
4340
4341   CPPFLAGS="$SAVE_CPPFLAGS"
4342 fi
4343
4344 if test "x$with_libpq" = "xyes"; then
4345   with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
4346   pg_config_status=$?
4347
4348   if test $pg_config_status -eq 0
4349   then
4350     if test -n "$with_libpq_libdir"; then
4351       for dir in $with_libpq_libdir; do
4352         with_libpq_ldflags="$with_libpq_ldflags -L$dir"
4353       done
4354     fi
4355   else
4356     AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
4357   fi
4358
4359   SAVE_LDFLAGS="$LDFLAGS"
4360   LDFLAGS="$LDFLAGS $with_libpq_ldflags"
4361
4362   AC_CHECK_LIB([pq], [PQserverVersion],
4363     [with_libpq="yes"],
4364     [with_libpq="no (symbol 'PQserverVersion' not found)"])
4365
4366   LDFLAGS="$SAVE_LDFLAGS"
4367 fi
4368
4369 if test "x$with_libpq" = "xyes"; then
4370   BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
4371   BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
4372   BUILD_WITH_LIBPQ_LIBS="-lpq"
4373 fi
4374
4375 AC_SUBST([BUILD_WITH_LIBPQ_CPPFLAGS])
4376 AC_SUBST([BUILD_WITH_LIBPQ_LDFLAGS])
4377 AC_SUBST([BUILD_WITH_LIBPQ_LIBS])
4378 # }}}
4379
4380 # --with-libpqos {{{
4381 AC_ARG_WITH([libpqos],
4382   [AS_HELP_STRING([--with-libpqos@<:@=PREFIX@:>@], [Path to libpqos.])],
4383   [
4384     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4385       with_libpqos_cppflags="-I$withval/include"
4386       with_libpqos_ldflags="-L$withval/lib"
4387       with_libpqos="yes"
4388     else
4389       with_libpqos="$withval"
4390     fi
4391   ],
4392   [with_libpqos="yes"]
4393 )
4394
4395 if test "x$with_libpqos" = "xyes"; then
4396   SAVE_CPPFLAGS="$CPPFLAGS"
4397   CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4398
4399   AC_CHECK_HEADERS([pqos.h],
4400     [with_libpqos="yes"],
4401     [with_libpqos="no (pqos.h not found)"]
4402   )
4403
4404   CPPFLAGS="$SAVE_CPPFLAGS"
4405 fi
4406
4407 if test "x$with_libpqos" = "xyes"; then
4408   SAVE_LDFLAGS="$LDFLAGS"
4409   LDFLAGS="$LDFLAGS $with_libpqos_ldflags"
4410
4411   AC_CHECK_LIB([pqos], [pqos_init],
4412     [with_libpqos="yes"],
4413     [with_libpqos="no (Can't find libpqos)"]
4414   )
4415
4416   LDFLAGS="$SAVE_LDFLAGS"
4417 fi
4418
4419 if test "x$with_libpqos" = "xyes"; then
4420   SAVE_CPPFLAGS="$CPPFLAGS"
4421   CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4422   AC_PREPROC_IFELSE(
4423     [
4424       AC_LANG_SOURCE(
4425         [[
4426           #include <pqos.h>
4427           #if PQOS_VERSION < 106
4428           #error "required PQOS version >= 1.06"
4429           #endif
4430         ]]
4431       )
4432     ],
4433     [with_libpqos="yes"],
4434     [with_libpqos="no (pqos library version 1.06 or higher is required)"]
4435   )
4436
4437   CPPFLAGS="$SAVE_CPPFLAGS"
4438 fi
4439
4440 if test "x$with_libpqos" = "xyes"; then
4441   BUILD_WITH_LIBPQOS_CPPFLAGS="$with_libpqos_cppflags"
4442   BUILD_WITH_LIBPQOS_LDFLAGS="$with_libpqos_ldflags"
4443   BUILD_WITH_LIBPQOS_LIBS="-lpqos"
4444 fi
4445
4446 AC_SUBST([BUILD_WITH_LIBPQOS_CPPFLAGS])
4447 AC_SUBST([BUILD_WITH_LIBPQOS_LDFLAGS])
4448 AC_SUBST([BUILD_WITH_LIBPQOS_LIBS])
4449 # }}}
4450
4451 # --with-libjevents {{{
4452 with_libjevents_cppflags=""
4453 with_libjevents_ldflags=""
4454 AC_ARG_WITH([libjevents],
4455   [AS_HELP_STRING([--with-libjevents@<:@=PREFIX@:>@], [Path to libjevents.])],
4456   [
4457     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4458       with_libjevents_cppflags="-I$withval/include"
4459       with_libjevents_ldflags="-L$withval/lib"
4460       with_libjevents="yes"
4461     else
4462       with_libjevents="$withval"
4463     fi
4464   ],
4465   [with_libjevents="yes"]
4466 )
4467
4468 if test "x$with_libjevents" = "xyes"; then
4469   SAVE_CPPFLAGS="$CPPFLAGS"
4470   CPPFLAGS="$CPPFLAGS $with_libjevents_cppflags"
4471
4472   AC_CHECK_HEADERS([jevents.h], [with_libjevents="yes"], [with_libjevents="no (jevents.h not found)"])
4473
4474   CPPFLAGS="$SAVE_CPPFLAGS"
4475 fi
4476 if test "x$with_libjevents" = "xyes"; then
4477   SAVE_LDFLAGS="$LDFLAGS"
4478   LDFLAGS="$LDFLAGS $with_libjevents_ldflags"
4479
4480   AC_CHECK_LIB([jevents], [json_events], [with_libjevents="yes"], [with_libjevents="no (Can't find libjevents)"])
4481
4482   LDFLAGS="$SAVE_LDFLAGS"
4483 fi
4484 if test "x$with_libjevents" = "xyes"; then
4485   BUILD_WITH_LIBJEVENTS_CPPFLAGS="$with_libjevents_cppflags"
4486   BUILD_WITH_LIBJEVENTS_LDFLAGS="$with_libjevents_ldflags"
4487   BUILD_WITH_LIBJEVENTS_LIBS="-ljevents"
4488 fi
4489 AC_SUBST([BUILD_WITH_LIBJEVENTS_CPPFLAGS])
4490 AC_SUBST([BUILD_WITH_LIBJEVENTS_LDFLAGS])
4491 AC_SUBST([BUILD_WITH_LIBJEVENTS_LIBS])
4492 # }}}
4493
4494 # --with-libprotobuf {{{
4495 with_libprotobuf_cppflags=""
4496 with_libprotobuf_ldflags=""
4497 AC_ARG_WITH([libprotobuf],
4498   [AS_HELP_STRING([--with-libprotobuf@<:@=PREFIX@:>@], [Path to libprotobuf.])],
4499   [
4500     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4501       with_libprotobuf_cppflags="-I$withval/include"
4502       with_libprotobuf_ldflags="-L$withval/lib"
4503       with_libprotobuf="yes"
4504     fi
4505     if test "x$withval" = "xno"; then
4506       with_libprotobuf="no (disabled on command line)"
4507     fi
4508   ],
4509   [withval="yes"]
4510 )
4511
4512 if test "x$withval" = "xyes"; then
4513   PKG_CHECK_MODULES([PROTOBUF], [protobuf],
4514     [with_libprotobuf="yes"],
4515     [with_libprotobuf="no (pkg-config could not find libprotobuf)"]
4516   )
4517 fi
4518
4519 if test "x$withval" != "xno"; then
4520   SAVE_LDFLAGS="$LDFLAGS"
4521   SAVE_LIBS="$LIBS"
4522   LDFLAGS="$with_libprotobuf_ldflags"
4523   LIBS="$PROTOBUF_LIBS $LIBS"
4524   AC_LANG_PUSH([C++])
4525   AC_CHECK_LIB([protobuf], [main],
4526     [
4527       SAVE_CPPFLAGS="$CPPFLAGS"
4528       CPPFLAGS="$with_libprotobuf_cppflags $PROTOBUF_CFLAGS"
4529       if test "x$PROTOBUF_LIBS" = "x"
4530       then
4531         PROTOBUF_LIBS="-lprotobuf"
4532       fi
4533       AC_CHECK_HEADERS([google/protobuf/util/time_util.h],
4534         [with_libprotobuf="yes"],
4535         [with_libprotobuf="no (<google/protobuf/util/time_util.h> not found)"]
4536       )
4537       CPPFLAGS="$SAVE_CPPFLAGS"
4538     ],
4539     [with_libprotobuf="no (libprotobuf not found)"]
4540   )
4541   AC_LANG_POP([C++])
4542   LDFLAGS="$SAVE_LDFLAGS"
4543   LIBS="$SAVE_LIBS"
4544 fi
4545
4546 BUILD_WITH_LIBPROTOBUF_CPPFLAGS="$with_libprotobuf_cppflags $PROTOBUF_CFLAGS"
4547 BUILD_WITH_LIBPROTOBUF_LDFLAGS="$with_libprotobuf_ldflags"
4548 BUILD_WITH_LIBPROTOBUF_LIBS="$PROTOBUF_LIBS"
4549 AC_SUBST([BUILD_WITH_LIBPROTOBUF_CPPFLAGS])
4550 AC_SUBST([BUILD_WITH_LIBPROTOBUF_LDFLAGS])
4551 AC_SUBST([BUILD_WITH_LIBPROTOBUF_LIBS])
4552 # }}}
4553
4554 AC_ARG_VAR([PROTOC], [path to the protoc binary])
4555 AC_PATH_PROG([PROTOC], [protoc])
4556 have_protoc3="no"
4557 if test "x$PROTOC" != "x"; then
4558   AC_MSG_CHECKING([for protoc 3.0.0+])
4559   if $PROTOC --version | $EGREP libprotoc.3 >/dev/null; then
4560     protoc3="yes (`$PROTOC --version`)"
4561     have_protoc3="yes"
4562   else
4563     protoc3="no (`$PROTOC --version`)"
4564   fi
4565   AC_MSG_RESULT([$protoc3])
4566 fi
4567 AM_CONDITIONAL([HAVE_PROTOC3], [test "x$have_protoc3" = "xyes"])
4568
4569 # --with-libprotobuf-c {{{
4570 AC_ARG_WITH([libprotobuf-c],
4571   [AS_HELP_STRING([--with-libprotobuf-c@<:@=PREFIX@:>@], [Path to libprotobuf-c.])],
4572   [
4573     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4574       with_libprotobuf_c_cppflags="-I$withval/include"
4575       with_libprotobuf_c_ldflags="-L$withval/lib"
4576       with_libprotobuf_c="yes"
4577     fi
4578
4579     if test "x$withval" = "xno"; then
4580       with_libprotobuf_c="no (disabled on command line)"
4581     fi
4582   ],
4583   [withval="yes"]
4584 )
4585
4586 if test "x$withval" = "xyes"; then
4587   PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c],
4588     [with_libprotobuf_c="yes"],
4589     [with_libprotobuf_c="no (pkg-config could not find libprotobuf-c)"]
4590   )
4591 fi
4592
4593 if test "x$withval" != "xno"; then
4594   SAVE_LDFLAGS="$LDFLAGS"
4595   SAVE_LIBS="$LIBS"
4596   LDFLAGS="$with_libprotobuf_c_ldflags"
4597   LIBS="$PROTOBUF_C_LIBS $LIBS"
4598   AC_CHECK_LIB([protobuf-c], [protobuf_c_message_pack],
4599     [
4600       SAVE_CPPFLAGS="$CPPFLAGS"
4601       CPPFLAGS="$with_libprotobuf_c_cppflags $PROTOBUF_C_CFLAGS"
4602       if test "x$PROTOBUF_C_LIBS" = "x"; then
4603         PROTOBUF_C_LIBS="-lprotobuf-c"
4604       fi
4605
4606       AC_CHECK_HEADERS([protobuf-c/protobuf-c.h google/protobuf-c/protobuf-c.h],
4607         [
4608           with_libprotobuf_c="yes"
4609           break
4610         ],
4611         [with_libprotobuf_c="no (<protobuf-c.h> not found)"]
4612       )
4613
4614       CPPFLAGS="$SAVE_CPPFLAGS"
4615     ],
4616     [with_libprotobuf_c="no (libprotobuf-c not found)"]
4617   )
4618   LDFLAGS="$SAVE_LDFLAGS"
4619   LIBS="$SAVE_LIBS"
4620 fi
4621
4622 BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS="$with_libprotobuf_c_cppflags $PROTOBUF_C_CFLAGS"
4623 BUILD_WITH_LIBPROTOBUF_C_LDFLAGS="$with_libprotobuf_c_ldflags"
4624 BUILD_WITH_LIBPROTOBUF_C_LIBS="$PROTOBUF_C_LIBS"
4625 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS])
4626 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_LDFLAGS])
4627 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_LIBS])
4628 # }}}
4629
4630 AC_ARG_VAR([PROTOC_C], [path to the protoc-c binary])
4631 AC_PATH_PROG([PROTOC_C], [protoc-c])
4632 if test "x$PROTOC_C" = "x"
4633 then
4634   have_protoc_c="no (protoc-c compiler not found)"
4635 else
4636   have_protoc_c="yes"
4637 fi
4638
4639 # --with-libpython {{{
4640 AC_ARG_VAR([LIBPYTHON_CPPFLAGS], [Preprocessor flags for libpython])
4641 AC_ARG_VAR([LIBPYTHON_LDFLAGS], [Linker flags for libpython])
4642 AC_ARG_VAR([LIBPYTHON_LIBS], [Libraries for libpython])
4643
4644 AC_ARG_WITH([libpython],
4645   [AS_HELP_STRING([--with-libpython], [if we should build with libpython @<:@default=yes@:>@])],
4646   [with_libpython="$withval"],
4647   [with_libpython="check"]
4648 )
4649
4650 if test "$with_libpython" != "no"; then
4651   if test "$LIBPYTHON_CPPFLAGS" = "" && test "$LIBPYTHON_LDFLAGS" = ""; then
4652     AC_ARG_VAR([PYTHON_CONFIG], [path to python-config])
4653     AC_PATH_PROGS([PYTHON_CONFIG],
4654       [python3-config python2-config python-config]
4655     )
4656     if test "$PYTHON_CONFIG" = ""; then
4657       if test "$with_libpython" = "yes"; then
4658         AC_MSG_ERROR([Unable to find python-config])
4659       fi
4660       with_libpython="no"
4661     fi
4662   fi
4663 fi
4664
4665 if test "$PYTHON_CONFIG" != ""; then
4666   LIBPYTHON_CPPFLAGS="`${PYTHON_CONFIG} --includes`"
4667   if test $? -ne 0; then
4668     with_libpython="no"
4669   fi
4670   LIBPYTHON_LDFLAGS="`${PYTHON_CONFIG} --ldflags`"
4671   if test $? -ne 0; then
4672     with_libpython="no"
4673   fi
4674   LIBPYTHON_LIBS="`${PYTHON_CONFIG} --libs`"
4675   if test $? -ne 0; then
4676     with_libpython="no"
4677   fi
4678 fi
4679
4680 if test "$with_libpython" != "xno"; then
4681   SAVE_CPPFLAGS="$CPPFLAGS"
4682   SAVE_LDFLAGS="$LDFLAGS"
4683   SAVE_LIBS="$LIBS"
4684   CPPFLAGS="$LIBPYTHON_CPPFLAGS $CPPFLAGS"
4685   LDFLAGS="$LIBPYTHON_LDFLAGS $LDFLAGS"
4686   LIBS="$LIBPYTHON_LIBS $LIBS"
4687
4688   AC_CHECK_HEADERS([Python.h],
4689     [
4690       AC_MSG_CHECKING([for libpython])
4691       AC_LINK_IFELSE([AC_LANG_PROGRAM(
4692           [[#include <Python.h>]],
4693           [[Py_Initialize();]])
4694         ],
4695         [with_libpython="yes"],
4696         [with_libpython="no"]
4697       )
4698       AC_MSG_RESULT([$with_libpython])
4699     ],
4700     [with_libpython="no"]
4701   )
4702
4703   CPPFLAGS="$SAVE_CPPFLAGS"
4704   LDFLAGS="$SAVE_LDFLAGS"
4705   LIBS="$SAVE_LIBS"
4706 fi
4707 # }}} --with-libpython
4708
4709 # --with-librabbitmq {{{
4710 AC_ARG_WITH([librabbitmq],
4711   [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
4712   [
4713     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4714       with_librabbitmq_cppflags="-I$withval/include"
4715       with_librabbitmq_ldflags="-L$withval/lib"
4716       with_librabbitmq="yes"
4717     else
4718       with_librabbitmq="$withval"
4719     fi
4720   ],
4721   [with_librabbitmq="yes"]
4722 )
4723
4724 if test "x$with_librabbitmq" = "xyes"; then
4725   SAVE_CPPFLAGS="$CPPFLAGS"
4726   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4727
4728   AC_CHECK_HEADERS([amqp.h],
4729     [with_librabbitmq="yes"],
4730     [with_librabbitmq="no (amqp.h not found)"]
4731   )
4732
4733   CPPFLAGS="$SAVE_CPPFLAGS"
4734 fi
4735
4736 if test "x$with_librabbitmq" = "xyes"; then
4737   # librabbitmq up to version 0.9.1 provides "library_errno", later
4738   # versions use "library_error". The library does not provide a version
4739   # macro :(.
4740
4741   SAVE_CPPFLAGS="$CPPFLAGS"
4742   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4743
4744   AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],
4745     [],
4746     [],
4747     [[
4748       #include <stdlib.h>
4749       #include <stdio.h>
4750       #include <stdint.h>
4751       #include <inttypes.h>
4752       #include <amqp.h>
4753     ]]
4754   )
4755   CPPFLAGS="$SAVE_CPPFLAGS"
4756
4757   SAVE_LDFLAGS="$LDFLAGS"
4758   LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
4759
4760   AC_CHECK_LIB([rabbitmq], [amqp_basic_publish],
4761     [with_librabbitmq="yes"],
4762     [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"]
4763   )
4764
4765   LDFLAGS="$SAVE_LDFLAGS"
4766 fi
4767
4768 if test "x$with_librabbitmq" = "xyes"; then
4769   SAVE_CPPFLAGS="$CPPFLAGS"
4770   SAVE_LDFLAGS="$LDFLAGS"
4771   SAVE_LIBS="$LIBS"
4772   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4773   LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
4774   LIBS="-lrabbitmq"
4775
4776   AC_CHECK_HEADERS([amqp_tcp_socket.h amqp_socket.h])
4777   AC_CHECK_FUNC([amqp_tcp_socket_new],
4778     [
4779       AC_DEFINE([HAVE_AMQP_TCP_SOCKET], [1],
4780         [Define if librabbitmq provides the new TCP socket interface.])
4781     ]
4782   )
4783
4784   AC_CHECK_DECLS([amqp_socket_close],
4785     [],
4786     [],
4787     [[
4788       #include <amqp.h>
4789       #ifdef HAVE_AMQP_TCP_SOCKET_H
4790       # include <amqp_tcp_socket.h>
4791       #endif
4792       #ifdef HAVE_AMQP_SOCKET_H
4793       # include <amqp_socket.h>
4794       #endif
4795     ]]
4796   )
4797
4798   CPPFLAGS="$SAVE_CPPFLAGS"
4799   LDFLAGS="$SAVE_LDFLAGS"
4800   LIBS="$SAVE_LIBS"
4801 fi
4802
4803 if test "x$with_librabbitmq" = "xyes"; then
4804   BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
4805   BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
4806   BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
4807 fi
4808
4809 AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
4810 AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
4811 AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
4812
4813 # }}}
4814
4815 # --with-librdkafka {{{
4816 AC_ARG_WITH([librdkafka],
4817   [AS_HELP_STRING([--with-librdkafka@<:@=PREFIX@:>@], [Path to librdkafka.])],
4818   [
4819     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4820       with_librdkafka_cppflags="-I$withval/include"
4821       with_librdkafka_ldflags="-L$withval/lib"
4822       with_librdkafka_rpath="$withval/lib"
4823       with_librdkafka="yes"
4824     else
4825       with_librdkafka="$withval"
4826     fi
4827   ],
4828   [with_librdkafka="yes"]
4829 )
4830
4831 if test "x$with_librdkafka" = "xyes"; then
4832   SAVE_CPPFLAGS="$CPPFLAGS"
4833   CPPFLAGS="$CPPFLAGS $with_librdkafka_cppflags"
4834
4835   AC_CHECK_HEADERS([librdkafka/rdkafka.h],
4836     [with_librdkafka="yes"],
4837     [with_librdkafka="no (librdkafka/rdkafka.h not found)"]
4838   )
4839
4840   CPPFLAGS="$SAVE_CPPFLAGS"
4841 fi
4842
4843 if test "x$with_librdkafka" = "xyes"; then
4844   SAVE_LDFLAGS="$LDFLAGS"
4845   LDFLAGS="$LDFLAGS $with_librdkafka_ldflags"
4846
4847   AC_CHECK_LIB([rdkafka], [rd_kafka_new],
4848     [with_librdkafka="yes"],
4849     [with_librdkafka="no (Symbol 'rd_kafka_new' not found)"])
4850
4851   AC_CHECK_LIB([rdkafka], [rd_kafka_conf_set_log_cb],
4852     [with_librdkafka_log_cb="yes"],
4853     [with_librdkafka_log_cb="no"])
4854
4855   AC_CHECK_LIB([rdkafka], [rd_kafka_set_logger],
4856     [with_librdkafka_logger="yes"],
4857     [with_librdkafka_logger="no"]
4858   )
4859
4860   LDFLAGS="$SAVE_LDFLAGS"
4861 fi
4862
4863 if test "x$with_librdkafka" = "xyes"; then
4864   BUILD_WITH_LIBRDKAFKA_CPPFLAGS="$with_librdkafka_cppflags"
4865   BUILD_WITH_LIBRDKAFKA_LDFLAGS="$with_librdkafka_ldflags"
4866
4867   if test "x$with_librdkafka_rpath" != "x"; then
4868     BUILD_WITH_LIBRDKAFKA_LIBS="-Wl,-rpath,$with_librdkafka_rpath -lrdkafka"
4869   else
4870     BUILD_WITH_LIBRDKAFKA_LIBS="-lrdkafka"
4871   fi
4872
4873   if test "x$with_librdkafka_log_cb" = "xyes"; then
4874     AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.])
4875   else if test "x$with_librdkafka_logger" = "xyes"; then
4876     AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.])
4877   fi; fi
4878 fi
4879
4880 AC_SUBST([BUILD_WITH_LIBRDKAFKA_CPPFLAGS])
4881 AC_SUBST([BUILD_WITH_LIBRDKAFKA_LDFLAGS])
4882 AC_SUBST([BUILD_WITH_LIBRDKAFKA_LIBS])
4883 # }}}
4884
4885 # --with-librouteros {{{
4886 AC_ARG_WITH([librouteros],
4887   [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
4888   [
4889     if test "x$withval" = "xyes" || test "x$withval" = "xno"; then
4890       with_librouteros="$witval"
4891     else
4892       with_librouteros_cppflags="-I$withval/include"
4893       with_librouteros_ldflags="-L$withval/lib"
4894       with_librouteros="yes"
4895    fi
4896   ],
4897   [with_librouteros="yes"]
4898 )
4899
4900 if test "x$with_librouteros" = "xyes"; then
4901   SAVE_CPPFLAGS="$CPPFLAGS"
4902   CPPFLAGS="$CPPFLAGS $with_librouteros_cppflags"
4903
4904   AC_CHECK_HEADERS([routeros_api.h],
4905     [with_librouteros="yes"],
4906     [with_librouteros="no (routeros_api.h not found)"]
4907   )
4908
4909   CPPFLAGS="$SAVE_CPPFLAGS"
4910 fi
4911
4912 if test "x$with_librouteros" = "xyes"; then
4913   SAVE_LDFLAGS="$LDFLAGS"
4914   LDFLAGS="$LDFLAGS $with_librouteros_ldflags"
4915
4916   AC_CHECK_LIB([routeros], [ros_interface],
4917     [with_librouteros="yes"],
4918     [with_librouteros="no (symbol 'ros_interface' not found)"]
4919   )
4920
4921   LDFLAGS="$SAVE_LDFLAGS"
4922 fi
4923
4924 if test "x$with_librouteros" = "xyes"; then
4925   BUILD_WITH_LIBROUTEROS_CPPFLAGS="$with_librouteros_cppflags"
4926   BUILD_WITH_LIBROUTEROS_LDFLAGS="$with_librouteros_ldflags"
4927 fi
4928
4929 AC_SUBST([BUILD_WITH_LIBROUTEROS_CPPFLAGS])
4930 AC_SUBST([BUILD_WITH_LIBROUTEROS_LDFLAGS])
4931 # }}}
4932
4933 # --with-librrd {{{
4934 librrd_threadsafe="no"
4935 librrd_rrdc_update="no"
4936 AC_ARG_WITH([librrd],
4937   [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
4938   [
4939     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4940       librrd_cflags="-I$withval/include"
4941       librrd_ldflags="-L$withval/lib"
4942       with_librrd="yes"
4943     else
4944       with_librrd="$withval"
4945     fi
4946   ],
4947   [with_librrd="yes"]
4948 )
4949
4950 if test "x$with_librrd" = "xyes"; then
4951   SAVE_LDFLAGS="$LDFLAGS"
4952   LDFLAGS="$LDFLAGS $librrd_ldflags"
4953   PKG_CHECK_MODULES([RRD], [librrd >= 1.6.0],
4954     [
4955       AC_CHECK_LIB([rrd], [rrd_update_r],
4956         [librrd_threadsafe="yes"],
4957         [:]
4958       )
4959       AC_CHECK_LIB([rrd], [rrdc_update],
4960         [librrd_rrdc_update="yes"],
4961         [:]
4962       )
4963     ],[:]
4964   )
4965   LDFLAGS="$SAVE_LDFLAGS"
4966
4967   SAVE_CPPFLAGS="$CPPFLAGS"
4968   CPPFLAGS="$CPPFLAGS $RRD_CFLAGS $librrd_cflags"
4969
4970   AC_CHECK_HEADERS([rrd.h],, [with_librrd="no (rrd.h not found)"])
4971
4972   CPPFLAGS="$SAVE_CPPFLAGS"
4973 fi
4974
4975 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"; then
4976   SAVE_LDFLAGS="$LDFLAGS"
4977   LDFLAGS="$LDFLAGS $librrd_ldflags"
4978
4979   AC_CHECK_LIB([rrd_th], [rrd_update_r],
4980     [
4981       librrd_ldflags="$librrd_ldflags -lrrd_th"
4982       librrd_threadsafe="yes"
4983       AC_CHECK_LIB([rrd_th], [rrdc_update],
4984         [librrd_rrdc_update="yes"],
4985         [:],
4986       )
4987     ],
4988     [:]
4989   )
4990   LDFLAGS="$SAVE_LDFLAGS"
4991 fi
4992
4993 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"; then
4994   SAVE_LDFLAGS="$LDFLAGS"
4995   LDFLAGS="$LDFLAGS $librrd_ldflags"
4996
4997   AC_CHECK_LIB([rrd], [rrd_update],
4998     [
4999       librrd_ldflags="$librrd_ldflags -lrrd"
5000       AC_CHECK_LIB([rrd], [rrdc_update],
5001         [librrd_rrdc_update="yes"],
5002         [:]
5003       )
5004     ],
5005     [with_librrd="no (symbol 'rrd_update' not found)"]
5006   )
5007   LDFLAGS="$SAVE_LDFLAGS"
5008 fi
5009
5010 if test "x$with_librrd" = "xyes"; then
5011   BUILD_WITH_LIBRRD_CFLAGS="$RRD_CFLAGS $librrd_cflags"
5012   BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
5013   BUILD_WITH_LIBRRD_LIBS="$RRD_LIBS"
5014 fi
5015
5016 if test "x$librrd_threadsafe" = "xyes"; then
5017   AC_DEFINE([HAVE_THREADSAFE_LIBRRD], [1],
5018     [Define to 1 if the rrd library is thread-safe]
5019   )
5020 fi
5021
5022 AC_SUBST([BUILD_WITH_LIBRRD_CFLAGS])
5023 AC_SUBST([BUILD_WITH_LIBRRD_LDFLAGS])
5024 AC_SUBST([BUILD_WITH_LIBRRD_LIBS])
5025 # }}}
5026
5027 # --with-libsensors {{{
5028 AC_ARG_WITH([libsensors],
5029   [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
5030   [
5031     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5032       with_libsensors="$withval"
5033     else
5034       with_sensors_cppflags="-I$withval/include"
5035       with_sensors_ldflags="-L$withval/lib"
5036       with_libsensors="yes"
5037     fi
5038   ],
5039   [
5040     if test "x$ac_system" = "xLinux"; then
5041       with_libsensors="yes"
5042     else
5043       with_libsensors="no (Linux only library)"
5044     fi
5045   ]
5046 )
5047
5048 if test "x$with_libsensors" = "xyes"; then
5049   SAVE_CPPFLAGS="$CPPFLAGS"
5050   CPPFLAGS="$CPPFLAGS $with_sensors_cppflags"
5051
5052   AC_CHECK_HEADERS([sensors/sensors.h],
5053     [with_libsensors="yes"],
5054     [with_libsensors="no (sensors/sensors.h not found)"]
5055   )
5056
5057   CPPFLAGS="$SAVE_CPPFLAGS"
5058 fi
5059
5060 if test "x$with_libsensors" = "xyes"; then
5061   SAVE_LDFLAGS="$LDFLAGS"
5062   LDFLAGS="$LDFLAGS $with_sensors_ldflags"
5063
5064   AC_CHECK_LIB([sensors], [sensors_init],
5065     [with_libsensors="yes"],
5066     [with_libsensors="no (libsensors not found)"]
5067   )
5068
5069   LDFLAGS="$SAVE_LDFLAGS"
5070 fi
5071
5072 if test "x$with_libsensors" = "xyes"; then
5073   BUILD_WITH_LIBSENSORS_CPPFLAGS="$with_sensors_cppflags"
5074   BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
5075   BUILD_WITH_LIBSENSORS_LIBS="-lsensors"
5076 fi
5077
5078 AC_SUBST([BUILD_WITH_LIBSENSORS_CPPFLAGS])
5079 AC_SUBST([BUILD_WITH_LIBSENSORS_LDFLAGS])
5080 AC_SUBST([BUILD_WITH_LIBSENSORS_LIBS])
5081
5082 # }}}
5083
5084 # libsigrok {{{
5085 AC_SUBST([LIBSIGROK_CFLAGS])
5086 AC_SUBST([LIBSIGROK_LIBS])
5087 PKG_CHECK_MODULES([LIBSIGROK], [libsigrok < 0.4],
5088   [with_libsigrok="yes"],
5089   [with_libsigrok="no (pkg-config could not find libsigrok)"]
5090 )
5091 # }}}
5092
5093 # --with-libstatgrab {{{
5094 AC_ARG_WITH([libstatgrab],
5095   [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
5096   [
5097     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5098       with_libstatgrab_cflags="-I$withval/include"
5099       with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
5100       with_libstatgrab="yes"
5101       with_libstatgrab_pkg_config="no"
5102     else
5103       with_libstatgrab="$withval"
5104       with_libstatgrab_pkg_config="yes"
5105     fi
5106   ],
5107   [
5108     with_libstatgrab="yes"
5109     with_libstatgrab_pkg_config="yes"
5110   ])
5111
5112 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes"; then
5113   AC_MSG_CHECKING([pkg-config for libstatgrab])
5114   temp_result="found"
5115   $PKG_CONFIG --exists libstatgrab 2>/dev/null
5116   if test "$?" != "0"; then
5117     with_libstatgrab_pkg_config="no"
5118     with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
5119     temp_result="not found"
5120   fi
5121   AC_MSG_RESULT([$temp_result])
5122 fi
5123
5124 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes" && test "x$with_libstatgrab_cflags" = "x"; then
5125   AC_MSG_CHECKING([for libstatgrab CFLAGS])
5126   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
5127   if test "$?" = "0"; then
5128     with_libstatgrab_cflags="$temp_result"
5129   else
5130     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
5131     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
5132   fi
5133   AC_MSG_RESULT([$temp_result])
5134 fi
5135
5136 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes" && test "x$with_libstatgrab_ldflags" = "x"; then
5137   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
5138   temp_result="`$PKG_CONFIG --libs libstatgrab`"
5139   if test "$?" = "0"
5140   then
5141     with_libstatgrab_ldflags="$temp_result"
5142   else
5143     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
5144     temp_result="$PKG_CONFIG --libs libstatgrab failed"
5145   fi
5146   AC_MSG_RESULT([$temp_result])
5147 fi
5148
5149 if test "x$with_libstatgrab" = "xyes"; then
5150   SAVE_CPPFLAGS="$CPPFLAGS"
5151   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
5152
5153   AC_CHECK_HEADERS([statgrab.h],
5154     [with_libstatgrab="yes"],
5155     [with_libstatgrab="no (statgrab.h not found)"]
5156   )
5157
5158   CPPFLAGS="$SAVE_CPPFLAGS"
5159 fi
5160
5161 if test "x$with_libstatgrab" = "xyes"; then
5162   SAVE_LDFLAGS="$LDFLAGS"
5163   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5164
5165   AC_CHECK_LIB([statgrab], [sg_init],
5166     [with_libstatgrab="yes"],
5167     [with_libstatgrab="no (symbol sg_init not found)"]
5168   )
5169
5170   LDFLAGS="$SAVE_LDFLAGS"
5171 fi
5172
5173 if test "x$with_libstatgrab" = "xyes"; then
5174   SAVE_CFLAGS="$CFLAGS"
5175   SAVE_LDFLAGS="$LDFLAGS"
5176   SAVE_LIBS="$LIBS"
5177
5178   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
5179   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5180   LIBS="-lstatgrab $LIBS"
5181
5182   AC_CACHE_CHECK([if libstatgrab >= 0.90],
5183     [c_cv_have_libstatgrab_0_90],
5184     [
5185       AC_LINK_IFELSE(
5186         [
5187           AC_LANG_PROGRAM(
5188             [[
5189               #include <stdio.h>
5190               #include <statgrab.h>
5191             ]],
5192             [[
5193               if (sg_init()) return 0;
5194             ]]
5195           )
5196         ],
5197         [c_cv_have_libstatgrab_0_90="no"],
5198         [c_cv_have_libstatgrab_0_90="yes"]
5199       )
5200     ]
5201   )
5202
5203   CFLAGS="$SAVE_CFLAGS"
5204   LDFLAGS="$SAVE_LDFLAGS"
5205   LIBS="$SAVE_LIBS"
5206 fi
5207
5208 AM_CONDITIONAL([BUILD_WITH_LIBSTATGRAB], [test "x$with_libstatgrab" = "xyes"])
5209
5210 if test "x$with_libstatgrab" = "xyes"; then
5211   AC_DEFINE([HAVE_LIBSTATGRAB], [1],
5212     [Define to 1 if you have the 'statgrab' library (-lstatgrab)]
5213   )
5214
5215   if test "x$c_cv_have_libstatgrab_0_90" = "xyes"; then
5216     AC_DEFINE([HAVE_LIBSTATGRAB_0_90], [1],
5217       [Define to 1 if libstatgrab version >= 0.90]
5218     )
5219   fi
5220
5221   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
5222   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
5223
5224 fi
5225
5226 AC_SUBST([BUILD_WITH_LIBSTATGRAB_CFLAGS])
5227 AC_SUBST([BUILD_WITH_LIBSTATGRAB_LDFLAGS])
5228 # }}}
5229
5230 # --with-libtokyotyrant {{{
5231 AC_ARG_WITH([libtokyotyrant],
5232   [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
5233   [
5234     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5235       with_libtokyotyrant="$withval"
5236     else
5237       with_libtokyotyrant_cppflags="-I$withval/include"
5238       with_libtokyotyrant_ldflags="-L$withval/include"
5239       with_libtokyotyrant_libs="-ltokyotyrant"
5240       with_libtokyotyrant="yes"
5241     fi
5242   ],
5243   [with_libtokyotyrant="yes"]
5244 )
5245
5246 if test "x$with_libtokyotyrant" = "xyes"; then
5247   if $PKG_CONFIG --exists tokyotyrant; then
5248     with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
5249     with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `$PKG_CONFIG --libs-only-L tokyotyrant`"
5250     with_libtokyotyrant_libs="$with_libtokyotyrant_libs `$PKG_CONFIG --libs-only-l tokyotyrant`"
5251   fi
5252 fi
5253
5254 if test "x$with_libtokyotyrant" = "xyes"; then
5255   SAVE_CPPFLAGS="$CPPFLAGS"
5256   CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
5257
5258   AC_CHECK_HEADERS([tcrdb.h],
5259     [with_libtokyotyrant="yes"],
5260     [with_libtokyotyrant="no (tcrdb.h not found)"]
5261   )
5262
5263   CPPFLAGS="$SAVE_CPPFLAGS"
5264 fi
5265
5266 if test "x$with_libtokyotyrant" = "xyes"; then
5267   SAVE_LDFLAGS="$LDFLAGS"
5268   LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
5269
5270   AC_CHECK_LIB([tokyotyrant], [tcrdbrnum],
5271     [with_libtokyotyrant="yes"],
5272     [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
5273     [$with_libtokyotyrant_libs]
5274   )
5275
5276   LDFLAGS="$SAVE_LDFLAGS"
5277 fi
5278
5279 if test "x$with_libtokyotyrant" = "xyes"; then
5280   BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
5281   BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
5282   BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
5283 fi
5284 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS])
5285 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS])
5286 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_LIBS])
5287 # }}}
5288
5289 # --with-libudev {{{
5290 AC_ARG_WITH([libudev],
5291   [AS_HELP_STRING([--with-libudev@<:@=PREFIX@:>@], [Path to libudev.])],
5292   [
5293     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5294       with_libudev="$withval"
5295     else
5296       with_libudev_cppflags="-I$withval/include"
5297       with_libudev_ldflags="-L$withval/lib"
5298       with_libudev="yes"
5299     fi
5300   ],
5301   [
5302     if test "x$ac_system" = "xLinux"; then
5303       with_libudev="yes"
5304     else
5305       with_libudev="no (Linux only library)"
5306     fi
5307   ]
5308 )
5309
5310 if test "x$with_libudev" = "xyes"; then
5311   SAVE_CPPFLAGS="$CPPFLAGS"
5312   CPPFLAGS="$CPPFLAGS $with_libudev_cppflags"
5313
5314   AC_CHECK_HEADERS([libudev.h],
5315     [with_libudev="yes"],
5316     [with_libudev="no (libudev.h not found)"]
5317   )
5318
5319   CPPFLAGS="$SAVE_CPPFLAGS"
5320 fi
5321
5322 if test "x$with_libudev" = "xyes"; then
5323   SAVE_LDFLAGS="$LDFLAGS"
5324   LDFLAGS="$LDFLAGS $with_libudev_ldflags"
5325
5326   AC_CHECK_LIB([udev], [udev_new],
5327     [with_libudev="yes"],
5328     [with_libudev="no (libudev not found)"]
5329   )
5330
5331   LDFLAGS="$SAVE_LDFLAGS"
5332 fi
5333
5334 if test "x$with_libudev" = "xyes"; then
5335   BUILD_WITH_LIBUDEV_CPPFLAGS="$with_libudev_cppflags"
5336   BUILD_WITH_LIBUDEV_LDFLAGS="$with_libudev_ldflags"
5337   BUILD_WITH_LIBUDEV_LIBS="-ludev"
5338 fi
5339
5340 AC_SUBST([BUILD_WITH_LIBUDEV_CPPFLAGS])
5341 AC_SUBST([BUILD_WITH_LIBUDEV_LDFLAGS])
5342 AC_SUBST([BUILD_WITH_LIBUDEV_LIBS])
5343
5344 AM_CONDITIONAL([BUILD_WITH_LIBUDEV], [test "x$with_libudev" = "xyes"])
5345 # }}}
5346
5347 # --with-libupsclient {{{
5348 with_libupsclient_config=""
5349 AC_ARG_WITH([libupsclient],
5350   [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
5351   [
5352     if test "x$withval" = "xno"; then
5353       with_libupsclient="no"
5354     else if test "x$withval" = "xyes"; then
5355       with_libupsclient="use_pkgconfig"
5356     else
5357       if test -x "$withval"; then
5358         with_libupsclient_config="$withval"
5359         with_libupsclient="use_libupsclient_config"
5360       else if test -x "$withval/bin/libupsclient-config"; then
5361         with_libupsclient_config="$withval/bin/libupsclient-config"
5362         with_libupsclient="use_libupsclient_config"
5363       else
5364         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
5365         with_libupsclient_cflags="-I$withval/include"
5366         with_libupsclient_libs="-L$withval/lib -lupsclient"
5367         with_libupsclient="yes"
5368       fi; fi
5369     fi; fi
5370   ],
5371   [with_libupsclient="use_pkgconfig"]
5372 )
5373
5374 # configure using libupsclient-config
5375 if test "x$with_libupsclient" = "xuse_libupsclient_config"; then
5376   with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
5377   if test $? -ne 0; then
5378     with_libupsclient="no ($with_libupsclient_config failed)"
5379   fi
5380   with_libupsclient_libs="`$with_libupsclient_config --libs`"
5381   if test $? -ne 0; then
5382     with_libupsclient="no ($with_libupsclient_config failed)"
5383   fi
5384 fi
5385
5386 if test "x$with_libupsclient" = "xuse_libupsclient_config"; then
5387   with_libupsclient="yes"
5388 fi
5389
5390 # configure using pkg-config
5391 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5392   AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
5393   $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
5394   if test $? -ne 0; then
5395     with_libupsclient="no (pkg-config doesn't know libupsclient)"
5396   fi
5397 fi
5398
5399 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5400   with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
5401   if test $? -ne 0; then
5402     with_libupsclient="no ($PKG_CONFIG failed)"
5403   fi
5404
5405   with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
5406   if test $? -ne 0; then
5407     with_libupsclient="no ($PKG_CONFIG failed)"
5408   fi
5409 fi
5410
5411 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5412   with_libupsclient="yes"
5413 fi
5414
5415 if test "x$with_libupsclient" = "xyes"; then
5416   SAVE_CPPFLAGS="$CPPFLAGS"
5417   CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5418
5419   AC_CHECK_HEADERS([upsclient.h],
5420     [with_libupsclient="yes"],
5421     [with_libupsclient="no (upsclient.h not found)"]
5422   )
5423
5424   CPPFLAGS="$SAVE_CPPFLAGS"
5425 fi
5426
5427 if test "x$with_libupsclient" = "xyes"; then
5428   SAVE_LDFLAGS="$LDFLAGS"
5429   LDFLAGS="$LDFLAGS $with_libupsclient_libs"
5430
5431   AC_CHECK_LIB([upsclient], [upscli_connect],
5432     [with_libupsclient="yes"],
5433     [with_libupsclient="no (symbol upscli_connect not found)"]
5434   )
5435
5436   AC_CHECK_LIB([upsclient], [upscli_init],
5437     [AC_DEFINE([HAVE_UPSCLI_INIT], [1], [Define when upscli_init() (since version 2-7) is available.])]
5438   )
5439
5440   AC_CHECK_LIB([upsclient], [upscli_tryconnect],
5441     [AC_DEFINE([HAVE_UPSCLI_TRYCONNECT], [1], [Define when upscli_tryconnect() (since version 2.6.2) is available.])]
5442   )
5443
5444   LDFLAGS="$SAVE_LDFLAGS"
5445 fi
5446
5447 if test "x$with_libupsclient" = "xyes"; then
5448   SAVE_CPPFLAGS="$CPPFLAGS"
5449   CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5450
5451   AC_CHECK_TYPES([UPSCONN_t, UPSCONN],
5452     [],
5453     [],
5454     [[
5455       #include <stdlib.h>
5456       #include <stdio.h>
5457       #include <upsclient.h>
5458     ]]
5459   )
5460
5461   CPPFLAGS="$SAVE_CPPFLAGS"
5462 fi
5463
5464 if test "x$with_libupsclient" = "xyes"; then
5465   BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
5466   BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
5467 fi
5468
5469 AC_SUBST([BUILD_WITH_LIBUPSCLIENT_CFLAGS])
5470 AC_SUBST([BUILD_WITH_LIBUPSCLIENT_LIBS])
5471 # }}}
5472
5473 # --with-libxenctrl {{{
5474 AC_ARG_WITH([libxenctrl],
5475   [AS_HELP_STRING([--with-libxenctrl@<:@=PREFIX@:>@], [Path to libxenctrl.])],
5476   [
5477     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5478       with_libxenctrl_cppflags="-I$withval/include"
5479       with_libxenctrl_ldflags="-L$withval/lib"
5480       with_libxenctrl="yes"
5481     else
5482       with_libxenctrl="$withval"
5483     fi
5484   ],
5485   [with_libxenctrl="yes"]
5486 )
5487
5488 if test "x$with_libxenctrl" = "xyes"; then
5489   SAVE_CPPFLAGS="$CPPFLAGS"
5490   CPPFLAGS="$CPPFLAGS $with_libxenctrl_cppflags"
5491
5492   AC_CHECK_HEADERS([xenctrl.h],
5493     [with_libxenctrl="yes"],
5494     [with_libxenctrl="no (xenctrl.h not found)"]
5495   )
5496
5497   CPPFLAGS="$SAVE_CPPFLAGS"
5498 fi
5499
5500 if test "x$with_libxenctrl" = "xyes"; then
5501   SAVE_LDFLAGS="$LDFLAGS"
5502   LDFLAGS="$LDFLAGS $with_libxenctrl_ldflags"
5503
5504   #Xen versions older than 3.4 has no xc_getcpuinfo()
5505   AC_CHECK_LIB([xenctrl], [xc_getcpuinfo],
5506     [with_libxenctrl="yes"],
5507     [with_libxenctrl="no (symbol 'xc_getcpuinfo' not found)"]
5508   )
5509
5510   LDFLAGS="$SAVE_LDFLAGS"
5511 fi
5512
5513 LIBXENCTL_CPPFLAGS="$with_libxenctl_cppflags"
5514 LIBXENCTL_LDFLAGS="$with_libxenctl_ldflags"
5515 AC_SUBST([LIBXENCTL_CPPFLAGS])
5516 AC_SUBST([LIBXENCTL_LDFLAGS])
5517 # }}}
5518
5519 # --with-libxmms {{{
5520 with_xmms_config="xmms-config"
5521 AC_ARG_WITH([libxmms],
5522   [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
5523   [
5524     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5525       with_libxmms="$withval"
5526     else
5527       if test -f "$withval" && test -x "$withval"; then
5528         with_xmms_config="$withval"
5529       else if test -x "$withval/bin/xmms-config"; then
5530         with_xmms_config="$withval/bin/xmms-config"
5531       fi; fi
5532       with_libxmms="yes"
5533     fi
5534   ],
5535   [with_libxmms="yes"]
5536 )
5537
5538 if test "x$with_libxmms" = "xyes"; then
5539   with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
5540   if test $? -ne 0; then
5541     with_libxmms="no"
5542   fi
5543 fi
5544
5545 if test "x$with_libxmms" = "xyes"; then
5546   with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
5547   if test $? -ne 0; then
5548     with_libxmms="no"
5549   fi
5550 fi
5551
5552 if test "x$with_libxmms" = "xyes"; then
5553   SAVE_CFLAGS="$CFLAGS"
5554   CFLAGS="$with_xmms_cflags"
5555
5556   AC_CHECK_HEADER([xmmsctrl.h],
5557     [with_libxmms="yes"],
5558     [with_libxmms="no"],
5559   )
5560
5561   CFLAGS="$SAVE_CFLAGS"
5562 fi
5563
5564 if test "x$with_libxmms" = "xyes"; then
5565   SAVE_LIBS="$LIBS"
5566   LIBS="$with_xmms_libs"
5567
5568   AC_CHECK_LIB([xmms], [xmms_remote_get_info],
5569     [with_libxmss="yes"],
5570     [with_libxmms="no"],
5571     [$with_xmms_libs]
5572
5573   )
5574
5575   LIBS="$SAVE_LIBS"
5576 fi
5577
5578 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
5579 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
5580
5581 AC_SUBST([BUILD_WITH_LIBXMMS_CFLAGS])
5582 AC_SUBST([BUILD_WITH_LIBXMMS_LIBS])
5583 # }}}
5584
5585 # --with-libyajl {{{
5586 AC_ARG_WITH([libyajl],
5587   [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
5588   [
5589     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5590       with_libyajl_cppflags="-I$withval/include"
5591       with_libyajl_ldflags="-L$withval/lib"
5592       with_libyajl="yes"
5593     else
5594       with_libyajl="$withval"
5595     fi
5596   ],
5597   [with_libyajl="yes"]
5598 )
5599
5600 if test "x$with_libyajl" = "xyes"; then
5601   SAVE_CPPFLAGS="$CPPFLAGS"
5602   CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
5603
5604   AC_CHECK_HEADERS([yajl/yajl_parse.h],
5605     [with_libyajl="yes"],
5606     [with_libyajl="no (yajl/yajl_parse.h not found)"]
5607   )
5608
5609   AC_CHECK_HEADERS([yajl/yajl_tree.h],
5610     [with_libyajl2="yes"],
5611     [with_libyajl2="no (yajl/yajl_tree.h not found)"]
5612   )
5613
5614   AC_CHECK_HEADERS([yajl/yajl_version.h])
5615
5616   CPPFLAGS="$SAVE_CPPFLAGS"
5617 fi
5618
5619 if test "x$with_libyajl" = "xyes"; then
5620   SAVE_LDFLAGS="$LDFLAGS"
5621   LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
5622
5623   AC_CHECK_LIB([yajl], [yajl_alloc],
5624     [with_libyajl="yes"],
5625     [with_libyajl="no (Symbol 'yajl_alloc' not found)"]
5626   )
5627
5628   AC_CHECK_LIB([yajl], [yajl_tree_parse],
5629     [with_libyajl2="yes"],
5630     [with_libyajl2="no (Symbol 'yajl_tree_parse' not found)"]
5631   )
5632
5633   LDFLAGS="$SAVE_LDFLAGS"
5634 fi
5635
5636 if test "x$with_libyajl" = "xyes"; then
5637   BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
5638   BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
5639   BUILD_WITH_LIBYAJL_LIBS="-lyajl"
5640   AC_DEFINE([HAVE_LIBYAJL], [1], [Define if libyajl is present and usable.])
5641 fi
5642
5643 AC_SUBST([BUILD_WITH_LIBYAJL_CPPFLAGS])
5644 AC_SUBST([BUILD_WITH_LIBYAJL_LDFLAGS])
5645 AC_SUBST([BUILD_WITH_LIBYAJL_LIBS])
5646
5647 AM_CONDITIONAL([BUILD_WITH_LIBYAJL], [test "x$with_libyajl" = "xyes"])
5648 # }}}
5649
5650 # --with-mic {{{
5651 with_mic_cppflags="-I/opt/intel/mic/sysmgmt/sdk/include"
5652 with_mic_ldflags="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
5653 with_mic_libs="-lMicAccessSDK -scif"
5654 AC_ARG_WITH([mic],
5655   [AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
5656   [
5657     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5658       with_mic="$withval"
5659     else if test -d "$with_mic/lib"; then
5660       with_mic_cppflags="-I$withval/include"
5661       with_mic_ldflags="-L$withval/lib/Linux"
5662       with_mic="yes"
5663     fi; fi
5664   ],
5665   [with_mic="yes"]
5666 )
5667
5668 if test "x$with_mic" = "xyes"; then
5669   SAVE_CPPFLAGS="$CPPFLAGS"
5670   CPPFLAGS="$CPPFLAGS $with_mic_cppflags"
5671
5672   AC_CHECK_HEADERS([MicAccessApi.h],
5673     [with_mic="yes"],
5674     [with_mic="no (MicAccessApi not found)"]
5675   )
5676
5677   CPPFLAGS="$SAVE_CPPFLAGS"
5678 fi
5679
5680 if test "x$with_mic" = "xyes"; then
5681   SAVE_LDFLAGS="$LDFLAGS"
5682   LDFLAGS="$LDFLAGS $with_mic_ldflags"
5683
5684   AC_CHECK_LIB([MicAccessSDK], [MicInitAPI],
5685     [with_mic="yes"],
5686     [with_mic="no (symbol MicInitAPI not found)"],
5687     [$PTHREAD_LIBS -lscif]
5688   )
5689
5690   LDFLAGS="$SAVE_LDFLAGS"
5691 fi
5692
5693 if test "x$with_mic" = "xyes"; then
5694   BUILD_WITH_MIC_CPPFLAGS="$with_mic_cppflags"
5695   BUILD_WITH_MIC_LDFLAGS="$with_mic_ldflags"
5696   BUILD_WITH_MIC_LIBS="$with_mic_libs"
5697 fi
5698 AC_SUBST([BUILD_WITH_MIC_CPPFLAGS])
5699 AC_SUBST([BUILD_WITH_MIC_LDFLAGS])
5700 AC_SUBST([BUILD_WITH_MIC_LIBS])
5701 #}}}
5702
5703 # --with-libvarnish {{{
5704 AC_ARG_WITH([libvarnish],
5705   [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
5706   [
5707     if test "x$withval" = "xno"; then
5708       with_libvarnish="no"
5709     else if test "x$withval" = "xyes"; then
5710       with_libvarnish="use_pkgconfig"
5711     else if test -d "$with_libvarnish/lib"; then
5712       with_libvarnish_cflags="-I$withval/include"
5713       with_libvarnish_libs="-L$withval/lib -lvarnishapi"
5714       with_libvarnish="yes"
5715     fi; fi; fi
5716   ],
5717   [with_libvarnish="use_pkgconfig"]
5718 )
5719
5720 # configure using pkg-config
5721 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5722   $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
5723   if test $? -ne 0; then
5724     with_libvarnish="no (pkg-config doesn't know varnishapi)"
5725   fi
5726 fi
5727
5728 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5729   with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
5730   if test $? -ne 0; then
5731     with_libvarnish="no ($PKG_CONFIG failed)"
5732   fi
5733
5734   with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
5735   if test $? -ne 0; then
5736     with_libvarnish="no ($PKG_CONFIG failed)"
5737   fi
5738 fi
5739 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5740   with_libvarnish="yes"
5741 fi
5742
5743 if test "x$with_libvarnish" = "xyes"; then
5744   SAVE_CPPFLAGS="$CPPFLAGS"
5745   CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
5746
5747   AC_CHECK_HEADERS([vapi/vsc.h],
5748     [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
5749     [
5750       AC_CHECK_HEADERS([vsc.h],
5751         [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support]) ],
5752         [
5753           AC_CHECK_HEADERS([varnishapi.h],
5754             [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
5755             [with_libvarnish="no (found none of the varnish header files)"]
5756           )
5757         ]
5758       )
5759     ]
5760   )
5761
5762   CPPFLAGS="$SAVE_CPPFLAGS"
5763 fi
5764
5765 if test "x$with_libvarnish" = "xyes"; then
5766   BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
5767   BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
5768 fi
5769
5770 AC_SUBST([BUILD_WITH_LIBVARNISH_CFLAGS])
5771 AC_SUBST([BUILD_WITH_LIBVARNISH_LIBS])
5772 # }}}
5773
5774 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
5775 $PKG_CONFIG --exists 'libxml-2.0' 2>/dev/null
5776 if test $? -eq 0; then
5777   with_libxml2="yes"
5778 else
5779   with_libxml2="no (pkg-config doesn't know libxml-2.0)"
5780 fi
5781
5782 $PKG_CONFIG --exists libvirt 2>/dev/null
5783 if test $? = 0; then
5784   with_libvirt="yes"
5785 else
5786   with_libvirt="no (pkg-config doesn't know libvirt)"
5787 fi
5788
5789 if test "x$with_libxml2" = "xyes"; then
5790   with_libxml2_cflags="`$PKG_CONFIG --cflags libxml-2.0`"
5791   if test $? -ne 0; then
5792     with_libxml2="no"
5793   fi
5794
5795   with_libxml2_ldflags="`$PKG_CONFIG --libs libxml-2.0`"
5796   if test $? -ne 0; then
5797     with_libxml2="no"
5798   fi
5799 fi
5800
5801 if test "x$with_libxml2" = "xyes"; then
5802   SAVE_CPPFLAGS="$CPPFLAGS"
5803   CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
5804
5805   AC_CHECK_HEADERS([libxml/parser.h],
5806     [with_libxml2="yes"],
5807     [with_libxml2="no (libxml/parser.h not found)"]
5808   )
5809
5810   CPPFLAGS="$SAVE_CPPFLAGS"
5811 fi
5812
5813 if test "x$with_libxml2" = "xyes"; then
5814   SAVE_LDFLAGS="$LDFLAGS"
5815   LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
5816
5817   AC_CHECK_LIB([xml2], [xmlXPathEval],
5818     [with_libxml2="yes"],
5819     [with_libxml2="no (symbol xmlXPathEval not found)"]
5820   )
5821
5822   LDFLAGS="$SAVE_LDFLAGS"
5823 fi
5824
5825 if test "x$with_libxml2" = "xyes"; then
5826   BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
5827   BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
5828 fi
5829
5830 AC_SUBST([BUILD_WITH_LIBXML2_CFLAGS])
5831 AC_SUBST([BUILD_WITH_LIBXML2_LIBS])
5832
5833 if test "x$with_libvirt" = "xyes"; then
5834   with_libvirt_cflags="`$PKG_CONFIG --cflags libvirt`"
5835   if test $? -ne 0; then
5836     with_libvirt="no"
5837   fi
5838
5839   with_libvirt_ldflags="`$PKG_CONFIG --libs libvirt`"
5840   if test $? -ne 0; then
5841     with_libvirt="no"
5842   fi
5843 fi
5844
5845 if test "x$with_libvirt" = "xyes"; then
5846   SAVE_CPPFLAGS="$CPPFLAGS"
5847   CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
5848
5849   AC_CHECK_HEADERS([libvirt/libvirt.h],
5850     [with_libvirt="yes"],
5851     [with_libvirt="no (libvirt/libvirt.h not found)"]
5852   )
5853
5854   CPPFLAGS="$SAVE_CPPFLAGS"
5855 fi
5856
5857 if test "x$with_libvirt" = "xyes"; then
5858   SAVE_LDFLAGS="$LDFLAGS"
5859   LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
5860
5861   AC_CHECK_LIB([virt], [virDomainBlockStats],
5862     [with_libvirt="yes"],
5863     [with_libvirt="no (symbol virDomainBlockStats not found)"]
5864   )
5865
5866   LDFLAGS="$SAVE_LDFLAGS"
5867 fi
5868
5869 if test "x$with_libvirt" = "xyes"; then
5870   BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
5871   BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
5872 fi
5873
5874 AC_SUBST([BUILD_WITH_LIBVIRT_CFLAGS])
5875 AC_SUBST([BUILD_WITH_LIBVIRT_LIBS])
5876 # }}}
5877
5878 # $PKG_CONFIG --exists OpenIPMIpthread {{{
5879 with_libopenipmipthread="yes"
5880 AC_MSG_CHECKING([for libOpenIPMIpthread])
5881 $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
5882 if test $? -ne 0; then
5883   with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
5884 fi
5885 AC_MSG_RESULT([$with_libopenipmipthread])
5886
5887 if test "x$with_libopenipmipthread" = "xyes"; then
5888   AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
5889   temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
5890   if test $? -eq 0; then
5891     with_libopenipmipthread_cflags="$temp_result"
5892   else
5893     with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
5894     temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
5895   fi
5896   AC_MSG_RESULT([$temp_result])
5897 fi
5898
5899 if test "x$with_libopenipmipthread" = "xyes"; then
5900   AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
5901   temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
5902   if test $? -eq 0; then
5903     with_libopenipmipthread_ldflags="$temp_result"
5904   else
5905     with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
5906     temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
5907   fi
5908   AC_MSG_RESULT([$temp_result])
5909 fi
5910
5911 if test "x$with_libopenipmipthread" = "xyes"; then
5912   SAVE_CPPFLAGS="$CPPFLAGS"
5913   CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
5914
5915   AC_CHECK_HEADERS([OpenIPMI/ipmi_smi.h],
5916     [with_libopenipmipthread="yes"],
5917     [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
5918     [[
5919       #include <OpenIPMI/ipmiif.h>
5920       #include <OpenIPMI/ipmi_err.h>
5921       #include <OpenIPMI/ipmi_posix.h>
5922       #include <OpenIPMI/ipmi_conn.h>
5923     ]]
5924   )
5925
5926   CPPFLAGS="$SAVE_CPPFLAGS"
5927 fi
5928
5929 if test "x$with_libopenipmipthread" = "xyes"; then
5930   BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
5931   BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
5932 fi
5933
5934 AC_SUBST([BUILD_WITH_OPENIPMI_CFLAGS])
5935 AC_SUBST([BUILD_WITH_OPENIPMI_LIBS])
5936 # }}}
5937
5938 # --with-libatasmart {{{
5939 AC_ARG_WITH([libatasmart],
5940   [AS_HELP_STRING([--with-libatasmart@<:@=PREFIX@:>@], [Path to libatasmart.])],
5941   [
5942     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5943       with_libatasmart_cppflags="-I$withval/include"
5944       with_libatasmart_ldflags="-L$withval/lib"
5945       with_libatasmart="yes"
5946     else
5947       with_libatasmart="$withval"
5948     fi
5949   ],
5950   [
5951     if test "x$ac_system" = "xLinux"; then
5952       with_libatasmart="yes"
5953     else
5954       with_libatasmart="no (Linux only library)"
5955     fi
5956   ]
5957 )
5958
5959 if test "x$with_libatasmart" = "xyes"; then
5960   SAVE_CPPFLAGS="$CPPFLAGS"
5961   CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
5962
5963   AC_CHECK_HEADERS([atasmart.h],
5964     [with_libatasmart="yes"],
5965     [with_libatasmart="no (atasmart.h not found)"])
5966
5967   CPPFLAGS="$SAVE_CPPFLAGS"
5968 fi
5969
5970 if test "x$with_libatasmart" = "xyes"; then
5971   SAVE_LDFLAGS="$LDFLAGS"
5972   LDFLAGS="$LDFLAGS $with_libatasmart_ldflags"
5973
5974   AC_CHECK_LIB([atasmart], [sk_disk_open],
5975     [with_libatasmart="yes"],
5976     [with_libatasmart="no (Symbol 'sk_disk_open' not found)"]
5977   )
5978
5979   LDFLAGS="$SAVE_LDFLAGS"
5980 fi
5981
5982 if test "x$with_libatasmart" = "xyes"; then
5983   BUILD_WITH_LIBATASMART_CPPFLAGS="$with_libatasmart_cppflags"
5984   BUILD_WITH_LIBATASMART_LDFLAGS="$with_libatasmart_ldflags"
5985   BUILD_WITH_LIBATASMART_LIBS="-latasmart"
5986 fi
5987
5988 AC_SUBST([BUILD_WITH_LIBATASMART_CPPFLAGS])
5989 AC_SUBST([BUILD_WITH_LIBATASMART_LDFLAGS])
5990 AC_SUBST([BUILD_WITH_LIBATASMART_LIBS])
5991 # }}}
5992
5993 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
5994   [with_libnotify="yes"],
5995   [with_libnotify="no (pkg-config doesn't know libnotify)"]
5996 )
5997
5998 PKG_CHECK_MODULES([LIBRIEMANN_CLIENT], [riemann-client >= 1.6.0],
5999  [with_libriemann_client="yes"],
6000  [with_libriemann_client="no (pkg-config doesn't know libriemann-client)"]
6001 )
6002
6003 # Check for enabled/disabled features
6004 #
6005
6006 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
6007 # ------------------------------------------------------------
6008 dnl
6009 m4_define([my_toupper],[m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
6010 dnl
6011 AC_DEFUN(
6012   [AC_COLLECTD],
6013   [
6014   m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
6015   m4_if(
6016     [$2],
6017     [enable],
6018     [dnl
6019     m4_define([EnDis],[disabled])dnl
6020     m4_define([YesNo],[no])dnl
6021     ],dnl
6022     [m4_if(
6023       [$2],
6024       [disable],
6025       [dnl
6026       m4_define([EnDis],[enabled])dnl
6027       m4_define([YesNo],[yes])dnl
6028       ],
6029       [dnl
6030       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
6031       ]dnl
6032     )]dnl
6033   )dnl
6034   m4_if([$3], [feature], [],
6035     [m4_if(
6036       [$3], [module], [],
6037       [dnl
6038       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
6039       ]dnl
6040     )]dnl
6041   )dnl
6042   AC_ARG_ENABLE(
6043     [$1],
6044     AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
6045     [],
6046     enable_$1='[YesNo]'dnl
6047   )# AC_ARG_ENABLE
6048   if test "x$enable_$1" = "xno"; then
6049     collectd_$1=0
6050   else
6051     if test "x$enable_$1" = "xyes"; then
6052       collectd_$1=1
6053     else
6054       AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
6055       collectd_$1=1
6056       enable_$1='yes'
6057     fi
6058   fi
6059   AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [whether or not to enable $3 $4])
6060   AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
6061   ]dnl
6062 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
6063
6064 # AC_PLUGIN(name, default, info)
6065 # ------------------------------------------------------------
6066 dnl
6067 AC_DEFUN(
6068   [AC_PLUGIN],
6069   [
6070     enable_plugin="no"
6071     force="no"
6072     AC_ARG_ENABLE([$1],
6073       [AS_HELP_STRING([--enable-$1],[$3])],
6074       [
6075         if test "x$enableval" = "xyes"; then
6076           enable_plugin="yes"
6077         else if test "x$enableval" = "xforce"; then
6078           enable_plugin="yes"
6079           force="yes"
6080         else
6081           enable_plugin="no (disabled on command line)"
6082         fi; fi
6083       ],
6084       [
6085         if test "x$enable_all_plugins" = "xauto"; then
6086           if test "x$2" = "xyes"; then
6087             enable_plugin="yes"
6088           else
6089             enable_plugin="$2"
6090           fi
6091         else
6092           enable_plugin="$enable_all_plugins"
6093         fi
6094       ]
6095     )
6096     if test "x$enable_plugin" = "xyes"; then
6097       if test "x$2" = "xyes" || test "x$force" = "xyes"; then
6098         AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
6099         if test "x$2" != "xyes"; then
6100           dependency_warning="yes"
6101         fi
6102       else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
6103         dependency_error="yes"
6104         enable_plugin="$2 (dependency error)"
6105       fi
6106     fi
6107     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), [test "x$enable_plugin" = "xyes"])
6108     enable_$1="$enable_plugin"
6109   ]
6110 )# AC_PLUGIN(name, default, info)
6111
6112 m4_divert_once([HELP_ENABLE], [
6113 collectd features:])
6114 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
6115 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
6116 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
6117 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
6118 AC_COLLECTD([werror],    [disable], [feature], [building with -Werror])
6119
6120 dependency_warning="no"
6121 dependency_error="no"
6122
6123 plugin_ascent="no"
6124 plugin_barometer="no"
6125 plugin_battery="no"
6126 plugin_bind="no"
6127 plugin_ceph="no"
6128 plugin_cgroups="no"
6129 plugin_conntrack="no"
6130 plugin_contextswitch="no"
6131 plugin_cpu="no"
6132 plugin_cpufreq="no"
6133 plugin_cpusleep="no"
6134 plugin_curl_json="no"
6135 plugin_curl_xml="no"
6136 plugin_df="no"
6137 plugin_disk="no"
6138 plugin_drbd="no"
6139 plugin_dpdkevents="no"
6140 plugin_dpdkstat="no"
6141 plugin_entropy="no"
6142 plugin_ethstat="no"
6143 plugin_fhcount="no"
6144 plugin_fscache="no"
6145 plugin_gps="no"
6146 plugin_grpc="no"
6147 plugin_hugepages="no"
6148 plugin_intel_pmu="no"
6149 plugin_intel_rdt="no"
6150 plugin_interface="no"
6151 plugin_ipc="no"
6152 plugin_ipmi="no"
6153 plugin_ipvs="no"
6154 plugin_irq="no"
6155 plugin_load="no"
6156 plugin_log_logstash="no"
6157 plugin_mcelog="no"
6158 plugin_memory="no"
6159 plugin_multimeter="no"
6160 plugin_nfs="no"
6161 plugin_numa="no"
6162 plugin_ovs_events="no"
6163 plugin_ovs_stats="no"
6164 plugin_perl="no"
6165 plugin_pinba="no"
6166 plugin_processes="no"
6167 plugin_protocols="no"
6168 plugin_python="no"
6169 plugin_serial="no"
6170 plugin_smart="no"
6171 plugin_swap="no"
6172 plugin_synproxy="no"
6173 plugin_tape="no"
6174 plugin_tcpconns="no"
6175 plugin_ted="no"
6176 plugin_thermal="no"
6177 plugin_turbostat="no"
6178 plugin_uptime="no"
6179 plugin_users="no"
6180 plugin_virt="no"
6181 plugin_vmem="no"
6182 plugin_vserver="no"
6183 plugin_wireless="no"
6184 plugin_write_prometheus="no"
6185 plugin_xencpu="no"
6186 plugin_zfs_arc="no"
6187 plugin_zone="no"
6188 plugin_zookeeper="no"
6189
6190 # Linux
6191 if test "x$ac_system" = "xLinux"; then
6192   plugin_battery="yes"
6193   plugin_cgroups="yes"
6194   plugin_conntrack="yes"
6195   plugin_contextswitch="yes"
6196   plugin_cpu="yes"
6197   plugin_cpufreq="yes"
6198   plugin_disk="yes"
6199   plugin_drbd="yes"
6200   plugin_entropy="yes"
6201   plugin_fhcount="yes"
6202   plugin_fscache="yes"
6203   plugin_hugepages="yes"
6204   plugin_interface="yes"
6205   plugin_ipc="yes"
6206   plugin_irq="yes"
6207   plugin_load="yes"
6208   plugin_lvm="yes"
6209   plugin_mcelog="yes"
6210   plugin_memory="yes"
6211   plugin_nfs="yes"
6212   plugin_numa="yes"
6213   plugin_processes="yes"
6214   plugin_protocols="yes"
6215   plugin_serial="yes"
6216   plugin_swap="yes"
6217   plugin_synproxy="yes"
6218   plugin_tcpconns="yes"
6219   plugin_thermal="yes"
6220   plugin_uptime="yes"
6221   plugin_vmem="yes"
6222   plugin_vserver="yes"
6223   plugin_wireless="yes"
6224   plugin_zfs_arc="yes"
6225
6226   if test "x$ac_cv_header_linux_ip_vs_h" = "xyes"; then
6227     plugin_ipvs="yes"
6228   fi
6229
6230   if test "x$c_cv_have_usable_asm_msrindex_h" = "xyes" && test "x$have_cpuid_h" = "xyes"; then
6231     plugin_turbostat="yes"
6232   fi
6233
6234   if test "x$c_cv_have_clock_boottime_monotonic" = "xyes"; then
6235     plugin_cpusleep="yes"
6236   fi
6237
6238   if test "x$with_libyajl" = "xyes" && test "x$with_libyajl2" = "xyes"; then
6239     plugin_ovs_events="yes"
6240     plugin_ovs_stats="yes"
6241   fi
6242 fi
6243
6244 if test "x$ac_system" = "xOpenBSD"; then
6245   plugin_tcpconns="yes"
6246 fi
6247
6248 if test "x$ac_system" = "xNetBSD"; then
6249   plugin_disk="yes"
6250   plugin_entropy="yes"
6251   plugin_irq="yes"
6252   plugin_processes="yes"
6253 fi
6254
6255 # Mac OS X devices
6256 if test "x$with_libiokit" = "xyes"; then
6257   plugin_battery="yes"
6258   plugin_disk="yes"
6259 fi
6260
6261 # AIX
6262
6263 if test "x$ac_system" = "xAIX"; then
6264   plugin_ipc="yes"
6265   plugin_tcpconns="yes"
6266 fi
6267
6268 # FreeBSD
6269
6270 if test "x$ac_system" = "xFreeBSD"; then
6271   plugin_disk="yes"
6272   plugin_zfs_arc="yes"
6273 fi
6274
6275
6276 if test "x$with_perfstat" = "xyes"; then
6277   plugin_contextswitch="yes"
6278   plugin_cpu="yes"
6279   plugin_disk="yes"
6280   plugin_interface="yes"
6281   plugin_load="yes"
6282   plugin_memory="yes"
6283   plugin_swap="yes"
6284   plugin_uptime="yes"
6285 fi
6286
6287 if test "x$with_procinfo" = "xyes"; then
6288   plugin_processes="yes"
6289 fi
6290
6291 # Solaris
6292 if test "x$with_kstat" = "xyes"; then
6293   plugin_nfs="yes"
6294   plugin_processes="yes"
6295   plugin_uptime="yes"
6296   plugin_zfs_arc="yes"
6297   plugin_zone="yes"
6298 fi
6299
6300 if test "x$with_devinfo" = "xyes" && test "x$with_kstat" = "xyes"; then
6301   plugin_cpu="yes"
6302   plugin_disk="yes"
6303   plugin_interface="yes"
6304   plugin_memory="yes"
6305   plugin_tape="yes"
6306 fi
6307
6308 if test "x$with_libi2c" = "xyes"; then
6309   plugin_barometer="yes"
6310 fi
6311
6312
6313 # libstatgrab
6314 if test "x$with_libstatgrab" = "xyes"; then
6315   plugin_cpu="yes"
6316   plugin_disk="yes"
6317   plugin_interface="yes"
6318   plugin_load="yes"
6319   plugin_memory="yes"
6320   plugin_swap="yes"
6321   plugin_users="yes"
6322 fi
6323
6324 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"; then
6325   plugin_ascent="yes"
6326   if test "x$have_strptime" = "xyes"; then
6327     plugin_bind="yes"
6328   fi
6329 fi
6330
6331 if test "x$with_libopenipmipthread" = "xyes"; then
6332   plugin_ipmi="yes"
6333 fi
6334
6335 if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"; then
6336   plugin_curl_json="yes"
6337 fi
6338
6339 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"; then
6340   plugin_curl_xml="yes"
6341 fi
6342
6343 if test "x$with_libyajl" = "xyes"; then
6344   plugin_ceph="yes"
6345 fi
6346
6347 if test "x$have_processor_info" = "xyes"; then
6348   plugin_cpu="yes"
6349 fi
6350
6351 if test "x$have_sysctl" = "xyes"; then
6352   plugin_cpu="yes"
6353   plugin_memory="yes"
6354   plugin_uptime="yes"
6355   if test "x$ac_system" = "xDarwin"; then
6356     plugin_swap="yes"
6357   fi
6358 fi
6359
6360 if test "x$have_sysctlbyname" = "xyes"; then
6361   plugin_contextswitch="yes"
6362   plugin_cpu="yes"
6363   plugin_memory="yes"
6364   plugin_tcpconns="yes"
6365 fi
6366
6367 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"; then
6368   plugin_df="yes"
6369 fi
6370
6371 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"; then
6372   plugin_df="yes"
6373 fi
6374
6375 if test "x$c_cv_have_one_getmntent" = "xyes"; then
6376   plugin_df="yes"
6377 fi
6378
6379 if test "x$c_cv_have_getmntent_r" = "xyes"; then
6380   plugin_df="yes"
6381 fi
6382
6383 if test "x$plugin_df" = "xyes"; then
6384   plugin_df="no"
6385   if test "x$have_statfs" = "xyes"; then
6386     plugin_df="yes"
6387   fi
6388
6389   if test "x$have_statvfs" = "xyes"; then
6390     plugin_df="yes"
6391   fi
6392 fi
6393
6394 if test "x$have_linux_sockios_h" = "xyes" && test "x$have_linux_ethtool_h" = "xyes"; then
6395   plugin_ethstat="yes"
6396 fi
6397
6398 if test "x$with_libgps" = "xyes"; then
6399   plugin_gps="yes"
6400 fi
6401
6402 if test "x$with_libgrpcpp" = "xyes" && test "x$with_libprotobuf" = "xyes" && test "x$have_protoc3" = "xyes" && test "x$GRPC_CPP_PLUGIN" != "x"; then
6403   plugin_grpc="yes"
6404 fi
6405
6406 if test "x$have_getifaddrs" = "xyes"; then
6407   plugin_interface="yes"
6408 fi
6409
6410 if test "x$have_getloadavg" = "xyes"; then
6411   plugin_load="yes"
6412 fi
6413
6414 if test "x$with_libyajl" = "xyes"; then
6415   plugin_log_logstash="yes"
6416 fi
6417
6418 if test "x$with_libperl" = "xyes" && test "x$c_cv_have_perl_ithreads" = "xyes"; then
6419   plugin_perl="yes"
6420 fi
6421
6422 if test "x$have_protoc_c" = "xyes" && test "x$with_libprotobuf_c" = "xyes"; then
6423   plugin_pinba="yes"
6424   if test "x$with_libmicrohttpd" = "xyes"; then
6425     plugin_write_prometheus="yes"
6426   fi
6427 fi
6428
6429 # Mac OS X memory interface
6430 if test "x$have_host_statistics" = "xyes"; then
6431   plugin_memory="yes"
6432 fi
6433
6434 if test "x$have_termios_h" = "xyes"; then
6435   if test "x$ac_system" != "xAIX"; then
6436     plugin_multimeter="yes"
6437   fi
6438   plugin_ted="yes"
6439 fi
6440
6441 if test "x$have_thread_info" = "xyes"; then
6442   plugin_processes="yes"
6443 fi
6444
6445 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"; then
6446   plugin_processes="yes"
6447 fi
6448
6449 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_openbsd" = "xyes"; then
6450   plugin_processes="yes"
6451 fi
6452
6453 if test "x$with_libpython" != "xno"; then
6454   plugin_python="yes"
6455 fi
6456
6457 if test "x$with_libatasmart" = "xyes" && test "x$with_libudev" = "xyes"; then
6458   plugin_smart="yes"
6459 fi
6460
6461 if test "x$with_kvm_getswapinfo" = "xyes"; then
6462   plugin_swap="yes"
6463 fi
6464
6465 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"; then
6466   plugin_swap="yes"
6467 fi
6468
6469 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes"; then
6470   plugin_swap="yes"
6471 fi
6472
6473 if test "x$with_kvm_openfiles = "xyes" && $with_kvm_nlist" = "xyes"; then
6474   plugin_tcpconns="yes"
6475 fi
6476
6477 if test "x$have_getutent" = "xyes"; then
6478   plugin_users="yes"
6479 fi
6480
6481 if test "x$have_getutxent" = "xyes"; then
6482   plugin_users="yes"
6483 fi
6484
6485 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"; then
6486   plugin_virt="yes"
6487 fi
6488
6489 if test "x$with_libxenctrl" = "xyes"; then
6490   plugin_xencpu="yes"
6491 fi
6492
6493 if test "x$with_libdpdk" = "xyes"; then
6494   plugin_dpdkevents="$dpdk_keepalive"
6495   plugin_dpdkstat="yes"
6496 fi
6497
6498 m4_divert_once([HELP_ENABLE], [
6499 collectd plugins:])
6500
6501 AC_ARG_ENABLE([all-plugins],
6502   [AS_HELP_STRING([--enable-all-plugins], [enable all plugins @<:@default=yes@:>@])],
6503   [
6504      if test "x$enableval" = "xyes"; then
6505        enable_all_plugins="yes"
6506      else if test "x$enableval" = "xauto"; then
6507        enable_all_plugins="auto"
6508      else
6509        enable_all_plugins="no"
6510      fi; fi
6511   ],
6512   [enable_all_plugins="auto"]
6513 )
6514
6515 m4_divert_once([HELP_ENABLE], [])
6516
6517 AC_PLUGIN([aggregation],         [yes],                     [Aggregation plugin])
6518 AC_PLUGIN([amqp],                [$with_librabbitmq],       [AMQP output plugin])
6519 AC_PLUGIN([apache],              [$with_libcurl],           [Apache httpd statistics])
6520 AC_PLUGIN([apcups],              [yes],                     [Statistics of UPSes by APC])
6521 AC_PLUGIN([apple_sensors],       [$with_libiokit],          [Apple hardware sensors])
6522 AC_PLUGIN([aquaero],             [$with_libaquaero5],       [Aquaero hardware sensors])
6523 AC_PLUGIN([ascent],              [$plugin_ascent],          [AscentEmu player statistics])
6524 AC_PLUGIN([barometer],           [$plugin_barometer],       [Barometer sensor on I2C])
6525 AC_PLUGIN([battery],             [$plugin_battery],         [Battery statistics])
6526 AC_PLUGIN([bind],                [$plugin_bind],            [ISC Bind nameserver statistics])
6527 AC_PLUGIN([ceph],                [$plugin_ceph],            [Ceph daemon statistics])
6528 AC_PLUGIN([cgroups],             [$plugin_cgroups],         [CGroups CPU usage accounting])
6529 AC_PLUGIN([chrony],              [yes],                     [Chrony statistics])
6530 AC_PLUGIN([conntrack],           [$plugin_conntrack],       [nf_conntrack statistics])
6531 AC_PLUGIN([contextswitch],       [$plugin_contextswitch],   [context switch statistics])
6532 AC_PLUGIN([cpu],                 [$plugin_cpu],             [CPU usage statistics])
6533 AC_PLUGIN([cpufreq],             [$plugin_cpufreq],         [CPU frequency statistics])
6534 AC_PLUGIN([cpusleep],            [$plugin_cpusleep],        [CPU sleep statistics])
6535 AC_PLUGIN([csv],                 [yes],                     [CSV output plugin])
6536 AC_PLUGIN([curl],                [$with_libcurl],           [CURL generic web statistics])
6537 AC_PLUGIN([curl_json],           [$plugin_curl_json],       [CouchDB statistics])
6538 AC_PLUGIN([curl_xml],            [$plugin_curl_xml],        [CURL generic xml statistics])
6539 AC_PLUGIN([dbi],                 [$with_libdbi],            [General database statistics])
6540 AC_PLUGIN([df],                  [$plugin_df],              [Filesystem usage statistics])
6541 AC_PLUGIN([disk],                [$plugin_disk],            [Disk usage statistics])
6542 AC_PLUGIN([dns],                 [$with_libpcap],           [DNS traffic analysis])
6543 AC_PLUGIN([dpdkevents],          [$plugin_dpdkevents],      [Events from DPDK])
6544 AC_PLUGIN([dpdkstat],            [$plugin_dpdkstat],        [Stats from DPDK])
6545 AC_PLUGIN([drbd],                [$plugin_drbd],            [DRBD statistics])
6546 AC_PLUGIN([email],               [yes],                     [EMail statistics])
6547 AC_PLUGIN([entropy],             [$plugin_entropy],         [Entropy statistics])
6548 AC_PLUGIN([ethstat],             [$plugin_ethstat],         [Stats from NIC driver])
6549 AC_PLUGIN([exec],                [yes],                     [Execution of external programs])
6550 AC_PLUGIN([fhcount],             [$plugin_fhcount],         [File handles statistics])
6551 AC_PLUGIN([filecount],           [yes],                     [Count files in directories])
6552 AC_PLUGIN([fscache],             [$plugin_fscache],         [fscache statistics])
6553 AC_PLUGIN([gmond],               [$with_libganglia],        [Ganglia plugin])
6554 AC_PLUGIN([gps],                 [$plugin_gps],             [GPS plugin])
6555 AC_PLUGIN([grpc],                [$plugin_grpc],            [gRPC plugin])
6556 AC_PLUGIN([hddtemp],             [yes],                     [Query hddtempd])
6557 AC_PLUGIN([hugepages],           [$plugin_hugepages],       [Hugepages statistics])
6558 AC_PLUGIN([intel_pmu],           [$with_libjevents],        [Intel performance monitor plugin])
6559 AC_PLUGIN([intel_rdt],           [$with_libpqos],           [Intel RDT monitor plugin])
6560 AC_PLUGIN([interface],           [$plugin_interface],       [Interface traffic statistics])
6561 AC_PLUGIN([ipc],                 [$plugin_ipc],             [IPC statistics])
6562 AC_PLUGIN([ipmi],                [$plugin_ipmi],            [IPMI sensor statistics])
6563 AC_PLUGIN([iptables],            [$with_libiptc],           [IPTables rule counters])
6564 AC_PLUGIN([ipvs],                [$plugin_ipvs],            [IPVS connection statistics])
6565 AC_PLUGIN([irq],                 [$plugin_irq],             [IRQ statistics])
6566 AC_PLUGIN([java],                [$with_java],              [Embed the Java Virtual Machine])
6567 AC_PLUGIN([load],                [$plugin_load],            [System load])
6568 AC_PLUGIN([log_logstash],        [$plugin_log_logstash],    [Logstash json_event compatible logging])
6569 AC_PLUGIN([logfile],             [yes],                     [File logging plugin])
6570 AC_PLUGIN([lpar],                [$with_perfstat],          [AIX logical partitions statistics])
6571 AC_PLUGIN([lua],                 [$with_liblua],            [Lua plugin])
6572 AC_PLUGIN([lvm],                 [$with_liblvm2app],        [LVM statistics])
6573 AC_PLUGIN([madwifi],             [$have_linux_wireless_h],  [Madwifi wireless statistics])
6574 AC_PLUGIN([match_empty_counter], [yes],                     [The empty counter match])
6575 AC_PLUGIN([match_hashed],        [yes],                     [The hashed match])
6576 AC_PLUGIN([match_regex],         [yes],                     [The regex match])
6577 AC_PLUGIN([match_timediff],      [yes],                     [The timediff match])
6578 AC_PLUGIN([match_value],         [yes],                     [The value match])
6579 AC_PLUGIN([mbmon],               [yes],                     [Query mbmond])
6580 AC_PLUGIN([mcelog],              [$plugin_mcelog],          [Machine Check Exceptions notifications])
6581 AC_PLUGIN([md],                  [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
6582 AC_PLUGIN([memcachec],           [$with_libmemcached],      [memcachec statistics])
6583 AC_PLUGIN([memcached],           [yes],                     [memcached statistics])
6584 AC_PLUGIN([memory],              [$plugin_memory],          [Memory usage])
6585 AC_PLUGIN([mic],                 [$with_mic],               [Intel Many Integrated Core stats])
6586 AC_PLUGIN([modbus],              [$with_libmodbus],         [Modbus plugin])
6587 AC_PLUGIN([mqtt],                [$with_libmosquitto],      [MQTT output plugin])
6588 AC_PLUGIN([multimeter],          [$plugin_multimeter],      [Read multimeter values])
6589 AC_PLUGIN([mysql],               [$with_libmysql],          [MySQL statistics])
6590 AC_PLUGIN([netapp],              [$with_libnetapp],         [NetApp plugin])
6591 AC_PLUGIN([netlink],             [$with_libmnl],            [Enhanced Linux network statistics])
6592 AC_PLUGIN([network],             [yes],                     [Network communication plugin])
6593 AC_PLUGIN([nfs],                 [$plugin_nfs],             [NFS statistics])
6594 AC_PLUGIN([nginx],               [$with_libcurl],           [nginx statistics])
6595 AC_PLUGIN([notify_desktop],      [$with_libnotify],         [Desktop notifications])
6596 AC_PLUGIN([notify_email],        [$with_libesmtp],          [Email notifier])
6597 AC_PLUGIN([notify_nagios],       [yes],                     [Nagios notification plugin])
6598 AC_PLUGIN([ntpd],                [yes],                     [NTPd statistics])
6599 AC_PLUGIN([numa],                [$plugin_numa],            [NUMA virtual memory statistics])
6600 AC_PLUGIN([nut],                 [$with_libupsclient],      [Network UPS tools statistics])
6601 AC_PLUGIN([olsrd],               [yes],                     [olsrd statistics])
6602 AC_PLUGIN([onewire],             [$with_libowcapi],         [OneWire sensor statistics])
6603 AC_PLUGIN([openldap],            [$with_libldap],           [OpenLDAP statistics])
6604 AC_PLUGIN([openvpn],             [yes],                     [OpenVPN client statistics])
6605 AC_PLUGIN([oracle],              [$with_oracle],            [Oracle plugin])
6606 AC_PLUGIN([ovs_events],          [$plugin_ovs_events],      [OVS events plugin])
6607 AC_PLUGIN([ovs_stats],           [$plugin_ovs_stats],       [OVS statistics plugin])
6608 AC_PLUGIN([perl],                [$plugin_perl],            [Embed a Perl interpreter])
6609 AC_PLUGIN([pf],                  [$have_net_pfvar_h],       [BSD packet filter (PF) statistics])
6610 # FIXME: Check for libevent, too.
6611 AC_PLUGIN([pinba],               [$plugin_pinba],           [Pinba statistics])
6612 AC_PLUGIN([ping],                [$with_liboping],          [Network latency statistics])
6613 AC_PLUGIN([postgresql],          [$with_libpq],             [PostgreSQL database statistics])
6614 AC_PLUGIN([powerdns],            [yes],                     [PowerDNS statistics])
6615 AC_PLUGIN([processes],           [$plugin_processes],       [Process statistics])
6616 AC_PLUGIN([protocols],           [$plugin_protocols],       [Protocol (IP, TCP, ...) statistics])
6617 AC_PLUGIN([python],              [$plugin_python],          [Embed a Python interpreter])
6618 AC_PLUGIN([redis],               [$with_libhiredis],        [Redis plugin])
6619 AC_PLUGIN([routeros],            [$with_librouteros],       [RouterOS plugin])
6620 AC_PLUGIN([rrdcached],           [$librrd_rrdc_update],     [RRDTool output plugin])
6621 AC_PLUGIN([rrdtool],             [$with_librrd],            [RRDTool output plugin])
6622 AC_PLUGIN([sensors],             [$with_libsensors],        [lm_sensors statistics])
6623 AC_PLUGIN([serial],              [$plugin_serial],          [serial port traffic])
6624 AC_PLUGIN([sigrok],              [$with_libsigrok],         [sigrok acquisition sources])
6625 AC_PLUGIN([smart],               [$plugin_smart],           [SMART statistics])
6626 AC_PLUGIN([snmp],                [$with_libnetsnmp],        [SNMP querying plugin])
6627 AC_PLUGIN([snmp_agent],          [$with_libnetsnmpagent],   [SNMP agent plugin])
6628 AC_PLUGIN([statsd],              [yes],                     [StatsD plugin])
6629 AC_PLUGIN([swap],                [$plugin_swap],            [Swap usage statistics])
6630 AC_PLUGIN([synproxy],            [$plugin_synproxy],        [Synproxy stats plugin])
6631 AC_PLUGIN([syslog],              [$have_syslog],            [Syslog logging plugin])
6632 AC_PLUGIN([table],               [yes],                     [Parsing of tabular data])
6633 AC_PLUGIN([tail],                [yes],                     [Parsing of logfiles])
6634 AC_PLUGIN([tail_csv],            [yes],                     [Parsing of CSV files])
6635 AC_PLUGIN([tape],                [$plugin_tape],            [Tape drive statistics])
6636 AC_PLUGIN([target_notification], [yes],                     [The notification target])
6637 AC_PLUGIN([target_replace],      [yes],                     [The replace target])
6638 AC_PLUGIN([target_scale],        [yes],                     [The scale target])
6639 AC_PLUGIN([target_set],          [yes],                     [The set target])
6640 AC_PLUGIN([target_v5upgrade],    [yes],                     [The v5upgrade target])
6641 AC_PLUGIN([tcpconns],            [$plugin_tcpconns],        [TCP connection statistics])
6642 AC_PLUGIN([teamspeak2],          [yes],                     [TeamSpeak2 server statistics])
6643 AC_PLUGIN([ted],                 [$plugin_ted],             [Read The Energy Detective values])
6644 AC_PLUGIN([thermal],             [$plugin_thermal],         [Linux ACPI thermal zone statistics])
6645 AC_PLUGIN([threshold],           [yes],                     [Threshold checking plugin])
6646 AC_PLUGIN([tokyotyrant],         [$with_libtokyotyrant],    [TokyoTyrant database statistics])
6647 AC_PLUGIN([turbostat],           [$plugin_turbostat],       [Advanced statistic on Intel cpu states])
6648 AC_PLUGIN([unixsock],            [yes],                     [Unixsock communication plugin])
6649 AC_PLUGIN([uptime],              [$plugin_uptime],          [Uptime statistics])
6650 AC_PLUGIN([users],               [$plugin_users],           [User statistics])
6651 AC_PLUGIN([uuid],                [yes],                     [UUID as hostname plugin])
6652 AC_PLUGIN([varnish],             [$with_libvarnish],        [Varnish cache statistics])
6653 AC_PLUGIN([virt],                [$plugin_virt],            [Virtual machine statistics])
6654 AC_PLUGIN([vmem],                [$plugin_vmem],            [Virtual memory statistics])
6655 AC_PLUGIN([vserver],             [$plugin_vserver],         [Linux VServer statistics])
6656 AC_PLUGIN([wireless],            [$plugin_wireless],        [Wireless statistics])
6657 AC_PLUGIN([write_graphite],      [yes],                     [Graphite / Carbon output plugin])
6658 AC_PLUGIN([write_http],          [$with_libcurl],           [HTTP output plugin])
6659 AC_PLUGIN([write_kafka],         [$with_librdkafka],        [Kafka output plugin])
6660 AC_PLUGIN([write_log],           [yes],                     [Log output plugin])
6661 AC_PLUGIN([write_mongodb],       [$with_libmongoc],         [MongoDB output plugin])
6662 AC_PLUGIN([write_prometheus],    [$plugin_write_prometheus], [Prometheus write plugin])
6663 AC_PLUGIN([write_redis],         [$with_libhiredis],        [Redis output plugin])
6664 AC_PLUGIN([write_riemann],       [$with_libriemann_client], [Riemann output plugin])
6665 AC_PLUGIN([write_sensu],         [yes],                     [Sensu output plugin])
6666 AC_PLUGIN([write_tsdb],          [yes],                     [TSDB output plugin])
6667 AC_PLUGIN([xencpu],              [$plugin_xencpu],          [Xen Host CPU usage])
6668 AC_PLUGIN([xmms],                [$with_libxmms],           [XMMS statistics])
6669 AC_PLUGIN([zfs_arc],             [$plugin_zfs_arc],         [ZFS ARC statistics])
6670 AC_PLUGIN([zone],                [$plugin_zone],            [Solaris container statistics])
6671 AC_PLUGIN([zookeeper],           [yes],                     [Zookeeper statistics])
6672
6673 dnl Default configuration file
6674 # Load either syslog or logfile
6675 LOAD_PLUGIN_SYSLOG=""
6676 LOAD_PLUGIN_LOGFILE=""
6677 LOAD_PLUGIN_LOG_LOGSTASH=""
6678
6679 AC_MSG_CHECKING([which default log plugin to load])
6680 default_log_plugin="none"
6681 if test "x$enable_syslog" = "xyes"; then
6682   default_log_plugin="syslog"
6683 else
6684   LOAD_PLUGIN_SYSLOG="##"
6685 fi
6686
6687 if test "x$enable_logfile" = "xyes"; then
6688   if test "x$default_log_plugin" = "xnone"; then
6689     default_log_plugin="logfile"
6690   else
6691     LOAD_PLUGIN_LOGFILE="#"
6692   fi
6693 else
6694   LOAD_PLUGIN_LOGFILE="##"
6695 fi
6696
6697 if test "x$enable_log_logstash" = "xyes"; then
6698   LOAD_PLUGIN_LOG_LOGSTASH="#"
6699 else
6700   LOAD_PLUGIN_LOG_LOGSTASH="##"
6701 fi
6702
6703 AC_MSG_RESULT([$default_log_plugin])
6704
6705 AC_SUBST([LOAD_PLUGIN_SYSLOG])
6706 AC_SUBST([LOAD_PLUGIN_LOGFILE])
6707 AC_SUBST([LOAD_PLUGIN_LOG_LOGSTASH])
6708
6709 if test "x$enable_debug" = "xyes"; then
6710   DEFAULT_LOG_LEVEL="debug"
6711 else
6712   DEFAULT_LOG_LEVEL="info"
6713 fi
6714 AC_SUBST([DEFAULT_LOG_LEVEL])
6715
6716 # Load only one of rrdtool, network, csv in the default config.
6717 LOAD_PLUGIN_RRDTOOL=""
6718 LOAD_PLUGIN_NETWORK=""
6719 LOAD_PLUGIN_CSV=""
6720
6721 AC_MSG_CHECKING([which default write plugin to load])
6722 default_write_plugin="none"
6723 if test "x$enable_rrdtool" = "xyes"; then
6724   default_write_plugin="rrdtool"
6725 else
6726   LOAD_PLUGIN_RRDTOOL="##"
6727 fi
6728
6729 if test "x$enable_network" = "xyes"; then
6730   if test "x$default_write_plugin" = "xnone"; then
6731     default_write_plugin="network"
6732   else
6733     LOAD_PLUGIN_NETWORK="#"
6734   fi
6735 else
6736   LOAD_PLUGIN_NETWORK="##"
6737 fi
6738
6739 if test "x$enable_csv" = "xyes"; then
6740   if test "x$default_write_plugin" = "xnone"; then
6741     default_write_plugin="csv"
6742   else
6743     LOAD_PLUGIN_CSV="#"
6744   fi
6745 else
6746   LOAD_PLUGIN_CSV="##"
6747 fi
6748 AC_MSG_RESULT([$default_write_plugin])
6749
6750 AC_SUBST([LOAD_PLUGIN_RRDTOOL])
6751 AC_SUBST([LOAD_PLUGIN_NETWORK])
6752 AC_SUBST([LOAD_PLUGIN_CSV])
6753
6754 dnl Perl bindings
6755 PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
6756 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
6757 [
6758   if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
6759     PERL_BINDINGS_OPTIONS="$withval"
6760     with_perl_bindings="yes"
6761   else
6762     with_perl_bindings="$withval"
6763   fi
6764 ],
6765 [
6766   if test "x$PERL" != "x"; then
6767     with_perl_bindings="yes"
6768   else
6769     with_perl_bindings="no (no perl interpreter found)"
6770   fi
6771 ])
6772
6773 if test "x$with_perl_bindings" = "xyes"; then
6774   AC_MSG_CHECKING([for the ExtUtils::MakeMaker module])
6775   if $PERL -MExtUtils::MakeMaker -e '' 2>/dev/null; then
6776     AC_MSG_RESULT([yes])
6777   else
6778     AC_MSG_RESULT([no])
6779     with_perl_bindings="no (ExtUtils::MakeMaker not found)"
6780   fi
6781 fi
6782
6783 if test "x$with_perl_bindings" = "xyes"; then
6784   PERL_BINDINGS="perl"
6785 else
6786   PERL_BINDINGS=""
6787 fi
6788
6789 AC_SUBST([PERL_BINDINGS])
6790 AC_SUBST([PERL_BINDINGS_OPTIONS])
6791
6792 dnl libcollectdclient
6793 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
6794 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
6795 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
6796
6797 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
6798
6799 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
6800
6801 AC_SUBST([LCC_VERSION_MAJOR])
6802 AC_SUBST([LCC_VERSION_MINOR])
6803 AC_SUBST([LCC_VERSION_PATCH])
6804 AC_SUBST([LCC_VERSION_EXTRA])
6805 AC_SUBST([LCC_VERSION_STRING])
6806
6807 AC_CONFIG_FILES([src/libcollectdclient/collectd/lcc_features.h])
6808
6809 AM_CFLAGS="-Wall"
6810 AM_CXXFLAGS="-Wall"
6811 if test "x$enable_werror" != "xno"; then
6812   AM_CFLAGS="$AM_CFLAGS -Werror"
6813   AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
6814 fi
6815
6816 AC_SUBST([AM_CFLAGS])
6817 AC_SUBST([AM_CXXFLAGS])
6818
6819 AC_CONFIG_FILES([ \
6820   Makefile \
6821   src/collectd.conf \
6822   src/libcollectdclient/libcollectdclient.pc \
6823 ])
6824
6825 AC_OUTPUT
6826
6827 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" != "xyes"; then
6828   with_librrd="yes (warning: librrd is not thread-safe)"
6829 fi
6830
6831 if test "x$with_libperl" = "xyes"; then
6832   with_libperl="yes (version `$PERL -MConfig -e 'print $Config{version};'`)"
6833 else
6834   enable_perl="no (needs libperl)"
6835 fi
6836
6837 if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"; then
6838   enable_perl="no (libperl doesn't support ithreads)"
6839 fi
6840
6841 if test "x$with_perl_bindings" = "xyes" && test "x$PERL_BINDINGS_OPTIONS" != "x"; then
6842   with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
6843 fi
6844
6845 AC_MSG_RESULT()
6846 AC_MSG_RESULT([Configuration:])
6847 AC_MSG_RESULT([  Build:])
6848 AC_MSG_RESULT([    Platform  . . . . . . $ac_system])
6849 AC_MSG_RESULT([    Compiler vendor . . . $ax_cv_c_compiler_vendor])
6850 AC_MSG_RESULT([    CC  . . . . . . . . . $CC])
6851 AC_MSG_RESULT([    CFLAGS  . . . . . . . $AM_CFLAGS $CFLAGS])
6852 AC_MSG_RESULT([    CXXFLAGS  . . . . . . $AM_CXXFLAGS $CXXFLAGS])
6853 AC_MSG_RESULT([    CPP . . . . . . . . . $CPP])
6854 AC_MSG_RESULT([    CPPFLAGS  . . . . . . $CPPFLAGS])
6855 AC_MSG_RESULT([    GRPC_CPP_PLUGIN . . . $GRPC_CPP_PLUGIN])
6856 AC_MSG_RESULT([    LD  . . . . . . . . . $LD])
6857 AC_MSG_RESULT([    LDFLAGS . . . . . . . $LDFLAGS])
6858 AC_MSG_RESULT([    PROTOC  . . . . . . . $PROTOC])
6859 AC_MSG_RESULT([    YACC  . . . . . . . . $YACC])
6860 AC_MSG_RESULT([    YFLAGS  . . . . . . . $YFLAGS])
6861 AC_MSG_RESULT()
6862 AC_MSG_RESULT([  Libraries:])
6863 AC_MSG_RESULT([    intel mic . . . . . . $with_mic])
6864 AC_MSG_RESULT([    libaquaero5 . . . . . $with_libaquaero5])
6865 AC_MSG_RESULT([    libatasmart . . . . . $with_libatasmart])
6866 AC_MSG_RESULT([    libcurl . . . . . . . $with_libcurl])
6867 AC_MSG_RESULT([    libdbi  . . . . . . . $with_libdbi])
6868 AC_MSG_RESULT([    libdpdk . . . . . . . $with_libdpdk])
6869 AC_MSG_RESULT([    libesmtp  . . . . . . $with_libesmtp])
6870 AC_MSG_RESULT([    libganglia  . . . . . $with_libganglia])
6871 AC_MSG_RESULT([    libgcrypt . . . . . . $with_libgcrypt])
6872 AC_MSG_RESULT([    libgps  . . . . . . . $with_libgps])
6873 AC_MSG_RESULT([    libgrpc++ . . . . . . $with_libgrpcpp])
6874 AC_MSG_RESULT([    libhiredis  . . . . . $with_libhiredis])
6875 AC_MSG_RESULT([    libi2c-dev  . . . . . $with_libi2c])
6876 AC_MSG_RESULT([    libiokit  . . . . . . $with_libiokit])
6877 AC_MSG_RESULT([    libiptc . . . . . . . $with_libiptc])
6878 AC_MSG_RESULT([    libjevents  . . . . . $with_libjevents])
6879 AC_MSG_RESULT([    libjvm  . . . . . . . $with_java])
6880 AC_MSG_RESULT([    libkstat  . . . . . . $with_kstat])
6881 AC_MSG_RESULT([    libkvm  . . . . . . . $with_libkvm])
6882 AC_MSG_RESULT([    libldap . . . . . . . $with_libldap])
6883 AC_MSG_RESULT([    liblua  . . . . . . . $with_liblua])
6884 AC_MSG_RESULT([    liblvm2app  . . . . . $with_liblvm2app])
6885 AC_MSG_RESULT([    libmemcached  . . . . $with_libmemcached])
6886 AC_MSG_RESULT([    libmicrohttpd . . . . $with_libmicrohttpd])
6887 AC_MSG_RESULT([    libmnl  . . . . . . . $with_libmnl])
6888 AC_MSG_RESULT([    libmodbus . . . . . . $with_libmodbus])
6889 AC_MSG_RESULT([    libmongoc . . . . . . $with_libmongoc])
6890 AC_MSG_RESULT([    libmosquitto  . . . . $with_libmosquitto])
6891 AC_MSG_RESULT([    libmysql  . . . . . . $with_libmysql])
6892 AC_MSG_RESULT([    libnetapp . . . . . . $with_libnetapp])
6893 AC_MSG_RESULT([    libnetsnmp  . . . . . $with_libnetsnmp])
6894 AC_MSG_RESULT([    libnetsnmpagent . . . $with_libnetsnmpagent])
6895 AC_MSG_RESULT([    libnotify . . . . . . $with_libnotify])
6896 AC_MSG_RESULT([    libopenipmi . . . . . $with_libopenipmipthread])
6897 AC_MSG_RESULT([    liboping  . . . . . . $with_liboping])
6898 AC_MSG_RESULT([    libowcapi . . . . . . $with_libowcapi])
6899 AC_MSG_RESULT([    libpcap . . . . . . . $with_libpcap])
6900 AC_MSG_RESULT([    libperfstat . . . . . $with_perfstat])
6901 AC_MSG_RESULT([    libperl . . . . . . . $with_libperl])
6902 AC_MSG_RESULT([    libpq . . . . . . . . $with_libpq])
6903 AC_MSG_RESULT([    libpqos . . . . . . . $with_libpqos])
6904 AC_MSG_RESULT([    libprotobuf . . . . . $with_libprotobuf])
6905 AC_MSG_RESULT([    libprotobuf-c . . . . $with_libprotobuf_c])
6906 AC_MSG_RESULT([    libpython . . . . . . $with_libpython])
6907 AC_MSG_RESULT([    librabbitmq . . . . . $with_librabbitmq])
6908 AC_MSG_RESULT([    libriemann-client . . $with_libriemann_client])
6909 AC_MSG_RESULT([    librdkafka  . . . . . $with_librdkafka])
6910 AC_MSG_RESULT([    librouteros . . . . . $with_librouteros])
6911 AC_MSG_RESULT([    librrd  . . . . . . . $with_librrd])
6912 AC_MSG_RESULT([    libsensors  . . . . . $with_libsensors])
6913 AC_MSG_RESULT([    libsigrok   . . . . . $with_libsigrok])
6914 AC_MSG_RESULT([    libstatgrab . . . . . $with_libstatgrab])
6915 AC_MSG_RESULT([    libtokyotyrant  . . . $with_libtokyotyrant])
6916 AC_MSG_RESULT([    libudev . . . . . . . $with_libudev])
6917 AC_MSG_RESULT([    libupsclient  . . . . $with_libupsclient])
6918 AC_MSG_RESULT([    libvarnish  . . . . . $with_libvarnish])
6919 AC_MSG_RESULT([    libvirt . . . . . . . $with_libvirt])
6920 AC_MSG_RESULT([    libxenctrl  . . . . . $with_libxenctrl])
6921 AC_MSG_RESULT([    libxml2 . . . . . . . $with_libxml2])
6922 AC_MSG_RESULT([    libxmms . . . . . . . $with_libxmms])
6923 AC_MSG_RESULT([    libyajl . . . . . . . $with_libyajl])
6924 AC_MSG_RESULT([    oracle  . . . . . . . $with_oracle])
6925 AC_MSG_RESULT([    protobuf-c  . . . . . $have_protoc_c])
6926 AC_MSG_RESULT([    protoc 3  . . . . . . $have_protoc3])
6927 AC_MSG_RESULT()
6928 AC_MSG_RESULT([  Features:])
6929 AC_MSG_RESULT([    daemon mode . . . . . $enable_daemon])
6930 AC_MSG_RESULT([    debug . . . . . . . . $enable_debug])
6931 AC_MSG_RESULT()
6932 AC_MSG_RESULT([  Bindings:])
6933 AC_MSG_RESULT([    perl  . . . . . . . . $with_perl_bindings])
6934 AC_MSG_RESULT()
6935 AC_MSG_RESULT([  Modules:])
6936 AC_MSG_RESULT([    aggregation . . . . . $enable_aggregation])
6937 AC_MSG_RESULT([    amqp    . . . . . . . $enable_amqp])
6938 AC_MSG_RESULT([    apache  . . . . . . . $enable_apache])
6939 AC_MSG_RESULT([    apcups  . . . . . . . $enable_apcups])
6940 AC_MSG_RESULT([    apple_sensors . . . . $enable_apple_sensors])
6941 AC_MSG_RESULT([    aquaero . . . . . . . $enable_aquaero])
6942 AC_MSG_RESULT([    ascent  . . . . . . . $enable_ascent])
6943 AC_MSG_RESULT([    barometer . . . . . . $enable_barometer])
6944 AC_MSG_RESULT([    battery . . . . . . . $enable_battery])
6945 AC_MSG_RESULT([    bind  . . . . . . . . $enable_bind])
6946 AC_MSG_RESULT([    ceph  . . . . . . . . $enable_ceph])
6947 AC_MSG_RESULT([    cgroups . . . . . . . $enable_cgroups])
6948 AC_MSG_RESULT([    chrony. . . . . . . . $enable_chrony])
6949 AC_MSG_RESULT([    conntrack . . . . . . $enable_conntrack])
6950 AC_MSG_RESULT([    contextswitch . . . . $enable_contextswitch])
6951 AC_MSG_RESULT([    cpu . . . . . . . . . $enable_cpu])
6952 AC_MSG_RESULT([    cpufreq . . . . . . . $enable_cpufreq])
6953 AC_MSG_RESULT([    cpusleep  . . . . . . $enable_cpusleep])
6954 AC_MSG_RESULT([    csv . . . . . . . . . $enable_csv])
6955 AC_MSG_RESULT([    curl  . . . . . . . . $enable_curl])
6956 AC_MSG_RESULT([    curl_json . . . . . . $enable_curl_json])
6957 AC_MSG_RESULT([    curl_xml  . . . . . . $enable_curl_xml])
6958 AC_MSG_RESULT([    dbi . . . . . . . . . $enable_dbi])
6959 AC_MSG_RESULT([    df  . . . . . . . . . $enable_df])
6960 AC_MSG_RESULT([    disk  . . . . . . . . $enable_disk])
6961 AC_MSG_RESULT([    dns . . . . . . . . . $enable_dns])
6962 AC_MSG_RESULT([    dpdkevents. . . . . . $enable_dpdkevents])
6963 AC_MSG_RESULT([    dpdkstat  . . . . . . $enable_dpdkstat])
6964 AC_MSG_RESULT([    drbd  . . . . . . . . $enable_drbd])
6965 AC_MSG_RESULT([    email . . . . . . . . $enable_email])
6966 AC_MSG_RESULT([    entropy . . . . . . . $enable_entropy])
6967 AC_MSG_RESULT([    ethstat . . . . . . . $enable_ethstat])
6968 AC_MSG_RESULT([    exec  . . . . . . . . $enable_exec])
6969 AC_MSG_RESULT([    fhcount . . . . . . . $enable_fhcount])
6970 AC_MSG_RESULT([    filecount . . . . . . $enable_filecount])
6971 AC_MSG_RESULT([    fscache . . . . . . . $enable_fscache])
6972 AC_MSG_RESULT([    gmond . . . . . . . . $enable_gmond])
6973 AC_MSG_RESULT([    gps . . . . . . . . . $enable_gps])
6974 AC_MSG_RESULT([    grpc  . . . . . . . . $enable_grpc])
6975 AC_MSG_RESULT([    hddtemp . . . . . . . $enable_hddtemp])
6976 AC_MSG_RESULT([    hugepages . . . . . . $enable_hugepages])
6977 AC_MSG_RESULT([    intel_pmu . . . . . . $enable_intel_pmu])
6978 AC_MSG_RESULT([    intel_rdt . . . . . . $enable_intel_rdt])
6979 AC_MSG_RESULT([    interface . . . . . . $enable_interface])
6980 AC_MSG_RESULT([    ipc . . . . . . . . . $enable_ipc])
6981 AC_MSG_RESULT([    ipmi  . . . . . . . . $enable_ipmi])
6982 AC_MSG_RESULT([    iptables  . . . . . . $enable_iptables])
6983 AC_MSG_RESULT([    ipvs  . . . . . . . . $enable_ipvs])
6984 AC_MSG_RESULT([    irq . . . . . . . . . $enable_irq])
6985 AC_MSG_RESULT([    java  . . . . . . . . $enable_java])
6986 AC_MSG_RESULT([    load  . . . . . . . . $enable_load])
6987 AC_MSG_RESULT([    logfile . . . . . . . $enable_logfile])
6988 AC_MSG_RESULT([    log_logstash  . . . . $enable_log_logstash])
6989 AC_MSG_RESULT([    lpar  . . . . . . . . $enable_lpar])
6990 AC_MSG_RESULT([    lua . . . . . . . . . $enable_lua])
6991 AC_MSG_RESULT([    lvm . . . . . . . . . $enable_lvm])
6992 AC_MSG_RESULT([    madwifi . . . . . . . $enable_madwifi])
6993 AC_MSG_RESULT([    match_empty_counter . $enable_match_empty_counter])
6994 AC_MSG_RESULT([    match_hashed  . . . . $enable_match_hashed])
6995 AC_MSG_RESULT([    match_regex . . . . . $enable_match_regex])
6996 AC_MSG_RESULT([    match_timediff  . . . $enable_match_timediff])
6997 AC_MSG_RESULT([    match_value . . . . . $enable_match_value])
6998 AC_MSG_RESULT([    mbmon . . . . . . . . $enable_mbmon])
6999 AC_MSG_RESULT([    mcelog  . . . . . . . $enable_mcelog])
7000 AC_MSG_RESULT([    md  . . . . . . . . . $enable_md])
7001 AC_MSG_RESULT([    memcachec . . . . . . $enable_memcachec])
7002 AC_MSG_RESULT([    memcached . . . . . . $enable_memcached])
7003 AC_MSG_RESULT([    memory  . . . . . . . $enable_memory])
7004 AC_MSG_RESULT([    mic . . . . . . . . . $enable_mic])
7005 AC_MSG_RESULT([    modbus  . . . . . . . $enable_modbus])
7006 AC_MSG_RESULT([    mqtt  . . . . . . . . $enable_mqtt])
7007 AC_MSG_RESULT([    multimeter  . . . . . $enable_multimeter])
7008 AC_MSG_RESULT([    mysql . . . . . . . . $enable_mysql])
7009 AC_MSG_RESULT([    netapp  . . . . . . . $enable_netapp])
7010 AC_MSG_RESULT([    netlink . . . . . . . $enable_netlink])
7011 AC_MSG_RESULT([    network . . . . . . . $enable_network])
7012 AC_MSG_RESULT([    nfs . . . . . . . . . $enable_nfs])
7013 AC_MSG_RESULT([    nginx . . . . . . . . $enable_nginx])
7014 AC_MSG_RESULT([    notify_desktop  . . . $enable_notify_desktop])
7015 AC_MSG_RESULT([    notify_email  . . . . $enable_notify_email])
7016 AC_MSG_RESULT([    notify_nagios . . . . $enable_notify_nagios])
7017 AC_MSG_RESULT([    ntpd  . . . . . . . . $enable_ntpd])
7018 AC_MSG_RESULT([    numa  . . . . . . . . $enable_numa])
7019 AC_MSG_RESULT([    nut . . . . . . . . . $enable_nut])
7020 AC_MSG_RESULT([    olsrd . . . . . . . . $enable_olsrd])
7021 AC_MSG_RESULT([    onewire . . . . . . . $enable_onewire])
7022 AC_MSG_RESULT([    openldap  . . . . . . $enable_openldap])
7023 AC_MSG_RESULT([    openvpn . . . . . . . $enable_openvpn])
7024 AC_MSG_RESULT([    oracle  . . . . . . . $enable_oracle])
7025 AC_MSG_RESULT([    ovs_events  . . . . . $enable_ovs_events])
7026 AC_MSG_RESULT([    ovs_stats . . . . . . $enable_ovs_stats])
7027 AC_MSG_RESULT([    perl  . . . . . . . . $enable_perl])
7028 AC_MSG_RESULT([    pf  . . . . . . . . . $enable_pf])
7029 AC_MSG_RESULT([    pinba . . . . . . . . $enable_pinba])
7030 AC_MSG_RESULT([    ping  . . . . . . . . $enable_ping])
7031 AC_MSG_RESULT([    postgresql  . . . . . $enable_postgresql])
7032 AC_MSG_RESULT([    powerdns  . . . . . . $enable_powerdns])
7033 AC_MSG_RESULT([    processes . . . . . . $enable_processes])
7034 AC_MSG_RESULT([    protocols . . . . . . $enable_protocols])
7035 AC_MSG_RESULT([    python  . . . . . . . $enable_python])
7036 AC_MSG_RESULT([    redis . . . . . . . . $enable_redis])
7037 AC_MSG_RESULT([    routeros  . . . . . . $enable_routeros])
7038 AC_MSG_RESULT([    rrdcached . . . . . . $enable_rrdcached])
7039 AC_MSG_RESULT([    rrdtool . . . . . . . $enable_rrdtool])
7040 AC_MSG_RESULT([    sensors . . . . . . . $enable_sensors])
7041 AC_MSG_RESULT([    serial  . . . . . . . $enable_serial])
7042 AC_MSG_RESULT([    sigrok  . . . . . . . $enable_sigrok])
7043 AC_MSG_RESULT([    smart . . . . . . . . $enable_smart])
7044 AC_MSG_RESULT([    snmp  . . . . . . . . $enable_snmp])
7045 AC_MSG_RESULT([    snmp_agent  . . . . . $enable_snmp_agent])
7046 AC_MSG_RESULT([    statsd  . . . . . . . $enable_statsd])
7047 AC_MSG_RESULT([    swap  . . . . . . . . $enable_swap])
7048 AC_MSG_RESULT([    synproxy  . . . . . . $enable_synproxy])
7049 AC_MSG_RESULT([    syslog  . . . . . . . $enable_syslog])
7050 AC_MSG_RESULT([    table . . . . . . . . $enable_table])
7051 AC_MSG_RESULT([    tail_csv  . . . . . . $enable_tail_csv])
7052 AC_MSG_RESULT([    tail  . . . . . . . . $enable_tail])
7053 AC_MSG_RESULT([    tape  . . . . . . . . $enable_tape])
7054 AC_MSG_RESULT([    target_notification . $enable_target_notification])
7055 AC_MSG_RESULT([    target_replace  . . . $enable_target_replace])
7056 AC_MSG_RESULT([    target_scale  . . . . $enable_target_scale])
7057 AC_MSG_RESULT([    target_set  . . . . . $enable_target_set])
7058 AC_MSG_RESULT([    target_v5upgrade  . . $enable_target_v5upgrade])
7059 AC_MSG_RESULT([    tcpconns  . . . . . . $enable_tcpconns])
7060 AC_MSG_RESULT([    teamspeak2  . . . . . $enable_teamspeak2])
7061 AC_MSG_RESULT([    ted . . . . . . . . . $enable_ted])
7062 AC_MSG_RESULT([    thermal . . . . . . . $enable_thermal])
7063 AC_MSG_RESULT([    threshold . . . . . . $enable_threshold])
7064 AC_MSG_RESULT([    tokyotyrant . . . . . $enable_tokyotyrant])
7065 AC_MSG_RESULT([    turbostat . . . . . . $enable_turbostat])
7066 AC_MSG_RESULT([    unixsock  . . . . . . $enable_unixsock])
7067 AC_MSG_RESULT([    uptime  . . . . . . . $enable_uptime])
7068 AC_MSG_RESULT([    users . . . . . . . . $enable_users])
7069 AC_MSG_RESULT([    uuid  . . . . . . . . $enable_uuid])
7070 AC_MSG_RESULT([    varnish . . . . . . . $enable_varnish])
7071 AC_MSG_RESULT([    virt  . . . . . . . . $enable_virt])
7072 AC_MSG_RESULT([    vmem  . . . . . . . . $enable_vmem])
7073 AC_MSG_RESULT([    vserver . . . . . . . $enable_vserver])
7074 AC_MSG_RESULT([    wireless  . . . . . . $enable_wireless])
7075 AC_MSG_RESULT([    write_graphite  . . . $enable_write_graphite])
7076 AC_MSG_RESULT([    write_http  . . . . . $enable_write_http])
7077 AC_MSG_RESULT([    write_kafka . . . . . $enable_write_kafka])
7078 AC_MSG_RESULT([    write_log . . . . . . $enable_write_log])
7079 AC_MSG_RESULT([    write_mongodb . . . . $enable_write_mongodb])
7080 AC_MSG_RESULT([    write_prometheus. . . $enable_write_prometheus])
7081 AC_MSG_RESULT([    write_redis . . . . . $enable_write_redis])
7082 AC_MSG_RESULT([    write_riemann . . . . $enable_write_riemann])
7083 AC_MSG_RESULT([    write_sensu . . . . . $enable_write_sensu])
7084 AC_MSG_RESULT([    write_tsdb  . . . . . $enable_write_tsdb])
7085 AC_MSG_RESULT([    xencpu  . . . . . . . $enable_xencpu])
7086 AC_MSG_RESULT([    xmms  . . . . . . . . $enable_xmms])
7087 AC_MSG_RESULT([    zfs_arc . . . . . . . $enable_zfs_arc])
7088 AC_MSG_RESULT([    zone  . . . . . . . . $enable_zone])
7089 AC_MSG_RESULT([    zookeeper . . . . . . $enable_zookeeper])
7090 AC_MSG_RESULT()
7091
7092 if test "x$dependency_error" = "xyes"; then
7093   AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
7094 fi
7095
7096 if test "x$dependency_warning" = "xyes"; then
7097   AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
7098 fi
7099
7100 # vim: set fdm=marker sw=2 sts=2 ts=2 et :