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