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