Merge pull request #2618 from ajssmith/amqp1_dev1_branch
[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-libqpid_proton {{{
4723 AC_ARG_WITH([libqpid_proton],
4724   [AS_HELP_STRING([--with-libqpid_proton@<:@=PREFIX@:>@], [Path to libqpid_proton.])],
4725   [
4726     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4727       with_libqpid_proton_cppflags="-I$withval/include"
4728       with_libqpid_proton_ldflags="-L$withval/lib"
4729       with_libqpid_proton="yes"
4730     else
4731       with_libqpid_proton="$withval"
4732     fi
4733   ],
4734   [with_libqpid_proton="yes"]
4735 )
4736
4737 if test "x$with_libqpid_proton" = "xyes"; then
4738   SAVE_CPPFLAGS="$CPPFLAGS"
4739   CPPFLAGS="$CPPFLAGS $with_libqpid_proton_cppflags"
4740
4741   AC_CHECK_HEADERS([proton/proactor.h],
4742     [with_libqpid_proton="yes"],
4743     [with_libqpid_proton="no (proton/proactor.h not found)"]
4744   )
4745
4746   CPPFLAGS="$SAVE_CPPFLAGS"
4747 fi
4748
4749 if test "x$with_libqpid_proton" = "xyes"; then
4750   SAVE_LDFLAGS="$LDFLAGS"
4751   LDFLAGS="$LDFLAGS $with_libqpid_proton_ldflags"
4752
4753   AC_CHECK_LIB([qpid-proton], [pn_connection],
4754     [with_libqpid_proton="yes"],
4755     [with_libqpid_proton="no (Symbol 'pn_connection' not found)"])
4756
4757   LDFLAGS="$SAVE_LDFLAGS"
4758 fi
4759
4760 if test "x$with_libqpid_proton" = "xyes"; then
4761   BUILD_WITH_LIBQPIDPROTON_CPPFLAGS="$with_libqpid_proton_cppflags"
4762   BUILD_WITH_LIBQPIDPROTON_LDFLAGS="$with_libqpid_proton_ldflags"
4763   BUILD_WITH_LIBQPIDPROTON_LIBS="-lqpid-proton"
4764 fi
4765
4766 AC_SUBST(BUILD_WITH_LIBQPIDPROTON_CPPFLAGS)
4767 AC_SUBST(BUILD_WITH_LIBQPIDPROTON_LDFLAGS)
4768 AC_SUBST(BUILD_WITH_LIBQPIDPROTON_LIBS)
4769
4770 # }}}
4771
4772 # --with-librabbitmq {{{
4773 AC_ARG_WITH([librabbitmq],
4774   [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
4775   [
4776     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4777       with_librabbitmq_cppflags="-I$withval/include"
4778       with_librabbitmq_ldflags="-L$withval/lib"
4779       with_librabbitmq="yes"
4780     else
4781       with_librabbitmq="$withval"
4782     fi
4783   ],
4784   [with_librabbitmq="yes"]
4785 )
4786
4787 if test "x$with_librabbitmq" = "xyes"; then
4788   SAVE_CPPFLAGS="$CPPFLAGS"
4789   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4790
4791   AC_CHECK_HEADERS([amqp.h],
4792     [with_librabbitmq="yes"],
4793     [with_librabbitmq="no (amqp.h not found)"]
4794   )
4795
4796   CPPFLAGS="$SAVE_CPPFLAGS"
4797 fi
4798
4799 if test "x$with_librabbitmq" = "xyes"; then
4800   # librabbitmq up to version 0.9.1 provides "library_errno", later
4801   # versions use "library_error". The library does not provide a version
4802   # macro :(.
4803
4804   SAVE_CPPFLAGS="$CPPFLAGS"
4805   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4806
4807   AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],
4808     [],
4809     [],
4810     [[
4811       #include <stdlib.h>
4812       #include <stdio.h>
4813       #include <stdint.h>
4814       #include <inttypes.h>
4815       #include <amqp.h>
4816     ]]
4817   )
4818   CPPFLAGS="$SAVE_CPPFLAGS"
4819
4820   SAVE_LDFLAGS="$LDFLAGS"
4821   LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
4822
4823   AC_CHECK_LIB([rabbitmq], [amqp_basic_publish],
4824     [with_librabbitmq="yes"],
4825     [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"]
4826   )
4827
4828   LDFLAGS="$SAVE_LDFLAGS"
4829 fi
4830
4831 if test "x$with_librabbitmq" = "xyes"; then
4832   SAVE_CPPFLAGS="$CPPFLAGS"
4833   SAVE_LDFLAGS="$LDFLAGS"
4834   SAVE_LIBS="$LIBS"
4835   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4836   LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
4837   LIBS="-lrabbitmq"
4838
4839   AC_CHECK_HEADERS([amqp_tcp_socket.h amqp_socket.h])
4840   AC_CHECK_FUNC([amqp_tcp_socket_new],
4841     [
4842       AC_DEFINE([HAVE_AMQP_TCP_SOCKET], [1],
4843         [Define if librabbitmq provides the new TCP socket interface.])
4844     ]
4845   )
4846
4847   AC_CHECK_DECLS([amqp_socket_close],
4848     [],
4849     [],
4850     [[
4851       #include <amqp.h>
4852       #ifdef HAVE_AMQP_TCP_SOCKET_H
4853       # include <amqp_tcp_socket.h>
4854       #endif
4855       #ifdef HAVE_AMQP_SOCKET_H
4856       # include <amqp_socket.h>
4857       #endif
4858     ]]
4859   )
4860
4861   CPPFLAGS="$SAVE_CPPFLAGS"
4862   LDFLAGS="$SAVE_LDFLAGS"
4863   LIBS="$SAVE_LIBS"
4864 fi
4865
4866 if test "x$with_librabbitmq" = "xyes"; then
4867   BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
4868   BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
4869   BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
4870 fi
4871
4872 AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
4873 AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
4874 AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
4875
4876 # }}}
4877
4878 # --with-librdkafka {{{
4879 AC_ARG_WITH([librdkafka],
4880   [AS_HELP_STRING([--with-librdkafka@<:@=PREFIX@:>@], [Path to librdkafka.])],
4881   [
4882     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4883       with_librdkafka_cppflags="-I$withval/include"
4884       with_librdkafka_ldflags="-L$withval/lib"
4885       with_librdkafka_rpath="$withval/lib"
4886       with_librdkafka="yes"
4887     else
4888       with_librdkafka="$withval"
4889     fi
4890   ],
4891   [with_librdkafka="yes"]
4892 )
4893
4894 if test "x$with_librdkafka" = "xyes"; then
4895   SAVE_CPPFLAGS="$CPPFLAGS"
4896   CPPFLAGS="$CPPFLAGS $with_librdkafka_cppflags"
4897
4898   AC_CHECK_HEADERS([librdkafka/rdkafka.h],
4899     [with_librdkafka="yes"],
4900     [with_librdkafka="no (librdkafka/rdkafka.h not found)"]
4901   )
4902
4903   CPPFLAGS="$SAVE_CPPFLAGS"
4904 fi
4905
4906 if test "x$with_librdkafka" = "xyes"; then
4907   SAVE_LDFLAGS="$LDFLAGS"
4908   LDFLAGS="$LDFLAGS $with_librdkafka_ldflags"
4909
4910   AC_CHECK_LIB([rdkafka], [rd_kafka_new],
4911     [with_librdkafka="yes"],
4912     [with_librdkafka="no (Symbol 'rd_kafka_new' not found)"])
4913
4914   AC_CHECK_LIB([rdkafka], [rd_kafka_conf_set_log_cb],
4915     [with_librdkafka_log_cb="yes"],
4916     [with_librdkafka_log_cb="no"])
4917
4918   AC_CHECK_LIB([rdkafka], [rd_kafka_set_logger],
4919     [with_librdkafka_logger="yes"],
4920     [with_librdkafka_logger="no"]
4921   )
4922
4923   LDFLAGS="$SAVE_LDFLAGS"
4924 fi
4925
4926 if test "x$with_librdkafka" = "xyes"; then
4927   BUILD_WITH_LIBRDKAFKA_CPPFLAGS="$with_librdkafka_cppflags"
4928   BUILD_WITH_LIBRDKAFKA_LDFLAGS="$with_librdkafka_ldflags"
4929
4930   if test "x$with_librdkafka_rpath" != "x"; then
4931     BUILD_WITH_LIBRDKAFKA_LIBS="-Wl,-rpath,$with_librdkafka_rpath -lrdkafka"
4932   else
4933     BUILD_WITH_LIBRDKAFKA_LIBS="-lrdkafka"
4934   fi
4935
4936   if test "x$with_librdkafka_log_cb" = "xyes"; then
4937     AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.])
4938   else if test "x$with_librdkafka_logger" = "xyes"; then
4939     AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.])
4940   fi; fi
4941 fi
4942
4943 AC_SUBST([BUILD_WITH_LIBRDKAFKA_CPPFLAGS])
4944 AC_SUBST([BUILD_WITH_LIBRDKAFKA_LDFLAGS])
4945 AC_SUBST([BUILD_WITH_LIBRDKAFKA_LIBS])
4946 # }}}
4947
4948 # --with-librouteros {{{
4949 AC_ARG_WITH([librouteros],
4950   [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
4951   [
4952     if test "x$withval" = "xyes" || test "x$withval" = "xno"; then
4953       with_librouteros="$witval"
4954     else
4955       with_librouteros_cppflags="-I$withval/include"
4956       with_librouteros_ldflags="-L$withval/lib"
4957       with_librouteros="yes"
4958    fi
4959   ],
4960   [with_librouteros="yes"]
4961 )
4962
4963 if test "x$with_librouteros" = "xyes"; then
4964   SAVE_CPPFLAGS="$CPPFLAGS"
4965   CPPFLAGS="$CPPFLAGS $with_librouteros_cppflags"
4966
4967   AC_CHECK_HEADERS([routeros_api.h],
4968     [with_librouteros="yes"],
4969     [with_librouteros="no (routeros_api.h not found)"]
4970   )
4971
4972   CPPFLAGS="$SAVE_CPPFLAGS"
4973 fi
4974
4975 if test "x$with_librouteros" = "xyes"; then
4976   SAVE_LDFLAGS="$LDFLAGS"
4977   LDFLAGS="$LDFLAGS $with_librouteros_ldflags"
4978
4979   AC_CHECK_LIB([routeros], [ros_interface],
4980     [with_librouteros="yes"],
4981     [with_librouteros="no (symbol 'ros_interface' not found)"]
4982   )
4983
4984   LDFLAGS="$SAVE_LDFLAGS"
4985 fi
4986
4987 if test "x$with_librouteros" = "xyes"; then
4988   BUILD_WITH_LIBROUTEROS_CPPFLAGS="$with_librouteros_cppflags"
4989   BUILD_WITH_LIBROUTEROS_LDFLAGS="$with_librouteros_ldflags"
4990 fi
4991
4992 AC_SUBST([BUILD_WITH_LIBROUTEROS_CPPFLAGS])
4993 AC_SUBST([BUILD_WITH_LIBROUTEROS_LDFLAGS])
4994 # }}}
4995
4996 # --with-librrd {{{
4997 librrd_threadsafe="no"
4998 librrd_rrdc_update="no"
4999 AC_ARG_WITH([librrd],
5000   [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
5001   [
5002     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5003       librrd_cflags="-I$withval/include"
5004       librrd_ldflags="-L$withval/lib"
5005       with_librrd="yes"
5006     else
5007       with_librrd="$withval"
5008     fi
5009   ],
5010   [with_librrd="yes"]
5011 )
5012
5013 if test "x$with_librrd" = "xyes"; then
5014   SAVE_LDFLAGS="$LDFLAGS"
5015   LDFLAGS="$LDFLAGS $librrd_ldflags"
5016   PKG_CHECK_MODULES([RRD], [librrd >= 1.6.0],
5017     [
5018       AC_CHECK_LIB([rrd], [rrd_update_r],
5019         [librrd_threadsafe="yes"],
5020         [:]
5021       )
5022       AC_CHECK_LIB([rrd], [rrdc_update],
5023         [librrd_rrdc_update="yes"],
5024         [:]
5025       )
5026     ],[:]
5027   )
5028   LDFLAGS="$SAVE_LDFLAGS"
5029
5030   SAVE_CPPFLAGS="$CPPFLAGS"
5031   CPPFLAGS="$CPPFLAGS $RRD_CFLAGS $librrd_cflags"
5032
5033   AC_CHECK_HEADERS([rrd.h],, [with_librrd="no (rrd.h not found)"])
5034
5035   CPPFLAGS="$SAVE_CPPFLAGS"
5036 fi
5037
5038 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"; then
5039   SAVE_LDFLAGS="$LDFLAGS"
5040   LDFLAGS="$LDFLAGS $librrd_ldflags"
5041
5042   AC_CHECK_LIB([rrd_th], [rrd_update_r],
5043     [
5044       librrd_ldflags="$librrd_ldflags -lrrd_th"
5045       librrd_threadsafe="yes"
5046       AC_CHECK_LIB([rrd_th], [rrdc_update],
5047         [librrd_rrdc_update="yes"],
5048         [:],
5049       )
5050     ],
5051     [:]
5052   )
5053   LDFLAGS="$SAVE_LDFLAGS"
5054 fi
5055
5056 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"; then
5057   SAVE_LDFLAGS="$LDFLAGS"
5058   LDFLAGS="$LDFLAGS $librrd_ldflags"
5059
5060   AC_CHECK_LIB([rrd], [rrd_update],
5061     [
5062       librrd_ldflags="$librrd_ldflags -lrrd"
5063       AC_CHECK_LIB([rrd], [rrdc_update],
5064         [librrd_rrdc_update="yes"],
5065         [:]
5066       )
5067     ],
5068     [with_librrd="no (symbol 'rrd_update' not found)"]
5069   )
5070   LDFLAGS="$SAVE_LDFLAGS"
5071 fi
5072
5073 if test "x$with_librrd" = "xyes"; then
5074   BUILD_WITH_LIBRRD_CFLAGS="$RRD_CFLAGS $librrd_cflags"
5075   BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
5076   BUILD_WITH_LIBRRD_LIBS="$RRD_LIBS"
5077 fi
5078
5079 if test "x$librrd_threadsafe" = "xyes"; then
5080   AC_DEFINE([HAVE_THREADSAFE_LIBRRD], [1],
5081     [Define to 1 if the rrd library is thread-safe]
5082   )
5083 fi
5084
5085 AC_SUBST([BUILD_WITH_LIBRRD_CFLAGS])
5086 AC_SUBST([BUILD_WITH_LIBRRD_LDFLAGS])
5087 AC_SUBST([BUILD_WITH_LIBRRD_LIBS])
5088 # }}}
5089
5090 # --with-libsensors {{{
5091 AC_ARG_WITH([libsensors],
5092   [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
5093   [
5094     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5095       with_libsensors="$withval"
5096     else
5097       with_sensors_cppflags="-I$withval/include"
5098       with_sensors_ldflags="-L$withval/lib"
5099       with_libsensors="yes"
5100     fi
5101   ],
5102   [
5103     if test "x$ac_system" = "xLinux"; then
5104       with_libsensors="yes"
5105     else
5106       with_libsensors="no (Linux only library)"
5107     fi
5108   ]
5109 )
5110
5111 if test "x$with_libsensors" = "xyes"; then
5112   SAVE_CPPFLAGS="$CPPFLAGS"
5113   CPPFLAGS="$CPPFLAGS $with_sensors_cppflags"
5114
5115   AC_CHECK_HEADERS([sensors/sensors.h],
5116     [with_libsensors="yes"],
5117     [with_libsensors="no (sensors/sensors.h not found)"]
5118   )
5119
5120   CPPFLAGS="$SAVE_CPPFLAGS"
5121 fi
5122
5123 if test "x$with_libsensors" = "xyes"; then
5124   SAVE_LDFLAGS="$LDFLAGS"
5125   LDFLAGS="$LDFLAGS $with_sensors_ldflags"
5126
5127   AC_CHECK_LIB([sensors], [sensors_init],
5128     [with_libsensors="yes"],
5129     [with_libsensors="no (libsensors not found)"]
5130   )
5131
5132   LDFLAGS="$SAVE_LDFLAGS"
5133 fi
5134
5135 if test "x$with_libsensors" = "xyes"; then
5136   BUILD_WITH_LIBSENSORS_CPPFLAGS="$with_sensors_cppflags"
5137   BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
5138   BUILD_WITH_LIBSENSORS_LIBS="-lsensors"
5139 fi
5140
5141 AC_SUBST([BUILD_WITH_LIBSENSORS_CPPFLAGS])
5142 AC_SUBST([BUILD_WITH_LIBSENSORS_LDFLAGS])
5143 AC_SUBST([BUILD_WITH_LIBSENSORS_LIBS])
5144
5145 # }}}
5146
5147 # libsigrok {{{
5148 AC_SUBST([LIBSIGROK_CFLAGS])
5149 AC_SUBST([LIBSIGROK_LIBS])
5150 PKG_CHECK_MODULES([LIBSIGROK], [libsigrok < 0.4],
5151   [with_libsigrok="yes"],
5152   [with_libsigrok="no (pkg-config could not find libsigrok)"]
5153 )
5154 # }}}
5155
5156 # --with-libstatgrab {{{
5157 AC_ARG_WITH([libstatgrab],
5158   [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
5159   [
5160     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5161       with_libstatgrab_cflags="-I$withval/include"
5162       with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
5163       with_libstatgrab="yes"
5164       with_libstatgrab_pkg_config="no"
5165     else
5166       with_libstatgrab="$withval"
5167       with_libstatgrab_pkg_config="yes"
5168     fi
5169   ],
5170   [
5171     with_libstatgrab="yes"
5172     with_libstatgrab_pkg_config="yes"
5173   ])
5174
5175 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes"; then
5176   AC_MSG_CHECKING([pkg-config for libstatgrab])
5177   temp_result="found"
5178   $PKG_CONFIG --exists libstatgrab 2>/dev/null
5179   if test "$?" != "0"; then
5180     with_libstatgrab_pkg_config="no"
5181     with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
5182     temp_result="not found"
5183   fi
5184   AC_MSG_RESULT([$temp_result])
5185 fi
5186
5187 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes" && test "x$with_libstatgrab_cflags" = "x"; then
5188   AC_MSG_CHECKING([for libstatgrab CFLAGS])
5189   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
5190   if test "$?" = "0"; then
5191     with_libstatgrab_cflags="$temp_result"
5192   else
5193     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
5194     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
5195   fi
5196   AC_MSG_RESULT([$temp_result])
5197 fi
5198
5199 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes" && test "x$with_libstatgrab_ldflags" = "x"; then
5200   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
5201   temp_result="`$PKG_CONFIG --libs libstatgrab`"
5202   if test "$?" = "0"
5203   then
5204     with_libstatgrab_ldflags="$temp_result"
5205   else
5206     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
5207     temp_result="$PKG_CONFIG --libs libstatgrab failed"
5208   fi
5209   AC_MSG_RESULT([$temp_result])
5210 fi
5211
5212 if test "x$with_libstatgrab" = "xyes"; then
5213   SAVE_CPPFLAGS="$CPPFLAGS"
5214   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
5215
5216   AC_CHECK_HEADERS([statgrab.h],
5217     [with_libstatgrab="yes"],
5218     [with_libstatgrab="no (statgrab.h not found)"]
5219   )
5220
5221   CPPFLAGS="$SAVE_CPPFLAGS"
5222 fi
5223
5224 if test "x$with_libstatgrab" = "xyes"; then
5225   SAVE_LDFLAGS="$LDFLAGS"
5226   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5227
5228   AC_CHECK_LIB([statgrab], [sg_init],
5229     [with_libstatgrab="yes"],
5230     [with_libstatgrab="no (symbol sg_init not found)"]
5231   )
5232
5233   LDFLAGS="$SAVE_LDFLAGS"
5234 fi
5235
5236 if test "x$with_libstatgrab" = "xyes"; then
5237   SAVE_CFLAGS="$CFLAGS"
5238   SAVE_LDFLAGS="$LDFLAGS"
5239   SAVE_LIBS="$LIBS"
5240
5241   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
5242   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5243   LIBS="-lstatgrab $LIBS"
5244
5245   AC_CACHE_CHECK([if libstatgrab >= 0.90],
5246     [c_cv_have_libstatgrab_0_90],
5247     [
5248       AC_LINK_IFELSE(
5249         [
5250           AC_LANG_PROGRAM(
5251             [[
5252               #include <stdio.h>
5253               #include <statgrab.h>
5254             ]],
5255             [[
5256               if (sg_init()) return 0;
5257             ]]
5258           )
5259         ],
5260         [c_cv_have_libstatgrab_0_90="no"],
5261         [c_cv_have_libstatgrab_0_90="yes"]
5262       )
5263     ]
5264   )
5265
5266   CFLAGS="$SAVE_CFLAGS"
5267   LDFLAGS="$SAVE_LDFLAGS"
5268   LIBS="$SAVE_LIBS"
5269 fi
5270
5271 AM_CONDITIONAL([BUILD_WITH_LIBSTATGRAB], [test "x$with_libstatgrab" = "xyes"])
5272
5273 if test "x$with_libstatgrab" = "xyes"; then
5274   AC_DEFINE([HAVE_LIBSTATGRAB], [1],
5275     [Define to 1 if you have the 'statgrab' library (-lstatgrab)]
5276   )
5277
5278   if test "x$c_cv_have_libstatgrab_0_90" = "xyes"; then
5279     AC_DEFINE([HAVE_LIBSTATGRAB_0_90], [1],
5280       [Define to 1 if libstatgrab version >= 0.90]
5281     )
5282   fi
5283
5284   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
5285   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
5286
5287 fi
5288
5289 AC_SUBST([BUILD_WITH_LIBSTATGRAB_CFLAGS])
5290 AC_SUBST([BUILD_WITH_LIBSTATGRAB_LDFLAGS])
5291 # }}}
5292
5293 # --with-libtokyotyrant {{{
5294 AC_ARG_WITH([libtokyotyrant],
5295   [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
5296   [
5297     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5298       with_libtokyotyrant="$withval"
5299     else
5300       with_libtokyotyrant_cppflags="-I$withval/include"
5301       with_libtokyotyrant_ldflags="-L$withval/include"
5302       with_libtokyotyrant_libs="-ltokyotyrant"
5303       with_libtokyotyrant="yes"
5304     fi
5305   ],
5306   [with_libtokyotyrant="yes"]
5307 )
5308
5309 if test "x$with_libtokyotyrant" = "xyes"; then
5310   if $PKG_CONFIG --exists tokyotyrant; then
5311     with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
5312     with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `$PKG_CONFIG --libs-only-L tokyotyrant`"
5313     with_libtokyotyrant_libs="$with_libtokyotyrant_libs `$PKG_CONFIG --libs-only-l tokyotyrant`"
5314   fi
5315 fi
5316
5317 if test "x$with_libtokyotyrant" = "xyes"; then
5318   SAVE_CPPFLAGS="$CPPFLAGS"
5319   CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
5320
5321   AC_CHECK_HEADERS([tcrdb.h],
5322     [with_libtokyotyrant="yes"],
5323     [with_libtokyotyrant="no (tcrdb.h not found)"]
5324   )
5325
5326   CPPFLAGS="$SAVE_CPPFLAGS"
5327 fi
5328
5329 if test "x$with_libtokyotyrant" = "xyes"; then
5330   SAVE_LDFLAGS="$LDFLAGS"
5331   LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
5332
5333   AC_CHECK_LIB([tokyotyrant], [tcrdbrnum],
5334     [with_libtokyotyrant="yes"],
5335     [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
5336     [$with_libtokyotyrant_libs]
5337   )
5338
5339   LDFLAGS="$SAVE_LDFLAGS"
5340 fi
5341
5342 if test "x$with_libtokyotyrant" = "xyes"; then
5343   BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
5344   BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
5345   BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
5346 fi
5347 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS])
5348 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS])
5349 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_LIBS])
5350 # }}}
5351
5352 # --with-libudev {{{
5353 AC_ARG_WITH([libudev],
5354   [AS_HELP_STRING([--with-libudev@<:@=PREFIX@:>@], [Path to libudev.])],
5355   [
5356     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5357       with_libudev="$withval"
5358     else
5359       with_libudev_cppflags="-I$withval/include"
5360       with_libudev_ldflags="-L$withval/lib"
5361       with_libudev="yes"
5362     fi
5363   ],
5364   [
5365     if test "x$ac_system" = "xLinux"; then
5366       with_libudev="yes"
5367     else
5368       with_libudev="no (Linux only library)"
5369     fi
5370   ]
5371 )
5372
5373 if test "x$with_libudev" = "xyes"; then
5374   SAVE_CPPFLAGS="$CPPFLAGS"
5375   CPPFLAGS="$CPPFLAGS $with_libudev_cppflags"
5376
5377   AC_CHECK_HEADERS([libudev.h],
5378     [with_libudev="yes"],
5379     [with_libudev="no (libudev.h not found)"]
5380   )
5381
5382   CPPFLAGS="$SAVE_CPPFLAGS"
5383 fi
5384
5385 if test "x$with_libudev" = "xyes"; then
5386   SAVE_LDFLAGS="$LDFLAGS"
5387   LDFLAGS="$LDFLAGS $with_libudev_ldflags"
5388
5389   AC_CHECK_LIB([udev], [udev_new],
5390     [with_libudev="yes"],
5391     [with_libudev="no (libudev not found)"]
5392   )
5393
5394   LDFLAGS="$SAVE_LDFLAGS"
5395 fi
5396
5397 if test "x$with_libudev" = "xyes"; then
5398   BUILD_WITH_LIBUDEV_CPPFLAGS="$with_libudev_cppflags"
5399   BUILD_WITH_LIBUDEV_LDFLAGS="$with_libudev_ldflags"
5400   BUILD_WITH_LIBUDEV_LIBS="-ludev"
5401 fi
5402
5403 AC_SUBST([BUILD_WITH_LIBUDEV_CPPFLAGS])
5404 AC_SUBST([BUILD_WITH_LIBUDEV_LDFLAGS])
5405 AC_SUBST([BUILD_WITH_LIBUDEV_LIBS])
5406
5407 AM_CONDITIONAL([BUILD_WITH_LIBUDEV], [test "x$with_libudev" = "xyes"])
5408 # }}}
5409
5410 # --with-libupsclient {{{
5411 with_libupsclient_config=""
5412 AC_ARG_WITH([libupsclient],
5413   [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
5414   [
5415     if test "x$withval" = "xno"; then
5416       with_libupsclient="no"
5417     else if test "x$withval" = "xyes"; then
5418       with_libupsclient="use_pkgconfig"
5419     else
5420       if test -x "$withval"; then
5421         with_libupsclient_config="$withval"
5422         with_libupsclient="use_libupsclient_config"
5423       else if test -x "$withval/bin/libupsclient-config"; then
5424         with_libupsclient_config="$withval/bin/libupsclient-config"
5425         with_libupsclient="use_libupsclient_config"
5426       else
5427         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
5428         with_libupsclient_cflags="-I$withval/include"
5429         with_libupsclient_libs="-L$withval/lib -lupsclient"
5430         with_libupsclient="yes"
5431       fi; fi
5432     fi; fi
5433   ],
5434   [with_libupsclient="use_pkgconfig"]
5435 )
5436
5437 # configure using libupsclient-config
5438 if test "x$with_libupsclient" = "xuse_libupsclient_config"; then
5439   with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
5440   if test $? -ne 0; then
5441     with_libupsclient="no ($with_libupsclient_config failed)"
5442   fi
5443   with_libupsclient_libs="`$with_libupsclient_config --libs`"
5444   if test $? -ne 0; then
5445     with_libupsclient="no ($with_libupsclient_config failed)"
5446   fi
5447 fi
5448
5449 if test "x$with_libupsclient" = "xuse_libupsclient_config"; then
5450   with_libupsclient="yes"
5451 fi
5452
5453 # configure using pkg-config
5454 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5455   AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
5456   $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
5457   if test $? -ne 0; then
5458     with_libupsclient="no (pkg-config doesn't know libupsclient)"
5459   fi
5460 fi
5461
5462 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5463   with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
5464   if test $? -ne 0; then
5465     with_libupsclient="no ($PKG_CONFIG failed)"
5466   fi
5467
5468   with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
5469   if test $? -ne 0; then
5470     with_libupsclient="no ($PKG_CONFIG failed)"
5471   fi
5472 fi
5473
5474 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5475   with_libupsclient="yes"
5476 fi
5477
5478 if test "x$with_libupsclient" = "xyes"; then
5479   SAVE_CPPFLAGS="$CPPFLAGS"
5480   CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5481
5482   AC_CHECK_HEADERS([upsclient.h],
5483     [with_libupsclient="yes"],
5484     [with_libupsclient="no (upsclient.h not found)"]
5485   )
5486
5487   CPPFLAGS="$SAVE_CPPFLAGS"
5488 fi
5489
5490 if test "x$with_libupsclient" = "xyes"; then
5491   SAVE_LDFLAGS="$LDFLAGS"
5492   LDFLAGS="$LDFLAGS $with_libupsclient_libs"
5493
5494   AC_CHECK_LIB([upsclient], [upscli_connect],
5495     [with_libupsclient="yes"],
5496     [with_libupsclient="no (symbol upscli_connect not found)"]
5497   )
5498
5499   AC_CHECK_LIB([upsclient], [upscli_init],
5500     [AC_DEFINE([HAVE_UPSCLI_INIT], [1], [Define when upscli_init() (since version 2-7) is available.])]
5501   )
5502
5503   AC_CHECK_LIB([upsclient], [upscli_tryconnect],
5504     [AC_DEFINE([HAVE_UPSCLI_TRYCONNECT], [1], [Define when upscli_tryconnect() (since version 2.6.2) is available.])]
5505   )
5506
5507   LDFLAGS="$SAVE_LDFLAGS"
5508 fi
5509
5510 if test "x$with_libupsclient" = "xyes"; then
5511   SAVE_CPPFLAGS="$CPPFLAGS"
5512   CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5513
5514   AC_CHECK_TYPES([UPSCONN_t, UPSCONN],
5515     [],
5516     [],
5517     [[
5518       #include <stdlib.h>
5519       #include <stdio.h>
5520       #include <upsclient.h>
5521     ]]
5522   )
5523
5524   CPPFLAGS="$SAVE_CPPFLAGS"
5525 fi
5526
5527 if test "x$with_libupsclient" = "xyes"; then
5528   BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
5529   BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
5530 fi
5531
5532 AC_SUBST([BUILD_WITH_LIBUPSCLIENT_CFLAGS])
5533 AC_SUBST([BUILD_WITH_LIBUPSCLIENT_LIBS])
5534 # }}}
5535
5536 # --with-libxenctrl {{{
5537 AC_ARG_WITH([libxenctrl],
5538   [AS_HELP_STRING([--with-libxenctrl@<:@=PREFIX@:>@], [Path to libxenctrl.])],
5539   [
5540     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5541       with_libxenctrl_cppflags="-I$withval/include"
5542       with_libxenctrl_ldflags="-L$withval/lib"
5543       with_libxenctrl="yes"
5544     else
5545       with_libxenctrl="$withval"
5546     fi
5547   ],
5548   [with_libxenctrl="yes"]
5549 )
5550
5551 if test "x$with_libxenctrl" = "xyes"; then
5552   SAVE_CPPFLAGS="$CPPFLAGS"
5553   CPPFLAGS="$CPPFLAGS $with_libxenctrl_cppflags"
5554
5555   AC_CHECK_HEADERS([xenctrl.h],
5556     [with_libxenctrl="yes"],
5557     [with_libxenctrl="no (xenctrl.h not found)"]
5558   )
5559
5560   CPPFLAGS="$SAVE_CPPFLAGS"
5561 fi
5562
5563 if test "x$with_libxenctrl" = "xyes"; then
5564   SAVE_LDFLAGS="$LDFLAGS"
5565   LDFLAGS="$LDFLAGS $with_libxenctrl_ldflags"
5566
5567   #Xen versions older than 3.4 has no xc_getcpuinfo()
5568   AC_CHECK_LIB([xenctrl], [xc_getcpuinfo],
5569     [with_libxenctrl="yes"],
5570     [with_libxenctrl="no (symbol 'xc_getcpuinfo' not found)"]
5571   )
5572
5573   LDFLAGS="$SAVE_LDFLAGS"
5574 fi
5575
5576 LIBXENCTL_CPPFLAGS="$with_libxenctl_cppflags"
5577 LIBXENCTL_LDFLAGS="$with_libxenctl_ldflags"
5578 AC_SUBST([LIBXENCTL_CPPFLAGS])
5579 AC_SUBST([LIBXENCTL_LDFLAGS])
5580 # }}}
5581
5582 # --with-libxmms {{{
5583 with_xmms_config="xmms-config"
5584 AC_ARG_WITH([libxmms],
5585   [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
5586   [
5587     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5588       with_libxmms="$withval"
5589     else
5590       if test -f "$withval" && test -x "$withval"; then
5591         with_xmms_config="$withval"
5592       else if test -x "$withval/bin/xmms-config"; then
5593         with_xmms_config="$withval/bin/xmms-config"
5594       fi; fi
5595       with_libxmms="yes"
5596     fi
5597   ],
5598   [with_libxmms="yes"]
5599 )
5600
5601 if test "x$with_libxmms" = "xyes"; then
5602   with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
5603   if test $? -ne 0; then
5604     with_libxmms="no"
5605   fi
5606 fi
5607
5608 if test "x$with_libxmms" = "xyes"; then
5609   with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
5610   if test $? -ne 0; then
5611     with_libxmms="no"
5612   fi
5613 fi
5614
5615 if test "x$with_libxmms" = "xyes"; then
5616   SAVE_CFLAGS="$CFLAGS"
5617   CFLAGS="$with_xmms_cflags"
5618
5619   AC_CHECK_HEADER([xmmsctrl.h],
5620     [with_libxmms="yes"],
5621     [with_libxmms="no"],
5622   )
5623
5624   CFLAGS="$SAVE_CFLAGS"
5625 fi
5626
5627 if test "x$with_libxmms" = "xyes"; then
5628   SAVE_LIBS="$LIBS"
5629   LIBS="$with_xmms_libs"
5630
5631   AC_CHECK_LIB([xmms], [xmms_remote_get_info],
5632     [with_libxmss="yes"],
5633     [with_libxmms="no"],
5634     [$with_xmms_libs]
5635
5636   )
5637
5638   LIBS="$SAVE_LIBS"
5639 fi
5640
5641 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
5642 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
5643
5644 AC_SUBST([BUILD_WITH_LIBXMMS_CFLAGS])
5645 AC_SUBST([BUILD_WITH_LIBXMMS_LIBS])
5646 # }}}
5647
5648 # --with-libyajl {{{
5649 AC_ARG_WITH([libyajl],
5650   [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
5651   [
5652     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5653       with_libyajl_cppflags="-I$withval/include"
5654       with_libyajl_ldflags="-L$withval/lib"
5655       with_libyajl="yes"
5656     else
5657       with_libyajl="$withval"
5658     fi
5659   ],
5660   [with_libyajl="yes"]
5661 )
5662
5663 if test "x$with_libyajl" = "xyes"; then
5664   SAVE_CPPFLAGS="$CPPFLAGS"
5665   CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
5666
5667   AC_CHECK_HEADERS([yajl/yajl_parse.h],
5668     [with_libyajl="yes"],
5669     [with_libyajl="no (yajl/yajl_parse.h not found)"]
5670   )
5671
5672   AC_CHECK_HEADERS([yajl/yajl_tree.h],
5673     [with_libyajl2="yes"],
5674     [with_libyajl2="no (yajl/yajl_tree.h not found)"]
5675   )
5676
5677   AC_CHECK_HEADERS([yajl/yajl_version.h])
5678
5679   CPPFLAGS="$SAVE_CPPFLAGS"
5680 fi
5681
5682 if test "x$with_libyajl" = "xyes"; then
5683   SAVE_LDFLAGS="$LDFLAGS"
5684   LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
5685
5686   AC_CHECK_LIB([yajl], [yajl_alloc],
5687     [with_libyajl="yes"],
5688     [with_libyajl="no (Symbol 'yajl_alloc' not found)"]
5689   )
5690
5691   AC_CHECK_LIB([yajl], [yajl_tree_parse],
5692     [with_libyajl2="yes"],
5693     [with_libyajl2="no (Symbol 'yajl_tree_parse' not found)"]
5694   )
5695
5696   LDFLAGS="$SAVE_LDFLAGS"
5697 fi
5698
5699 if test "x$with_libyajl" = "xyes"; then
5700   BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
5701   BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
5702   BUILD_WITH_LIBYAJL_LIBS="-lyajl"
5703   AC_DEFINE([HAVE_LIBYAJL], [1], [Define if libyajl is present and usable.])
5704 fi
5705
5706 AC_SUBST([BUILD_WITH_LIBYAJL_CPPFLAGS])
5707 AC_SUBST([BUILD_WITH_LIBYAJL_LDFLAGS])
5708 AC_SUBST([BUILD_WITH_LIBYAJL_LIBS])
5709
5710 AM_CONDITIONAL([BUILD_WITH_LIBYAJL], [test "x$with_libyajl" = "xyes"])
5711 # }}}
5712
5713 # --with-mic {{{
5714 with_mic_cppflags="-I/opt/intel/mic/sysmgmt/sdk/include"
5715 with_mic_ldflags="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
5716 with_mic_libs="-lMicAccessSDK -scif"
5717 AC_ARG_WITH([mic],
5718   [AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
5719   [
5720     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5721       with_mic="$withval"
5722     else if test -d "$with_mic/lib"; then
5723       with_mic_cppflags="-I$withval/include"
5724       with_mic_ldflags="-L$withval/lib/Linux"
5725       with_mic="yes"
5726     fi; fi
5727   ],
5728   [with_mic="yes"]
5729 )
5730
5731 if test "x$with_mic" = "xyes"; then
5732   SAVE_CPPFLAGS="$CPPFLAGS"
5733   CPPFLAGS="$CPPFLAGS $with_mic_cppflags"
5734
5735   AC_CHECK_HEADERS([MicAccessApi.h],
5736     [with_mic="yes"],
5737     [with_mic="no (MicAccessApi not found)"]
5738   )
5739
5740   CPPFLAGS="$SAVE_CPPFLAGS"
5741 fi
5742
5743 if test "x$with_mic" = "xyes"; then
5744   SAVE_LDFLAGS="$LDFLAGS"
5745   LDFLAGS="$LDFLAGS $with_mic_ldflags"
5746
5747   AC_CHECK_LIB([MicAccessSDK], [MicInitAPI],
5748     [with_mic="yes"],
5749     [with_mic="no (symbol MicInitAPI not found)"],
5750     [$PTHREAD_LIBS -lscif]
5751   )
5752
5753   LDFLAGS="$SAVE_LDFLAGS"
5754 fi
5755
5756 if test "x$with_mic" = "xyes"; then
5757   BUILD_WITH_MIC_CPPFLAGS="$with_mic_cppflags"
5758   BUILD_WITH_MIC_LDFLAGS="$with_mic_ldflags"
5759   BUILD_WITH_MIC_LIBS="$with_mic_libs"
5760 fi
5761 AC_SUBST([BUILD_WITH_MIC_CPPFLAGS])
5762 AC_SUBST([BUILD_WITH_MIC_LDFLAGS])
5763 AC_SUBST([BUILD_WITH_MIC_LIBS])
5764 #}}}
5765
5766 # --with-libvarnish {{{
5767 AC_ARG_WITH([libvarnish],
5768   [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
5769   [
5770     if test "x$withval" = "xno"; then
5771       with_libvarnish="no"
5772     else if test "x$withval" = "xyes"; then
5773       with_libvarnish="use_pkgconfig"
5774     else if test -d "$with_libvarnish/lib"; then
5775       with_libvarnish_cflags="-I$withval/include"
5776       with_libvarnish_libs="-L$withval/lib -lvarnishapi"
5777       with_libvarnish="yes"
5778     fi; fi; fi
5779   ],
5780   [with_libvarnish="use_pkgconfig"]
5781 )
5782
5783 # configure using pkg-config
5784 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5785   $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
5786   if test $? -ne 0; then
5787     with_libvarnish="no (pkg-config doesn't know varnishapi)"
5788   fi
5789 fi
5790
5791 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5792   with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
5793   if test $? -ne 0; then
5794     with_libvarnish="no ($PKG_CONFIG failed)"
5795   fi
5796
5797   with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
5798   if test $? -ne 0; then
5799     with_libvarnish="no ($PKG_CONFIG failed)"
5800   fi
5801 fi
5802 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5803   with_libvarnish="yes"
5804 fi
5805
5806 if test "x$with_libvarnish" = "xyes"; then
5807   SAVE_CPPFLAGS="$CPPFLAGS"
5808   CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
5809
5810   $PKG_CONFIG --atleast-version=5.2 'varnishapi' 2>/dev/null
5811   if test $? -eq 0; then
5812     AC_DEFINE([HAVE_VARNISH_V5], [1], [Varnish 5 API support])
5813   else
5814     AC_CHECK_HEADERS([vapi/vsc.h],
5815       [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
5816       [
5817         AC_CHECK_HEADERS([vsc.h],
5818           [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support]) ],
5819           [
5820             AC_CHECK_HEADERS([varnishapi.h],
5821               [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
5822               [with_libvarnish="no (found none of the varnish header files)"]
5823             )
5824           ]
5825         )
5826       ]
5827     )
5828   fi
5829
5830   CPPFLAGS="$SAVE_CPPFLAGS"
5831 fi
5832
5833 if test "x$with_libvarnish" = "xyes"; then
5834   BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
5835   BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
5836 fi
5837
5838 AC_SUBST([BUILD_WITH_LIBVARNISH_CFLAGS])
5839 AC_SUBST([BUILD_WITH_LIBVARNISH_LIBS])
5840 # }}}
5841
5842 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
5843 $PKG_CONFIG --exists 'libxml-2.0' 2>/dev/null
5844 if test $? -eq 0; then
5845   with_libxml2="yes"
5846 else
5847   with_libxml2="no (pkg-config doesn't know libxml-2.0)"
5848 fi
5849
5850 $PKG_CONFIG --exists libvirt 2>/dev/null
5851 if test $? = 0; then
5852   with_libvirt="yes"
5853 else
5854   with_libvirt="no (pkg-config doesn't know libvirt)"
5855 fi
5856
5857 if test "x$with_libxml2" = "xyes"; then
5858   with_libxml2_cflags="`$PKG_CONFIG --cflags libxml-2.0`"
5859   if test $? -ne 0; then
5860     with_libxml2="no"
5861   fi
5862
5863   with_libxml2_ldflags="`$PKG_CONFIG --libs libxml-2.0`"
5864   if test $? -ne 0; then
5865     with_libxml2="no"
5866   fi
5867 fi
5868
5869 if test "x$with_libxml2" = "xyes"; then
5870   SAVE_CPPFLAGS="$CPPFLAGS"
5871   CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
5872
5873   AC_CHECK_HEADERS([libxml/parser.h],
5874     [with_libxml2="yes"],
5875     [with_libxml2="no (libxml/parser.h not found)"]
5876   )
5877
5878   CPPFLAGS="$SAVE_CPPFLAGS"
5879 fi
5880
5881 if test "x$with_libxml2" = "xyes"; then
5882   SAVE_LDFLAGS="$LDFLAGS"
5883   LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
5884
5885   AC_CHECK_LIB([xml2], [xmlXPathEval],
5886     [with_libxml2="yes"],
5887     [with_libxml2="no (symbol xmlXPathEval not found)"]
5888   )
5889
5890   LDFLAGS="$SAVE_LDFLAGS"
5891 fi
5892
5893 if test "x$with_libxml2" = "xyes"; then
5894   BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
5895   BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
5896 fi
5897
5898 AC_SUBST([BUILD_WITH_LIBXML2_CFLAGS])
5899 AC_SUBST([BUILD_WITH_LIBXML2_LIBS])
5900
5901 if test "x$with_libvirt" = "xyes"; then
5902   with_libvirt_cflags="`$PKG_CONFIG --cflags libvirt`"
5903   if test $? -ne 0; then
5904     with_libvirt="no"
5905   fi
5906
5907   with_libvirt_ldflags="`$PKG_CONFIG --libs libvirt`"
5908   if test $? -ne 0; then
5909     with_libvirt="no"
5910   fi
5911 fi
5912
5913 if test "x$with_libvirt" = "xyes"; then
5914   SAVE_CPPFLAGS="$CPPFLAGS"
5915   CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
5916
5917   AC_CHECK_HEADERS([libvirt/libvirt.h],
5918     [with_libvirt="yes"],
5919     [with_libvirt="no (libvirt/libvirt.h not found)"]
5920   )
5921
5922   CPPFLAGS="$SAVE_CPPFLAGS"
5923 fi
5924
5925 if test "x$with_libvirt" = "xyes"; then
5926   SAVE_LDFLAGS="$LDFLAGS"
5927   LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
5928
5929   AC_CHECK_LIB([virt], [virDomainBlockStats],
5930     [with_libvirt="yes"],
5931     [with_libvirt="no (symbol virDomainBlockStats not found)"]
5932   )
5933
5934   LDFLAGS="$SAVE_LDFLAGS"
5935 fi
5936
5937 if test "x$with_libvirt" = "xyes"; then
5938   BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
5939   BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
5940 fi
5941
5942 AC_SUBST([BUILD_WITH_LIBVIRT_CFLAGS])
5943 AC_SUBST([BUILD_WITH_LIBVIRT_LIBS])
5944 # }}}
5945
5946 # $PKG_CONFIG --exists OpenIPMIpthread {{{
5947 with_libopenipmipthread="yes"
5948 AC_MSG_CHECKING([for libOpenIPMIpthread])
5949 $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
5950 if test $? -ne 0; then
5951   with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
5952 fi
5953 AC_MSG_RESULT([$with_libopenipmipthread])
5954
5955 if test "x$with_libopenipmipthread" = "xyes"; then
5956   AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
5957   temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
5958   if test $? -eq 0; then
5959     with_libopenipmipthread_cflags="$temp_result"
5960   else
5961     with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
5962     temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
5963   fi
5964   AC_MSG_RESULT([$temp_result])
5965 fi
5966
5967 if test "x$with_libopenipmipthread" = "xyes"; then
5968   AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
5969   temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
5970   if test $? -eq 0; then
5971     with_libopenipmipthread_ldflags="$temp_result"
5972   else
5973     with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
5974     temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
5975   fi
5976   AC_MSG_RESULT([$temp_result])
5977 fi
5978
5979 if test "x$with_libopenipmipthread" = "xyes"; then
5980   SAVE_CPPFLAGS="$CPPFLAGS"
5981   CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
5982
5983   AC_CHECK_HEADERS([OpenIPMI/ipmi_smi.h],
5984     [with_libopenipmipthread="yes"],
5985     [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
5986     [[
5987       #include <OpenIPMI/ipmiif.h>
5988       #include <OpenIPMI/ipmi_err.h>
5989       #include <OpenIPMI/ipmi_posix.h>
5990       #include <OpenIPMI/ipmi_conn.h>
5991     ]]
5992   )
5993
5994   CPPFLAGS="$SAVE_CPPFLAGS"
5995 fi
5996
5997 if test "x$with_libopenipmipthread" = "xyes"; then
5998   BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
5999   BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
6000 fi
6001
6002 AC_SUBST([BUILD_WITH_OPENIPMI_CFLAGS])
6003 AC_SUBST([BUILD_WITH_OPENIPMI_LIBS])
6004 # }}}
6005
6006 # --with-libatasmart {{{
6007 AC_ARG_WITH([libatasmart],
6008   [AS_HELP_STRING([--with-libatasmart@<:@=PREFIX@:>@], [Path to libatasmart.])],
6009   [
6010     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
6011       with_libatasmart_cppflags="-I$withval/include"
6012       with_libatasmart_ldflags="-L$withval/lib"
6013       with_libatasmart="yes"
6014     else
6015       with_libatasmart="$withval"
6016     fi
6017   ],
6018   [
6019     if test "x$ac_system" = "xLinux"; then
6020       with_libatasmart="yes"
6021     else
6022       with_libatasmart="no (Linux only library)"
6023     fi
6024   ]
6025 )
6026
6027 if test "x$with_libatasmart" = "xyes"; then
6028   SAVE_CPPFLAGS="$CPPFLAGS"
6029   CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
6030
6031   AC_CHECK_HEADERS([atasmart.h],
6032     [with_libatasmart="yes"],
6033     [with_libatasmart="no (atasmart.h not found)"])
6034
6035   CPPFLAGS="$SAVE_CPPFLAGS"
6036 fi
6037
6038 if test "x$with_libatasmart" = "xyes"; then
6039   SAVE_LDFLAGS="$LDFLAGS"
6040   LDFLAGS="$LDFLAGS $with_libatasmart_ldflags"
6041
6042   AC_CHECK_LIB([atasmart], [sk_disk_open],
6043     [with_libatasmart="yes"],
6044     [with_libatasmart="no (Symbol 'sk_disk_open' not found)"]
6045   )
6046
6047   LDFLAGS="$SAVE_LDFLAGS"
6048 fi
6049
6050 if test "x$with_libatasmart" = "xyes"; then
6051   BUILD_WITH_LIBATASMART_CPPFLAGS="$with_libatasmart_cppflags"
6052   BUILD_WITH_LIBATASMART_LDFLAGS="$with_libatasmart_ldflags"
6053   BUILD_WITH_LIBATASMART_LIBS="-latasmart"
6054 fi
6055
6056 AC_SUBST([BUILD_WITH_LIBATASMART_CPPFLAGS])
6057 AC_SUBST([BUILD_WITH_LIBATASMART_LDFLAGS])
6058 AC_SUBST([BUILD_WITH_LIBATASMART_LIBS])
6059 # }}}
6060
6061 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
6062   [with_libnotify="yes"],
6063   [with_libnotify="no (pkg-config doesn't know libnotify)"]
6064 )
6065
6066 PKG_CHECK_MODULES([LIBRIEMANN_CLIENT], [riemann-client >= 1.6.0],
6067  [with_libriemann_client="yes"],
6068  [with_libriemann_client="no (pkg-config doesn't know libriemann-client)"]
6069 )
6070
6071 # Check for enabled/disabled features
6072 #
6073
6074 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
6075 # ------------------------------------------------------------
6076 dnl
6077 m4_define([my_toupper],[m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
6078 dnl
6079 AC_DEFUN(
6080   [AC_COLLECTD],
6081   [
6082   m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
6083   m4_if(
6084     [$2],
6085     [enable],
6086     [dnl
6087     m4_define([EnDis],[disabled])dnl
6088     m4_define([YesNo],[no])dnl
6089     ],dnl
6090     [m4_if(
6091       [$2],
6092       [disable],
6093       [dnl
6094       m4_define([EnDis],[enabled])dnl
6095       m4_define([YesNo],[yes])dnl
6096       ],
6097       [dnl
6098       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
6099       ]dnl
6100     )]dnl
6101   )dnl
6102   m4_if([$3], [feature], [],
6103     [m4_if(
6104       [$3], [module], [],
6105       [dnl
6106       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
6107       ]dnl
6108     )]dnl
6109   )dnl
6110   AC_ARG_ENABLE(
6111     [$1],
6112     AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
6113     [],
6114     enable_$1='[YesNo]'dnl
6115   )# AC_ARG_ENABLE
6116   if test "x$enable_$1" = "xno"; then
6117     collectd_$1=0
6118   else
6119     if test "x$enable_$1" = "xyes"; then
6120       collectd_$1=1
6121     else
6122       AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
6123       collectd_$1=1
6124       enable_$1='yes'
6125     fi
6126   fi
6127   AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [whether or not to enable $3 $4])
6128   AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
6129   ]dnl
6130 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
6131
6132 # AC_PLUGIN(name, default, info)
6133 # ------------------------------------------------------------
6134 dnl
6135 AC_DEFUN(
6136   [AC_PLUGIN],
6137   [
6138     enable_plugin="no"
6139     force="no"
6140     AC_ARG_ENABLE([$1],
6141       [AS_HELP_STRING([--enable-$1],[$3])],
6142       [
6143         if test "x$enableval" = "xyes"; then
6144           enable_plugin="yes"
6145         else if test "x$enableval" = "xforce"; then
6146           enable_plugin="yes"
6147           force="yes"
6148         else
6149           enable_plugin="no (disabled on command line)"
6150         fi; fi
6151       ],
6152       [
6153         if test "x$enable_all_plugins" = "xauto"; then
6154           if test "x$2" = "xyes"; then
6155             enable_plugin="yes"
6156           else
6157             enable_plugin="$2"
6158           fi
6159         else
6160           enable_plugin="$enable_all_plugins"
6161         fi
6162       ]
6163     )
6164     if test "x$enable_plugin" = "xyes"; then
6165       if test "x$2" = "xyes" || test "x$force" = "xyes"; then
6166         AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
6167         if test "x$2" != "xyes"; then
6168           dependency_warning="yes"
6169         fi
6170       else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
6171         dependency_error="yes"
6172         enable_plugin="$2 (dependency error)"
6173       fi
6174     fi
6175     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), [test "x$enable_plugin" = "xyes"])
6176     enable_$1="$enable_plugin"
6177   ]
6178 )# AC_PLUGIN(name, default, info)
6179
6180 m4_divert_once([HELP_ENABLE], [
6181 collectd features:])
6182 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
6183 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
6184 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
6185 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
6186 AC_COLLECTD([werror],    [disable], [feature], [building with -Werror])
6187
6188 dependency_warning="no"
6189 dependency_error="no"
6190
6191 plugin_ascent="no"
6192 plugin_barometer="no"
6193 plugin_battery="no"
6194 plugin_bind="no"
6195 plugin_ceph="no"
6196 plugin_cgroups="no"
6197 plugin_conntrack="no"
6198 plugin_contextswitch="no"
6199 plugin_cpu="no"
6200 plugin_cpufreq="no"
6201 plugin_cpusleep="no"
6202 plugin_curl_json="no"
6203 plugin_curl_xml="no"
6204 plugin_df="no"
6205 plugin_disk="no"
6206 plugin_drbd="no"
6207 plugin_dpdkevents="no"
6208 plugin_dpdkstat="no"
6209 plugin_entropy="no"
6210 plugin_ethstat="no"
6211 plugin_fhcount="no"
6212 plugin_fscache="no"
6213 plugin_gps="no"
6214 plugin_grpc="no"
6215 plugin_hugepages="no"
6216 plugin_intel_pmu="no"
6217 plugin_intel_rdt="no"
6218 plugin_interface="no"
6219 plugin_ipc="no"
6220 plugin_ipmi="no"
6221 plugin_ipvs="no"
6222 plugin_irq="no"
6223 plugin_load="no"
6224 plugin_log_logstash="no"
6225 plugin_mcelog="no"
6226 plugin_memory="no"
6227 plugin_multimeter="no"
6228 plugin_nfs="no"
6229 plugin_numa="no"
6230 plugin_ovs_events="no"
6231 plugin_ovs_stats="no"
6232 plugin_perl="no"
6233 plugin_pinba="no"
6234 plugin_processes="no"
6235 plugin_protocols="no"
6236 plugin_python="no"
6237 plugin_serial="no"
6238 plugin_smart="no"
6239 plugin_swap="no"
6240 plugin_synproxy="no"
6241 plugin_tape="no"
6242 plugin_tcpconns="no"
6243 plugin_ted="no"
6244 plugin_thermal="no"
6245 plugin_turbostat="no"
6246 plugin_uptime="no"
6247 plugin_users="no"
6248 plugin_virt="no"
6249 plugin_vmem="no"
6250 plugin_vserver="no"
6251 plugin_wireless="no"
6252 plugin_write_prometheus="no"
6253 plugin_xencpu="no"
6254 plugin_zfs_arc="no"
6255 plugin_zone="no"
6256 plugin_zookeeper="no"
6257
6258 # Linux
6259 if test "x$ac_system" = "xLinux"; then
6260   plugin_battery="yes"
6261   plugin_cgroups="yes"
6262   plugin_conntrack="yes"
6263   plugin_contextswitch="yes"
6264   plugin_cpu="yes"
6265   plugin_cpufreq="yes"
6266   plugin_disk="yes"
6267   plugin_drbd="yes"
6268   plugin_entropy="yes"
6269   plugin_fhcount="yes"
6270   plugin_fscache="yes"
6271   plugin_hugepages="yes"
6272   plugin_interface="yes"
6273   plugin_ipc="yes"
6274   plugin_irq="yes"
6275   plugin_load="yes"
6276   plugin_lvm="yes"
6277   plugin_mcelog="yes"
6278   plugin_memory="yes"
6279   plugin_nfs="yes"
6280   plugin_numa="yes"
6281   plugin_processes="yes"
6282   plugin_protocols="yes"
6283   plugin_serial="yes"
6284   plugin_swap="yes"
6285   plugin_synproxy="yes"
6286   plugin_tcpconns="yes"
6287   plugin_thermal="yes"
6288   plugin_uptime="yes"
6289   plugin_vmem="yes"
6290   plugin_vserver="yes"
6291   plugin_wireless="yes"
6292   plugin_zfs_arc="yes"
6293
6294   if test "x$ac_cv_header_linux_ip_vs_h" = "xyes"; then
6295     plugin_ipvs="yes"
6296   fi
6297
6298   if test "x$have_cpuid_h" = "xyes"; then
6299     plugin_turbostat="yes"
6300   fi
6301
6302   if test "x$c_cv_have_clock_boottime_monotonic" = "xyes"; then
6303     plugin_cpusleep="yes"
6304   fi
6305
6306   if test "x$with_libyajl" = "xyes" && test "x$with_libyajl2" = "xyes"; then
6307     plugin_ovs_events="yes"
6308     plugin_ovs_stats="yes"
6309   fi
6310 fi
6311
6312 if test "x$ac_system" = "xOpenBSD"; then
6313   plugin_tcpconns="yes"
6314 fi
6315
6316 if test "x$ac_system" = "xNetBSD"; then
6317   plugin_disk="yes"
6318   plugin_entropy="yes"
6319   plugin_irq="yes"
6320   plugin_processes="yes"
6321 fi
6322
6323 # Mac OS X devices
6324 if test "x$with_libiokit" = "xyes"; then
6325   plugin_battery="yes"
6326   plugin_disk="yes"
6327 fi
6328
6329 # AIX
6330
6331 if test "x$ac_system" = "xAIX"; then
6332   plugin_ipc="yes"
6333   plugin_tcpconns="yes"
6334 fi
6335
6336 # FreeBSD
6337
6338 if test "x$ac_system" = "xFreeBSD"; then
6339   plugin_disk="yes"
6340   plugin_zfs_arc="yes"
6341 fi
6342
6343
6344 if test "x$with_perfstat" = "xyes"; then
6345   plugin_contextswitch="yes"
6346   plugin_cpu="yes"
6347   plugin_disk="yes"
6348   plugin_interface="yes"
6349   plugin_load="yes"
6350   plugin_memory="yes"
6351   plugin_swap="yes"
6352   plugin_uptime="yes"
6353 fi
6354
6355 if test "x$with_procinfo" = "xyes"; then
6356   plugin_processes="yes"
6357 fi
6358
6359 # Solaris
6360 if test "x$with_kstat" = "xyes"; then
6361   plugin_nfs="yes"
6362   plugin_processes="yes"
6363   plugin_uptime="yes"
6364   plugin_zfs_arc="yes"
6365   plugin_zone="yes"
6366 fi
6367
6368 if test "x$with_devinfo" = "xyes" && test "x$with_kstat" = "xyes"; then
6369   plugin_cpu="yes"
6370   plugin_disk="yes"
6371   plugin_interface="yes"
6372   plugin_memory="yes"
6373   plugin_tape="yes"
6374 fi
6375
6376 if test "x$with_libi2c" = "xyes"; then
6377   plugin_barometer="yes"
6378 fi
6379
6380
6381 # libstatgrab
6382 if test "x$with_libstatgrab" = "xyes"; then
6383   plugin_cpu="yes"
6384   plugin_disk="yes"
6385   plugin_interface="yes"
6386   plugin_load="yes"
6387   plugin_memory="yes"
6388   plugin_swap="yes"
6389   plugin_users="yes"
6390 fi
6391
6392 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"; then
6393   plugin_ascent="yes"
6394   if test "x$have_strptime" = "xyes"; then
6395     plugin_bind="yes"
6396   fi
6397 fi
6398
6399 if test "x$with_libopenipmipthread" = "xyes"; then
6400   plugin_ipmi="yes"
6401 fi
6402
6403 if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"; then
6404   plugin_curl_json="yes"
6405 fi
6406
6407 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"; then
6408   plugin_curl_xml="yes"
6409 fi
6410
6411 if test "x$with_libyajl" = "xyes"; then
6412   plugin_ceph="yes"
6413 fi
6414
6415 if test "x$have_processor_info" = "xyes"; then
6416   plugin_cpu="yes"
6417 fi
6418
6419 if test "x$have_sysctl" = "xyes"; then
6420   plugin_cpu="yes"
6421   plugin_memory="yes"
6422   plugin_uptime="yes"
6423   if test "x$ac_system" = "xDarwin"; then
6424     plugin_swap="yes"
6425   fi
6426 fi
6427
6428 if test "x$have_sysctlbyname" = "xyes"; then
6429   plugin_contextswitch="yes"
6430   plugin_cpu="yes"
6431   plugin_memory="yes"
6432   plugin_tcpconns="yes"
6433 fi
6434
6435 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"; then
6436   plugin_df="yes"
6437 fi
6438
6439 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"; then
6440   plugin_df="yes"
6441 fi
6442
6443 if test "x$c_cv_have_one_getmntent" = "xyes"; then
6444   plugin_df="yes"
6445 fi
6446
6447 if test "x$c_cv_have_getmntent_r" = "xyes"; then
6448   plugin_df="yes"
6449 fi
6450
6451 if test "x$plugin_df" = "xyes"; then
6452   plugin_df="no"
6453   if test "x$have_statfs" = "xyes"; then
6454     plugin_df="yes"
6455   fi
6456
6457   if test "x$have_statvfs" = "xyes"; then
6458     plugin_df="yes"
6459   fi
6460 fi
6461
6462 if test "x$have_linux_sockios_h" = "xyes" && test "x$have_linux_ethtool_h" = "xyes"; then
6463   plugin_ethstat="yes"
6464 fi
6465
6466 if test "x$with_libgps" = "xyes"; then
6467   plugin_gps="yes"
6468 fi
6469
6470 plugin_grpc="yes"
6471 if test "x$GRPC_CPP_PLUGIN" = "x"; then
6472   plugin_grpc="no (grpc_cpp_plugin not found)"
6473 fi
6474 if test "x$have_protoc3" != "xyes"; then
6475   plugin_grpc="no (protoc3 not found)"
6476 fi
6477 if test "x$with_libprotobuf" != "xyes"; then
6478   plugin_grpc="no (libprotobuf not found)"
6479 fi
6480 if test "x$with_libgrpcpp" != "xyes"; then
6481   plugin_grpc="no (libgrpc++ not found)"
6482 fi
6483
6484 if test "x$have_getifaddrs" = "xyes"; then
6485   plugin_interface="yes"
6486 fi
6487
6488 if test "x$have_getloadavg" = "xyes"; then
6489   plugin_load="yes"
6490 fi
6491
6492 if test "x$with_libyajl" = "xyes"; then
6493   plugin_log_logstash="yes"
6494 fi
6495
6496 if test "x$with_libperl" = "xyes" && test "x$c_cv_have_perl_ithreads" = "xyes"; then
6497   plugin_perl="yes"
6498 fi
6499
6500 if test "x$have_protoc_c" = "xyes" && test "x$with_libprotobuf_c" = "xyes"; then
6501   plugin_pinba="yes"
6502   if test "x$with_libmicrohttpd" = "xyes"; then
6503     plugin_write_prometheus="yes"
6504   fi
6505 fi
6506
6507 # Mac OS X memory interface
6508 if test "x$have_host_statistics" = "xyes"; then
6509   plugin_memory="yes"
6510 fi
6511
6512 if test "x$have_termios_h" = "xyes"; then
6513   if test "x$ac_system" != "xAIX"; then
6514     plugin_multimeter="yes"
6515   fi
6516   plugin_ted="yes"
6517 fi
6518
6519 if test "x$have_thread_info" = "xyes"; then
6520   plugin_processes="yes"
6521 fi
6522
6523 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"; then
6524   plugin_processes="yes"
6525 fi
6526
6527 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_openbsd" = "xyes"; then
6528   plugin_processes="yes"
6529 fi
6530
6531 if test "x$with_libpython" != "xno"; then
6532   plugin_python="yes"
6533 fi
6534
6535 if test "x$with_libatasmart" = "xyes" && test "x$with_libudev" = "xyes"; then
6536   plugin_smart="yes"
6537 fi
6538
6539 if test "x$with_kvm_getswapinfo" = "xyes"; then
6540   plugin_swap="yes"
6541 fi
6542
6543 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"; then
6544   plugin_swap="yes"
6545 fi
6546
6547 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes"; then
6548   plugin_swap="yes"
6549 fi
6550
6551 if test "x$with_kvm_openfiles = "xyes" && $with_kvm_nlist" = "xyes"; then
6552   plugin_tcpconns="yes"
6553 fi
6554
6555 if test "x$have_getutent" = "xyes"; then
6556   plugin_users="yes"
6557 fi
6558
6559 if test "x$have_getutxent" = "xyes"; then
6560   plugin_users="yes"
6561 fi
6562
6563 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"; then
6564   plugin_virt="yes"
6565 fi
6566
6567 if test "x$with_libxenctrl" = "xyes"; then
6568   plugin_xencpu="yes"
6569 fi
6570
6571 if test "x$with_libdpdk" = "xyes"; then
6572   plugin_dpdkevents="$dpdk_keepalive"
6573   plugin_dpdkstat="yes"
6574 fi
6575
6576 m4_divert_once([HELP_ENABLE], [
6577 collectd plugins:])
6578
6579 AC_ARG_ENABLE([all-plugins],
6580   [AS_HELP_STRING([--enable-all-plugins], [enable all plugins @<:@default=yes@:>@])],
6581   [
6582      if test "x$enableval" = "xyes"; then
6583        enable_all_plugins="yes"
6584      else if test "x$enableval" = "xauto"; then
6585        enable_all_plugins="auto"
6586      else
6587        enable_all_plugins="no"
6588      fi; fi
6589   ],
6590   [enable_all_plugins="auto"]
6591 )
6592
6593 m4_divert_once([HELP_ENABLE], [])
6594
6595 AC_PLUGIN([aggregation],         [yes],                     [Aggregation plugin])
6596 AC_PLUGIN([amqp],                [$with_librabbitmq],       [AMQP output plugin])
6597 AC_PLUGIN([amqp1],               [$with_libqpid_proton],    [AMQP 1.0 output plugin])
6598 AC_PLUGIN([apache],              [$with_libcurl],           [Apache httpd statistics])
6599 AC_PLUGIN([apcups],              [yes],                     [Statistics of UPSes by APC])
6600 AC_PLUGIN([apple_sensors],       [$with_libiokit],          [Apple hardware sensors])
6601 AC_PLUGIN([aquaero],             [$with_libaquaero5],       [Aquaero hardware sensors])
6602 AC_PLUGIN([ascent],              [$plugin_ascent],          [AscentEmu player statistics])
6603 AC_PLUGIN([barometer],           [$plugin_barometer],       [Barometer sensor on I2C])
6604 AC_PLUGIN([battery],             [$plugin_battery],         [Battery statistics])
6605 AC_PLUGIN([bind],                [$plugin_bind],            [ISC Bind nameserver statistics])
6606 AC_PLUGIN([ceph],                [$plugin_ceph],            [Ceph daemon statistics])
6607 AC_PLUGIN([cgroups],             [$plugin_cgroups],         [CGroups CPU usage accounting])
6608 AC_PLUGIN([chrony],              [yes],                     [Chrony statistics])
6609 AC_PLUGIN([conntrack],           [$plugin_conntrack],       [nf_conntrack statistics])
6610 AC_PLUGIN([contextswitch],       [$plugin_contextswitch],   [context switch statistics])
6611 AC_PLUGIN([cpu],                 [$plugin_cpu],             [CPU usage statistics])
6612 AC_PLUGIN([cpufreq],             [$plugin_cpufreq],         [CPU frequency statistics])
6613 AC_PLUGIN([cpusleep],            [$plugin_cpusleep],        [CPU sleep statistics])
6614 AC_PLUGIN([csv],                 [yes],                     [CSV output plugin])
6615 AC_PLUGIN([curl],                [$with_libcurl],           [CURL generic web statistics])
6616 AC_PLUGIN([curl_json],           [$plugin_curl_json],       [CouchDB statistics])
6617 AC_PLUGIN([curl_xml],            [$plugin_curl_xml],        [CURL generic xml statistics])
6618 AC_PLUGIN([dbi],                 [$with_libdbi],            [General database statistics])
6619 AC_PLUGIN([df],                  [$plugin_df],              [Filesystem usage statistics])
6620 AC_PLUGIN([disk],                [$plugin_disk],            [Disk usage statistics])
6621 AC_PLUGIN([dns],                 [$with_libpcap],           [DNS traffic analysis])
6622 AC_PLUGIN([dpdkevents],          [$plugin_dpdkevents],      [Events from DPDK])
6623 AC_PLUGIN([dpdkstat],            [$plugin_dpdkstat],        [Stats from DPDK])
6624 AC_PLUGIN([drbd],                [$plugin_drbd],            [DRBD statistics])
6625 AC_PLUGIN([email],               [yes],                     [EMail statistics])
6626 AC_PLUGIN([entropy],             [$plugin_entropy],         [Entropy statistics])
6627 AC_PLUGIN([ethstat],             [$plugin_ethstat],         [Stats from NIC driver])
6628 AC_PLUGIN([exec],                [yes],                     [Execution of external programs])
6629 AC_PLUGIN([fhcount],             [$plugin_fhcount],         [File handles statistics])
6630 AC_PLUGIN([filecount],           [yes],                     [Count files in directories])
6631 AC_PLUGIN([fscache],             [$plugin_fscache],         [fscache statistics])
6632 AC_PLUGIN([gmond],               [$with_libganglia],        [Ganglia plugin])
6633 AC_PLUGIN([gps],                 [$plugin_gps],             [GPS plugin])
6634 AC_PLUGIN([grpc],                [$plugin_grpc],            [gRPC plugin])
6635 AC_PLUGIN([hddtemp],             [yes],                     [Query hddtempd])
6636 AC_PLUGIN([hugepages],           [$plugin_hugepages],       [Hugepages statistics])
6637 AC_PLUGIN([intel_pmu],           [$with_libjevents],        [Intel performance monitor plugin])
6638 AC_PLUGIN([intel_rdt],           [$with_libpqos],           [Intel RDT monitor plugin])
6639 AC_PLUGIN([interface],           [$plugin_interface],       [Interface traffic statistics])
6640 AC_PLUGIN([ipc],                 [$plugin_ipc],             [IPC statistics])
6641 AC_PLUGIN([ipmi],                [$plugin_ipmi],            [IPMI sensor statistics])
6642 AC_PLUGIN([iptables],            [$with_libiptc],           [IPTables rule counters])
6643 AC_PLUGIN([ipvs],                [$plugin_ipvs],            [IPVS connection statistics])
6644 AC_PLUGIN([irq],                 [$plugin_irq],             [IRQ statistics])
6645 AC_PLUGIN([java],                [$with_java],              [Embed the Java Virtual Machine])
6646 AC_PLUGIN([load],                [$plugin_load],            [System load])
6647 AC_PLUGIN([log_logstash],        [$plugin_log_logstash],    [Logstash json_event compatible logging])
6648 AC_PLUGIN([logfile],             [yes],                     [File logging plugin])
6649 AC_PLUGIN([lpar],                [$with_perfstat],          [AIX logical partitions statistics])
6650 AC_PLUGIN([lua],                 [$with_liblua],            [Lua plugin])
6651 AC_PLUGIN([lvm],                 [$with_liblvm2app],        [LVM statistics])
6652 AC_PLUGIN([madwifi],             [$have_linux_wireless_h],  [Madwifi wireless statistics])
6653 AC_PLUGIN([match_empty_counter], [yes],                     [The empty counter match])
6654 AC_PLUGIN([match_hashed],        [yes],                     [The hashed match])
6655 AC_PLUGIN([match_regex],         [yes],                     [The regex match])
6656 AC_PLUGIN([match_timediff],      [yes],                     [The timediff match])
6657 AC_PLUGIN([match_value],         [yes],                     [The value match])
6658 AC_PLUGIN([mbmon],               [yes],                     [Query mbmond])
6659 AC_PLUGIN([mcelog],              [$plugin_mcelog],          [Machine Check Exceptions notifications])
6660 AC_PLUGIN([md],                  [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
6661 AC_PLUGIN([memcachec],           [$with_libmemcached],      [memcachec statistics])
6662 AC_PLUGIN([memcached],           [yes],                     [memcached statistics])
6663 AC_PLUGIN([memory],              [$plugin_memory],          [Memory usage])
6664 AC_PLUGIN([mic],                 [$with_mic],               [Intel Many Integrated Core stats])
6665 AC_PLUGIN([modbus],              [$with_libmodbus],         [Modbus plugin])
6666 AC_PLUGIN([mqtt],                [$with_libmosquitto],      [MQTT output plugin])
6667 AC_PLUGIN([multimeter],          [$plugin_multimeter],      [Read multimeter values])
6668 AC_PLUGIN([mysql],               [$with_libmysql],          [MySQL statistics])
6669 AC_PLUGIN([netapp],              [$with_libnetapp],         [NetApp plugin])
6670 AC_PLUGIN([netlink],             [$with_libmnl],            [Enhanced Linux network statistics])
6671 AC_PLUGIN([network],             [yes],                     [Network communication plugin])
6672 AC_PLUGIN([nfs],                 [$plugin_nfs],             [NFS statistics])
6673 AC_PLUGIN([nginx],               [$with_libcurl],           [nginx statistics])
6674 AC_PLUGIN([notify_desktop],      [$with_libnotify],         [Desktop notifications])
6675 AC_PLUGIN([notify_email],        [$with_libesmtp],          [Email notifier])
6676 AC_PLUGIN([notify_nagios],       [yes],                     [Nagios notification plugin])
6677 AC_PLUGIN([ntpd],                [yes],                     [NTPd statistics])
6678 AC_PLUGIN([numa],                [$plugin_numa],            [NUMA virtual memory statistics])
6679 AC_PLUGIN([nut],                 [$with_libupsclient],      [Network UPS tools statistics])
6680 AC_PLUGIN([olsrd],               [yes],                     [olsrd statistics])
6681 AC_PLUGIN([onewire],             [$with_libowcapi],         [OneWire sensor statistics])
6682 AC_PLUGIN([openldap],            [$with_libldap],           [OpenLDAP statistics])
6683 AC_PLUGIN([openvpn],             [yes],                     [OpenVPN client statistics])
6684 AC_PLUGIN([oracle],              [$with_oracle],            [Oracle plugin])
6685 AC_PLUGIN([ovs_events],          [$plugin_ovs_events],      [OVS events plugin])
6686 AC_PLUGIN([ovs_stats],           [$plugin_ovs_stats],       [OVS statistics plugin])
6687 AC_PLUGIN([perl],                [$plugin_perl],            [Embed a Perl interpreter])
6688 AC_PLUGIN([pf],                  [$have_net_pfvar_h],       [BSD packet filter (PF) statistics])
6689 # FIXME: Check for libevent, too.
6690 AC_PLUGIN([pinba],               [$plugin_pinba],           [Pinba statistics])
6691 AC_PLUGIN([ping],                [$with_liboping],          [Network latency statistics])
6692 AC_PLUGIN([postgresql],          [$with_libpq],             [PostgreSQL database statistics])
6693 AC_PLUGIN([powerdns],            [yes],                     [PowerDNS statistics])
6694 AC_PLUGIN([processes],           [$plugin_processes],       [Process statistics])
6695 AC_PLUGIN([protocols],           [$plugin_protocols],       [Protocol (IP, TCP, ...) statistics])
6696 AC_PLUGIN([python],              [$plugin_python],          [Embed a Python interpreter])
6697 AC_PLUGIN([redis],               [$with_libhiredis],        [Redis plugin])
6698 AC_PLUGIN([routeros],            [$with_librouteros],       [RouterOS plugin])
6699 AC_PLUGIN([rrdcached],           [$librrd_rrdc_update],     [RRDTool output plugin])
6700 AC_PLUGIN([rrdtool],             [$with_librrd],            [RRDTool output plugin])
6701 AC_PLUGIN([sensors],             [$with_libsensors],        [lm_sensors statistics])
6702 AC_PLUGIN([serial],              [$plugin_serial],          [serial port traffic])
6703 AC_PLUGIN([sigrok],              [$with_libsigrok],         [sigrok acquisition sources])
6704 AC_PLUGIN([smart],               [$plugin_smart],           [SMART statistics])
6705 AC_PLUGIN([snmp],                [$with_libnetsnmp],        [SNMP querying plugin])
6706 AC_PLUGIN([snmp_agent],          [$with_libnetsnmpagent],   [SNMP agent plugin])
6707 AC_PLUGIN([statsd],              [yes],                     [StatsD plugin])
6708 AC_PLUGIN([swap],                [$plugin_swap],            [Swap usage statistics])
6709 AC_PLUGIN([synproxy],            [$plugin_synproxy],        [Synproxy stats plugin])
6710 AC_PLUGIN([syslog],              [$have_syslog],            [Syslog logging plugin])
6711 AC_PLUGIN([table],               [yes],                     [Parsing of tabular data])
6712 AC_PLUGIN([tail],                [yes],                     [Parsing of logfiles])
6713 AC_PLUGIN([tail_csv],            [yes],                     [Parsing of CSV files])
6714 AC_PLUGIN([tape],                [$plugin_tape],            [Tape drive statistics])
6715 AC_PLUGIN([target_notification], [yes],                     [The notification target])
6716 AC_PLUGIN([target_replace],      [yes],                     [The replace target])
6717 AC_PLUGIN([target_scale],        [yes],                     [The scale target])
6718 AC_PLUGIN([target_set],          [yes],                     [The set target])
6719 AC_PLUGIN([target_v5upgrade],    [yes],                     [The v5upgrade target])
6720 AC_PLUGIN([tcpconns],            [$plugin_tcpconns],        [TCP connection statistics])
6721 AC_PLUGIN([teamspeak2],          [yes],                     [TeamSpeak2 server statistics])
6722 AC_PLUGIN([ted],                 [$plugin_ted],             [Read The Energy Detective values])
6723 AC_PLUGIN([thermal],             [$plugin_thermal],         [Linux ACPI thermal zone statistics])
6724 AC_PLUGIN([threshold],           [yes],                     [Threshold checking plugin])
6725 AC_PLUGIN([tokyotyrant],         [$with_libtokyotyrant],    [TokyoTyrant database statistics])
6726 AC_PLUGIN([turbostat],           [$plugin_turbostat],       [Advanced statistic on Intel cpu states])
6727 AC_PLUGIN([unixsock],            [yes],                     [Unixsock communication plugin])
6728 AC_PLUGIN([uptime],              [$plugin_uptime],          [Uptime statistics])
6729 AC_PLUGIN([users],               [$plugin_users],           [User statistics])
6730 AC_PLUGIN([uuid],                [yes],                     [UUID as hostname plugin])
6731 AC_PLUGIN([varnish],             [$with_libvarnish],        [Varnish cache statistics])
6732 AC_PLUGIN([virt],                [$plugin_virt],            [Virtual machine statistics])
6733 AC_PLUGIN([vmem],                [$plugin_vmem],            [Virtual memory statistics])
6734 AC_PLUGIN([vserver],             [$plugin_vserver],         [Linux VServer statistics])
6735 AC_PLUGIN([wireless],            [$plugin_wireless],        [Wireless statistics])
6736 AC_PLUGIN([write_graphite],      [yes],                     [Graphite / Carbon output plugin])
6737 AC_PLUGIN([write_http],          [$with_libcurl],           [HTTP output plugin])
6738 AC_PLUGIN([write_kafka],         [$with_librdkafka],        [Kafka output plugin])
6739 AC_PLUGIN([write_log],           [yes],                     [Log output plugin])
6740 AC_PLUGIN([write_mongodb],       [$with_libmongoc],         [MongoDB output plugin])
6741 AC_PLUGIN([write_prometheus],    [$plugin_write_prometheus], [Prometheus write plugin])
6742 AC_PLUGIN([write_redis],         [$with_libhiredis],        [Redis output plugin])
6743 AC_PLUGIN([write_riemann],       [$with_libriemann_client], [Riemann output plugin])
6744 AC_PLUGIN([write_sensu],         [yes],                     [Sensu output plugin])
6745 AC_PLUGIN([write_tsdb],          [yes],                     [TSDB output plugin])
6746 AC_PLUGIN([xencpu],              [$plugin_xencpu],          [Xen Host CPU usage])
6747 AC_PLUGIN([xmms],                [$with_libxmms],           [XMMS statistics])
6748 AC_PLUGIN([zfs_arc],             [$plugin_zfs_arc],         [ZFS ARC statistics])
6749 AC_PLUGIN([zone],                [$plugin_zone],            [Solaris container statistics])
6750 AC_PLUGIN([zookeeper],           [yes],                     [Zookeeper statistics])
6751
6752 dnl Default configuration file
6753 # Load either syslog or logfile
6754 LOAD_PLUGIN_SYSLOG=""
6755 LOAD_PLUGIN_LOGFILE=""
6756 LOAD_PLUGIN_LOG_LOGSTASH=""
6757
6758 AC_MSG_CHECKING([which default log plugin to load])
6759 default_log_plugin="none"
6760 if test "x$enable_syslog" = "xyes"; then
6761   default_log_plugin="syslog"
6762 else
6763   LOAD_PLUGIN_SYSLOG="##"
6764 fi
6765
6766 if test "x$enable_logfile" = "xyes"; then
6767   if test "x$default_log_plugin" = "xnone"; then
6768     default_log_plugin="logfile"
6769   else
6770     LOAD_PLUGIN_LOGFILE="#"
6771   fi
6772 else
6773   LOAD_PLUGIN_LOGFILE="##"
6774 fi
6775
6776 if test "x$enable_log_logstash" = "xyes"; then
6777   LOAD_PLUGIN_LOG_LOGSTASH="#"
6778 else
6779   LOAD_PLUGIN_LOG_LOGSTASH="##"
6780 fi
6781
6782 AC_MSG_RESULT([$default_log_plugin])
6783
6784 AC_SUBST([LOAD_PLUGIN_SYSLOG])
6785 AC_SUBST([LOAD_PLUGIN_LOGFILE])
6786 AC_SUBST([LOAD_PLUGIN_LOG_LOGSTASH])
6787
6788 if test "x$enable_debug" = "xyes"; then
6789   DEFAULT_LOG_LEVEL="debug"
6790 else
6791   DEFAULT_LOG_LEVEL="info"
6792 fi
6793 AC_SUBST([DEFAULT_LOG_LEVEL])
6794
6795 # Load only one of rrdtool, network, csv in the default config.
6796 LOAD_PLUGIN_RRDTOOL=""
6797 LOAD_PLUGIN_NETWORK=""
6798 LOAD_PLUGIN_CSV=""
6799
6800 AC_MSG_CHECKING([which default write plugin to load])
6801 default_write_plugin="none"
6802 if test "x$enable_rrdtool" = "xyes"; then
6803   default_write_plugin="rrdtool"
6804 else
6805   LOAD_PLUGIN_RRDTOOL="##"
6806 fi
6807
6808 if test "x$enable_network" = "xyes"; then
6809   if test "x$default_write_plugin" = "xnone"; then
6810     default_write_plugin="network"
6811   else
6812     LOAD_PLUGIN_NETWORK="#"
6813   fi
6814 else
6815   LOAD_PLUGIN_NETWORK="##"
6816 fi
6817
6818 if test "x$enable_csv" = "xyes"; then
6819   if test "x$default_write_plugin" = "xnone"; then
6820     default_write_plugin="csv"
6821   else
6822     LOAD_PLUGIN_CSV="#"
6823   fi
6824 else
6825   LOAD_PLUGIN_CSV="##"
6826 fi
6827 AC_MSG_RESULT([$default_write_plugin])
6828
6829 AC_SUBST([LOAD_PLUGIN_RRDTOOL])
6830 AC_SUBST([LOAD_PLUGIN_NETWORK])
6831 AC_SUBST([LOAD_PLUGIN_CSV])
6832
6833 dnl Perl bindings
6834 PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
6835 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
6836 [
6837   if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
6838     PERL_BINDINGS_OPTIONS="$withval"
6839     with_perl_bindings="yes"
6840   else
6841     with_perl_bindings="$withval"
6842   fi
6843 ],
6844 [
6845   if test "x$PERL" != "x"; then
6846     with_perl_bindings="yes"
6847   else
6848     with_perl_bindings="no (no perl interpreter found)"
6849   fi
6850 ])
6851
6852 if test "x$with_perl_bindings" = "xyes"; then
6853   AC_MSG_CHECKING([for the ExtUtils::MakeMaker module])
6854   if $PERL -MExtUtils::MakeMaker -e '' 2>/dev/null; then
6855     AC_MSG_RESULT([yes])
6856   else
6857     AC_MSG_RESULT([no])
6858     with_perl_bindings="no (ExtUtils::MakeMaker not found)"
6859   fi
6860 fi
6861
6862 if test "x$with_perl_bindings" = "xyes"; then
6863   PERL_BINDINGS="perl"
6864 else
6865   PERL_BINDINGS=""
6866 fi
6867
6868 AC_SUBST([PERL_BINDINGS])
6869 AC_SUBST([PERL_BINDINGS_OPTIONS])
6870
6871 dnl libcollectdclient
6872 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
6873 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
6874 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
6875
6876 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
6877
6878 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
6879
6880 AC_SUBST([LCC_VERSION_MAJOR])
6881 AC_SUBST([LCC_VERSION_MINOR])
6882 AC_SUBST([LCC_VERSION_PATCH])
6883 AC_SUBST([LCC_VERSION_EXTRA])
6884 AC_SUBST([LCC_VERSION_STRING])
6885
6886 AC_CONFIG_FILES([src/libcollectdclient/collectd/lcc_features.h])
6887
6888 AM_CFLAGS="-Wall"
6889 AM_CXXFLAGS="-Wall"
6890 if test "x$enable_werror" != "xno"; then
6891   AM_CFLAGS="$AM_CFLAGS -Werror"
6892   AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
6893 fi
6894
6895 AC_SUBST([AM_CFLAGS])
6896 AC_SUBST([AM_CXXFLAGS])
6897
6898 AC_CONFIG_FILES([ \
6899   Makefile \
6900   src/collectd.conf \
6901   src/libcollectdclient/libcollectdclient.pc \
6902 ])
6903
6904 AC_OUTPUT
6905
6906 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" != "xyes"; then
6907   with_librrd="yes (warning: librrd is not thread-safe)"
6908 fi
6909
6910 if test "x$with_libperl" = "xyes"; then
6911   with_libperl="yes (version `$PERL -MConfig -e 'print $Config{version};'`)"
6912 else
6913   enable_perl="no (needs libperl)"
6914 fi
6915
6916 if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"; then
6917   enable_perl="no (libperl doesn't support ithreads)"
6918 fi
6919
6920 if test "x$with_perl_bindings" = "xyes" && test "x$PERL_BINDINGS_OPTIONS" != "x"; then
6921   with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
6922 fi
6923
6924 AC_MSG_RESULT()
6925 AC_MSG_RESULT([Configuration:])
6926 AC_MSG_RESULT([  Build:])
6927 AC_MSG_RESULT([    Platform  . . . . . . $ac_system])
6928 AC_MSG_RESULT([    Compiler vendor . . . $ax_cv_c_compiler_vendor])
6929 AC_MSG_RESULT([    CC  . . . . . . . . . $CC])
6930 AC_MSG_RESULT([    CFLAGS  . . . . . . . $AM_CFLAGS $CFLAGS])
6931 AC_MSG_RESULT([    CXXFLAGS  . . . . . . $AM_CXXFLAGS $CXXFLAGS])
6932 AC_MSG_RESULT([    CPP . . . . . . . . . $CPP])
6933 AC_MSG_RESULT([    CPPFLAGS  . . . . . . $CPPFLAGS])
6934 AC_MSG_RESULT([    GRPC_CPP_PLUGIN . . . $GRPC_CPP_PLUGIN])
6935 AC_MSG_RESULT([    LD  . . . . . . . . . $LD])
6936 AC_MSG_RESULT([    LDFLAGS . . . . . . . $LDFLAGS])
6937 AC_MSG_RESULT([    PROTOC  . . . . . . . $PROTOC])
6938 AC_MSG_RESULT([    YACC  . . . . . . . . $YACC])
6939 AC_MSG_RESULT([    YFLAGS  . . . . . . . $YFLAGS])
6940 AC_MSG_RESULT()
6941 AC_MSG_RESULT([  Libraries:])
6942 AC_MSG_RESULT([    intel mic . . . . . . $with_mic])
6943 AC_MSG_RESULT([    libaquaero5 . . . . . $with_libaquaero5])
6944 AC_MSG_RESULT([    libatasmart . . . . . $with_libatasmart])
6945 AC_MSG_RESULT([    libcurl . . . . . . . $with_libcurl])
6946 AC_MSG_RESULT([    libdbi  . . . . . . . $with_libdbi])
6947 AC_MSG_RESULT([    libdpdk . . . . . . . $with_libdpdk])
6948 AC_MSG_RESULT([    libesmtp  . . . . . . $with_libesmtp])
6949 AC_MSG_RESULT([    libganglia  . . . . . $with_libganglia])
6950 AC_MSG_RESULT([    libgcrypt . . . . . . $with_libgcrypt])
6951 AC_MSG_RESULT([    libgps  . . . . . . . $with_libgps])
6952 AC_MSG_RESULT([    libgrpc++ . . . . . . $with_libgrpcpp])
6953 AC_MSG_RESULT([    libhiredis  . . . . . $with_libhiredis])
6954 AC_MSG_RESULT([    libi2c-dev  . . . . . $with_libi2c])
6955 AC_MSG_RESULT([    libiokit  . . . . . . $with_libiokit])
6956 AC_MSG_RESULT([    libiptc . . . . . . . $with_libiptc])
6957 AC_MSG_RESULT([    libjevents  . . . . . $with_libjevents])
6958 AC_MSG_RESULT([    libjvm  . . . . . . . $with_java])
6959 AC_MSG_RESULT([    libkstat  . . . . . . $with_kstat])
6960 AC_MSG_RESULT([    libkvm  . . . . . . . $with_libkvm])
6961 AC_MSG_RESULT([    libldap . . . . . . . $with_libldap])
6962 AC_MSG_RESULT([    liblua  . . . . . . . $with_liblua])
6963 AC_MSG_RESULT([    liblvm2app  . . . . . $with_liblvm2app])
6964 AC_MSG_RESULT([    libmemcached  . . . . $with_libmemcached])
6965 AC_MSG_RESULT([    libmicrohttpd . . . . $with_libmicrohttpd])
6966 AC_MSG_RESULT([    libmnl  . . . . . . . $with_libmnl])
6967 AC_MSG_RESULT([    libmodbus . . . . . . $with_libmodbus])
6968 AC_MSG_RESULT([    libmongoc . . . . . . $with_libmongoc])
6969 AC_MSG_RESULT([    libmosquitto  . . . . $with_libmosquitto])
6970 AC_MSG_RESULT([    libmysql  . . . . . . $with_libmysql])
6971 AC_MSG_RESULT([    libnetapp . . . . . . $with_libnetapp])
6972 AC_MSG_RESULT([    libnetsnmp  . . . . . $with_libnetsnmp])
6973 AC_MSG_RESULT([    libnetsnmpagent . . . $with_libnetsnmpagent])
6974 AC_MSG_RESULT([    libnotify . . . . . . $with_libnotify])
6975 AC_MSG_RESULT([    libopenipmi . . . . . $with_libopenipmipthread])
6976 AC_MSG_RESULT([    liboping  . . . . . . $with_liboping])
6977 AC_MSG_RESULT([    libowcapi . . . . . . $with_libowcapi])
6978 AC_MSG_RESULT([    libpcap . . . . . . . $with_libpcap])
6979 AC_MSG_RESULT([    libperfstat . . . . . $with_perfstat])
6980 AC_MSG_RESULT([    libperl . . . . . . . $with_libperl])
6981 AC_MSG_RESULT([    libpq . . . . . . . . $with_libpq])
6982 AC_MSG_RESULT([    libpqos . . . . . . . $with_libpqos])
6983 AC_MSG_RESULT([    libprotobuf . . . . . $with_libprotobuf])
6984 AC_MSG_RESULT([    libprotobuf-c . . . . $with_libprotobuf_c])
6985 AC_MSG_RESULT([    libpython . . . . . . $with_libpython])
6986 AC_MSG_RESULT([    libqpid-proton .  . . $with_libqpid_proton])
6987 AC_MSG_RESULT([    librabbitmq . . . . . $with_librabbitmq])
6988 AC_MSG_RESULT([    libriemann-client . . $with_libriemann_client])
6989 AC_MSG_RESULT([    librdkafka  . . . . . $with_librdkafka])
6990 AC_MSG_RESULT([    librouteros . . . . . $with_librouteros])
6991 AC_MSG_RESULT([    librrd  . . . . . . . $with_librrd])
6992 AC_MSG_RESULT([    libsensors  . . . . . $with_libsensors])
6993 AC_MSG_RESULT([    libsigrok   . . . . . $with_libsigrok])
6994 AC_MSG_RESULT([    libstatgrab . . . . . $with_libstatgrab])
6995 AC_MSG_RESULT([    libtokyotyrant  . . . $with_libtokyotyrant])
6996 AC_MSG_RESULT([    libudev . . . . . . . $with_libudev])
6997 AC_MSG_RESULT([    libupsclient  . . . . $with_libupsclient])
6998 AC_MSG_RESULT([    libvarnish  . . . . . $with_libvarnish])
6999 AC_MSG_RESULT([    libvirt . . . . . . . $with_libvirt])
7000 AC_MSG_RESULT([    libxenctrl  . . . . . $with_libxenctrl])
7001 AC_MSG_RESULT([    libxml2 . . . . . . . $with_libxml2])
7002 AC_MSG_RESULT([    libxmms . . . . . . . $with_libxmms])
7003 AC_MSG_RESULT([    libyajl . . . . . . . $with_libyajl])
7004 AC_MSG_RESULT([    oracle  . . . . . . . $with_oracle])
7005 AC_MSG_RESULT([    protobuf-c  . . . . . $have_protoc_c])
7006 AC_MSG_RESULT([    protoc 3  . . . . . . $have_protoc3])
7007 AC_MSG_RESULT()
7008 AC_MSG_RESULT([  Features:])
7009 AC_MSG_RESULT([    daemon mode . . . . . $enable_daemon])
7010 AC_MSG_RESULT([    debug . . . . . . . . $enable_debug])
7011 AC_MSG_RESULT()
7012 AC_MSG_RESULT([  Bindings:])
7013 AC_MSG_RESULT([    perl  . . . . . . . . $with_perl_bindings])
7014 AC_MSG_RESULT()
7015 AC_MSG_RESULT([  Modules:])
7016 AC_MSG_RESULT([    aggregation . . . . . $enable_aggregation])
7017 AC_MSG_RESULT([    amqp    . . . . . . . $enable_amqp])
7018 AC_MSG_RESULT([    amqp1   . . . . . . . $enable_amqp1])
7019 AC_MSG_RESULT([    apache  . . . . . . . $enable_apache])
7020 AC_MSG_RESULT([    apcups  . . . . . . . $enable_apcups])
7021 AC_MSG_RESULT([    apple_sensors . . . . $enable_apple_sensors])
7022 AC_MSG_RESULT([    aquaero . . . . . . . $enable_aquaero])
7023 AC_MSG_RESULT([    ascent  . . . . . . . $enable_ascent])
7024 AC_MSG_RESULT([    barometer . . . . . . $enable_barometer])
7025 AC_MSG_RESULT([    battery . . . . . . . $enable_battery])
7026 AC_MSG_RESULT([    bind  . . . . . . . . $enable_bind])
7027 AC_MSG_RESULT([    ceph  . . . . . . . . $enable_ceph])
7028 AC_MSG_RESULT([    cgroups . . . . . . . $enable_cgroups])
7029 AC_MSG_RESULT([    chrony. . . . . . . . $enable_chrony])
7030 AC_MSG_RESULT([    conntrack . . . . . . $enable_conntrack])
7031 AC_MSG_RESULT([    contextswitch . . . . $enable_contextswitch])
7032 AC_MSG_RESULT([    cpu . . . . . . . . . $enable_cpu])
7033 AC_MSG_RESULT([    cpufreq . . . . . . . $enable_cpufreq])
7034 AC_MSG_RESULT([    cpusleep  . . . . . . $enable_cpusleep])
7035 AC_MSG_RESULT([    csv . . . . . . . . . $enable_csv])
7036 AC_MSG_RESULT([    curl  . . . . . . . . $enable_curl])
7037 AC_MSG_RESULT([    curl_json . . . . . . $enable_curl_json])
7038 AC_MSG_RESULT([    curl_xml  . . . . . . $enable_curl_xml])
7039 AC_MSG_RESULT([    dbi . . . . . . . . . $enable_dbi])
7040 AC_MSG_RESULT([    df  . . . . . . . . . $enable_df])
7041 AC_MSG_RESULT([    disk  . . . . . . . . $enable_disk])
7042 AC_MSG_RESULT([    dns . . . . . . . . . $enable_dns])
7043 AC_MSG_RESULT([    dpdkevents. . . . . . $enable_dpdkevents])
7044 AC_MSG_RESULT([    dpdkstat  . . . . . . $enable_dpdkstat])
7045 AC_MSG_RESULT([    drbd  . . . . . . . . $enable_drbd])
7046 AC_MSG_RESULT([    email . . . . . . . . $enable_email])
7047 AC_MSG_RESULT([    entropy . . . . . . . $enable_entropy])
7048 AC_MSG_RESULT([    ethstat . . . . . . . $enable_ethstat])
7049 AC_MSG_RESULT([    exec  . . . . . . . . $enable_exec])
7050 AC_MSG_RESULT([    fhcount . . . . . . . $enable_fhcount])
7051 AC_MSG_RESULT([    filecount . . . . . . $enable_filecount])
7052 AC_MSG_RESULT([    fscache . . . . . . . $enable_fscache])
7053 AC_MSG_RESULT([    gmond . . . . . . . . $enable_gmond])
7054 AC_MSG_RESULT([    gps . . . . . . . . . $enable_gps])
7055 AC_MSG_RESULT([    grpc  . . . . . . . . $enable_grpc])
7056 AC_MSG_RESULT([    hddtemp . . . . . . . $enable_hddtemp])
7057 AC_MSG_RESULT([    hugepages . . . . . . $enable_hugepages])
7058 AC_MSG_RESULT([    intel_pmu . . . . . . $enable_intel_pmu])
7059 AC_MSG_RESULT([    intel_rdt . . . . . . $enable_intel_rdt])
7060 AC_MSG_RESULT([    interface . . . . . . $enable_interface])
7061 AC_MSG_RESULT([    ipc . . . . . . . . . $enable_ipc])
7062 AC_MSG_RESULT([    ipmi  . . . . . . . . $enable_ipmi])
7063 AC_MSG_RESULT([    iptables  . . . . . . $enable_iptables])
7064 AC_MSG_RESULT([    ipvs  . . . . . . . . $enable_ipvs])
7065 AC_MSG_RESULT([    irq . . . . . . . . . $enable_irq])
7066 AC_MSG_RESULT([    java  . . . . . . . . $enable_java])
7067 AC_MSG_RESULT([    load  . . . . . . . . $enable_load])
7068 AC_MSG_RESULT([    logfile . . . . . . . $enable_logfile])
7069 AC_MSG_RESULT([    log_logstash  . . . . $enable_log_logstash])
7070 AC_MSG_RESULT([    lpar  . . . . . . . . $enable_lpar])
7071 AC_MSG_RESULT([    lua . . . . . . . . . $enable_lua])
7072 AC_MSG_RESULT([    lvm . . . . . . . . . $enable_lvm])
7073 AC_MSG_RESULT([    madwifi . . . . . . . $enable_madwifi])
7074 AC_MSG_RESULT([    match_empty_counter . $enable_match_empty_counter])
7075 AC_MSG_RESULT([    match_hashed  . . . . $enable_match_hashed])
7076 AC_MSG_RESULT([    match_regex . . . . . $enable_match_regex])
7077 AC_MSG_RESULT([    match_timediff  . . . $enable_match_timediff])
7078 AC_MSG_RESULT([    match_value . . . . . $enable_match_value])
7079 AC_MSG_RESULT([    mbmon . . . . . . . . $enable_mbmon])
7080 AC_MSG_RESULT([    mcelog  . . . . . . . $enable_mcelog])
7081 AC_MSG_RESULT([    md  . . . . . . . . . $enable_md])
7082 AC_MSG_RESULT([    memcachec . . . . . . $enable_memcachec])
7083 AC_MSG_RESULT([    memcached . . . . . . $enable_memcached])
7084 AC_MSG_RESULT([    memory  . . . . . . . $enable_memory])
7085 AC_MSG_RESULT([    mic . . . . . . . . . $enable_mic])
7086 AC_MSG_RESULT([    modbus  . . . . . . . $enable_modbus])
7087 AC_MSG_RESULT([    mqtt  . . . . . . . . $enable_mqtt])
7088 AC_MSG_RESULT([    multimeter  . . . . . $enable_multimeter])
7089 AC_MSG_RESULT([    mysql . . . . . . . . $enable_mysql])
7090 AC_MSG_RESULT([    netapp  . . . . . . . $enable_netapp])
7091 AC_MSG_RESULT([    netlink . . . . . . . $enable_netlink])
7092 AC_MSG_RESULT([    network . . . . . . . $enable_network])
7093 AC_MSG_RESULT([    nfs . . . . . . . . . $enable_nfs])
7094 AC_MSG_RESULT([    nginx . . . . . . . . $enable_nginx])
7095 AC_MSG_RESULT([    notify_desktop  . . . $enable_notify_desktop])
7096 AC_MSG_RESULT([    notify_email  . . . . $enable_notify_email])
7097 AC_MSG_RESULT([    notify_nagios . . . . $enable_notify_nagios])
7098 AC_MSG_RESULT([    ntpd  . . . . . . . . $enable_ntpd])
7099 AC_MSG_RESULT([    numa  . . . . . . . . $enable_numa])
7100 AC_MSG_RESULT([    nut . . . . . . . . . $enable_nut])
7101 AC_MSG_RESULT([    olsrd . . . . . . . . $enable_olsrd])
7102 AC_MSG_RESULT([    onewire . . . . . . . $enable_onewire])
7103 AC_MSG_RESULT([    openldap  . . . . . . $enable_openldap])
7104 AC_MSG_RESULT([    openvpn . . . . . . . $enable_openvpn])
7105 AC_MSG_RESULT([    oracle  . . . . . . . $enable_oracle])
7106 AC_MSG_RESULT([    ovs_events  . . . . . $enable_ovs_events])
7107 AC_MSG_RESULT([    ovs_stats . . . . . . $enable_ovs_stats])
7108 AC_MSG_RESULT([    perl  . . . . . . . . $enable_perl])
7109 AC_MSG_RESULT([    pf  . . . . . . . . . $enable_pf])
7110 AC_MSG_RESULT([    pinba . . . . . . . . $enable_pinba])
7111 AC_MSG_RESULT([    ping  . . . . . . . . $enable_ping])
7112 AC_MSG_RESULT([    postgresql  . . . . . $enable_postgresql])
7113 AC_MSG_RESULT([    powerdns  . . . . . . $enable_powerdns])
7114 AC_MSG_RESULT([    processes . . . . . . $enable_processes])
7115 AC_MSG_RESULT([    protocols . . . . . . $enable_protocols])
7116 AC_MSG_RESULT([    python  . . . . . . . $enable_python])
7117 AC_MSG_RESULT([    redis . . . . . . . . $enable_redis])
7118 AC_MSG_RESULT([    routeros  . . . . . . $enable_routeros])
7119 AC_MSG_RESULT([    rrdcached . . . . . . $enable_rrdcached])
7120 AC_MSG_RESULT([    rrdtool . . . . . . . $enable_rrdtool])
7121 AC_MSG_RESULT([    sensors . . . . . . . $enable_sensors])
7122 AC_MSG_RESULT([    serial  . . . . . . . $enable_serial])
7123 AC_MSG_RESULT([    sigrok  . . . . . . . $enable_sigrok])
7124 AC_MSG_RESULT([    smart . . . . . . . . $enable_smart])
7125 AC_MSG_RESULT([    snmp  . . . . . . . . $enable_snmp])
7126 AC_MSG_RESULT([    snmp_agent  . . . . . $enable_snmp_agent])
7127 AC_MSG_RESULT([    statsd  . . . . . . . $enable_statsd])
7128 AC_MSG_RESULT([    swap  . . . . . . . . $enable_swap])
7129 AC_MSG_RESULT([    synproxy  . . . . . . $enable_synproxy])
7130 AC_MSG_RESULT([    syslog  . . . . . . . $enable_syslog])
7131 AC_MSG_RESULT([    table . . . . . . . . $enable_table])
7132 AC_MSG_RESULT([    tail_csv  . . . . . . $enable_tail_csv])
7133 AC_MSG_RESULT([    tail  . . . . . . . . $enable_tail])
7134 AC_MSG_RESULT([    tape  . . . . . . . . $enable_tape])
7135 AC_MSG_RESULT([    target_notification . $enable_target_notification])
7136 AC_MSG_RESULT([    target_replace  . . . $enable_target_replace])
7137 AC_MSG_RESULT([    target_scale  . . . . $enable_target_scale])
7138 AC_MSG_RESULT([    target_set  . . . . . $enable_target_set])
7139 AC_MSG_RESULT([    target_v5upgrade  . . $enable_target_v5upgrade])
7140 AC_MSG_RESULT([    tcpconns  . . . . . . $enable_tcpconns])
7141 AC_MSG_RESULT([    teamspeak2  . . . . . $enable_teamspeak2])
7142 AC_MSG_RESULT([    ted . . . . . . . . . $enable_ted])
7143 AC_MSG_RESULT([    thermal . . . . . . . $enable_thermal])
7144 AC_MSG_RESULT([    threshold . . . . . . $enable_threshold])
7145 AC_MSG_RESULT([    tokyotyrant . . . . . $enable_tokyotyrant])
7146 AC_MSG_RESULT([    turbostat . . . . . . $enable_turbostat])
7147 AC_MSG_RESULT([    unixsock  . . . . . . $enable_unixsock])
7148 AC_MSG_RESULT([    uptime  . . . . . . . $enable_uptime])
7149 AC_MSG_RESULT([    users . . . . . . . . $enable_users])
7150 AC_MSG_RESULT([    uuid  . . . . . . . . $enable_uuid])
7151 AC_MSG_RESULT([    varnish . . . . . . . $enable_varnish])
7152 AC_MSG_RESULT([    virt  . . . . . . . . $enable_virt])
7153 AC_MSG_RESULT([    vmem  . . . . . . . . $enable_vmem])
7154 AC_MSG_RESULT([    vserver . . . . . . . $enable_vserver])
7155 AC_MSG_RESULT([    wireless  . . . . . . $enable_wireless])
7156 AC_MSG_RESULT([    write_graphite  . . . $enable_write_graphite])
7157 AC_MSG_RESULT([    write_http  . . . . . $enable_write_http])
7158 AC_MSG_RESULT([    write_kafka . . . . . $enable_write_kafka])
7159 AC_MSG_RESULT([    write_log . . . . . . $enable_write_log])
7160 AC_MSG_RESULT([    write_mongodb . . . . $enable_write_mongodb])
7161 AC_MSG_RESULT([    write_prometheus. . . $enable_write_prometheus])
7162 AC_MSG_RESULT([    write_redis . . . . . $enable_write_redis])
7163 AC_MSG_RESULT([    write_riemann . . . . $enable_write_riemann])
7164 AC_MSG_RESULT([    write_sensu . . . . . $enable_write_sensu])
7165 AC_MSG_RESULT([    write_tsdb  . . . . . $enable_write_tsdb])
7166 AC_MSG_RESULT([    xencpu  . . . . . . . $enable_xencpu])
7167 AC_MSG_RESULT([    xmms  . . . . . . . . $enable_xmms])
7168 AC_MSG_RESULT([    zfs_arc . . . . . . . $enable_zfs_arc])
7169 AC_MSG_RESULT([    zone  . . . . . . . . $enable_zone])
7170 AC_MSG_RESULT([    zookeeper . . . . . . $enable_zookeeper])
7171 AC_MSG_RESULT()
7172
7173 if test "x$dependency_error" = "xyes"; then
7174   AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
7175 fi
7176
7177 if test "x$dependency_warning" = "xyes"; then
7178   AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
7179 fi
7180
7181 # vim: set fdm=marker sw=2 sts=2 ts=2 et :