snmp plugin: codestyle
[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_libnetsnmp="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   SAVE_LDFLAGS="$LDFLAGS"
3826   LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
3827
3828   AC_CHECK_LIB([netsnmp], [netsnmp_get_version],
3829     [with_libnetsnmp="yes"],
3830     [with_libnetsnmp="no (couldn't get libnetsnmp version)"]
3831   )
3832
3833   LDFLAGS="$SAVE_LDFLAGS"
3834 fi
3835
3836 if test "x$with_libnetsnmp" = "xyes"; then
3837   SAVE_CPPFLAGS="$CPPFLAGS"
3838   SAVE_LDFLAGS="$LDFLAGS"
3839   SAVE_LIBS="$LIBS"
3840   CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags -Wall -Werror"
3841   LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
3842   LIBS="$LIBS -lnetsnmp"
3843
3844   AC_CACHE_CHECK([whether netsnmp library has old API],
3845     [c_cv_have_netsnmp_old_api],
3846     [
3847       AC_LINK_IFELSE(
3848         [
3849           AC_LANG_PROGRAM(
3850             [[
3851               #include <net-snmp/net-snmp-config.h>
3852               #include <net-snmp/net-snmp-includes.h>
3853             ]],
3854             [[
3855               netsnmp_variable_list *key = SNMP_MALLOC_TYPEDEF(netsnmp_variable_list);;
3856               int val;
3857               u_char type = ASN_INTEGER;
3858               snmp_set_var_value(key, &val, sizeof(val));
3859               snmp_set_var_typed_value(key, type, &val, sizeof(val));
3860               return 0;
3861             ]]
3862           )
3863         ],
3864         [c_cv_have_netsnmp_old_api="no"],
3865         [c_cv_have_netsnmp_old_api="yes"]
3866       )
3867     ]
3868   )
3869
3870   if test "x$c_cv_have_netsnmp_old_api" = "xyes"; then
3871     AC_DEFINE([HAVE_NETSNMP_OLD_API], [1],
3872               ["Define 1 if you have old netsnmp API]")
3873   fi
3874
3875   CPPFLAGS="$SAVE_CPPFLAGS"
3876   LDFLAGS="$SAVE_LDFLAGS"
3877   LIBS="$SAVE_LIBS"
3878 fi
3879
3880 if test "x$with_libnetsnmp" = "xyes"; then
3881   BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
3882   BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
3883   BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
3884 fi
3885
3886 AC_SUBST([BUILD_WITH_LIBNETSNMP_CPPFLAGS])
3887 AC_SUBST([BUILD_WITH_LIBNETSNMP_LDFLAGS])
3888 AC_SUBST([BUILD_WITH_LIBNETSNMP_LIBS])
3889 # }}}
3890
3891 # --with-libnetsnmpagent {{{
3892 AC_ARG_WITH([libnetsnmpagent],
3893   [AS_HELP_STRING([--with-libnetsnmpagent@<:@=PREFIX@:>@], [Path to libnetsnmpagent.])],
3894   [
3895     if test "x$withval" = "xno"; then
3896       with_libnetsnmpagent="no"
3897     else if test "x$withval" = "xyes"; then
3898       with_libnetsnmpagent="yes"
3899     else
3900       with_libnetsnmpagent_cppflags="-I$withval/include"
3901       with_libnetsnmpagent_ldflags="-I$withval/lib"
3902       with_libnetsnmpagent="yes"
3903     fi; fi
3904   ],
3905   [with_libnetsnmpagent="yes"]
3906 )
3907
3908 if test "x$with_libnetsnmpagent" = "xyes"; then
3909   SAVE_CPPFLAGS="$CPPFLAGS"
3910   CPPFLAGS="$CPPFLAGS $with_libnetsnmpagent_cppflags"
3911
3912   AC_CHECK_HEADERS([net-snmp/agent/net-snmp-agent-includes.h],
3913     [],
3914     [with_libnetsnmpagent="no (net-snmp/agent/net-snmp-agent-includes.h not found)"],
3915     [[
3916       #if HAVE_NET_SNMP_NET_SNMP_CONFIG_H
3917       # include <net-snmp/net-snmp-config.h>
3918       #endif
3919       #if HAVE_NET_SNMP_NET_SNMP_INCLUDES_H
3920       # include <net-snmp/net-snmp-includes.h>
3921       #endif
3922     ]]
3923   )
3924
3925   CPPFLAGS="$SAVE_CPPFLAGS"
3926 fi
3927
3928 if test "x$with_libnetsnmpagent" = "xyes"; then
3929   SAVE_LDFLAGS="$LDFLAGS"
3930   LDFLAGS="$LDFLAGS $with_libnetsnmpagent_ldflags"
3931
3932   # older versions of libnetsnmpagent fail to link
3933   # against the helpers library, so do that explicitly
3934   AC_CHECK_LIB([netsnmphelpers], [netsnmp_init_helpers],
3935     [libnetsnmphelpers="-lnetsnmphelpers"],
3936     [libnetsnmphelpers=""]
3937   )
3938
3939   AC_CHECK_LIB([netsnmpagent], [init_agent],
3940     [with_libnetsnmpagent="yes"],
3941     [with_libnetsnmpagent="no (libnetsnmpagent not found)"],
3942     [$libnetsnmphelpers]
3943   )
3944
3945   LDFLAGS="$SAVE_LDFLAGS"
3946 fi
3947
3948 if test "x$with_libnetsnmpagent" = "xyes"; then
3949   BUILD_WITH_LIBNETSNMPAGENT_LIBS="-lnetsnmpagent $libnetsnmphelpers"
3950 fi
3951
3952 AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_CPPFLAGS])
3953 AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LDFLAGS])
3954 AC_SUBST([BUILD_WITH_LIBNETSNMPAGENT_LIBS])
3955 # }}}
3956
3957 # --with-liboping {{{
3958 AC_ARG_WITH([liboping],
3959   [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
3960   [
3961     if test "x$withval" = "xyes"; then
3962       with_liboping="yes"
3963     else if test "x$withval" = "xno"; then
3964       with_liboping="no"
3965     else
3966       with_liboping="yes"
3967       LIBOPING_CPPFLAGS="-I$withval/include"
3968       LIBOPING_LDFLAGS="-L$withval/lib"
3969     fi; fi
3970   ],
3971   [with_liboping="yes"]
3972 )
3973
3974 SAVE_CPPFLAGS="$CPPFLAGS"
3975 SAVE_LDFLAGS="$LDFLAGS"
3976 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
3977 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
3978
3979 if test "x$with_liboping" = "xyes"; then
3980   AC_CHECK_HEADERS([oping.h],
3981     [with_liboping="yes"],
3982     [with_liboping="no (oping.h not found)"]
3983   )
3984 fi
3985
3986 if test "x$with_liboping" = "xyes"; then
3987   AC_CHECK_LIB([oping], [ping_construct],
3988     [with_liboping="yes"],
3989     [with_liboping="no (symbol 'ping_construct' not found)"]
3990   )
3991 fi
3992
3993 CPPFLAGS="$SAVE_CPPFLAGS"
3994 LDFLAGS="$SAVE_LDFLAGS"
3995
3996 if test "x$with_liboping" = "xyes"; then
3997   BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
3998   BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
3999 fi
4000
4001 AC_SUBST([BUILD_WITH_LIBOPING_CPPFLAGS])
4002 AC_SUBST([BUILD_WITH_LIBOPING_LDFLAGS])
4003 # }}}
4004
4005 # --with-oracle {{{
4006 AC_ARG_WITH([oracle],
4007   [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
4008   [
4009     if test "x$withval" = "xyes"; then
4010       if test "x$ORACLE_HOME" = "x"; then
4011         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
4012       fi
4013       with_oracle="yes"
4014     else if test "x$withval" = "xno"; then
4015       with_oracle="no"
4016     else
4017       with_oracle="yes"
4018       ORACLE_HOME="$withval"
4019     fi; fi
4020   ],
4021   [
4022     if test "x$ORACLE_HOME" = "x"; then
4023       with_oracle="no (ORACLE_HOME is not set)"
4024     else
4025       with_oracle="yes"
4026     fi
4027   ]
4028 )
4029
4030 if test "x$ORACLE_HOME" != "x"; then
4031   with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
4032   if test -e "$ORACLE_HOME/lib/ldflags"; then
4033     with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
4034   fi
4035   with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
4036 fi
4037
4038 if test "x$with_oracle" = "xyes"; then
4039   SAVE_CPPFLAGS="$CPPFLAGS"
4040   CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
4041
4042   AC_CHECK_HEADERS([oci.h],
4043     [with_oracle="yes"],
4044     [with_oracle="no (oci.h not found)"]
4045   )
4046
4047   CPPFLAGS="$SAVE_CPPFLAGS"
4048 fi
4049
4050 if test "x$with_oracle" = "xyes"; then
4051   SAVE_CPPFLAGS="$CPPFLAGS"
4052   SAVE_LIBS="$LIBS"
4053   CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
4054   LIBS="$LIBS $with_oracle_libs"
4055
4056   AC_CHECK_FUNC([OCIEnvCreate],
4057     [with_oracle="yes"],
4058     [with_oracle="no (Symbol 'OCIEnvCreate' not found)"]
4059   )
4060
4061   CPPFLAGS="$SAVE_CPPFLAGS"
4062   LIBS="$SAVE_LIBS"
4063 fi
4064
4065 if test "x$with_oracle" = "xyes"; then
4066   BUILD_WITH_ORACLE_CPPFLAGS="$with_oracle_cppflags"
4067   BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
4068 fi
4069
4070 AC_SUBST([BUILD_WITH_ORACLE_CPPFLAGS])
4071 AC_SUBST([BUILD_WITH_ORACLE_LIBS])
4072 # }}}
4073
4074 # --with-libowcapi {{{
4075 AC_ARG_WITH([libowcapi],
4076   [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
4077   [
4078     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4079       with_libowcapi_cppflags="-I$withval/include"
4080       with_libowcapi_ldflags="-L$withval/lib"
4081       with_libowcapi="yes"
4082     else
4083       with_libowcapi="$withval"
4084     fi
4085   ],
4086   [with_libowcapi="yes"]
4087 )
4088
4089 if test "x$with_libowcapi" = "xyes"; then
4090   SAVE_CPPFLAGS="$CPPFLAGS"
4091   CPPFLAGS="$CPPFLAGS $with_libowcapi_cppflags"
4092
4093   AC_CHECK_HEADERS([owcapi.h],
4094     [with_libowcapi="yes"],
4095     [with_libowcapi="no (owcapi.h not found)"]
4096   )
4097
4098   CPPFLAGS="$SAVE_CPPFLAGS"
4099 fi
4100
4101 if test "x$with_libowcapi" = "xyes"; then
4102   SAVE_LDFLAGS="$LDFLAGS"
4103   LDFLAGS="$LDFLAGS $with_libowcapi_ldflags"
4104
4105   AC_CHECK_LIB([owcapi], [OW_get],
4106     [with_libowcapi="yes"],
4107     [with_libowcapi="no (libowcapi not found)"]
4108   )
4109
4110   LDFLAGS="$SAVE_LDFLAGS"
4111 fi
4112
4113 if test "x$with_libowcapi" = "xyes"; then
4114   BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
4115   BUILD_WITH_LIBOWCAPI_LDFLAGS="$with_libowcapi_ldflags"
4116   BUILD_WITH_LIBOWCAPI_LIBS="-lowcapi"
4117 fi
4118
4119 AC_SUBST([BUILD_WITH_LIBOWCAPI_CPPFLAGS])
4120 AC_SUBST([BUILD_WITH_LIBOWCAPI_LDFLAGS])
4121 AC_SUBST([BUILD_WITH_LIBOWCAPI_LIBS])
4122 # }}}
4123
4124 # --with-libpcap {{{
4125 AC_ARG_WITH([libpcap],
4126   [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
4127   [
4128     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4129       with_libpcap_cppflags="-I$withval/include"
4130       with_libpcap_ldflags="$LDFLAGS -L$withval/lib"
4131       with_libpcap="yes"
4132     else
4133       with_libpcap="$withval"
4134     fi
4135   ],
4136   [with_libpcap="yes"]
4137 )
4138
4139 if test "x$with_libpcap" = "xyes"; then
4140   SAVE_CPPFLAGS="$CPPFLAGS"
4141   CPPFLAGS="$CPPFLAGS $with_libpcap_cppflags"
4142
4143   AC_CHECK_HEADERS([pcap.h],
4144     [with_libpcap="yes"],
4145     [with_libpcap="no (pcap.h not found)"]
4146   )
4147
4148   CPPFLAGS="$SAVE_CPPFLAGS"
4149 fi
4150
4151 if test "x$with_libpcap" = "xyes"; then
4152   SAVE_LDFLAGS="$LDFLAGS"
4153   LDFLAGS="$LDFLAGS $with_libpcap_ldflags"
4154
4155   AC_CHECK_LIB([pcap], [pcap_open_live],
4156     [with_libpcap="yes"],
4157     [with_libpcap="no (libpcap not found)"]
4158   )
4159
4160   LDFLAGS="$SAVE_LDFLAGS"
4161 fi
4162
4163 if test "x$with_libpcap" = "xyes"; then
4164   AC_CACHE_CHECK([whether libpcap has PCAP_ERROR_IFACE_NOT_UP],
4165     [c_cv_libpcap_have_pcap_error_iface_not_up],
4166     [
4167       AC_COMPILE_IFELSE(
4168         [
4169           AC_LANG_PROGRAM(
4170             [[#include <pcap.h>]],
4171             [[
4172               int val = PCAP_ERROR_IFACE_NOT_UP;
4173               return val;
4174             ]]
4175           )
4176         ],
4177         [c_cv_libpcap_have_pcap_error_iface_not_up="yes"],
4178         [c_cv_libpcap_have_pcap_error_iface_not_up="no"]
4179       )
4180     ]
4181   )
4182 fi
4183
4184 if test "x$c_cv_libpcap_have_pcap_error_iface_not_up" != "xyes"; then
4185   with_libpcap="no (pcap.h misses PCAP_ERROR_IFACE_NOT_UP)"
4186 fi
4187
4188 if test "x$with_libpcap" = "xyes"; then
4189   BUILD_WITH_LIBPCAP_CPPFLAGS="$with_libpcap_cppflags"
4190   BUILD_WITH_LIBPCAP_LDFLAGS="$with_libpcap_ldflags"
4191   BUILD_WITH_LIBPCAP_LIBS="-lpcap"
4192 fi
4193
4194 AC_SUBST([BUILD_WITH_LIBPCAP_CPPFLAGS])
4195 AC_SUBST([BUILD_WITH_LIBPCAP_LDFLAGS])
4196 AC_SUBST([BUILD_WITH_LIBPCAP_LIBS])
4197 # }}}
4198
4199 # --with-libperl {{{
4200 AC_ARG_WITH([libperl],
4201   [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
4202   [
4203     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4204       LDFLAGS="$LDFLAGS -L$withval/lib"
4205       CPPFLAGS="$CPPFLAGS -I$withval/include"
4206       with_libperl="yes"
4207     else
4208       with_libperl="$withval"
4209     fi
4210   ],
4211   [with_libperl="yes"]
4212 )
4213
4214 AC_ARG_VAR([PERL], [path to Perl interpreter])
4215 AC_PATH_PROG([PERL], [perl])
4216
4217 if test "x$PERL" = "x"; then
4218   with_libperl="no (no Perl interpreter found)"
4219 fi
4220
4221 if test "x$with_libperl" = "xyes"; then
4222   SAVE_CFLAGS="$CFLAGS"
4223   SAVE_LIBS="$LIBS"
4224   dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
4225   PERL_CFLAGS=`ARCHFLAGS="" $PERL -MExtUtils::Embed -e perl_inc`
4226   PERL_LIBS=`ARCHFLAGS="" $PERL -MExtUtils::Embed -e ldopts`
4227   CFLAGS="$CFLAGS $PERL_CFLAGS"
4228   LIBS="$LIBS $PERL_LIBS"
4229
4230   AC_CACHE_CHECK([for libperl],
4231     [c_cv_have_libperl],
4232     [
4233       AC_LINK_IFELSE(
4234         [
4235           AC_LANG_PROGRAM(
4236             [[
4237               #define PERL_NO_GET_CONTEXT
4238               #include <EXTERN.h>
4239               #include <perl.h>
4240               #include <XSUB.h>
4241             ]],
4242             [[
4243               dTHX;
4244               load_module (PERL_LOADMOD_NOIMPORT,
4245                 newSVpv ("Collectd::Plugin::FooBar", 24),
4246                 Nullsv);
4247             ]]
4248           )
4249         ],
4250         [c_cv_have_libperl="yes"],
4251         [c_cv_have_libperl="no"]
4252       )
4253     ]
4254   )
4255
4256   CFLAGS="$SAVE_CFLAGS"
4257   LIBS="$SAVE_LIBS"
4258
4259   if test "x$c_cv_have_libperl" = "xno"; then
4260     with_libperl="no"
4261   fi
4262 fi
4263
4264 if test "x$with_libperl" = "xyes"; then
4265   SAVE_CFLAGS="$CFLAGS"
4266   SAVE_LIBS="$LIBS"
4267   CFLAGS="$CFLAGS $PERL_CFLAGS"
4268   LIBS="$LIBS $PERL_LIBS"
4269
4270   AC_CACHE_CHECK([if Perl supports ithreads],
4271     [c_cv_have_perl_ithreads],
4272     [
4273       AC_LINK_IFELSE(
4274         [
4275           AC_LANG_PROGRAM(
4276             [[
4277               #include <EXTERN.h>
4278               #include <perl.h>
4279               #include <XSUB.h>
4280
4281               #if !defined(USE_ITHREADS)
4282               # error "Perl does not support ithreads!"
4283               #endif /* !defined(USE_ITHREADS) */
4284             ]],
4285             []
4286           )
4287         ],
4288         [c_cv_have_perl_ithreads="yes"],
4289         [c_cv_have_perl_ithreads="no"]
4290       )
4291     ]
4292   )
4293
4294   CFLAGS="$SAVE_CFLAGS"
4295   LIBS="$SAVE_LIBS"
4296 fi
4297
4298 if test "x$with_libperl" = "xyes"; then
4299   # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
4300   # (see issues #41 and #42)
4301   SAVE_CFLAGS="$CFLAGS"
4302   SAVE_LIBS="$LIBS"
4303   CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
4304   LIBS="$LIBS $PERL_LIBS"
4305
4306   AC_CACHE_CHECK([for broken Perl_load_module()],
4307     [c_cv_have_broken_perl_load_module],
4308     [
4309       AC_LINK_IFELSE(
4310         [
4311           AC_LANG_PROGRAM(
4312             [[
4313               #define PERL_NO_GET_CONTEXT
4314               #include <EXTERN.h>
4315               #include <perl.h>
4316               #include <XSUB.h>
4317             ]],
4318             [[
4319               dTHX;
4320               load_module (PERL_LOADMOD_NOIMPORT,
4321                 newSVpv ("Collectd::Plugin::FooBar", 24),
4322                 Nullsv);
4323             ]]
4324           )
4325         ],
4326         [c_cv_have_broken_perl_load_module="no"],
4327         [c_cv_have_broken_perl_load_module="yes"]
4328       )
4329     ]
4330   )
4331
4332   CFLAGS="$SAVE_CFLAGS"
4333   LIBS="$SAVE_LIBS"
4334 fi
4335
4336 if test "x$c_cv_have_broken_perl_load_module" = "xyes"; then
4337   PERL_CFLAGS="$PERL_CFLAGS -Wno-nonnull"
4338 fi
4339
4340 if test "x$with_libperl" = "xyes"; then
4341   SAVE_CFLAGS="$CFLAGS"
4342   SAVE_LIBS="$LIBS"
4343   CFLAGS="$CFLAGS $PERL_CFLAGS"
4344   LIBS="$LIBS $PERL_LIBS"
4345
4346   AC_CHECK_MEMBER(
4347     [struct mgvtbl.svt_local],
4348     [have_struct_mgvtbl_svt_local="yes"],
4349     [have_struct_mgvtbl_svt_local="no"],
4350     [[
4351       #include <EXTERN.h>
4352       #include <perl.h>
4353       #include <XSUB.h>
4354     ]]
4355   )
4356
4357   if test "x$have_struct_mgvtbl_svt_local" = "xyes"; then
4358     AC_DEFINE([HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL], [1], [Define if Perls struct mgvtbl has member svt_local.])
4359   fi
4360
4361   CFLAGS="$SAVE_CFLAGS"
4362   LIBS="$SAVE_LIBS"
4363 fi
4364 AC_SUBST([PERL_CFLAGS])
4365 AC_SUBST([PERL_LIBS])
4366
4367 # }}}
4368
4369 # --with-libpq {{{
4370 with_pg_config="pg_config"
4371 AC_ARG_WITH([libpq],
4372   [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@], [Path to libpq.])],
4373   [
4374     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
4375       with_libpq="$withval"
4376     else
4377       if test -f "$withval" && test -x "$withval"; then
4378         with_pg_config="$withval"
4379       else if test -x "$withval/bin/pg_config"; then
4380         with_pg_config="$withval/bin/pg_config"
4381       fi; fi
4382       with_libpq="yes"
4383     fi
4384   ],
4385   [with_libpq="yes"]
4386 )
4387
4388 if test "x$with_libpq" = "xyes"; then
4389   with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
4390   pg_config_status=$?
4391
4392   if test $pg_config_status -eq 0; then
4393     if test -n "$with_libpq_includedir"; then
4394       for dir in $with_libpq_includedir; do
4395         with_libpq_cppflags="$with_libpq_cppflags -I$dir"
4396       done
4397     fi
4398   else
4399     AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
4400   fi
4401
4402   SAVE_CPPFLAGS="$CPPFLAGS"
4403   CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
4404
4405   AC_CHECK_HEADERS([libpq-fe.h],
4406     [with_libpq="yes"],
4407     [with_libpq="no (libpq-fe.h not found)"]
4408   )
4409
4410   CPPFLAGS="$SAVE_CPPFLAGS"
4411 fi
4412
4413 if test "x$with_libpq" = "xyes"; then
4414   with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
4415   pg_config_status=$?
4416
4417   if test $pg_config_status -eq 0
4418   then
4419     if test -n "$with_libpq_libdir"; then
4420       for dir in $with_libpq_libdir; do
4421         with_libpq_ldflags="$with_libpq_ldflags -L$dir"
4422       done
4423     fi
4424   else
4425     AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
4426   fi
4427
4428   SAVE_LDFLAGS="$LDFLAGS"
4429   LDFLAGS="$LDFLAGS $with_libpq_ldflags"
4430
4431   AC_CHECK_LIB([pq], [PQserverVersion],
4432     [with_libpq="yes"],
4433     [with_libpq="no (symbol 'PQserverVersion' not found)"])
4434
4435   LDFLAGS="$SAVE_LDFLAGS"
4436 fi
4437
4438 if test "x$with_libpq" = "xyes"; then
4439   BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
4440   BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
4441   BUILD_WITH_LIBPQ_LIBS="-lpq"
4442 fi
4443
4444 AC_SUBST([BUILD_WITH_LIBPQ_CPPFLAGS])
4445 AC_SUBST([BUILD_WITH_LIBPQ_LDFLAGS])
4446 AC_SUBST([BUILD_WITH_LIBPQ_LIBS])
4447 # }}}
4448
4449 # --with-libpqos {{{
4450 AC_ARG_WITH([libpqos],
4451   [AS_HELP_STRING([--with-libpqos@<:@=PREFIX@:>@], [Path to libpqos.])],
4452   [
4453     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4454       with_libpqos_cppflags="-I$withval/include"
4455       with_libpqos_ldflags="-L$withval/lib"
4456       with_libpqos="yes"
4457     else
4458       with_libpqos="$withval"
4459     fi
4460   ],
4461   [with_libpqos="yes"]
4462 )
4463
4464 if test "x$with_libpqos" = "xyes"; then
4465   SAVE_CPPFLAGS="$CPPFLAGS"
4466   CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4467
4468   AC_CHECK_HEADERS([pqos.h],
4469     [with_libpqos="yes"],
4470     [with_libpqos="no (pqos.h not found)"]
4471   )
4472
4473   CPPFLAGS="$SAVE_CPPFLAGS"
4474 fi
4475
4476 if test "x$with_libpqos" = "xyes"; then
4477   SAVE_LDFLAGS="$LDFLAGS"
4478   LDFLAGS="$LDFLAGS $with_libpqos_ldflags"
4479
4480   AC_CHECK_LIB([pqos], [pqos_init],
4481     [with_libpqos="yes"],
4482     [with_libpqos="no (Can't find libpqos)"]
4483   )
4484
4485   LDFLAGS="$SAVE_LDFLAGS"
4486 fi
4487
4488 if test "x$with_libpqos" = "xyes"; then
4489   SAVE_CPPFLAGS="$CPPFLAGS"
4490   CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4491   AC_PREPROC_IFELSE(
4492     [
4493       AC_LANG_SOURCE(
4494         [[
4495           #include <pqos.h>
4496           #if PQOS_VERSION < 106
4497           #error "required PQOS version >= 1.06"
4498           #endif
4499         ]]
4500       )
4501     ],
4502     [with_libpqos="yes"],
4503     [with_libpqos="no (pqos library version 1.06 or higher is required)"]
4504   )
4505
4506   CPPFLAGS="$SAVE_CPPFLAGS"
4507 fi
4508
4509 if test "x$with_libpqos" = "xyes"; then
4510   BUILD_WITH_LIBPQOS_CPPFLAGS="$with_libpqos_cppflags"
4511   BUILD_WITH_LIBPQOS_LDFLAGS="$with_libpqos_ldflags"
4512   BUILD_WITH_LIBPQOS_LIBS="-lpqos"
4513 fi
4514
4515 AC_SUBST([BUILD_WITH_LIBPQOS_CPPFLAGS])
4516 AC_SUBST([BUILD_WITH_LIBPQOS_LDFLAGS])
4517 AC_SUBST([BUILD_WITH_LIBPQOS_LIBS])
4518 # }}}
4519
4520 # --with-libjevents {{{
4521 with_libjevents_cppflags=""
4522 with_libjevents_ldflags=""
4523 AC_ARG_WITH([libjevents],
4524   [AS_HELP_STRING([--with-libjevents@<:@=PREFIX@:>@], [Path to libjevents.])],
4525   [
4526     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4527       with_libjevents_cppflags="-I$withval/include"
4528       with_libjevents_ldflags="-L$withval/lib"
4529       with_libjevents="yes"
4530     else
4531       with_libjevents="$withval"
4532     fi
4533   ],
4534   [with_libjevents="yes"]
4535 )
4536
4537 if test "x$with_libjevents" = "xyes"; then
4538   SAVE_CPPFLAGS="$CPPFLAGS"
4539   CPPFLAGS="$CPPFLAGS $with_libjevents_cppflags"
4540
4541   AC_CHECK_HEADERS([jevents.h], [with_libjevents="yes"], [with_libjevents="no (jevents.h not found)"])
4542
4543   CPPFLAGS="$SAVE_CPPFLAGS"
4544 fi
4545 if test "x$with_libjevents" = "xyes"; then
4546   SAVE_LDFLAGS="$LDFLAGS"
4547   LDFLAGS="$LDFLAGS $with_libjevents_ldflags"
4548
4549   AC_CHECK_LIB([jevents], [json_events], [with_libjevents="yes"], [with_libjevents="no (Can't find libjevents)"])
4550
4551   LDFLAGS="$SAVE_LDFLAGS"
4552 fi
4553 if test "x$with_libjevents" = "xyes"; then
4554   BUILD_WITH_LIBJEVENTS_CPPFLAGS="$with_libjevents_cppflags"
4555   BUILD_WITH_LIBJEVENTS_LDFLAGS="$with_libjevents_ldflags"
4556   BUILD_WITH_LIBJEVENTS_LIBS="-ljevents"
4557 fi
4558 AC_SUBST([BUILD_WITH_LIBJEVENTS_CPPFLAGS])
4559 AC_SUBST([BUILD_WITH_LIBJEVENTS_LDFLAGS])
4560 AC_SUBST([BUILD_WITH_LIBJEVENTS_LIBS])
4561 # }}}
4562
4563 # --with-libprotobuf {{{
4564 with_libprotobuf_cppflags=""
4565 with_libprotobuf_ldflags=""
4566 AC_ARG_WITH([libprotobuf],
4567   [AS_HELP_STRING([--with-libprotobuf@<:@=PREFIX@:>@], [Path to libprotobuf.])],
4568   [
4569     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4570       with_libprotobuf_cppflags="-I$withval/include"
4571       with_libprotobuf_ldflags="-L$withval/lib"
4572       with_libprotobuf="yes"
4573     fi
4574     if test "x$withval" = "xno"; then
4575       with_libprotobuf="no (disabled on command line)"
4576     fi
4577   ],
4578   [withval="yes"]
4579 )
4580
4581 if test "x$withval" = "xyes"; then
4582   PKG_CHECK_MODULES([PROTOBUF], [protobuf],
4583     [with_libprotobuf="yes"],
4584     [with_libprotobuf="no (pkg-config could not find libprotobuf)"]
4585   )
4586 fi
4587
4588 if test "x$withval" != "xno"; then
4589   SAVE_LDFLAGS="$LDFLAGS"
4590   SAVE_LIBS="$LIBS"
4591   LDFLAGS="$with_libprotobuf_ldflags"
4592   LIBS="$PROTOBUF_LIBS $LIBS"
4593   AC_LANG_PUSH([C++])
4594   AC_CHECK_LIB([protobuf], [main],
4595     [
4596       SAVE_CPPFLAGS="$CPPFLAGS"
4597       CPPFLAGS="$with_libprotobuf_cppflags $PROTOBUF_CFLAGS"
4598       if test "x$PROTOBUF_LIBS" = "x"
4599       then
4600         PROTOBUF_LIBS="-lprotobuf"
4601       fi
4602       AC_CHECK_HEADERS([google/protobuf/util/time_util.h],
4603         [with_libprotobuf="yes"],
4604         [with_libprotobuf="no (<google/protobuf/util/time_util.h> not found)"]
4605       )
4606       CPPFLAGS="$SAVE_CPPFLAGS"
4607     ],
4608     [with_libprotobuf="no (libprotobuf not found)"]
4609   )
4610   AC_LANG_POP([C++])
4611   LDFLAGS="$SAVE_LDFLAGS"
4612   LIBS="$SAVE_LIBS"
4613 fi
4614
4615 BUILD_WITH_LIBPROTOBUF_CPPFLAGS="$with_libprotobuf_cppflags $PROTOBUF_CFLAGS"
4616 BUILD_WITH_LIBPROTOBUF_LDFLAGS="$with_libprotobuf_ldflags"
4617 BUILD_WITH_LIBPROTOBUF_LIBS="$PROTOBUF_LIBS"
4618 AC_SUBST([BUILD_WITH_LIBPROTOBUF_CPPFLAGS])
4619 AC_SUBST([BUILD_WITH_LIBPROTOBUF_LDFLAGS])
4620 AC_SUBST([BUILD_WITH_LIBPROTOBUF_LIBS])
4621 # }}}
4622
4623 AC_ARG_VAR([PROTOC], [path to the protoc binary])
4624 AC_PATH_PROG([PROTOC], [protoc])
4625 have_protoc3="no"
4626 if test "x$PROTOC" != "x"; then
4627   AC_MSG_CHECKING([for protoc 3.0.0+])
4628   if $PROTOC --version | $EGREP libprotoc.3 >/dev/null; then
4629     protoc3="yes (`$PROTOC --version`)"
4630     have_protoc3="yes"
4631   else
4632     protoc3="no (`$PROTOC --version`)"
4633   fi
4634   AC_MSG_RESULT([$protoc3])
4635 fi
4636 AM_CONDITIONAL([HAVE_PROTOC3], [test "x$have_protoc3" = "xyes"])
4637
4638 # --with-libprotobuf-c {{{
4639 AC_ARG_WITH([libprotobuf-c],
4640   [AS_HELP_STRING([--with-libprotobuf-c@<:@=PREFIX@:>@], [Path to libprotobuf-c.])],
4641   [
4642     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4643       with_libprotobuf_c_cppflags="-I$withval/include"
4644       with_libprotobuf_c_ldflags="-L$withval/lib"
4645       with_libprotobuf_c="yes"
4646     fi
4647
4648     if test "x$withval" = "xno"; then
4649       with_libprotobuf_c="no (disabled on command line)"
4650     fi
4651   ],
4652   [withval="yes"]
4653 )
4654
4655 if test "x$withval" = "xyes"; then
4656   PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c],
4657     [with_libprotobuf_c="yes"],
4658     [with_libprotobuf_c="no (pkg-config could not find libprotobuf-c)"]
4659   )
4660 fi
4661
4662 if test "x$withval" != "xno"; then
4663   SAVE_LDFLAGS="$LDFLAGS"
4664   SAVE_LIBS="$LIBS"
4665   LDFLAGS="$with_libprotobuf_c_ldflags"
4666   LIBS="$PROTOBUF_C_LIBS $LIBS"
4667   AC_CHECK_LIB([protobuf-c], [protobuf_c_message_pack],
4668     [
4669       SAVE_CPPFLAGS="$CPPFLAGS"
4670       CPPFLAGS="$with_libprotobuf_c_cppflags $PROTOBUF_C_CFLAGS"
4671       if test "x$PROTOBUF_C_LIBS" = "x"; then
4672         PROTOBUF_C_LIBS="-lprotobuf-c"
4673       fi
4674
4675       AC_CHECK_HEADERS([protobuf-c/protobuf-c.h google/protobuf-c/protobuf-c.h],
4676         [
4677           with_libprotobuf_c="yes"
4678           break
4679         ],
4680         [with_libprotobuf_c="no (<protobuf-c.h> not found)"]
4681       )
4682
4683       CPPFLAGS="$SAVE_CPPFLAGS"
4684     ],
4685     [with_libprotobuf_c="no (libprotobuf-c not found)"]
4686   )
4687   LDFLAGS="$SAVE_LDFLAGS"
4688   LIBS="$SAVE_LIBS"
4689 fi
4690
4691 BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS="$with_libprotobuf_c_cppflags $PROTOBUF_C_CFLAGS"
4692 BUILD_WITH_LIBPROTOBUF_C_LDFLAGS="$with_libprotobuf_c_ldflags"
4693 BUILD_WITH_LIBPROTOBUF_C_LIBS="$PROTOBUF_C_LIBS"
4694 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS])
4695 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_LDFLAGS])
4696 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_LIBS])
4697 # }}}
4698
4699 AC_ARG_VAR([PROTOC_C], [path to the protoc-c binary])
4700 AC_PATH_PROG([PROTOC_C], [protoc-c])
4701 if test "x$PROTOC_C" = "x"
4702 then
4703   have_protoc_c="no (protoc-c compiler not found)"
4704 else
4705   have_protoc_c="yes"
4706 fi
4707
4708 # --with-libpython {{{
4709 AC_ARG_VAR([LIBPYTHON_CPPFLAGS], [Preprocessor flags for libpython])
4710 AC_ARG_VAR([LIBPYTHON_LDFLAGS], [Linker flags for libpython])
4711 AC_ARG_VAR([LIBPYTHON_LIBS], [Libraries for libpython])
4712
4713 AC_ARG_WITH([libpython],
4714   [AS_HELP_STRING([--with-libpython], [if we should build with libpython @<:@default=yes@:>@])],
4715   [with_libpython="$withval"],
4716   [with_libpython="check"]
4717 )
4718
4719 if test "$with_libpython" != "no"; then
4720   if test "$LIBPYTHON_CPPFLAGS" = "" && test "$LIBPYTHON_LDFLAGS" = ""; then
4721     AC_ARG_VAR([PYTHON_CONFIG], [path to python-config])
4722     AC_PATH_PROGS([PYTHON_CONFIG],
4723       [python3-config python2-config python-config]
4724     )
4725     if test "$PYTHON_CONFIG" = ""; then
4726       if test "$with_libpython" = "yes"; then
4727         AC_MSG_ERROR([Unable to find python-config])
4728       fi
4729       with_libpython="no"
4730     fi
4731   fi
4732 fi
4733
4734 if test "$PYTHON_CONFIG" != ""; then
4735   LIBPYTHON_CPPFLAGS="`${PYTHON_CONFIG} --includes`"
4736   if test $? -ne 0; then
4737     with_libpython="no"
4738   fi
4739   LIBPYTHON_LDFLAGS="`${PYTHON_CONFIG} --ldflags`"
4740   if test $? -ne 0; then
4741     with_libpython="no"
4742   fi
4743   LIBPYTHON_LIBS="`${PYTHON_CONFIG} --libs`"
4744   if test $? -ne 0; then
4745     with_libpython="no"
4746   fi
4747 fi
4748
4749 if test "$with_libpython" != "xno"; then
4750   SAVE_CPPFLAGS="$CPPFLAGS"
4751   SAVE_LDFLAGS="$LDFLAGS"
4752   SAVE_LIBS="$LIBS"
4753   CPPFLAGS="$LIBPYTHON_CPPFLAGS $CPPFLAGS"
4754   LDFLAGS="$LIBPYTHON_LDFLAGS $LDFLAGS"
4755   LIBS="$LIBPYTHON_LIBS $LIBS"
4756
4757   AC_CHECK_HEADERS([Python.h],
4758     [
4759       AC_MSG_CHECKING([for libpython])
4760       AC_LINK_IFELSE([AC_LANG_PROGRAM(
4761           [[#include <Python.h>]],
4762           [[Py_Initialize();]])
4763         ],
4764         [with_libpython="yes"],
4765         [with_libpython="no"]
4766       )
4767       AC_MSG_RESULT([$with_libpython])
4768     ],
4769     [with_libpython="no"]
4770   )
4771
4772   CPPFLAGS="$SAVE_CPPFLAGS"
4773   LDFLAGS="$SAVE_LDFLAGS"
4774   LIBS="$SAVE_LIBS"
4775 fi
4776 # }}} --with-libpython
4777
4778 # --with-libqpid_proton {{{
4779 AC_ARG_WITH([libqpid_proton],
4780   [AS_HELP_STRING([--with-libqpid_proton@<:@=PREFIX@:>@], [Path to libqpid_proton.])],
4781   [
4782     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4783       with_libqpid_proton_cppflags="-I$withval/include"
4784       with_libqpid_proton_ldflags="-L$withval/lib"
4785       with_libqpid_proton="yes"
4786     else
4787       with_libqpid_proton="$withval"
4788     fi
4789   ],
4790   [with_libqpid_proton="yes"]
4791 )
4792
4793 if test "x$with_libqpid_proton" = "xyes"; then
4794   SAVE_CPPFLAGS="$CPPFLAGS"
4795   CPPFLAGS="$CPPFLAGS $with_libqpid_proton_cppflags"
4796
4797   AC_CHECK_HEADERS([proton/proactor.h],
4798     [with_libqpid_proton="yes"],
4799     [with_libqpid_proton="no (proton/proactor.h not found)"]
4800   )
4801
4802   CPPFLAGS="$SAVE_CPPFLAGS"
4803 fi
4804
4805 if test "x$with_libqpid_proton" = "xyes"; then
4806   SAVE_LDFLAGS="$LDFLAGS"
4807   LDFLAGS="$LDFLAGS $with_libqpid_proton_ldflags"
4808
4809   AC_CHECK_LIB([qpid-proton], [pn_connection],
4810     [with_libqpid_proton="yes"],
4811     [with_libqpid_proton="no (Symbol 'pn_connection' not found)"])
4812
4813   LDFLAGS="$SAVE_LDFLAGS"
4814 fi
4815
4816 if test "x$with_libqpid_proton" = "xyes"; then
4817   BUILD_WITH_LIBQPIDPROTON_CPPFLAGS="$with_libqpid_proton_cppflags"
4818   BUILD_WITH_LIBQPIDPROTON_LDFLAGS="$with_libqpid_proton_ldflags"
4819   BUILD_WITH_LIBQPIDPROTON_LIBS="-lqpid-proton"
4820 fi
4821
4822 AC_SUBST(BUILD_WITH_LIBQPIDPROTON_CPPFLAGS)
4823 AC_SUBST(BUILD_WITH_LIBQPIDPROTON_LDFLAGS)
4824 AC_SUBST(BUILD_WITH_LIBQPIDPROTON_LIBS)
4825
4826 # }}}
4827
4828 # --with-librabbitmq {{{
4829 AC_ARG_WITH([librabbitmq],
4830   [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
4831   [
4832     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4833       with_librabbitmq_cppflags="-I$withval/include"
4834       with_librabbitmq_ldflags="-L$withval/lib"
4835       with_librabbitmq="yes"
4836     else
4837       with_librabbitmq="$withval"
4838     fi
4839   ],
4840   [with_librabbitmq="yes"]
4841 )
4842
4843 if test "x$with_librabbitmq" = "xyes"; then
4844   SAVE_CPPFLAGS="$CPPFLAGS"
4845   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4846
4847   AC_CHECK_HEADERS([amqp.h],
4848     [with_librabbitmq="yes"],
4849     [with_librabbitmq="no (amqp.h not found)"]
4850   )
4851
4852   CPPFLAGS="$SAVE_CPPFLAGS"
4853 fi
4854
4855 if test "x$with_librabbitmq" = "xyes"; then
4856   # librabbitmq up to version 0.9.1 provides "library_errno", later
4857   # versions use "library_error". The library does not provide a version
4858   # macro :(.
4859
4860   SAVE_CPPFLAGS="$CPPFLAGS"
4861   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4862
4863   AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],
4864     [],
4865     [],
4866     [[
4867       #include <stdlib.h>
4868       #include <stdio.h>
4869       #include <stdint.h>
4870       #include <inttypes.h>
4871       #include <amqp.h>
4872     ]]
4873   )
4874   CPPFLAGS="$SAVE_CPPFLAGS"
4875
4876   SAVE_LDFLAGS="$LDFLAGS"
4877   LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
4878
4879   AC_CHECK_LIB([rabbitmq], [amqp_basic_publish],
4880     [with_librabbitmq="yes"],
4881     [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"]
4882   )
4883
4884   LDFLAGS="$SAVE_LDFLAGS"
4885 fi
4886
4887 if test "x$with_librabbitmq" = "xyes"; then
4888   SAVE_CPPFLAGS="$CPPFLAGS"
4889   SAVE_LDFLAGS="$LDFLAGS"
4890   SAVE_LIBS="$LIBS"
4891   CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4892   LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
4893   LIBS="-lrabbitmq"
4894
4895   AC_CHECK_HEADERS([amqp_tcp_socket.h amqp_socket.h])
4896   AC_CHECK_FUNC([amqp_tcp_socket_new],
4897     [
4898       AC_DEFINE([HAVE_AMQP_TCP_SOCKET], [1],
4899         [Define if librabbitmq provides the new TCP socket interface.])
4900     ]
4901   )
4902
4903   AC_CHECK_DECLS([amqp_socket_close],
4904     [],
4905     [],
4906     [[
4907       #include <amqp.h>
4908       #ifdef HAVE_AMQP_TCP_SOCKET_H
4909       # include <amqp_tcp_socket.h>
4910       #endif
4911       #ifdef HAVE_AMQP_SOCKET_H
4912       # include <amqp_socket.h>
4913       #endif
4914     ]]
4915   )
4916
4917   CPPFLAGS="$SAVE_CPPFLAGS"
4918   LDFLAGS="$SAVE_LDFLAGS"
4919   LIBS="$SAVE_LIBS"
4920 fi
4921
4922 if test "x$with_librabbitmq" = "xyes"; then
4923   BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
4924   BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
4925   BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
4926 fi
4927
4928 AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
4929 AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
4930 AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
4931
4932 # }}}
4933
4934 # --with-librdkafka {{{
4935 AC_ARG_WITH([librdkafka],
4936   [AS_HELP_STRING([--with-librdkafka@<:@=PREFIX@:>@], [Path to librdkafka.])],
4937   [
4938     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
4939       with_librdkafka_cppflags="-I$withval/include"
4940       with_librdkafka_ldflags="-L$withval/lib"
4941       with_librdkafka_rpath="$withval/lib"
4942       with_librdkafka="yes"
4943     else
4944       with_librdkafka="$withval"
4945     fi
4946   ],
4947   [with_librdkafka="yes"]
4948 )
4949
4950 if test "x$with_librdkafka" = "xyes"; then
4951   SAVE_CPPFLAGS="$CPPFLAGS"
4952   CPPFLAGS="$CPPFLAGS $with_librdkafka_cppflags"
4953
4954   AC_CHECK_HEADERS([librdkafka/rdkafka.h],
4955     [with_librdkafka="yes"],
4956     [with_librdkafka="no (librdkafka/rdkafka.h not found)"]
4957   )
4958
4959   CPPFLAGS="$SAVE_CPPFLAGS"
4960 fi
4961
4962 if test "x$with_librdkafka" = "xyes"; then
4963   SAVE_LDFLAGS="$LDFLAGS"
4964   LDFLAGS="$LDFLAGS $with_librdkafka_ldflags"
4965
4966   AC_CHECK_LIB([rdkafka], [rd_kafka_new],
4967     [with_librdkafka="yes"],
4968     [with_librdkafka="no (Symbol 'rd_kafka_new' not found)"])
4969
4970   AC_CHECK_LIB([rdkafka], [rd_kafka_conf_set_log_cb],
4971     [with_librdkafka_log_cb="yes"],
4972     [with_librdkafka_log_cb="no"])
4973
4974   AC_CHECK_LIB([rdkafka], [rd_kafka_set_logger],
4975     [with_librdkafka_logger="yes"],
4976     [with_librdkafka_logger="no"]
4977   )
4978
4979   LDFLAGS="$SAVE_LDFLAGS"
4980 fi
4981
4982 if test "x$with_librdkafka" = "xyes"; then
4983   BUILD_WITH_LIBRDKAFKA_CPPFLAGS="$with_librdkafka_cppflags"
4984   BUILD_WITH_LIBRDKAFKA_LDFLAGS="$with_librdkafka_ldflags"
4985
4986   if test "x$with_librdkafka_rpath" != "x"; then
4987     BUILD_WITH_LIBRDKAFKA_LIBS="-Wl,-rpath,$with_librdkafka_rpath -lrdkafka"
4988   else
4989     BUILD_WITH_LIBRDKAFKA_LIBS="-lrdkafka"
4990   fi
4991
4992   if test "x$with_librdkafka_log_cb" = "xyes"; then
4993     AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.])
4994   else if test "x$with_librdkafka_logger" = "xyes"; then
4995     AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.])
4996   fi; fi
4997 fi
4998
4999 AC_SUBST([BUILD_WITH_LIBRDKAFKA_CPPFLAGS])
5000 AC_SUBST([BUILD_WITH_LIBRDKAFKA_LDFLAGS])
5001 AC_SUBST([BUILD_WITH_LIBRDKAFKA_LIBS])
5002 # }}}
5003
5004 # --with-librouteros {{{
5005 AC_ARG_WITH([librouteros],
5006   [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
5007   [
5008     if test "x$withval" = "xyes" || test "x$withval" = "xno"; then
5009       with_librouteros="$witval"
5010     else
5011       with_librouteros_cppflags="-I$withval/include"
5012       with_librouteros_ldflags="-L$withval/lib"
5013       with_librouteros="yes"
5014    fi
5015   ],
5016   [with_librouteros="yes"]
5017 )
5018
5019 if test "x$with_librouteros" = "xyes"; then
5020   SAVE_CPPFLAGS="$CPPFLAGS"
5021   CPPFLAGS="$CPPFLAGS $with_librouteros_cppflags"
5022
5023   AC_CHECK_HEADERS([routeros_api.h],
5024     [with_librouteros="yes"],
5025     [with_librouteros="no (routeros_api.h not found)"]
5026   )
5027
5028   CPPFLAGS="$SAVE_CPPFLAGS"
5029 fi
5030
5031 if test "x$with_librouteros" = "xyes"; then
5032   SAVE_LDFLAGS="$LDFLAGS"
5033   LDFLAGS="$LDFLAGS $with_librouteros_ldflags"
5034
5035   AC_CHECK_LIB([routeros], [ros_interface],
5036     [with_librouteros="yes"],
5037     [with_librouteros="no (symbol 'ros_interface' not found)"]
5038   )
5039
5040   LDFLAGS="$SAVE_LDFLAGS"
5041 fi
5042
5043 if test "x$with_librouteros" = "xyes"; then
5044   BUILD_WITH_LIBROUTEROS_CPPFLAGS="$with_librouteros_cppflags"
5045   BUILD_WITH_LIBROUTEROS_LDFLAGS="$with_librouteros_ldflags"
5046 fi
5047
5048 AC_SUBST([BUILD_WITH_LIBROUTEROS_CPPFLAGS])
5049 AC_SUBST([BUILD_WITH_LIBROUTEROS_LDFLAGS])
5050 # }}}
5051
5052 # --with-librrd {{{
5053 librrd_threadsafe="no"
5054 librrd_rrdc_update="no"
5055 AC_ARG_WITH([librrd],
5056   [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
5057   [
5058     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5059       librrd_cflags="-I$withval/include"
5060       librrd_ldflags="-L$withval/lib"
5061       with_librrd="yes"
5062     else
5063       with_librrd="$withval"
5064     fi
5065   ],
5066   [with_librrd="yes"]
5067 )
5068
5069 if test "x$with_librrd" = "xyes"; then
5070   SAVE_LDFLAGS="$LDFLAGS"
5071   LDFLAGS="$LDFLAGS $librrd_ldflags"
5072   PKG_CHECK_MODULES([RRD], [librrd >= 1.6.0],
5073     [
5074       AC_CHECK_LIB([rrd], [rrd_update_r],
5075         [librrd_threadsafe="yes"],
5076         [:]
5077       )
5078       AC_CHECK_LIB([rrd], [rrdc_update],
5079         [librrd_rrdc_update="yes"],
5080         [:]
5081       )
5082     ],[:]
5083   )
5084   LDFLAGS="$SAVE_LDFLAGS"
5085
5086   SAVE_CPPFLAGS="$CPPFLAGS"
5087   CPPFLAGS="$CPPFLAGS $RRD_CFLAGS $librrd_cflags"
5088
5089   AC_CHECK_HEADERS([rrd.h],, [with_librrd="no (rrd.h not found)"])
5090
5091   CPPFLAGS="$SAVE_CPPFLAGS"
5092 fi
5093
5094 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"; then
5095   SAVE_LDFLAGS="$LDFLAGS"
5096   LDFLAGS="$LDFLAGS $librrd_ldflags"
5097
5098   AC_CHECK_LIB([rrd_th], [rrd_update_r],
5099     [
5100       librrd_ldflags="$librrd_ldflags -lrrd_th"
5101       librrd_threadsafe="yes"
5102       AC_CHECK_LIB([rrd_th], [rrdc_update],
5103         [librrd_rrdc_update="yes"],
5104         [:],
5105       )
5106     ],
5107     [:]
5108   )
5109   LDFLAGS="$SAVE_LDFLAGS"
5110 fi
5111
5112 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"; then
5113   SAVE_LDFLAGS="$LDFLAGS"
5114   LDFLAGS="$LDFLAGS $librrd_ldflags"
5115
5116   AC_CHECK_LIB([rrd], [rrd_update],
5117     [
5118       librrd_ldflags="$librrd_ldflags -lrrd"
5119       AC_CHECK_LIB([rrd], [rrdc_update],
5120         [librrd_rrdc_update="yes"],
5121         [:]
5122       )
5123     ],
5124     [with_librrd="no (symbol 'rrd_update' not found)"]
5125   )
5126   LDFLAGS="$SAVE_LDFLAGS"
5127 fi
5128
5129 if test "x$with_librrd" = "xyes"; then
5130   BUILD_WITH_LIBRRD_CFLAGS="$RRD_CFLAGS $librrd_cflags"
5131   BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
5132   BUILD_WITH_LIBRRD_LIBS="$RRD_LIBS"
5133 fi
5134
5135 if test "x$librrd_threadsafe" = "xyes"; then
5136   AC_DEFINE([HAVE_THREADSAFE_LIBRRD], [1],
5137     [Define to 1 if the rrd library is thread-safe]
5138   )
5139 fi
5140
5141 AC_SUBST([BUILD_WITH_LIBRRD_CFLAGS])
5142 AC_SUBST([BUILD_WITH_LIBRRD_LDFLAGS])
5143 AC_SUBST([BUILD_WITH_LIBRRD_LIBS])
5144 # }}}
5145
5146 # --with-libsensors {{{
5147 AC_ARG_WITH([libsensors],
5148   [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
5149   [
5150     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5151       with_libsensors="$withval"
5152     else
5153       with_sensors_cppflags="-I$withval/include"
5154       with_sensors_ldflags="-L$withval/lib"
5155       with_libsensors="yes"
5156     fi
5157   ],
5158   [
5159     if test "x$ac_system" = "xLinux"; then
5160       with_libsensors="yes"
5161     else
5162       with_libsensors="no (Linux only library)"
5163     fi
5164   ]
5165 )
5166
5167 if test "x$with_libsensors" = "xyes"; then
5168   SAVE_CPPFLAGS="$CPPFLAGS"
5169   CPPFLAGS="$CPPFLAGS $with_sensors_cppflags"
5170
5171   AC_CHECK_HEADERS([sensors/sensors.h],
5172     [with_libsensors="yes"],
5173     [with_libsensors="no (sensors/sensors.h not found)"]
5174   )
5175
5176   CPPFLAGS="$SAVE_CPPFLAGS"
5177 fi
5178
5179 if test "x$with_libsensors" = "xyes"; then
5180   SAVE_LDFLAGS="$LDFLAGS"
5181   LDFLAGS="$LDFLAGS $with_sensors_ldflags"
5182
5183   AC_CHECK_LIB([sensors], [sensors_init],
5184     [with_libsensors="yes"],
5185     [with_libsensors="no (libsensors not found)"]
5186   )
5187
5188   LDFLAGS="$SAVE_LDFLAGS"
5189 fi
5190
5191 if test "x$with_libsensors" = "xyes"; then
5192   BUILD_WITH_LIBSENSORS_CPPFLAGS="$with_sensors_cppflags"
5193   BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
5194   BUILD_WITH_LIBSENSORS_LIBS="-lsensors"
5195 fi
5196
5197 AC_SUBST([BUILD_WITH_LIBSENSORS_CPPFLAGS])
5198 AC_SUBST([BUILD_WITH_LIBSENSORS_LDFLAGS])
5199 AC_SUBST([BUILD_WITH_LIBSENSORS_LIBS])
5200
5201 # }}}
5202
5203 # libsigrok {{{
5204 AC_SUBST([LIBSIGROK_CFLAGS])
5205 AC_SUBST([LIBSIGROK_LIBS])
5206 PKG_CHECK_MODULES([LIBSIGROK], [libsigrok < 0.4],
5207   [with_libsigrok="yes"],
5208   [with_libsigrok="no (pkg-config could not find libsigrok)"]
5209 )
5210 # }}}
5211
5212 # --with-libstatgrab {{{
5213 AC_ARG_WITH([libstatgrab],
5214   [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
5215   [
5216     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5217       with_libstatgrab_cflags="-I$withval/include"
5218       with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
5219       with_libstatgrab="yes"
5220       with_libstatgrab_pkg_config="no"
5221     else
5222       with_libstatgrab="$withval"
5223       with_libstatgrab_pkg_config="yes"
5224     fi
5225   ],
5226   [
5227     with_libstatgrab="yes"
5228     with_libstatgrab_pkg_config="yes"
5229   ])
5230
5231 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes"; then
5232   AC_MSG_CHECKING([pkg-config for libstatgrab])
5233   temp_result="found"
5234   $PKG_CONFIG --exists libstatgrab 2>/dev/null
5235   if test "$?" != "0"; then
5236     with_libstatgrab_pkg_config="no"
5237     with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
5238     temp_result="not found"
5239   fi
5240   AC_MSG_RESULT([$temp_result])
5241 fi
5242
5243 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes" && test "x$with_libstatgrab_cflags" = "x"; then
5244   AC_MSG_CHECKING([for libstatgrab CFLAGS])
5245   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
5246   if test "$?" = "0"; then
5247     with_libstatgrab_cflags="$temp_result"
5248   else
5249     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
5250     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
5251   fi
5252   AC_MSG_RESULT([$temp_result])
5253 fi
5254
5255 if test "x$with_libstatgrab" = "xyes" && test "x$with_libstatgrab_pkg_config" = "xyes" && test "x$with_libstatgrab_ldflags" = "x"; then
5256   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
5257   temp_result="`$PKG_CONFIG --libs libstatgrab`"
5258   if test "$?" = "0"
5259   then
5260     with_libstatgrab_ldflags="$temp_result"
5261   else
5262     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
5263     temp_result="$PKG_CONFIG --libs libstatgrab failed"
5264   fi
5265   AC_MSG_RESULT([$temp_result])
5266 fi
5267
5268 if test "x$with_libstatgrab" = "xyes"; then
5269   SAVE_CPPFLAGS="$CPPFLAGS"
5270   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
5271
5272   AC_CHECK_HEADERS([statgrab.h],
5273     [with_libstatgrab="yes"],
5274     [with_libstatgrab="no (statgrab.h not found)"]
5275   )
5276
5277   CPPFLAGS="$SAVE_CPPFLAGS"
5278 fi
5279
5280 if test "x$with_libstatgrab" = "xyes"; then
5281   SAVE_LDFLAGS="$LDFLAGS"
5282   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5283
5284   AC_CHECK_LIB([statgrab], [sg_init],
5285     [with_libstatgrab="yes"],
5286     [with_libstatgrab="no (symbol sg_init not found)"]
5287   )
5288
5289   LDFLAGS="$SAVE_LDFLAGS"
5290 fi
5291
5292 if test "x$with_libstatgrab" = "xyes"; then
5293   SAVE_CFLAGS="$CFLAGS"
5294   SAVE_LDFLAGS="$LDFLAGS"
5295   SAVE_LIBS="$LIBS"
5296
5297   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
5298   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5299   LIBS="-lstatgrab $LIBS"
5300
5301   AC_CACHE_CHECK([if libstatgrab >= 0.90],
5302     [c_cv_have_libstatgrab_0_90],
5303     [
5304       AC_LINK_IFELSE(
5305         [
5306           AC_LANG_PROGRAM(
5307             [[
5308               #include <stdio.h>
5309               #include <statgrab.h>
5310             ]],
5311             [[
5312               if (sg_init()) return 0;
5313             ]]
5314           )
5315         ],
5316         [c_cv_have_libstatgrab_0_90="no"],
5317         [c_cv_have_libstatgrab_0_90="yes"]
5318       )
5319     ]
5320   )
5321
5322   CFLAGS="$SAVE_CFLAGS"
5323   LDFLAGS="$SAVE_LDFLAGS"
5324   LIBS="$SAVE_LIBS"
5325 fi
5326
5327 AM_CONDITIONAL([BUILD_WITH_LIBSTATGRAB], [test "x$with_libstatgrab" = "xyes"])
5328
5329 if test "x$with_libstatgrab" = "xyes"; then
5330   AC_DEFINE([HAVE_LIBSTATGRAB], [1],
5331     [Define to 1 if you have the 'statgrab' library (-lstatgrab)]
5332   )
5333
5334   if test "x$c_cv_have_libstatgrab_0_90" = "xyes"; then
5335     AC_DEFINE([HAVE_LIBSTATGRAB_0_90], [1],
5336       [Define to 1 if libstatgrab version >= 0.90]
5337     )
5338   fi
5339
5340   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
5341   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
5342
5343 fi
5344
5345 AC_SUBST([BUILD_WITH_LIBSTATGRAB_CFLAGS])
5346 AC_SUBST([BUILD_WITH_LIBSTATGRAB_LDFLAGS])
5347 # }}}
5348
5349 # --with-libtokyotyrant {{{
5350 AC_ARG_WITH([libtokyotyrant],
5351   [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
5352   [
5353     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5354       with_libtokyotyrant="$withval"
5355     else
5356       with_libtokyotyrant_cppflags="-I$withval/include"
5357       with_libtokyotyrant_ldflags="-L$withval/include"
5358       with_libtokyotyrant_libs="-ltokyotyrant"
5359       with_libtokyotyrant="yes"
5360     fi
5361   ],
5362   [with_libtokyotyrant="yes"]
5363 )
5364
5365 if test "x$with_libtokyotyrant" = "xyes"; then
5366   if $PKG_CONFIG --exists tokyotyrant; then
5367     with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
5368     with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `$PKG_CONFIG --libs-only-L tokyotyrant`"
5369     with_libtokyotyrant_libs="$with_libtokyotyrant_libs `$PKG_CONFIG --libs-only-l tokyotyrant`"
5370   fi
5371 fi
5372
5373 if test "x$with_libtokyotyrant" = "xyes"; then
5374   SAVE_CPPFLAGS="$CPPFLAGS"
5375   CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
5376
5377   AC_CHECK_HEADERS([tcrdb.h],
5378     [with_libtokyotyrant="yes"],
5379     [with_libtokyotyrant="no (tcrdb.h not found)"]
5380   )
5381
5382   CPPFLAGS="$SAVE_CPPFLAGS"
5383 fi
5384
5385 if test "x$with_libtokyotyrant" = "xyes"; then
5386   SAVE_LDFLAGS="$LDFLAGS"
5387   LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
5388
5389   AC_CHECK_LIB([tokyotyrant], [tcrdbrnum],
5390     [with_libtokyotyrant="yes"],
5391     [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
5392     [$with_libtokyotyrant_libs]
5393   )
5394
5395   LDFLAGS="$SAVE_LDFLAGS"
5396 fi
5397
5398 if test "x$with_libtokyotyrant" = "xyes"; then
5399   BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
5400   BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
5401   BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
5402 fi
5403 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS])
5404 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS])
5405 AC_SUBST([BUILD_WITH_LIBTOKYOTYRANT_LIBS])
5406 # }}}
5407
5408 # --with-libudev {{{
5409 AC_ARG_WITH([libudev],
5410   [AS_HELP_STRING([--with-libudev@<:@=PREFIX@:>@], [Path to libudev.])],
5411   [
5412     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5413       with_libudev="$withval"
5414     else
5415       with_libudev_cppflags="-I$withval/include"
5416       with_libudev_ldflags="-L$withval/lib"
5417       with_libudev="yes"
5418     fi
5419   ],
5420   [
5421     if test "x$ac_system" = "xLinux"; then
5422       with_libudev="yes"
5423     else
5424       with_libudev="no (Linux only library)"
5425     fi
5426   ]
5427 )
5428
5429 if test "x$with_libudev" = "xyes"; then
5430   SAVE_CPPFLAGS="$CPPFLAGS"
5431   CPPFLAGS="$CPPFLAGS $with_libudev_cppflags"
5432
5433   AC_CHECK_HEADERS([libudev.h],
5434     [with_libudev="yes"],
5435     [with_libudev="no (libudev.h not found)"]
5436   )
5437
5438   CPPFLAGS="$SAVE_CPPFLAGS"
5439 fi
5440
5441 if test "x$with_libudev" = "xyes"; then
5442   SAVE_LDFLAGS="$LDFLAGS"
5443   LDFLAGS="$LDFLAGS $with_libudev_ldflags"
5444
5445   AC_CHECK_LIB([udev], [udev_new],
5446     [with_libudev="yes"],
5447     [with_libudev="no (libudev not found)"]
5448   )
5449
5450   LDFLAGS="$SAVE_LDFLAGS"
5451 fi
5452
5453 if test "x$with_libudev" = "xyes"; then
5454   BUILD_WITH_LIBUDEV_CPPFLAGS="$with_libudev_cppflags"
5455   BUILD_WITH_LIBUDEV_LDFLAGS="$with_libudev_ldflags"
5456   BUILD_WITH_LIBUDEV_LIBS="-ludev"
5457 fi
5458
5459 AC_SUBST([BUILD_WITH_LIBUDEV_CPPFLAGS])
5460 AC_SUBST([BUILD_WITH_LIBUDEV_LDFLAGS])
5461 AC_SUBST([BUILD_WITH_LIBUDEV_LIBS])
5462
5463 AM_CONDITIONAL([BUILD_WITH_LIBUDEV], [test "x$with_libudev" = "xyes"])
5464 # }}}
5465
5466 # --with-libupsclient {{{
5467 with_libupsclient_config=""
5468 AC_ARG_WITH([libupsclient],
5469   [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
5470   [
5471     if test "x$withval" = "xno"; then
5472       with_libupsclient="no"
5473     else if test "x$withval" = "xyes"; then
5474       with_libupsclient="use_pkgconfig"
5475     else
5476       if test -x "$withval"; then
5477         with_libupsclient_config="$withval"
5478         with_libupsclient="use_libupsclient_config"
5479       else if test -x "$withval/bin/libupsclient-config"; then
5480         with_libupsclient_config="$withval/bin/libupsclient-config"
5481         with_libupsclient="use_libupsclient_config"
5482       else
5483         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
5484         with_libupsclient_cflags="-I$withval/include"
5485         with_libupsclient_libs="-L$withval/lib -lupsclient"
5486         with_libupsclient="yes"
5487       fi; fi
5488     fi; fi
5489   ],
5490   [with_libupsclient="use_pkgconfig"]
5491 )
5492
5493 # configure using libupsclient-config
5494 if test "x$with_libupsclient" = "xuse_libupsclient_config"; then
5495   with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
5496   if test $? -ne 0; then
5497     with_libupsclient="no ($with_libupsclient_config failed)"
5498   fi
5499   with_libupsclient_libs="`$with_libupsclient_config --libs`"
5500   if test $? -ne 0; then
5501     with_libupsclient="no ($with_libupsclient_config failed)"
5502   fi
5503 fi
5504
5505 if test "x$with_libupsclient" = "xuse_libupsclient_config"; then
5506   with_libupsclient="yes"
5507 fi
5508
5509 # configure using pkg-config
5510 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5511   AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
5512   $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
5513   if test $? -ne 0; then
5514     with_libupsclient="no (pkg-config doesn't know libupsclient)"
5515   fi
5516 fi
5517
5518 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5519   with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
5520   if test $? -ne 0; then
5521     with_libupsclient="no ($PKG_CONFIG failed)"
5522   fi
5523
5524   with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
5525   if test $? -ne 0; then
5526     with_libupsclient="no ($PKG_CONFIG failed)"
5527   fi
5528 fi
5529
5530 if test "x$with_libupsclient" = "xuse_pkgconfig"; then
5531   with_libupsclient="yes"
5532 fi
5533
5534 if test "x$with_libupsclient" = "xyes"; then
5535   SAVE_CPPFLAGS="$CPPFLAGS"
5536   CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5537
5538   AC_CHECK_HEADERS([upsclient.h],
5539     [with_libupsclient="yes"],
5540     [with_libupsclient="no (upsclient.h not found)"]
5541   )
5542
5543   CPPFLAGS="$SAVE_CPPFLAGS"
5544 fi
5545
5546 if test "x$with_libupsclient" = "xyes"; then
5547   SAVE_LDFLAGS="$LDFLAGS"
5548   LDFLAGS="$LDFLAGS $with_libupsclient_libs"
5549
5550   AC_CHECK_LIB([upsclient], [upscli_connect],
5551     [with_libupsclient="yes"],
5552     [with_libupsclient="no (symbol upscli_connect not found)"]
5553   )
5554
5555   AC_CHECK_LIB([upsclient], [upscli_init],
5556     [AC_DEFINE([HAVE_UPSCLI_INIT], [1], [Define when upscli_init() (since version 2-7) is available.])]
5557   )
5558
5559   AC_CHECK_LIB([upsclient], [upscli_tryconnect],
5560     [AC_DEFINE([HAVE_UPSCLI_TRYCONNECT], [1], [Define when upscli_tryconnect() (since version 2.6.2) is available.])]
5561   )
5562
5563   LDFLAGS="$SAVE_LDFLAGS"
5564 fi
5565
5566 if test "x$with_libupsclient" = "xyes"; then
5567   SAVE_CPPFLAGS="$CPPFLAGS"
5568   CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5569
5570   AC_CHECK_TYPES([UPSCONN_t, UPSCONN],
5571     [],
5572     [],
5573     [[
5574       #include <stdlib.h>
5575       #include <stdio.h>
5576       #include <upsclient.h>
5577     ]]
5578   )
5579
5580   CPPFLAGS="$SAVE_CPPFLAGS"
5581 fi
5582
5583 if test "x$with_libupsclient" = "xyes"; then
5584   BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
5585   BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
5586 fi
5587
5588 AC_SUBST([BUILD_WITH_LIBUPSCLIENT_CFLAGS])
5589 AC_SUBST([BUILD_WITH_LIBUPSCLIENT_LIBS])
5590 # }}}
5591
5592 # --with-libxenctrl {{{
5593 AC_ARG_WITH([libxenctrl],
5594   [AS_HELP_STRING([--with-libxenctrl@<:@=PREFIX@:>@], [Path to libxenctrl.])],
5595   [
5596     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5597       with_libxenctrl_cppflags="-I$withval/include"
5598       with_libxenctrl_ldflags="-L$withval/lib"
5599       with_libxenctrl="yes"
5600     else
5601       with_libxenctrl="$withval"
5602     fi
5603   ],
5604   [with_libxenctrl="yes"]
5605 )
5606
5607 if test "x$with_libxenctrl" = "xyes"; then
5608   SAVE_CPPFLAGS="$CPPFLAGS"
5609   CPPFLAGS="$CPPFLAGS $with_libxenctrl_cppflags"
5610
5611   AC_CHECK_HEADERS([xenctrl.h],
5612     [with_libxenctrl="yes"],
5613     [with_libxenctrl="no (xenctrl.h not found)"]
5614   )
5615
5616   CPPFLAGS="$SAVE_CPPFLAGS"
5617 fi
5618
5619 if test "x$with_libxenctrl" = "xyes"; then
5620   SAVE_LDFLAGS="$LDFLAGS"
5621   LDFLAGS="$LDFLAGS $with_libxenctrl_ldflags"
5622
5623   #Xen versions older than 3.4 has no xc_getcpuinfo()
5624   AC_CHECK_LIB([xenctrl], [xc_getcpuinfo],
5625     [with_libxenctrl="yes"],
5626     [with_libxenctrl="no (symbol 'xc_getcpuinfo' not found)"]
5627   )
5628
5629   LDFLAGS="$SAVE_LDFLAGS"
5630 fi
5631
5632 LIBXENCTL_CPPFLAGS="$with_libxenctl_cppflags"
5633 LIBXENCTL_LDFLAGS="$with_libxenctl_ldflags"
5634 AC_SUBST([LIBXENCTL_CPPFLAGS])
5635 AC_SUBST([LIBXENCTL_LDFLAGS])
5636 # }}}
5637
5638 # --with-libxmms {{{
5639 with_xmms_config="xmms-config"
5640 AC_ARG_WITH([libxmms],
5641   [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
5642   [
5643     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5644       with_libxmms="$withval"
5645     else
5646       if test -f "$withval" && test -x "$withval"; then
5647         with_xmms_config="$withval"
5648       else if test -x "$withval/bin/xmms-config"; then
5649         with_xmms_config="$withval/bin/xmms-config"
5650       fi; fi
5651       with_libxmms="yes"
5652     fi
5653   ],
5654   [with_libxmms="yes"]
5655 )
5656
5657 if test "x$with_libxmms" = "xyes"; then
5658   with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
5659   if test $? -ne 0; then
5660     with_libxmms="no"
5661   fi
5662 fi
5663
5664 if test "x$with_libxmms" = "xyes"; then
5665   with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
5666   if test $? -ne 0; then
5667     with_libxmms="no"
5668   fi
5669 fi
5670
5671 if test "x$with_libxmms" = "xyes"; then
5672   SAVE_CFLAGS="$CFLAGS"
5673   CFLAGS="$with_xmms_cflags"
5674
5675   AC_CHECK_HEADER([xmmsctrl.h],
5676     [with_libxmms="yes"],
5677     [with_libxmms="no"],
5678   )
5679
5680   CFLAGS="$SAVE_CFLAGS"
5681 fi
5682
5683 if test "x$with_libxmms" = "xyes"; then
5684   SAVE_LIBS="$LIBS"
5685   LIBS="$with_xmms_libs"
5686
5687   AC_CHECK_LIB([xmms], [xmms_remote_get_info],
5688     [with_libxmss="yes"],
5689     [with_libxmms="no"],
5690     [$with_xmms_libs]
5691
5692   )
5693
5694   LIBS="$SAVE_LIBS"
5695 fi
5696
5697 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
5698 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
5699
5700 AC_SUBST([BUILD_WITH_LIBXMMS_CFLAGS])
5701 AC_SUBST([BUILD_WITH_LIBXMMS_LIBS])
5702 # }}}
5703
5704 # --with-libyajl {{{
5705 AC_ARG_WITH([libyajl],
5706   [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
5707   [
5708     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
5709       with_libyajl_cppflags="-I$withval/include"
5710       with_libyajl_ldflags="-L$withval/lib"
5711       with_libyajl="yes"
5712     else
5713       with_libyajl="$withval"
5714     fi
5715   ],
5716   [with_libyajl="yes"]
5717 )
5718
5719 if test "x$with_libyajl" = "xyes"; then
5720   SAVE_CPPFLAGS="$CPPFLAGS"
5721   CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
5722
5723   AC_CHECK_HEADERS([yajl/yajl_parse.h],
5724     [with_libyajl="yes"],
5725     [with_libyajl="no (yajl/yajl_parse.h not found)"]
5726   )
5727
5728   AC_CHECK_HEADERS([yajl/yajl_tree.h],
5729     [with_libyajl2="yes"],
5730     [with_libyajl2="no (yajl/yajl_tree.h not found)"]
5731   )
5732
5733   AC_CHECK_HEADERS([yajl/yajl_version.h])
5734
5735   CPPFLAGS="$SAVE_CPPFLAGS"
5736 fi
5737
5738 if test "x$with_libyajl" = "xyes"; then
5739   SAVE_LDFLAGS="$LDFLAGS"
5740   LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
5741
5742   AC_CHECK_LIB([yajl], [yajl_alloc],
5743     [with_libyajl="yes"],
5744     [with_libyajl="no (Symbol 'yajl_alloc' not found)"]
5745   )
5746
5747   AC_CHECK_LIB([yajl], [yajl_tree_parse],
5748     [with_libyajl2="yes"],
5749     [with_libyajl2="no (Symbol 'yajl_tree_parse' not found)"]
5750   )
5751
5752   LDFLAGS="$SAVE_LDFLAGS"
5753 fi
5754
5755 if test "x$with_libyajl" = "xyes"; then
5756   BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
5757   BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
5758   BUILD_WITH_LIBYAJL_LIBS="-lyajl"
5759   AC_DEFINE([HAVE_LIBYAJL], [1], [Define if libyajl is present and usable.])
5760 fi
5761
5762 AC_SUBST([BUILD_WITH_LIBYAJL_CPPFLAGS])
5763 AC_SUBST([BUILD_WITH_LIBYAJL_LDFLAGS])
5764 AC_SUBST([BUILD_WITH_LIBYAJL_LIBS])
5765
5766 AM_CONDITIONAL([BUILD_WITH_LIBYAJL], [test "x$with_libyajl" = "xyes"])
5767 # }}}
5768
5769 # --with-mic {{{
5770 with_mic_cppflags="-I/opt/intel/mic/sysmgmt/sdk/include"
5771 with_mic_ldflags="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
5772 with_mic_libs="-lMicAccessSDK -scif"
5773 AC_ARG_WITH([mic],
5774   [AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
5775   [
5776     if test "x$withval" = "xno" || test "x$withval" = "xyes"; then
5777       with_mic="$withval"
5778     else if test -d "$with_mic/lib"; then
5779       with_mic_cppflags="-I$withval/include"
5780       with_mic_ldflags="-L$withval/lib/Linux"
5781       with_mic="yes"
5782     fi; fi
5783   ],
5784   [with_mic="yes"]
5785 )
5786
5787 if test "x$with_mic" = "xyes"; then
5788   SAVE_CPPFLAGS="$CPPFLAGS"
5789   CPPFLAGS="$CPPFLAGS $with_mic_cppflags"
5790
5791   AC_CHECK_HEADERS([MicAccessApi.h],
5792     [with_mic="yes"],
5793     [with_mic="no (MicAccessApi not found)"]
5794   )
5795
5796   CPPFLAGS="$SAVE_CPPFLAGS"
5797 fi
5798
5799 if test "x$with_mic" = "xyes"; then
5800   SAVE_LDFLAGS="$LDFLAGS"
5801   LDFLAGS="$LDFLAGS $with_mic_ldflags"
5802
5803   AC_CHECK_LIB([MicAccessSDK], [MicInitAPI],
5804     [with_mic="yes"],
5805     [with_mic="no (symbol MicInitAPI not found)"],
5806     [$PTHREAD_LIBS -lscif]
5807   )
5808
5809   LDFLAGS="$SAVE_LDFLAGS"
5810 fi
5811
5812 if test "x$with_mic" = "xyes"; then
5813   BUILD_WITH_MIC_CPPFLAGS="$with_mic_cppflags"
5814   BUILD_WITH_MIC_LDFLAGS="$with_mic_ldflags"
5815   BUILD_WITH_MIC_LIBS="$with_mic_libs"
5816 fi
5817 AC_SUBST([BUILD_WITH_MIC_CPPFLAGS])
5818 AC_SUBST([BUILD_WITH_MIC_LDFLAGS])
5819 AC_SUBST([BUILD_WITH_MIC_LIBS])
5820 #}}}
5821
5822 # --with-libvarnish {{{
5823 AC_ARG_WITH([libvarnish],
5824   [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
5825   [
5826     if test "x$withval" = "xno"; then
5827       with_libvarnish="no"
5828     else if test "x$withval" = "xyes"; then
5829       with_libvarnish="use_pkgconfig"
5830     else if test -d "$with_libvarnish/lib"; then
5831       with_libvarnish_cflags="-I$withval/include"
5832       with_libvarnish_libs="-L$withval/lib -lvarnishapi"
5833       with_libvarnish="yes"
5834     fi; fi; fi
5835   ],
5836   [with_libvarnish="use_pkgconfig"]
5837 )
5838
5839 # configure using pkg-config
5840 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5841   $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
5842   if test $? -ne 0; then
5843     with_libvarnish="no (pkg-config doesn't know varnishapi)"
5844   fi
5845 fi
5846
5847 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5848   with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
5849   if test $? -ne 0; then
5850     with_libvarnish="no ($PKG_CONFIG failed)"
5851   fi
5852
5853   with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
5854   if test $? -ne 0; then
5855     with_libvarnish="no ($PKG_CONFIG failed)"
5856   fi
5857 fi
5858 if test "x$with_libvarnish" = "xuse_pkgconfig"; then
5859   with_libvarnish="yes"
5860 fi
5861
5862 if test "x$with_libvarnish" = "xyes"; then
5863   SAVE_CPPFLAGS="$CPPFLAGS"
5864   CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
5865
5866   $PKG_CONFIG --atleast-version=5.2 'varnishapi' 2>/dev/null
5867   if test $? -eq 0; then
5868     AC_DEFINE([HAVE_VARNISH_V5], [1], [Varnish 5 API support])
5869   else
5870     AC_CHECK_HEADERS([vapi/vsc.h],
5871       [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
5872       [
5873         AC_CHECK_HEADERS([vsc.h],
5874           [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support]) ],
5875           [
5876             AC_CHECK_HEADERS([varnishapi.h],
5877               [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
5878               [with_libvarnish="no (found none of the varnish header files)"]
5879             )
5880           ]
5881         )
5882       ]
5883     )
5884   fi
5885
5886   CPPFLAGS="$SAVE_CPPFLAGS"
5887 fi
5888
5889 if test "x$with_libvarnish" = "xyes"; then
5890   BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
5891   BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
5892 fi
5893
5894 AC_SUBST([BUILD_WITH_LIBVARNISH_CFLAGS])
5895 AC_SUBST([BUILD_WITH_LIBVARNISH_LIBS])
5896 # }}}
5897
5898 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
5899 $PKG_CONFIG --exists 'libxml-2.0' 2>/dev/null
5900 if test $? -eq 0; then
5901   with_libxml2="yes"
5902 else
5903   with_libxml2="no (pkg-config doesn't know libxml-2.0)"
5904 fi
5905
5906 $PKG_CONFIG --exists libvirt 2>/dev/null
5907 if test $? = 0; then
5908   with_libvirt="yes"
5909 else
5910   with_libvirt="no (pkg-config doesn't know libvirt)"
5911 fi
5912
5913 if test "x$with_libxml2" = "xyes"; then
5914   with_libxml2_cflags="`$PKG_CONFIG --cflags libxml-2.0`"
5915   if test $? -ne 0; then
5916     with_libxml2="no"
5917   fi
5918
5919   with_libxml2_ldflags="`$PKG_CONFIG --libs libxml-2.0`"
5920   if test $? -ne 0; then
5921     with_libxml2="no"
5922   fi
5923 fi
5924
5925 if test "x$with_libxml2" = "xyes"; then
5926   SAVE_CPPFLAGS="$CPPFLAGS"
5927   CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
5928
5929   AC_CHECK_HEADERS([libxml/parser.h],
5930     [with_libxml2="yes"],
5931     [with_libxml2="no (libxml/parser.h not found)"]
5932   )
5933
5934   CPPFLAGS="$SAVE_CPPFLAGS"
5935 fi
5936
5937 if test "x$with_libxml2" = "xyes"; then
5938   SAVE_LDFLAGS="$LDFLAGS"
5939   LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
5940
5941   AC_CHECK_LIB([xml2], [xmlXPathEval],
5942     [with_libxml2="yes"],
5943     [with_libxml2="no (symbol xmlXPathEval not found)"]
5944   )
5945
5946   LDFLAGS="$SAVE_LDFLAGS"
5947 fi
5948
5949 if test "x$with_libxml2" = "xyes"; then
5950   BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
5951   BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
5952 fi
5953
5954 AC_SUBST([BUILD_WITH_LIBXML2_CFLAGS])
5955 AC_SUBST([BUILD_WITH_LIBXML2_LIBS])
5956
5957 if test "x$with_libvirt" = "xyes"; then
5958   with_libvirt_cflags="`$PKG_CONFIG --cflags libvirt`"
5959   if test $? -ne 0; then
5960     with_libvirt="no"
5961   fi
5962
5963   with_libvirt_ldflags="`$PKG_CONFIG --libs libvirt`"
5964   if test $? -ne 0; then
5965     with_libvirt="no"
5966   fi
5967 fi
5968
5969 if test "x$with_libvirt" = "xyes"; then
5970   SAVE_CPPFLAGS="$CPPFLAGS"
5971   CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
5972
5973   AC_CHECK_HEADERS([libvirt/libvirt.h],
5974     [with_libvirt="yes"],
5975     [with_libvirt="no (libvirt/libvirt.h not found)"]
5976   )
5977
5978   CPPFLAGS="$SAVE_CPPFLAGS"
5979 fi
5980
5981 if test "x$with_libvirt" = "xyes"; then
5982   SAVE_LDFLAGS="$LDFLAGS"
5983   LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
5984
5985   AC_CHECK_LIB([virt], [virDomainBlockStats],
5986     [with_libvirt="yes"],
5987     [with_libvirt="no (symbol virDomainBlockStats not found)"]
5988   )
5989
5990   LDFLAGS="$SAVE_LDFLAGS"
5991 fi
5992
5993 if test "x$with_libvirt" = "xyes"; then
5994   BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
5995   BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
5996 fi
5997
5998 AC_SUBST([BUILD_WITH_LIBVIRT_CFLAGS])
5999 AC_SUBST([BUILD_WITH_LIBVIRT_LIBS])
6000 # }}}
6001
6002 # $PKG_CONFIG --exists OpenIPMIpthread {{{
6003 with_libopenipmipthread="yes"
6004 AC_MSG_CHECKING([for libOpenIPMIpthread])
6005 $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
6006 if test $? -ne 0; then
6007   with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
6008 fi
6009 AC_MSG_RESULT([$with_libopenipmipthread])
6010
6011 if test "x$with_libopenipmipthread" = "xyes"; then
6012   AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
6013   temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
6014   if test $? -eq 0; then
6015     with_libopenipmipthread_cflags="$temp_result"
6016   else
6017     with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
6018     temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
6019   fi
6020   AC_MSG_RESULT([$temp_result])
6021 fi
6022
6023 if test "x$with_libopenipmipthread" = "xyes"; then
6024   AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
6025   temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
6026   if test $? -eq 0; then
6027     with_libopenipmipthread_ldflags="$temp_result"
6028   else
6029     with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
6030     temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
6031   fi
6032   AC_MSG_RESULT([$temp_result])
6033 fi
6034
6035 if test "x$with_libopenipmipthread" = "xyes"; then
6036   SAVE_CPPFLAGS="$CPPFLAGS"
6037   CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
6038
6039   AC_CHECK_HEADERS([OpenIPMI/ipmi_smi.h],
6040     [with_libopenipmipthread="yes"],
6041     [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
6042     [[
6043       #include <OpenIPMI/ipmiif.h>
6044       #include <OpenIPMI/ipmi_err.h>
6045       #include <OpenIPMI/ipmi_posix.h>
6046       #include <OpenIPMI/ipmi_conn.h>
6047     ]]
6048   )
6049
6050   CPPFLAGS="$SAVE_CPPFLAGS"
6051 fi
6052
6053 if test "x$with_libopenipmipthread" = "xyes"; then
6054   BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
6055   BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
6056 fi
6057
6058 AC_SUBST([BUILD_WITH_OPENIPMI_CFLAGS])
6059 AC_SUBST([BUILD_WITH_OPENIPMI_LIBS])
6060 # }}}
6061
6062 # --with-libatasmart {{{
6063 AC_ARG_WITH([libatasmart],
6064   [AS_HELP_STRING([--with-libatasmart@<:@=PREFIX@:>@], [Path to libatasmart.])],
6065   [
6066     if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
6067       with_libatasmart_cppflags="-I$withval/include"
6068       with_libatasmart_ldflags="-L$withval/lib"
6069       with_libatasmart="yes"
6070     else
6071       with_libatasmart="$withval"
6072     fi
6073   ],
6074   [
6075     if test "x$ac_system" = "xLinux"; then
6076       with_libatasmart="yes"
6077     else
6078       with_libatasmart="no (Linux only library)"
6079     fi
6080   ]
6081 )
6082
6083 if test "x$with_libatasmart" = "xyes"; then
6084   SAVE_CPPFLAGS="$CPPFLAGS"
6085   CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
6086
6087   AC_CHECK_HEADERS([atasmart.h],
6088     [with_libatasmart="yes"],
6089     [with_libatasmart="no (atasmart.h not found)"])
6090
6091   CPPFLAGS="$SAVE_CPPFLAGS"
6092 fi
6093
6094 if test "x$with_libatasmart" = "xyes"; then
6095   SAVE_LDFLAGS="$LDFLAGS"
6096   LDFLAGS="$LDFLAGS $with_libatasmart_ldflags"
6097
6098   AC_CHECK_LIB([atasmart], [sk_disk_open],
6099     [with_libatasmart="yes"],
6100     [with_libatasmart="no (Symbol 'sk_disk_open' not found)"]
6101   )
6102
6103   LDFLAGS="$SAVE_LDFLAGS"
6104 fi
6105
6106 if test "x$with_libatasmart" = "xyes"; then
6107   BUILD_WITH_LIBATASMART_CPPFLAGS="$with_libatasmart_cppflags"
6108   BUILD_WITH_LIBATASMART_LDFLAGS="$with_libatasmart_ldflags"
6109   BUILD_WITH_LIBATASMART_LIBS="-latasmart"
6110 fi
6111
6112 AC_SUBST([BUILD_WITH_LIBATASMART_CPPFLAGS])
6113 AC_SUBST([BUILD_WITH_LIBATASMART_LDFLAGS])
6114 AC_SUBST([BUILD_WITH_LIBATASMART_LIBS])
6115 # }}}
6116
6117 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
6118   [with_libnotify="yes"],
6119   [with_libnotify="no (pkg-config doesn't know libnotify)"]
6120 )
6121
6122 PKG_CHECK_MODULES([LIBRIEMANN_CLIENT], [riemann-client >= 1.6.0],
6123  [with_libriemann_client="yes"],
6124  [with_libriemann_client="no (pkg-config doesn't know libriemann-client)"]
6125 )
6126
6127 # Check for enabled/disabled features
6128 #
6129
6130 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
6131 # ------------------------------------------------------------
6132 dnl
6133 m4_define([my_toupper],[m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
6134 dnl
6135 AC_DEFUN(
6136   [AC_COLLECTD],
6137   [
6138   m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
6139   m4_if(
6140     [$2],
6141     [enable],
6142     [dnl
6143     m4_define([EnDis],[disabled])dnl
6144     m4_define([YesNo],[no])dnl
6145     ],dnl
6146     [m4_if(
6147       [$2],
6148       [disable],
6149       [dnl
6150       m4_define([EnDis],[enabled])dnl
6151       m4_define([YesNo],[yes])dnl
6152       ],
6153       [dnl
6154       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
6155       ]dnl
6156     )]dnl
6157   )dnl
6158   m4_if([$3], [feature], [],
6159     [m4_if(
6160       [$3], [module], [],
6161       [dnl
6162       AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
6163       ]dnl
6164     )]dnl
6165   )dnl
6166   AC_ARG_ENABLE(
6167     [$1],
6168     AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
6169     [],
6170     enable_$1='[YesNo]'dnl
6171   )# AC_ARG_ENABLE
6172   if test "x$enable_$1" = "xno"; then
6173     collectd_$1=0
6174   else
6175     if test "x$enable_$1" = "xyes"; then
6176       collectd_$1=1
6177     else
6178       AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
6179       collectd_$1=1
6180       enable_$1='yes'
6181     fi
6182   fi
6183   AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [whether or not to enable $3 $4])
6184   AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
6185   ]dnl
6186 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
6187
6188 # AC_PLUGIN(name, default, info)
6189 # ------------------------------------------------------------
6190 dnl
6191 AC_DEFUN(
6192   [AC_PLUGIN],
6193   [
6194     enable_plugin="no"
6195     force="no"
6196     AC_ARG_ENABLE([$1],
6197       [AS_HELP_STRING([--enable-$1],[$3])],
6198       [
6199         if test "x$enableval" = "xyes"; then
6200           enable_plugin="yes"
6201         else if test "x$enableval" = "xforce"; then
6202           enable_plugin="yes"
6203           force="yes"
6204         else
6205           enable_plugin="no (disabled on command line)"
6206         fi; fi
6207       ],
6208       [
6209         if test "x$enable_all_plugins" = "xauto"; then
6210           if test "x$2" = "xyes"; then
6211             enable_plugin="yes"
6212           else
6213             enable_plugin="$2"
6214           fi
6215         else
6216           enable_plugin="$enable_all_plugins"
6217         fi
6218       ]
6219     )
6220     if test "x$enable_plugin" = "xyes"; then
6221       if test "x$2" = "xyes" || test "x$force" = "xyes"; then
6222         AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
6223         if test "x$2" != "xyes"; then
6224           dependency_warning="yes"
6225         fi
6226       else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
6227         dependency_error="yes"
6228         enable_plugin="$2 (dependency error)"
6229       fi
6230     fi
6231     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), [test "x$enable_plugin" = "xyes"])
6232     enable_$1="$enable_plugin"
6233   ]
6234 )# AC_PLUGIN(name, default, info)
6235
6236 m4_divert_once([HELP_ENABLE], [
6237 collectd features:])
6238 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
6239 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
6240 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
6241 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
6242 AC_COLLECTD([werror],    [disable], [feature], [building with -Werror])
6243
6244 dependency_warning="no"
6245 dependency_error="no"
6246
6247 plugin_ascent="no"
6248 plugin_barometer="no"
6249 plugin_battery="no"
6250 plugin_bind="no"
6251 plugin_ceph="no"
6252 plugin_cgroups="no"
6253 plugin_conntrack="no"
6254 plugin_contextswitch="no"
6255 plugin_cpu="no"
6256 plugin_cpufreq="no"
6257 plugin_cpusleep="no"
6258 plugin_curl_json="no"
6259 plugin_curl_xml="no"
6260 plugin_df="no"
6261 plugin_disk="no"
6262 plugin_drbd="no"
6263 plugin_dpdkevents="no"
6264 plugin_dpdkstat="no"
6265 plugin_entropy="no"
6266 plugin_ethstat="no"
6267 plugin_fhcount="no"
6268 plugin_fscache="no"
6269 plugin_gps="no"
6270 plugin_grpc="no"
6271 plugin_hugepages="no"
6272 plugin_intel_pmu="no"
6273 plugin_intel_rdt="no"
6274 plugin_interface="no"
6275 plugin_ipc="no"
6276 plugin_ipmi="no"
6277 plugin_ipvs="no"
6278 plugin_irq="no"
6279 plugin_load="no"
6280 plugin_log_logstash="no"
6281 plugin_mcelog="no"
6282 plugin_memory="no"
6283 plugin_multimeter="no"
6284 plugin_nfs="no"
6285 plugin_numa="no"
6286 plugin_ovs_events="no"
6287 plugin_ovs_stats="no"
6288 plugin_perl="no"
6289 plugin_pinba="no"
6290 plugin_processes="no"
6291 plugin_protocols="no"
6292 plugin_python="no"
6293 plugin_serial="no"
6294 plugin_smart="no"
6295 plugin_swap="no"
6296 plugin_synproxy="no"
6297 plugin_tape="no"
6298 plugin_tcpconns="no"
6299 plugin_ted="no"
6300 plugin_thermal="no"
6301 plugin_turbostat="no"
6302 plugin_uptime="no"
6303 plugin_users="no"
6304 plugin_virt="no"
6305 plugin_vmem="no"
6306 plugin_vserver="no"
6307 plugin_wireless="no"
6308 plugin_write_prometheus="no"
6309 plugin_xencpu="no"
6310 plugin_zfs_arc="no"
6311 plugin_zone="no"
6312 plugin_zookeeper="no"
6313
6314 # Linux
6315 if test "x$ac_system" = "xLinux"; then
6316   plugin_battery="yes"
6317   plugin_cgroups="yes"
6318   plugin_conntrack="yes"
6319   plugin_contextswitch="yes"
6320   plugin_cpu="yes"
6321   plugin_cpufreq="yes"
6322   plugin_disk="yes"
6323   plugin_drbd="yes"
6324   plugin_entropy="yes"
6325   plugin_fhcount="yes"
6326   plugin_fscache="yes"
6327   plugin_hugepages="yes"
6328   plugin_interface="yes"
6329   plugin_ipc="yes"
6330   plugin_irq="yes"
6331   plugin_load="yes"
6332   plugin_lvm="yes"
6333   plugin_mcelog="yes"
6334   plugin_memory="yes"
6335   plugin_nfs="yes"
6336   plugin_numa="yes"
6337   plugin_processes="yes"
6338   plugin_protocols="yes"
6339   plugin_serial="yes"
6340   plugin_swap="yes"
6341   plugin_synproxy="yes"
6342   plugin_tcpconns="yes"
6343   plugin_thermal="yes"
6344   plugin_uptime="yes"
6345   plugin_vmem="yes"
6346   plugin_vserver="yes"
6347   plugin_wireless="yes"
6348   plugin_zfs_arc="yes"
6349
6350   if test "x$ac_cv_header_linux_ip_vs_h" = "xyes"; then
6351     plugin_ipvs="yes"
6352   fi
6353
6354   if test "x$have_cpuid_h" = "xyes"; then
6355     plugin_turbostat="yes"
6356   fi
6357
6358   if test "x$c_cv_have_clock_boottime_monotonic" = "xyes"; then
6359     plugin_cpusleep="yes"
6360   fi
6361
6362   if test "x$with_libyajl" = "xyes" && test "x$with_libyajl2" = "xyes"; then
6363     plugin_ovs_events="yes"
6364     plugin_ovs_stats="yes"
6365   fi
6366 fi
6367
6368 if test "x$ac_system" = "xOpenBSD"; then
6369   plugin_tcpconns="yes"
6370 fi
6371
6372 if test "x$ac_system" = "xNetBSD"; then
6373   plugin_disk="yes"
6374   plugin_entropy="yes"
6375   plugin_irq="yes"
6376   plugin_processes="yes"
6377 fi
6378
6379 # Mac OS X devices
6380 if test "x$with_libiokit" = "xyes"; then
6381   plugin_battery="yes"
6382   plugin_disk="yes"
6383 fi
6384
6385 # AIX
6386
6387 if test "x$ac_system" = "xAIX"; then
6388   plugin_ipc="yes"
6389   plugin_tcpconns="yes"
6390 fi
6391
6392 # FreeBSD
6393
6394 if test "x$ac_system" = "xFreeBSD"; then
6395   plugin_disk="yes"
6396   plugin_zfs_arc="yes"
6397 fi
6398
6399
6400 if test "x$with_perfstat" = "xyes"; then
6401   plugin_contextswitch="yes"
6402   plugin_cpu="yes"
6403   plugin_disk="yes"
6404   plugin_interface="yes"
6405   plugin_load="yes"
6406   plugin_memory="yes"
6407   plugin_swap="yes"
6408   plugin_uptime="yes"
6409 fi
6410
6411 if test "x$with_procinfo" = "xyes"; then
6412   plugin_processes="yes"
6413 fi
6414
6415 # Solaris
6416 if test "x$with_kstat" = "xyes"; then
6417   plugin_nfs="yes"
6418   plugin_processes="yes"
6419   plugin_uptime="yes"
6420   plugin_zfs_arc="yes"
6421   plugin_zone="yes"
6422 fi
6423
6424 if test "x$with_devinfo" = "xyes" && test "x$with_kstat" = "xyes"; then
6425   plugin_cpu="yes"
6426   plugin_disk="yes"
6427   plugin_interface="yes"
6428   plugin_memory="yes"
6429   plugin_tape="yes"
6430 fi
6431
6432 if test "x$with_libi2c" = "xyes"; then
6433   plugin_barometer="yes"
6434 fi
6435
6436
6437 # libstatgrab
6438 if test "x$with_libstatgrab" = "xyes"; then
6439   plugin_cpu="yes"
6440   plugin_disk="yes"
6441   plugin_interface="yes"
6442   plugin_load="yes"
6443   plugin_memory="yes"
6444   plugin_swap="yes"
6445   plugin_users="yes"
6446 fi
6447
6448 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"; then
6449   plugin_ascent="yes"
6450   if test "x$have_strptime" = "xyes"; then
6451     plugin_bind="yes"
6452   fi
6453 fi
6454
6455 if test "x$with_libopenipmipthread" = "xyes"; then
6456   plugin_ipmi="yes"
6457 fi
6458
6459 if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"; then
6460   plugin_curl_json="yes"
6461 fi
6462
6463 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"; then
6464   plugin_curl_xml="yes"
6465 fi
6466
6467 if test "x$with_libyajl" = "xyes"; then
6468   plugin_ceph="yes"
6469 fi
6470
6471 if test "x$have_processor_info" = "xyes"; then
6472   plugin_cpu="yes"
6473 fi
6474
6475 if test "x$have_sysctl" = "xyes"; then
6476   plugin_cpu="yes"
6477   plugin_memory="yes"
6478   plugin_uptime="yes"
6479   if test "x$ac_system" = "xDarwin"; then
6480     plugin_swap="yes"
6481   fi
6482 fi
6483
6484 if test "x$have_sysctlbyname" = "xyes"; then
6485   plugin_contextswitch="yes"
6486   plugin_cpu="yes"
6487   plugin_memory="yes"
6488   plugin_tcpconns="yes"
6489 fi
6490
6491 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"; then
6492   plugin_df="yes"
6493 fi
6494
6495 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"; then
6496   plugin_df="yes"
6497 fi
6498
6499 if test "x$c_cv_have_one_getmntent" = "xyes"; then
6500   plugin_df="yes"
6501 fi
6502
6503 if test "x$c_cv_have_getmntent_r" = "xyes"; then
6504   plugin_df="yes"
6505 fi
6506
6507 if test "x$plugin_df" = "xyes"; then
6508   plugin_df="no"
6509   if test "x$have_statfs" = "xyes"; then
6510     plugin_df="yes"
6511   fi
6512
6513   if test "x$have_statvfs" = "xyes"; then
6514     plugin_df="yes"
6515   fi
6516 fi
6517
6518 if test "x$have_linux_sockios_h" = "xyes" && test "x$have_linux_ethtool_h" = "xyes"; then
6519   plugin_ethstat="yes"
6520 fi
6521
6522 if test "x$with_libgps" = "xyes"; then
6523   plugin_gps="yes"
6524 fi
6525
6526 plugin_grpc="yes"
6527 if test "x$GRPC_CPP_PLUGIN" = "x"; then
6528   plugin_grpc="no (grpc_cpp_plugin not found)"
6529 fi
6530 if test "x$have_protoc3" != "xyes"; then
6531   plugin_grpc="no (protoc3 not found)"
6532 fi
6533 if test "x$with_libprotobuf" != "xyes"; then
6534   plugin_grpc="no (libprotobuf not found)"
6535 fi
6536 if test "x$with_libgrpcpp" != "xyes"; then
6537   plugin_grpc="no (libgrpc++ not found)"
6538 fi
6539
6540 if test "x$have_getifaddrs" = "xyes"; then
6541   plugin_interface="yes"
6542 fi
6543
6544 if test "x$have_getloadavg" = "xyes"; then
6545   plugin_load="yes"
6546 fi
6547
6548 if test "x$with_libyajl" = "xyes"; then
6549   plugin_log_logstash="yes"
6550 fi
6551
6552 if test "x$with_libperl" = "xyes" && test "x$c_cv_have_perl_ithreads" = "xyes"; then
6553   plugin_perl="yes"
6554 fi
6555
6556 if test "x$have_protoc_c" = "xyes" && test "x$with_libprotobuf_c" = "xyes"; then
6557   plugin_pinba="yes"
6558   if test "x$with_libmicrohttpd" = "xyes"; then
6559     plugin_write_prometheus="yes"
6560   fi
6561 fi
6562
6563 # Mac OS X memory interface
6564 if test "x$have_host_statistics" = "xyes"; then
6565   plugin_memory="yes"
6566 fi
6567
6568 if test "x$have_termios_h" = "xyes"; then
6569   if test "x$ac_system" != "xAIX"; then
6570     plugin_multimeter="yes"
6571   fi
6572   plugin_ted="yes"
6573 fi
6574
6575 if test "x$have_thread_info" = "xyes"; then
6576   plugin_processes="yes"
6577 fi
6578
6579 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"; then
6580   plugin_processes="yes"
6581 fi
6582
6583 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_openbsd" = "xyes"; then
6584   plugin_processes="yes"
6585 fi
6586
6587 if test "x$with_libpython" != "xno"; then
6588   plugin_python="yes"
6589 fi
6590
6591 if test "x$with_libatasmart" = "xyes" && test "x$with_libudev" = "xyes"; then
6592   plugin_smart="yes"
6593 fi
6594
6595 if test "x$with_kvm_getswapinfo" = "xyes"; then
6596   plugin_swap="yes"
6597 fi
6598
6599 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"; then
6600   plugin_swap="yes"
6601 fi
6602
6603 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes"; then
6604   plugin_swap="yes"
6605 fi
6606
6607 if test "x$with_kvm_openfiles = "xyes" && $with_kvm_nlist" = "xyes"; then
6608   plugin_tcpconns="yes"
6609 fi
6610
6611 if test "x$have_getutent" = "xyes"; then
6612   plugin_users="yes"
6613 fi
6614
6615 if test "x$have_getutxent" = "xyes"; then
6616   plugin_users="yes"
6617 fi
6618
6619 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"; then
6620   plugin_virt="yes"
6621 fi
6622
6623 if test "x$with_libxenctrl" = "xyes"; then
6624   plugin_xencpu="yes"
6625 fi
6626
6627 if test "x$with_libdpdk" = "xyes"; then
6628   plugin_dpdkevents="$dpdk_keepalive"
6629   plugin_dpdkstat="yes"
6630 fi
6631
6632 m4_divert_once([HELP_ENABLE], [
6633 collectd plugins:])
6634
6635 AC_ARG_ENABLE([all-plugins],
6636   [AS_HELP_STRING([--enable-all-plugins], [enable all plugins @<:@default=yes@:>@])],
6637   [
6638      if test "x$enableval" = "xyes"; then
6639        enable_all_plugins="yes"
6640      else if test "x$enableval" = "xauto"; then
6641        enable_all_plugins="auto"
6642      else
6643        enable_all_plugins="no"
6644      fi; fi
6645   ],
6646   [enable_all_plugins="auto"]
6647 )
6648
6649 m4_divert_once([HELP_ENABLE], [])
6650
6651 AC_PLUGIN([aggregation],         [yes],                     [Aggregation plugin])
6652 AC_PLUGIN([amqp],                [$with_librabbitmq],       [AMQP output plugin])
6653 AC_PLUGIN([amqp1],               [$with_libqpid_proton],    [AMQP 1.0 output plugin])
6654 AC_PLUGIN([apache],              [$with_libcurl],           [Apache httpd statistics])
6655 AC_PLUGIN([apcups],              [yes],                     [Statistics of UPSes by APC])
6656 AC_PLUGIN([apple_sensors],       [$with_libiokit],          [Apple hardware sensors])
6657 AC_PLUGIN([aquaero],             [$with_libaquaero5],       [Aquaero hardware sensors])
6658 AC_PLUGIN([ascent],              [$plugin_ascent],          [AscentEmu player statistics])
6659 AC_PLUGIN([barometer],           [$plugin_barometer],       [Barometer sensor on I2C])
6660 AC_PLUGIN([battery],             [$plugin_battery],         [Battery statistics])
6661 AC_PLUGIN([bind],                [$plugin_bind],            [ISC Bind nameserver statistics])
6662 AC_PLUGIN([ceph],                [$plugin_ceph],            [Ceph daemon statistics])
6663 AC_PLUGIN([cgroups],             [$plugin_cgroups],         [CGroups CPU usage accounting])
6664 AC_PLUGIN([chrony],              [yes],                     [Chrony statistics])
6665 AC_PLUGIN([conntrack],           [$plugin_conntrack],       [nf_conntrack statistics])
6666 AC_PLUGIN([contextswitch],       [$plugin_contextswitch],   [context switch statistics])
6667 AC_PLUGIN([cpu],                 [$plugin_cpu],             [CPU usage statistics])
6668 AC_PLUGIN([cpufreq],             [$plugin_cpufreq],         [CPU frequency statistics])
6669 AC_PLUGIN([cpusleep],            [$plugin_cpusleep],        [CPU sleep statistics])
6670 AC_PLUGIN([csv],                 [yes],                     [CSV output plugin])
6671 AC_PLUGIN([curl],                [$with_libcurl],           [CURL generic web statistics])
6672 AC_PLUGIN([curl_json],           [$plugin_curl_json],       [CouchDB statistics])
6673 AC_PLUGIN([curl_xml],            [$plugin_curl_xml],        [CURL generic xml statistics])
6674 AC_PLUGIN([dbi],                 [$with_libdbi],            [General database statistics])
6675 AC_PLUGIN([df],                  [$plugin_df],              [Filesystem usage statistics])
6676 AC_PLUGIN([disk],                [$plugin_disk],            [Disk usage statistics])
6677 AC_PLUGIN([dns],                 [$with_libpcap],           [DNS traffic analysis])
6678 AC_PLUGIN([dpdkevents],          [$plugin_dpdkevents],      [Events from DPDK])
6679 AC_PLUGIN([dpdkstat],            [$plugin_dpdkstat],        [Stats from DPDK])
6680 AC_PLUGIN([drbd],                [$plugin_drbd],            [DRBD statistics])
6681 AC_PLUGIN([email],               [yes],                     [EMail statistics])
6682 AC_PLUGIN([entropy],             [$plugin_entropy],         [Entropy statistics])
6683 AC_PLUGIN([ethstat],             [$plugin_ethstat],         [Stats from NIC driver])
6684 AC_PLUGIN([exec],                [yes],                     [Execution of external programs])
6685 AC_PLUGIN([fhcount],             [$plugin_fhcount],         [File handles statistics])
6686 AC_PLUGIN([filecount],           [yes],                     [Count files in directories])
6687 AC_PLUGIN([fscache],             [$plugin_fscache],         [fscache statistics])
6688 AC_PLUGIN([gmond],               [$with_libganglia],        [Ganglia plugin])
6689 AC_PLUGIN([gps],                 [$plugin_gps],             [GPS plugin])
6690 AC_PLUGIN([grpc],                [$plugin_grpc],            [gRPC plugin])
6691 AC_PLUGIN([hddtemp],             [yes],                     [Query hddtempd])
6692 AC_PLUGIN([hugepages],           [$plugin_hugepages],       [Hugepages statistics])
6693 AC_PLUGIN([intel_pmu],           [$with_libjevents],        [Intel performance monitor plugin])
6694 AC_PLUGIN([intel_rdt],           [$with_libpqos],           [Intel RDT monitor plugin])
6695 AC_PLUGIN([interface],           [$plugin_interface],       [Interface traffic statistics])
6696 AC_PLUGIN([ipc],                 [$plugin_ipc],             [IPC statistics])
6697 AC_PLUGIN([ipmi],                [$plugin_ipmi],            [IPMI sensor statistics])
6698 AC_PLUGIN([iptables],            [$with_libiptc],           [IPTables rule counters])
6699 AC_PLUGIN([ipvs],                [$plugin_ipvs],            [IPVS connection statistics])
6700 AC_PLUGIN([irq],                 [$plugin_irq],             [IRQ statistics])
6701 AC_PLUGIN([java],                [$with_java],              [Embed the Java Virtual Machine])
6702 AC_PLUGIN([load],                [$plugin_load],            [System load])
6703 AC_PLUGIN([log_logstash],        [$plugin_log_logstash],    [Logstash json_event compatible logging])
6704 AC_PLUGIN([logfile],             [yes],                     [File logging plugin])
6705 AC_PLUGIN([lpar],                [$with_perfstat],          [AIX logical partitions statistics])
6706 AC_PLUGIN([lua],                 [$with_liblua],            [Lua plugin])
6707 AC_PLUGIN([lvm],                 [$with_liblvm2app],        [LVM statistics])
6708 AC_PLUGIN([madwifi],             [$have_linux_wireless_h],  [Madwifi wireless statistics])
6709 AC_PLUGIN([match_empty_counter], [yes],                     [The empty counter match])
6710 AC_PLUGIN([match_hashed],        [yes],                     [The hashed match])
6711 AC_PLUGIN([match_regex],         [yes],                     [The regex match])
6712 AC_PLUGIN([match_timediff],      [yes],                     [The timediff match])
6713 AC_PLUGIN([match_value],         [yes],                     [The value match])
6714 AC_PLUGIN([mbmon],               [yes],                     [Query mbmond])
6715 AC_PLUGIN([mcelog],              [$plugin_mcelog],          [Machine Check Exceptions notifications])
6716 AC_PLUGIN([md],                  [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
6717 AC_PLUGIN([memcachec],           [$with_libmemcached],      [memcachec statistics])
6718 AC_PLUGIN([memcached],           [yes],                     [memcached statistics])
6719 AC_PLUGIN([memory],              [$plugin_memory],          [Memory usage])
6720 AC_PLUGIN([mic],                 [$with_mic],               [Intel Many Integrated Core stats])
6721 AC_PLUGIN([modbus],              [$with_libmodbus],         [Modbus plugin])
6722 AC_PLUGIN([mqtt],                [$with_libmosquitto],      [MQTT output plugin])
6723 AC_PLUGIN([multimeter],          [$plugin_multimeter],      [Read multimeter values])
6724 AC_PLUGIN([mysql],               [$with_libmysql],          [MySQL statistics])
6725 AC_PLUGIN([netapp],              [$with_libnetapp],         [NetApp plugin])
6726 AC_PLUGIN([netlink],             [$with_libmnl],            [Enhanced Linux network statistics])
6727 AC_PLUGIN([network],             [yes],                     [Network communication plugin])
6728 AC_PLUGIN([nfs],                 [$plugin_nfs],             [NFS statistics])
6729 AC_PLUGIN([nginx],               [$with_libcurl],           [nginx statistics])
6730 AC_PLUGIN([notify_desktop],      [$with_libnotify],         [Desktop notifications])
6731 AC_PLUGIN([notify_email],        [$with_libesmtp],          [Email notifier])
6732 AC_PLUGIN([notify_nagios],       [yes],                     [Nagios notification plugin])
6733 AC_PLUGIN([ntpd],                [yes],                     [NTPd statistics])
6734 AC_PLUGIN([numa],                [$plugin_numa],            [NUMA virtual memory statistics])
6735 AC_PLUGIN([nut],                 [$with_libupsclient],      [Network UPS tools statistics])
6736 AC_PLUGIN([olsrd],               [yes],                     [olsrd statistics])
6737 AC_PLUGIN([onewire],             [$with_libowcapi],         [OneWire sensor statistics])
6738 AC_PLUGIN([openldap],            [$with_libldap],           [OpenLDAP statistics])
6739 AC_PLUGIN([openvpn],             [yes],                     [OpenVPN client statistics])
6740 AC_PLUGIN([oracle],              [$with_oracle],            [Oracle plugin])
6741 AC_PLUGIN([ovs_events],          [$plugin_ovs_events],      [OVS events plugin])
6742 AC_PLUGIN([ovs_stats],           [$plugin_ovs_stats],       [OVS statistics plugin])
6743 AC_PLUGIN([perl],                [$plugin_perl],            [Embed a Perl interpreter])
6744 AC_PLUGIN([pf],                  [$have_net_pfvar_h],       [BSD packet filter (PF) statistics])
6745 # FIXME: Check for libevent, too.
6746 AC_PLUGIN([pinba],               [$plugin_pinba],           [Pinba statistics])
6747 AC_PLUGIN([ping],                [$with_liboping],          [Network latency statistics])
6748 AC_PLUGIN([postgresql],          [$with_libpq],             [PostgreSQL database statistics])
6749 AC_PLUGIN([powerdns],            [yes],                     [PowerDNS statistics])
6750 AC_PLUGIN([processes],           [$plugin_processes],       [Process statistics])
6751 AC_PLUGIN([protocols],           [$plugin_protocols],       [Protocol (IP, TCP, ...) statistics])
6752 AC_PLUGIN([python],              [$plugin_python],          [Embed a Python interpreter])
6753 AC_PLUGIN([redis],               [$with_libhiredis],        [Redis plugin])
6754 AC_PLUGIN([routeros],            [$with_librouteros],       [RouterOS plugin])
6755 AC_PLUGIN([rrdcached],           [$librrd_rrdc_update],     [RRDTool output plugin])
6756 AC_PLUGIN([rrdtool],             [$with_librrd],            [RRDTool output plugin])
6757 AC_PLUGIN([sensors],             [$with_libsensors],        [lm_sensors statistics])
6758 AC_PLUGIN([serial],              [$plugin_serial],          [serial port traffic])
6759 AC_PLUGIN([sigrok],              [$with_libsigrok],         [sigrok acquisition sources])
6760 AC_PLUGIN([smart],               [$plugin_smart],           [SMART statistics])
6761 AC_PLUGIN([snmp],                [$with_libnetsnmp],        [SNMP querying plugin])
6762 AC_PLUGIN([snmp_agent],          [$with_libnetsnmpagent],   [SNMP agent plugin])
6763 AC_PLUGIN([statsd],              [yes],                     [StatsD plugin])
6764 AC_PLUGIN([swap],                [$plugin_swap],            [Swap usage statistics])
6765 AC_PLUGIN([synproxy],            [$plugin_synproxy],        [Synproxy stats plugin])
6766 AC_PLUGIN([syslog],              [$have_syslog],            [Syslog logging plugin])
6767 AC_PLUGIN([table],               [yes],                     [Parsing of tabular data])
6768 AC_PLUGIN([tail],                [yes],                     [Parsing of logfiles])
6769 AC_PLUGIN([tail_csv],            [yes],                     [Parsing of CSV files])
6770 AC_PLUGIN([tape],                [$plugin_tape],            [Tape drive statistics])
6771 AC_PLUGIN([target_notification], [yes],                     [The notification target])
6772 AC_PLUGIN([target_replace],      [yes],                     [The replace target])
6773 AC_PLUGIN([target_scale],        [yes],                     [The scale target])
6774 AC_PLUGIN([target_set],          [yes],                     [The set target])
6775 AC_PLUGIN([target_v5upgrade],    [yes],                     [The v5upgrade target])
6776 AC_PLUGIN([tcpconns],            [$plugin_tcpconns],        [TCP connection statistics])
6777 AC_PLUGIN([teamspeak2],          [yes],                     [TeamSpeak2 server statistics])
6778 AC_PLUGIN([ted],                 [$plugin_ted],             [Read The Energy Detective values])
6779 AC_PLUGIN([thermal],             [$plugin_thermal],         [Linux ACPI thermal zone statistics])
6780 AC_PLUGIN([threshold],           [yes],                     [Threshold checking plugin])
6781 AC_PLUGIN([tokyotyrant],         [$with_libtokyotyrant],    [TokyoTyrant database statistics])
6782 AC_PLUGIN([turbostat],           [$plugin_turbostat],       [Advanced statistic on Intel cpu states])
6783 AC_PLUGIN([unixsock],            [yes],                     [Unixsock communication plugin])
6784 AC_PLUGIN([uptime],              [$plugin_uptime],          [Uptime statistics])
6785 AC_PLUGIN([users],               [$plugin_users],           [User statistics])
6786 AC_PLUGIN([uuid],                [yes],                     [UUID as hostname plugin])
6787 AC_PLUGIN([varnish],             [$with_libvarnish],        [Varnish cache statistics])
6788 AC_PLUGIN([virt],                [$plugin_virt],            [Virtual machine statistics])
6789 AC_PLUGIN([vmem],                [$plugin_vmem],            [Virtual memory statistics])
6790 AC_PLUGIN([vserver],             [$plugin_vserver],         [Linux VServer statistics])
6791 AC_PLUGIN([wireless],            [$plugin_wireless],        [Wireless statistics])
6792 AC_PLUGIN([write_graphite],      [yes],                     [Graphite / Carbon output plugin])
6793 AC_PLUGIN([write_http],          [$with_libcurl],           [HTTP output plugin])
6794 AC_PLUGIN([write_kafka],         [$with_librdkafka],        [Kafka output plugin])
6795 AC_PLUGIN([write_log],           [yes],                     [Log output plugin])
6796 AC_PLUGIN([write_mongodb],       [$with_libmongoc],         [MongoDB output plugin])
6797 AC_PLUGIN([write_prometheus],    [$plugin_write_prometheus], [Prometheus write plugin])
6798 AC_PLUGIN([write_redis],         [$with_libhiredis],        [Redis output plugin])
6799 AC_PLUGIN([write_riemann],       [$with_libriemann_client], [Riemann output plugin])
6800 AC_PLUGIN([write_sensu],         [yes],                     [Sensu output plugin])
6801 AC_PLUGIN([write_tsdb],          [yes],                     [TSDB output plugin])
6802 AC_PLUGIN([xencpu],              [$plugin_xencpu],          [Xen Host CPU usage])
6803 AC_PLUGIN([xmms],                [$with_libxmms],           [XMMS statistics])
6804 AC_PLUGIN([zfs_arc],             [$plugin_zfs_arc],         [ZFS ARC statistics])
6805 AC_PLUGIN([zone],                [$plugin_zone],            [Solaris container statistics])
6806 AC_PLUGIN([zookeeper],           [yes],                     [Zookeeper statistics])
6807
6808 dnl Default configuration file
6809 # Load either syslog or logfile
6810 LOAD_PLUGIN_SYSLOG=""
6811 LOAD_PLUGIN_LOGFILE=""
6812 LOAD_PLUGIN_LOG_LOGSTASH=""
6813
6814 AC_MSG_CHECKING([which default log plugin to load])
6815 default_log_plugin="none"
6816 if test "x$enable_syslog" = "xyes"; then
6817   default_log_plugin="syslog"
6818 else
6819   LOAD_PLUGIN_SYSLOG="##"
6820 fi
6821
6822 if test "x$enable_logfile" = "xyes"; then
6823   if test "x$default_log_plugin" = "xnone"; then
6824     default_log_plugin="logfile"
6825   else
6826     LOAD_PLUGIN_LOGFILE="#"
6827   fi
6828 else
6829   LOAD_PLUGIN_LOGFILE="##"
6830 fi
6831
6832 if test "x$enable_log_logstash" = "xyes"; then
6833   LOAD_PLUGIN_LOG_LOGSTASH="#"
6834 else
6835   LOAD_PLUGIN_LOG_LOGSTASH="##"
6836 fi
6837
6838 AC_MSG_RESULT([$default_log_plugin])
6839
6840 AC_SUBST([LOAD_PLUGIN_SYSLOG])
6841 AC_SUBST([LOAD_PLUGIN_LOGFILE])
6842 AC_SUBST([LOAD_PLUGIN_LOG_LOGSTASH])
6843
6844 if test "x$enable_debug" = "xyes"; then
6845   DEFAULT_LOG_LEVEL="debug"
6846 else
6847   DEFAULT_LOG_LEVEL="info"
6848 fi
6849 AC_SUBST([DEFAULT_LOG_LEVEL])
6850
6851 # Load only one of rrdtool, network, csv in the default config.
6852 LOAD_PLUGIN_RRDTOOL=""
6853 LOAD_PLUGIN_NETWORK=""
6854 LOAD_PLUGIN_CSV=""
6855
6856 AC_MSG_CHECKING([which default write plugin to load])
6857 default_write_plugin="none"
6858 if test "x$enable_rrdtool" = "xyes"; then
6859   default_write_plugin="rrdtool"
6860 else
6861   LOAD_PLUGIN_RRDTOOL="##"
6862 fi
6863
6864 if test "x$enable_network" = "xyes"; then
6865   if test "x$default_write_plugin" = "xnone"; then
6866     default_write_plugin="network"
6867   else
6868     LOAD_PLUGIN_NETWORK="#"
6869   fi
6870 else
6871   LOAD_PLUGIN_NETWORK="##"
6872 fi
6873
6874 if test "x$enable_csv" = "xyes"; then
6875   if test "x$default_write_plugin" = "xnone"; then
6876     default_write_plugin="csv"
6877   else
6878     LOAD_PLUGIN_CSV="#"
6879   fi
6880 else
6881   LOAD_PLUGIN_CSV="##"
6882 fi
6883 AC_MSG_RESULT([$default_write_plugin])
6884
6885 AC_SUBST([LOAD_PLUGIN_RRDTOOL])
6886 AC_SUBST([LOAD_PLUGIN_NETWORK])
6887 AC_SUBST([LOAD_PLUGIN_CSV])
6888
6889 dnl Perl bindings
6890 PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
6891 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
6892 [
6893   if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
6894     PERL_BINDINGS_OPTIONS="$withval"
6895     with_perl_bindings="yes"
6896   else
6897     with_perl_bindings="$withval"
6898   fi
6899 ],
6900 [
6901   if test "x$PERL" != "x"; then
6902     with_perl_bindings="yes"
6903   else
6904     with_perl_bindings="no (no perl interpreter found)"
6905   fi
6906 ])
6907
6908 if test "x$with_perl_bindings" = "xyes"; then
6909   AC_MSG_CHECKING([for the ExtUtils::MakeMaker module])
6910   if $PERL -MExtUtils::MakeMaker -e '' 2>/dev/null; then
6911     AC_MSG_RESULT([yes])
6912   else
6913     AC_MSG_RESULT([no])
6914     with_perl_bindings="no (ExtUtils::MakeMaker not found)"
6915   fi
6916 fi
6917
6918 if test "x$with_perl_bindings" = "xyes"; then
6919   PERL_BINDINGS="perl"
6920 else
6921   PERL_BINDINGS=""
6922 fi
6923
6924 AC_SUBST([PERL_BINDINGS])
6925 AC_SUBST([PERL_BINDINGS_OPTIONS])
6926
6927 dnl libcollectdclient
6928 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
6929 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
6930 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
6931
6932 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
6933
6934 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
6935
6936 AC_SUBST([LCC_VERSION_MAJOR])
6937 AC_SUBST([LCC_VERSION_MINOR])
6938 AC_SUBST([LCC_VERSION_PATCH])
6939 AC_SUBST([LCC_VERSION_EXTRA])
6940 AC_SUBST([LCC_VERSION_STRING])
6941
6942 AC_CONFIG_FILES([src/libcollectdclient/collectd/lcc_features.h])
6943
6944 AM_CFLAGS="-Wall"
6945 AM_CXXFLAGS="-Wall"
6946 if test "x$enable_werror" != "xno"; then
6947   AM_CFLAGS="$AM_CFLAGS -Werror"
6948   AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
6949 fi
6950
6951 AC_SUBST([AM_CFLAGS])
6952 AC_SUBST([AM_CXXFLAGS])
6953
6954 AC_CONFIG_FILES([ \
6955   Makefile \
6956   src/collectd.conf \
6957   src/libcollectdclient/libcollectdclient.pc \
6958 ])
6959
6960 AC_OUTPUT
6961
6962 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" != "xyes"; then
6963   with_librrd="yes (warning: librrd is not thread-safe)"
6964 fi
6965
6966 if test "x$with_libperl" = "xyes"; then
6967   with_libperl="yes (version `$PERL -MConfig -e 'print $Config{version};'`)"
6968 else
6969   enable_perl="no (needs libperl)"
6970 fi
6971
6972 if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"; then
6973   enable_perl="no (libperl doesn't support ithreads)"
6974 fi
6975
6976 if test "x$with_perl_bindings" = "xyes" && test "x$PERL_BINDINGS_OPTIONS" != "x"; then
6977   with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
6978 fi
6979
6980 AC_MSG_RESULT()
6981 AC_MSG_RESULT([Configuration:])
6982 AC_MSG_RESULT([  Build:])
6983 AC_MSG_RESULT([    Platform  . . . . . . $ac_system])
6984 AC_MSG_RESULT([    Compiler vendor . . . $ax_cv_c_compiler_vendor])
6985 AC_MSG_RESULT([    CC  . . . . . . . . . $CC])
6986 AC_MSG_RESULT([    CFLAGS  . . . . . . . $AM_CFLAGS $CFLAGS])
6987 AC_MSG_RESULT([    CXXFLAGS  . . . . . . $AM_CXXFLAGS $CXXFLAGS])
6988 AC_MSG_RESULT([    CPP . . . . . . . . . $CPP])
6989 AC_MSG_RESULT([    CPPFLAGS  . . . . . . $CPPFLAGS])
6990 AC_MSG_RESULT([    GRPC_CPP_PLUGIN . . . $GRPC_CPP_PLUGIN])
6991 AC_MSG_RESULT([    LD  . . . . . . . . . $LD])
6992 AC_MSG_RESULT([    LDFLAGS . . . . . . . $LDFLAGS])
6993 AC_MSG_RESULT([    PROTOC  . . . . . . . $PROTOC])
6994 AC_MSG_RESULT([    YACC  . . . . . . . . $YACC])
6995 AC_MSG_RESULT([    YFLAGS  . . . . . . . $YFLAGS])
6996 AC_MSG_RESULT()
6997 AC_MSG_RESULT([  Libraries:])
6998 AC_MSG_RESULT([    intel mic . . . . . . $with_mic])
6999 AC_MSG_RESULT([    libaquaero5 . . . . . $with_libaquaero5])
7000 AC_MSG_RESULT([    libatasmart . . . . . $with_libatasmart])
7001 AC_MSG_RESULT([    libcurl . . . . . . . $with_libcurl])
7002 AC_MSG_RESULT([    libdbi  . . . . . . . $with_libdbi])
7003 AC_MSG_RESULT([    libdpdk . . . . . . . $with_libdpdk])
7004 AC_MSG_RESULT([    libesmtp  . . . . . . $with_libesmtp])
7005 AC_MSG_RESULT([    libganglia  . . . . . $with_libganglia])
7006 AC_MSG_RESULT([    libgcrypt . . . . . . $with_libgcrypt])
7007 AC_MSG_RESULT([    libgps  . . . . . . . $with_libgps])
7008 AC_MSG_RESULT([    libgrpc++ . . . . . . $with_libgrpcpp])
7009 AC_MSG_RESULT([    libhiredis  . . . . . $with_libhiredis])
7010 AC_MSG_RESULT([    libi2c-dev  . . . . . $with_libi2c])
7011 AC_MSG_RESULT([    libiokit  . . . . . . $with_libiokit])
7012 AC_MSG_RESULT([    libiptc . . . . . . . $with_libiptc])
7013 AC_MSG_RESULT([    libjevents  . . . . . $with_libjevents])
7014 AC_MSG_RESULT([    libjvm  . . . . . . . $with_java])
7015 AC_MSG_RESULT([    libkstat  . . . . . . $with_kstat])
7016 AC_MSG_RESULT([    libkvm  . . . . . . . $with_libkvm])
7017 AC_MSG_RESULT([    libldap . . . . . . . $with_libldap])
7018 AC_MSG_RESULT([    liblua  . . . . . . . $with_liblua])
7019 AC_MSG_RESULT([    liblvm2app  . . . . . $with_liblvm2app])
7020 AC_MSG_RESULT([    libmemcached  . . . . $with_libmemcached])
7021 AC_MSG_RESULT([    libmicrohttpd . . . . $with_libmicrohttpd])
7022 AC_MSG_RESULT([    libmnl  . . . . . . . $with_libmnl])
7023 AC_MSG_RESULT([    libmodbus . . . . . . $with_libmodbus])
7024 AC_MSG_RESULT([    libmongoc . . . . . . $with_libmongoc])
7025 AC_MSG_RESULT([    libmosquitto  . . . . $with_libmosquitto])
7026 AC_MSG_RESULT([    libmysql  . . . . . . $with_libmysql])
7027 AC_MSG_RESULT([    libnetapp . . . . . . $with_libnetapp])
7028 AC_MSG_RESULT([    libnetsnmp  . . . . . $with_libnetsnmp])
7029 AC_MSG_RESULT([    libnetsnmpagent . . . $with_libnetsnmpagent])
7030 AC_MSG_RESULT([    libnotify . . . . . . $with_libnotify])
7031 AC_MSG_RESULT([    libopenipmi . . . . . $with_libopenipmipthread])
7032 AC_MSG_RESULT([    liboping  . . . . . . $with_liboping])
7033 AC_MSG_RESULT([    libowcapi . . . . . . $with_libowcapi])
7034 AC_MSG_RESULT([    libpcap . . . . . . . $with_libpcap])
7035 AC_MSG_RESULT([    libperfstat . . . . . $with_perfstat])
7036 AC_MSG_RESULT([    libperl . . . . . . . $with_libperl])
7037 AC_MSG_RESULT([    libpq . . . . . . . . $with_libpq])
7038 AC_MSG_RESULT([    libpqos . . . . . . . $with_libpqos])
7039 AC_MSG_RESULT([    libprotobuf . . . . . $with_libprotobuf])
7040 AC_MSG_RESULT([    libprotobuf-c . . . . $with_libprotobuf_c])
7041 AC_MSG_RESULT([    libpython . . . . . . $with_libpython])
7042 AC_MSG_RESULT([    libqpid-proton .  . . $with_libqpid_proton])
7043 AC_MSG_RESULT([    librabbitmq . . . . . $with_librabbitmq])
7044 AC_MSG_RESULT([    libriemann-client . . $with_libriemann_client])
7045 AC_MSG_RESULT([    librdkafka  . . . . . $with_librdkafka])
7046 AC_MSG_RESULT([    librouteros . . . . . $with_librouteros])
7047 AC_MSG_RESULT([    librrd  . . . . . . . $with_librrd])
7048 AC_MSG_RESULT([    libsensors  . . . . . $with_libsensors])
7049 AC_MSG_RESULT([    libsigrok   . . . . . $with_libsigrok])
7050 AC_MSG_RESULT([    libstatgrab . . . . . $with_libstatgrab])
7051 AC_MSG_RESULT([    libtokyotyrant  . . . $with_libtokyotyrant])
7052 AC_MSG_RESULT([    libudev . . . . . . . $with_libudev])
7053 AC_MSG_RESULT([    libupsclient  . . . . $with_libupsclient])
7054 AC_MSG_RESULT([    libvarnish  . . . . . $with_libvarnish])
7055 AC_MSG_RESULT([    libvirt . . . . . . . $with_libvirt])
7056 AC_MSG_RESULT([    libxenctrl  . . . . . $with_libxenctrl])
7057 AC_MSG_RESULT([    libxml2 . . . . . . . $with_libxml2])
7058 AC_MSG_RESULT([    libxmms . . . . . . . $with_libxmms])
7059 AC_MSG_RESULT([    libyajl . . . . . . . $with_libyajl])
7060 AC_MSG_RESULT([    oracle  . . . . . . . $with_oracle])
7061 AC_MSG_RESULT([    protobuf-c  . . . . . $have_protoc_c])
7062 AC_MSG_RESULT([    protoc 3  . . . . . . $have_protoc3])
7063 AC_MSG_RESULT()
7064 AC_MSG_RESULT([  Features:])
7065 AC_MSG_RESULT([    daemon mode . . . . . $enable_daemon])
7066 AC_MSG_RESULT([    debug . . . . . . . . $enable_debug])
7067 AC_MSG_RESULT()
7068 AC_MSG_RESULT([  Bindings:])
7069 AC_MSG_RESULT([    perl  . . . . . . . . $with_perl_bindings])
7070 AC_MSG_RESULT()
7071 AC_MSG_RESULT([  Modules:])
7072 AC_MSG_RESULT([    aggregation . . . . . $enable_aggregation])
7073 AC_MSG_RESULT([    amqp    . . . . . . . $enable_amqp])
7074 AC_MSG_RESULT([    amqp1   . . . . . . . $enable_amqp1])
7075 AC_MSG_RESULT([    apache  . . . . . . . $enable_apache])
7076 AC_MSG_RESULT([    apcups  . . . . . . . $enable_apcups])
7077 AC_MSG_RESULT([    apple_sensors . . . . $enable_apple_sensors])
7078 AC_MSG_RESULT([    aquaero . . . . . . . $enable_aquaero])
7079 AC_MSG_RESULT([    ascent  . . . . . . . $enable_ascent])
7080 AC_MSG_RESULT([    barometer . . . . . . $enable_barometer])
7081 AC_MSG_RESULT([    battery . . . . . . . $enable_battery])
7082 AC_MSG_RESULT([    bind  . . . . . . . . $enable_bind])
7083 AC_MSG_RESULT([    ceph  . . . . . . . . $enable_ceph])
7084 AC_MSG_RESULT([    cgroups . . . . . . . $enable_cgroups])
7085 AC_MSG_RESULT([    chrony. . . . . . . . $enable_chrony])
7086 AC_MSG_RESULT([    conntrack . . . . . . $enable_conntrack])
7087 AC_MSG_RESULT([    contextswitch . . . . $enable_contextswitch])
7088 AC_MSG_RESULT([    cpu . . . . . . . . . $enable_cpu])
7089 AC_MSG_RESULT([    cpufreq . . . . . . . $enable_cpufreq])
7090 AC_MSG_RESULT([    cpusleep  . . . . . . $enable_cpusleep])
7091 AC_MSG_RESULT([    csv . . . . . . . . . $enable_csv])
7092 AC_MSG_RESULT([    curl  . . . . . . . . $enable_curl])
7093 AC_MSG_RESULT([    curl_json . . . . . . $enable_curl_json])
7094 AC_MSG_RESULT([    curl_xml  . . . . . . $enable_curl_xml])
7095 AC_MSG_RESULT([    dbi . . . . . . . . . $enable_dbi])
7096 AC_MSG_RESULT([    df  . . . . . . . . . $enable_df])
7097 AC_MSG_RESULT([    disk  . . . . . . . . $enable_disk])
7098 AC_MSG_RESULT([    dns . . . . . . . . . $enable_dns])
7099 AC_MSG_RESULT([    dpdkevents. . . . . . $enable_dpdkevents])
7100 AC_MSG_RESULT([    dpdkstat  . . . . . . $enable_dpdkstat])
7101 AC_MSG_RESULT([    drbd  . . . . . . . . $enable_drbd])
7102 AC_MSG_RESULT([    email . . . . . . . . $enable_email])
7103 AC_MSG_RESULT([    entropy . . . . . . . $enable_entropy])
7104 AC_MSG_RESULT([    ethstat . . . . . . . $enable_ethstat])
7105 AC_MSG_RESULT([    exec  . . . . . . . . $enable_exec])
7106 AC_MSG_RESULT([    fhcount . . . . . . . $enable_fhcount])
7107 AC_MSG_RESULT([    filecount . . . . . . $enable_filecount])
7108 AC_MSG_RESULT([    fscache . . . . . . . $enable_fscache])
7109 AC_MSG_RESULT([    gmond . . . . . . . . $enable_gmond])
7110 AC_MSG_RESULT([    gps . . . . . . . . . $enable_gps])
7111 AC_MSG_RESULT([    grpc  . . . . . . . . $enable_grpc])
7112 AC_MSG_RESULT([    hddtemp . . . . . . . $enable_hddtemp])
7113 AC_MSG_RESULT([    hugepages . . . . . . $enable_hugepages])
7114 AC_MSG_RESULT([    intel_pmu . . . . . . $enable_intel_pmu])
7115 AC_MSG_RESULT([    intel_rdt . . . . . . $enable_intel_rdt])
7116 AC_MSG_RESULT([    interface . . . . . . $enable_interface])
7117 AC_MSG_RESULT([    ipc . . . . . . . . . $enable_ipc])
7118 AC_MSG_RESULT([    ipmi  . . . . . . . . $enable_ipmi])
7119 AC_MSG_RESULT([    iptables  . . . . . . $enable_iptables])
7120 AC_MSG_RESULT([    ipvs  . . . . . . . . $enable_ipvs])
7121 AC_MSG_RESULT([    irq . . . . . . . . . $enable_irq])
7122 AC_MSG_RESULT([    java  . . . . . . . . $enable_java])
7123 AC_MSG_RESULT([    load  . . . . . . . . $enable_load])
7124 AC_MSG_RESULT([    logfile . . . . . . . $enable_logfile])
7125 AC_MSG_RESULT([    log_logstash  . . . . $enable_log_logstash])
7126 AC_MSG_RESULT([    lpar  . . . . . . . . $enable_lpar])
7127 AC_MSG_RESULT([    lua . . . . . . . . . $enable_lua])
7128 AC_MSG_RESULT([    lvm . . . . . . . . . $enable_lvm])
7129 AC_MSG_RESULT([    madwifi . . . . . . . $enable_madwifi])
7130 AC_MSG_RESULT([    match_empty_counter . $enable_match_empty_counter])
7131 AC_MSG_RESULT([    match_hashed  . . . . $enable_match_hashed])
7132 AC_MSG_RESULT([    match_regex . . . . . $enable_match_regex])
7133 AC_MSG_RESULT([    match_timediff  . . . $enable_match_timediff])
7134 AC_MSG_RESULT([    match_value . . . . . $enable_match_value])
7135 AC_MSG_RESULT([    mbmon . . . . . . . . $enable_mbmon])
7136 AC_MSG_RESULT([    mcelog  . . . . . . . $enable_mcelog])
7137 AC_MSG_RESULT([    md  . . . . . . . . . $enable_md])
7138 AC_MSG_RESULT([    memcachec . . . . . . $enable_memcachec])
7139 AC_MSG_RESULT([    memcached . . . . . . $enable_memcached])
7140 AC_MSG_RESULT([    memory  . . . . . . . $enable_memory])
7141 AC_MSG_RESULT([    mic . . . . . . . . . $enable_mic])
7142 AC_MSG_RESULT([    modbus  . . . . . . . $enable_modbus])
7143 AC_MSG_RESULT([    mqtt  . . . . . . . . $enable_mqtt])
7144 AC_MSG_RESULT([    multimeter  . . . . . $enable_multimeter])
7145 AC_MSG_RESULT([    mysql . . . . . . . . $enable_mysql])
7146 AC_MSG_RESULT([    netapp  . . . . . . . $enable_netapp])
7147 AC_MSG_RESULT([    netlink . . . . . . . $enable_netlink])
7148 AC_MSG_RESULT([    network . . . . . . . $enable_network])
7149 AC_MSG_RESULT([    nfs . . . . . . . . . $enable_nfs])
7150 AC_MSG_RESULT([    nginx . . . . . . . . $enable_nginx])
7151 AC_MSG_RESULT([    notify_desktop  . . . $enable_notify_desktop])
7152 AC_MSG_RESULT([    notify_email  . . . . $enable_notify_email])
7153 AC_MSG_RESULT([    notify_nagios . . . . $enable_notify_nagios])
7154 AC_MSG_RESULT([    ntpd  . . . . . . . . $enable_ntpd])
7155 AC_MSG_RESULT([    numa  . . . . . . . . $enable_numa])
7156 AC_MSG_RESULT([    nut . . . . . . . . . $enable_nut])
7157 AC_MSG_RESULT([    olsrd . . . . . . . . $enable_olsrd])
7158 AC_MSG_RESULT([    onewire . . . . . . . $enable_onewire])
7159 AC_MSG_RESULT([    openldap  . . . . . . $enable_openldap])
7160 AC_MSG_RESULT([    openvpn . . . . . . . $enable_openvpn])
7161 AC_MSG_RESULT([    oracle  . . . . . . . $enable_oracle])
7162 AC_MSG_RESULT([    ovs_events  . . . . . $enable_ovs_events])
7163 AC_MSG_RESULT([    ovs_stats . . . . . . $enable_ovs_stats])
7164 AC_MSG_RESULT([    perl  . . . . . . . . $enable_perl])
7165 AC_MSG_RESULT([    pf  . . . . . . . . . $enable_pf])
7166 AC_MSG_RESULT([    pinba . . . . . . . . $enable_pinba])
7167 AC_MSG_RESULT([    ping  . . . . . . . . $enable_ping])
7168 AC_MSG_RESULT([    postgresql  . . . . . $enable_postgresql])
7169 AC_MSG_RESULT([    powerdns  . . . . . . $enable_powerdns])
7170 AC_MSG_RESULT([    processes . . . . . . $enable_processes])
7171 AC_MSG_RESULT([    protocols . . . . . . $enable_protocols])
7172 AC_MSG_RESULT([    python  . . . . . . . $enable_python])
7173 AC_MSG_RESULT([    redis . . . . . . . . $enable_redis])
7174 AC_MSG_RESULT([    routeros  . . . . . . $enable_routeros])
7175 AC_MSG_RESULT([    rrdcached . . . . . . $enable_rrdcached])
7176 AC_MSG_RESULT([    rrdtool . . . . . . . $enable_rrdtool])
7177 AC_MSG_RESULT([    sensors . . . . . . . $enable_sensors])
7178 AC_MSG_RESULT([    serial  . . . . . . . $enable_serial])
7179 AC_MSG_RESULT([    sigrok  . . . . . . . $enable_sigrok])
7180 AC_MSG_RESULT([    smart . . . . . . . . $enable_smart])
7181 AC_MSG_RESULT([    snmp  . . . . . . . . $enable_snmp])
7182 AC_MSG_RESULT([    snmp_agent  . . . . . $enable_snmp_agent])
7183 AC_MSG_RESULT([    statsd  . . . . . . . $enable_statsd])
7184 AC_MSG_RESULT([    swap  . . . . . . . . $enable_swap])
7185 AC_MSG_RESULT([    synproxy  . . . . . . $enable_synproxy])
7186 AC_MSG_RESULT([    syslog  . . . . . . . $enable_syslog])
7187 AC_MSG_RESULT([    table . . . . . . . . $enable_table])
7188 AC_MSG_RESULT([    tail_csv  . . . . . . $enable_tail_csv])
7189 AC_MSG_RESULT([    tail  . . . . . . . . $enable_tail])
7190 AC_MSG_RESULT([    tape  . . . . . . . . $enable_tape])
7191 AC_MSG_RESULT([    target_notification . $enable_target_notification])
7192 AC_MSG_RESULT([    target_replace  . . . $enable_target_replace])
7193 AC_MSG_RESULT([    target_scale  . . . . $enable_target_scale])
7194 AC_MSG_RESULT([    target_set  . . . . . $enable_target_set])
7195 AC_MSG_RESULT([    target_v5upgrade  . . $enable_target_v5upgrade])
7196 AC_MSG_RESULT([    tcpconns  . . . . . . $enable_tcpconns])
7197 AC_MSG_RESULT([    teamspeak2  . . . . . $enable_teamspeak2])
7198 AC_MSG_RESULT([    ted . . . . . . . . . $enable_ted])
7199 AC_MSG_RESULT([    thermal . . . . . . . $enable_thermal])
7200 AC_MSG_RESULT([    threshold . . . . . . $enable_threshold])
7201 AC_MSG_RESULT([    tokyotyrant . . . . . $enable_tokyotyrant])
7202 AC_MSG_RESULT([    turbostat . . . . . . $enable_turbostat])
7203 AC_MSG_RESULT([    unixsock  . . . . . . $enable_unixsock])
7204 AC_MSG_RESULT([    uptime  . . . . . . . $enable_uptime])
7205 AC_MSG_RESULT([    users . . . . . . . . $enable_users])
7206 AC_MSG_RESULT([    uuid  . . . . . . . . $enable_uuid])
7207 AC_MSG_RESULT([    varnish . . . . . . . $enable_varnish])
7208 AC_MSG_RESULT([    virt  . . . . . . . . $enable_virt])
7209 AC_MSG_RESULT([    vmem  . . . . . . . . $enable_vmem])
7210 AC_MSG_RESULT([    vserver . . . . . . . $enable_vserver])
7211 AC_MSG_RESULT([    wireless  . . . . . . $enable_wireless])
7212 AC_MSG_RESULT([    write_graphite  . . . $enable_write_graphite])
7213 AC_MSG_RESULT([    write_http  . . . . . $enable_write_http])
7214 AC_MSG_RESULT([    write_kafka . . . . . $enable_write_kafka])
7215 AC_MSG_RESULT([    write_log . . . . . . $enable_write_log])
7216 AC_MSG_RESULT([    write_mongodb . . . . $enable_write_mongodb])
7217 AC_MSG_RESULT([    write_prometheus. . . $enable_write_prometheus])
7218 AC_MSG_RESULT([    write_redis . . . . . $enable_write_redis])
7219 AC_MSG_RESULT([    write_riemann . . . . $enable_write_riemann])
7220 AC_MSG_RESULT([    write_sensu . . . . . $enable_write_sensu])
7221 AC_MSG_RESULT([    write_tsdb  . . . . . $enable_write_tsdb])
7222 AC_MSG_RESULT([    xencpu  . . . . . . . $enable_xencpu])
7223 AC_MSG_RESULT([    xmms  . . . . . . . . $enable_xmms])
7224 AC_MSG_RESULT([    zfs_arc . . . . . . . $enable_zfs_arc])
7225 AC_MSG_RESULT([    zone  . . . . . . . . $enable_zone])
7226 AC_MSG_RESULT([    zookeeper . . . . . . $enable_zookeeper])
7227 AC_MSG_RESULT()
7228
7229 if test "x$dependency_error" = "xyes"; then
7230   AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
7231 fi
7232
7233 if test "x$dependency_warning" = "xyes"; then
7234   AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
7235 fi
7236
7237 # vim: set fdm=marker sw=2 sts=2 ts=2 et :