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