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