Merge branch 'collectd-5.6' into collectd-5.7
[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_LDFLAGS], [Linker flags for libdpdk])
2703
2704 AC_ARG_WITH([libdpdk], [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])])
2705
2706 if test "x$with_libdpdk" != "xno"
2707 then
2708         if test "x$LIBDPDK_CPPFLAGS" = "x"
2709         then
2710                 LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
2711         fi
2712         SAVE_CPPFLAGS="$CPPFLAGS"
2713         CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
2714         AC_CHECK_HEADERS([rte_config.h],
2715                 [with_libdpdk="yes"],
2716                 [with_libdpdk="no (rte_config.h not found)"]
2717         )
2718         CPPFLAGS="$SAVE_CPPFLAGS"
2719 fi
2720
2721 if test "x$with_libdpdk" = "xyes"
2722 then
2723         SAVE_LDFLAGS="$LDFLAGS"
2724         LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
2725         AC_CHECK_LIB([dpdk], [rte_eal_init],
2726                 [with_libdpdk="yes"],
2727                 [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
2728         )
2729         LDFLAGS="$SAVE_LDFLAGS"
2730 fi
2731
2732 # }}}
2733
2734 # --with-java {{{
2735 with_java_home="$JAVA_HOME"
2736 if test "x$with_java_home" = "x"
2737 then
2738         with_java_home="/usr/lib/jvm"
2739 fi
2740 JAVAC="$JAVAC"
2741 JAR="$JAR"
2742 AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
2743 [
2744         if test "x$withval" = "xno"
2745         then
2746                 with_java="no"
2747         else if test "x$withval" = "xyes"
2748         then
2749                 with_java="yes"
2750         else
2751                 with_java_home="$withval"
2752                 with_java="yes"
2753         fi; fi
2754 ],
2755 [with_java="yes"])
2756 if test "x$with_java" = "xyes"
2757 then
2758         if test -d "$with_java_home"
2759         then
2760                 AC_MSG_CHECKING([for jni.h])
2761                 TMPVAR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2762                 if test "x$TMPVAR" != "x"
2763                 then
2764                         AC_MSG_RESULT([found in $TMPVAR])
2765                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
2766                 else
2767                         AC_MSG_RESULT([not found])
2768                 fi
2769
2770                 AC_MSG_CHECKING([for jni_md.h])
2771                 TMPVAR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2772                 if test "x$TMPVAR" != "x"
2773                 then
2774                         AC_MSG_RESULT([found in $TMPVAR])
2775                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
2776                 else
2777                         AC_MSG_RESULT([not found])
2778                 fi
2779
2780                 AC_MSG_CHECKING([for libjvm.so])
2781                 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`
2782                 if test "x$TMPVAR" != "x"
2783                 then
2784                         AC_MSG_RESULT([found in $TMPVAR])
2785                         JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
2786                 else
2787                         AC_MSG_RESULT([not found])
2788                 fi
2789
2790                 if test "x$JAVAC" = "x"
2791                 then
2792                         AC_MSG_CHECKING([for javac])
2793                         TMPVAR=`find -L "$with_java_home" -name javac -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
2794                         if test "x$TMPVAR" != "x"
2795                         then
2796                                 JAVAC="$TMPVAR"
2797                                 AC_MSG_RESULT([$JAVAC])
2798                         else
2799                                 AC_MSG_RESULT([not found])
2800                         fi
2801                 fi
2802                 if test "x$JAR" = "x"
2803                 then
2804                         AC_MSG_CHECKING([for jar])
2805                         TMPVAR=`find -L "$with_java_home" -name jar -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
2806                         if test "x$TMPVAR" != "x"
2807                         then
2808                                 JAR="$TMPVAR"
2809                                 AC_MSG_RESULT([$JAR])
2810                         else
2811                                 AC_MSG_RESULT([not found])
2812                         fi
2813                 fi
2814         else if test "x$with_java_home" != "x"
2815         then
2816                 AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
2817         fi; fi
2818 fi
2819
2820 if test "x$JAVA_CPPFLAGS" != "x"
2821 then
2822         AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
2823 fi
2824 if test "x$JAVA_CFLAGS" != "x"
2825 then
2826         AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
2827 fi
2828 if test "x$JAVA_LDFLAGS" != "x"
2829 then
2830         AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
2831 fi
2832 if test "x$JAVA_LIBS" != "x"
2833 then
2834         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
2835 fi
2836 if test "x$JAVAC" = "x"
2837 then
2838         with_javac_path="$PATH"
2839         if test "x$with_java_home" != "x"
2840         then
2841                 with_javac_path="$with_java_home:with_javac_path"
2842                 if test -d "$with_java_home/bin"
2843                 then
2844                         with_javac_path="$with_java_home/bin:with_javac_path"
2845                 fi
2846         fi
2847
2848         AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
2849 fi
2850 if test "x$JAVAC" = "x"
2851 then
2852         with_java="no (javac not found)"
2853 fi
2854 if test "x$JAR" = "x"
2855 then
2856         with_jar_path="$PATH"
2857         if test "x$with_java_home" != "x"
2858         then
2859                 with_jar_path="$with_java_home:$with_jar_path"
2860                 if test -d "$with_java_home/bin"
2861                 then
2862                         with_jar_path="$with_java_home/bin:$with_jar_path"
2863                 fi
2864         fi
2865
2866         AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
2867 fi
2868 if test "x$JAR" = "x"
2869 then
2870         with_java="no (jar not found)"
2871 fi
2872
2873 SAVE_CPPFLAGS="$CPPFLAGS"
2874 SAVE_CFLAGS="$CFLAGS"
2875 SAVE_LDFLAGS="$LDFLAGS"
2876 SAVE_LIBS="$LIBS"
2877 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
2878 CFLAGS="$CFLAGS $JAVA_CFLAGS"
2879 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
2880 LIBS="$LIBS $JAVA_LIBS"
2881
2882 if test "x$with_java" = "xyes"
2883 then
2884         AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
2885 fi
2886 if test "x$with_java" = "xyes"
2887 then
2888         AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
2889         [with_java="yes"],
2890         [with_java="no (Symbol 'JNI_CreateJavaVM' not found)"],
2891         [$JAVA_LIBS $PTHREAD_LIBS])
2892 fi
2893 if test "x$with_java" = "xyes"
2894 then
2895         JAVA_LIBS="$JAVA_LIBS -ljvm"
2896         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
2897 fi
2898
2899 CPPFLAGS="$SAVE_CPPFLAGS"
2900 CFLAGS="$SAVE_CFLAGS"
2901 LDFLAGS="$SAVE_LDFLAGS"
2902 LIBS="$SAVE_LIBS"
2903
2904 AC_SUBST(JAVA_CPPFLAGS)
2905 AC_SUBST(JAVA_CFLAGS)
2906 AC_SUBST(JAVA_LDFLAGS)
2907 AC_SUBST(JAVA_LIBS)
2908 AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
2909 # }}}
2910
2911 # --with-libldap {{{
2912 AC_ARG_WITH(libldap, [AS_HELP_STRING([--with-libldap@<:@=PREFIX@:>@], [Path to libldap.])],
2913 [
2914  if test "x$withval" = "xyes"
2915  then
2916          with_libldap="yes"
2917  else if test "x$withval" = "xno"
2918  then
2919          with_libldap="no"
2920  else
2921          with_libldap="yes"
2922          LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS -I$withval/include"
2923          LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS -L$withval/lib"
2924  fi; fi
2925 ],
2926 [with_libldap="yes"])
2927
2928 SAVE_CPPFLAGS="$CPPFLAGS"
2929 SAVE_LDFLAGS="$LDFLAGS"
2930
2931 CPPFLAGS="$CPPFLAGS $LIBLDAP_CPPFLAGS"
2932 LDFLAGS="$LDFLAGS $LIBLDAP_LDFLAGS"
2933
2934 if test "x$with_libldap" = "xyes"
2935 then
2936         if test "x$LIBLDAP_CPPFLAGS" != "x"
2937         then
2938                 AC_MSG_NOTICE([libldap CPPFLAGS: $LIBLDAP_CPPFLAGS])
2939         fi
2940         AC_CHECK_HEADERS(ldap.h,
2941         [with_libldap="yes"],
2942         [with_libldap="no ('ldap.h' not found)"])
2943 fi
2944 if test "x$with_libldap" = "xyes"
2945 then
2946         if test "x$LIBLDAP_LDFLAGS" != "x"
2947         then
2948                 AC_MSG_NOTICE([libldap LDFLAGS: $LIBLDAP_LDFLAGS])
2949         fi
2950         AC_CHECK_LIB(ldap, ldap_initialize,
2951         [with_libldap="yes"],
2952         [with_libldap="no (symbol 'ldap_initialize' not found)"])
2953
2954 fi
2955
2956 CPPFLAGS="$SAVE_CPPFLAGS"
2957 LDFLAGS="$SAVE_LDFLAGS"
2958
2959 if test "x$with_libldap" = "xyes"
2960 then
2961         BUILD_WITH_LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS"
2962         BUILD_WITH_LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS"
2963         AC_SUBST(BUILD_WITH_LIBLDAP_CPPFLAGS)
2964         AC_SUBST(BUILD_WITH_LIBLDAP_LDFLAGS)
2965 fi
2966 AM_CONDITIONAL(BUILD_WITH_LIBLDAP, test "x$with_libldap" = "xyes")
2967 # }}}
2968
2969 # --with-liblua {{{
2970 AC_ARG_VAR([LIBLUA_PKG_CONFIG_NAME], [Name of liblua used by pkg-config])
2971 if test "x$LIBLUA_PKG_CONFIG_NAME" != "x"
2972 then
2973   PKG_CHECK_MODULES([LUA], [$LIBLUA_PKG_CONFIG_NAME],
2974     [with_liblua="yes"],
2975     [with_liblua="no"]
2976   )
2977 else
2978   PKG_CHECK_MODULES([LUA], [lua],
2979     [with_liblua="yes"],
2980     [
2981       PKG_CHECK_MODULES([LUA], [lua-5.3],
2982         [with_liblua="yes"],
2983         [
2984           PKG_CHECK_MODULES([LUA], [lua5.3],
2985             [with_liblua="yes"],
2986             [
2987               PKG_CHECK_MODULES([LUA], [lua-5.2],
2988                 [with_liblua="yes"],
2989                 [
2990                   PKG_CHECK_MODULES([LUA], [lua5.2],
2991                     [with_liblua="yes"],
2992                     [
2993                       PKG_CHECK_MODULES([LUA], [lua-5.1],
2994                         [with_liblua="yes"],
2995                         [
2996                           PKG_CHECK_MODULES([LUA], [lua5.1],
2997                             [with_liblua="yes"],
2998                             [with_liblua="no (pkg-config cannot find liblua)"]
2999                           )
3000                         ]
3001                       )
3002                     ]
3003                   )
3004                 ]
3005               )
3006             ]
3007           )
3008         ]
3009       )
3010     ]
3011   )
3012 fi
3013
3014 if test "x$with_liblua" = "xyes"
3015 then
3016   SAVE_CPPFLAGS="$CPPFLAGS"
3017   CPPFLAGS="$CPPFLAGS $LUA_CFLAGS"
3018
3019   AC_CHECK_HEADERS([lua.h lauxlib.h lualib.h],
3020     [with_liblua="yes"],
3021     [with_liblua="no (header not found)"]
3022   )
3023
3024   CPPFLAGS="$SAVE_CPPFLAGS"
3025 fi
3026
3027 if test "x$with_liblua" = "xyes"
3028 then
3029   SAVE_LIBS="$LIBS"
3030   LIBS="$LIBS $LUA_LIBS"
3031
3032   AC_CHECK_FUNC([lua_settop],
3033     [with_liblua="yes"],
3034     [with_liblua="no (symbol 'lua_settop' not found)"]
3035   )
3036
3037   LIBS="$SAVE_LIBS"
3038 fi
3039
3040 if test "x$with_liblua" = "xyes"
3041 then
3042     BUILD_WITH_LIBLUA_CFLAGS="$LUA_CFLAGS"
3043     BUILD_WITH_LIBLUA_LIBS="$LUA_LIBS"
3044 fi
3045 AC_SUBST(BUILD_WITH_LIBLUA_CFLAGS)
3046 AC_SUBST(BUILD_WITH_LIBLUA_LIBS)
3047 # }}}
3048
3049 # --with-liblvm2app {{{
3050 with_liblvm2app_cppflags=""
3051 with_liblvm2app_ldflags=""
3052 AC_ARG_WITH(liblvm2app, [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
3053 [
3054         if test "x$withval" = "xno"
3055         then
3056                 with_liblvm2app="no"
3057         else
3058                 with_liblvm2app="yes"
3059                 if test "x$withval" != "xyes"
3060                 then
3061                         with_liblvm2app_cppflags="-I$withval/include"
3062                         with_liblvm2app_ldflags="-L$withval/lib"
3063                 fi
3064         fi
3065 ],
3066 [
3067         if test "x$ac_system" = "xLinux"
3068         then
3069                 with_liblvm2app="yes"
3070         else
3071                 with_liblvm2app="no (Linux only library)"
3072         fi
3073 ])
3074 if test "x$with_liblvm2app" = "xyes"
3075 then
3076         SAVE_CPPFLAGS="$CPPFLAGS"
3077         CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
3078
3079         AC_CHECK_HEADERS(lvm2app.h, [with_liblvm2app="yes"], [with_liblvm2app="no (lvm2app.h not found)"])
3080
3081         CPPFLAGS="$SAVE_CPPFLAGS"
3082 fi
3083
3084 if test "x$with_liblvm2app" = "xyes"
3085 then
3086         SAVE_CPPFLAGS="$CPPFLAGS"
3087         SAVE_LDFLAGS="$LDFLAGS"
3088         CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
3089         LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
3090
3091         AC_CHECK_LIB(lvm2app, lvm_lv_get_property, [with_liblvm2app="yes"], [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"])
3092
3093         CPPFLAGS="$SAVE_CPPFLAGS"
3094         LDFLAGS="$SAVE_LDFLAGS"
3095 fi
3096 if test "x$with_liblvm2app" = "xyes"
3097 then
3098         BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
3099         BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
3100         BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
3101         AC_SUBST(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
3102         AC_SUBST(BUILD_WITH_LIBLVM2APP_LDFLAGS)
3103         AC_SUBST(BUILD_WITH_LIBLVM2APP_LIBS)
3104         AC_DEFINE(HAVE_LIBLVM2APP, 1, [Define if liblvm2app is present and usable.])
3105 fi
3106 AM_CONDITIONAL(BUILD_WITH_LIBLVM2APP, test "x$with_liblvm2app" = "xyes")
3107 # }}}
3108
3109 # --with-libmemcached {{{
3110 with_libmemcached_cppflags=""
3111 with_libmemcached_ldflags=""
3112 AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
3113 [
3114         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3115         then
3116                 with_libmemcached_cppflags="-I$withval/include"
3117                 with_libmemcached_ldflags="-L$withval/lib"
3118                 with_libmemcached="yes"
3119         else
3120                 with_libmemcached="$withval"
3121         fi
3122 ],
3123 [
3124         with_libmemcached="yes"
3125 ])
3126 if test "x$with_libmemcached" = "xyes"
3127 then
3128         SAVE_CPPFLAGS="$CPPFLAGS"
3129         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
3130
3131         AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
3132
3133         CPPFLAGS="$SAVE_CPPFLAGS"
3134 fi
3135 if test "x$with_libmemcached" = "xyes"
3136 then
3137         SAVE_CPPFLAGS="$CPPFLAGS"
3138         SAVE_LDFLAGS="$LDFLAGS"
3139         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
3140         LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
3141
3142         AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
3143
3144         CPPFLAGS="$SAVE_CPPFLAGS"
3145         LDFLAGS="$SAVE_LDFLAGS"
3146 fi
3147 if test "x$with_libmemcached" = "xyes"
3148 then
3149         BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
3150         BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
3151         BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
3152         AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
3153         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
3154         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
3155         AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
3156 fi
3157 AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
3158 # }}}
3159
3160 # --with-libmicrohttpd {{{
3161 with_libmicrohttpd_cppflags=""
3162 with_libmicrohttpd_ldflags=""
3163 AC_ARG_WITH([libmicrohttpd], [AS_HELP_STRING([--with-libmicrohttpd@<:@=PREFIX@:>@], [Path to libmicrohttpd.])],
3164   [
3165     if test "x$withval" != "xno" && test "x$withval" != "xyes"
3166     then
3167       with_libmicrohttpd_cppflags="-I$withval/include"
3168       with_libmicrohttpd_ldflags="-L$withval/lib"
3169       with_libmicrohttpd="yes"
3170     fi
3171     if test "x$withval" = "xno"
3172     then
3173       with_libmicrohttpd="no (disabled on command line)"
3174     fi
3175   ],
3176   [withval="yes"]
3177 )
3178 if test "x$withval" = "xyes"
3179 then
3180 PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd],
3181   [with_libmicrohttpd="yes"],
3182   [with_libmicrohttpd="no (pkg-config could not find libmicrohttpd)"]
3183 )
3184 fi
3185
3186 if test "x$MICROHTTPD_LIBS" = "x"
3187 then
3188   MICROHTTPD_LIBS="-lmicrohttpd"
3189 fi
3190
3191 SAVE_CPPFLAGS="$CPPFLAGS"
3192 SAVE_LDFLAGS="$LDFLAGS"
3193 SAVE_LIBS="$LIBS"
3194 CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
3195 LDFLAGS="$with_libmicrohttpd_ldflags $LDFLAGS"
3196 LIBS="$LIBS $MICROHTTPD_LIBS"
3197
3198 if test "x$with_libmicrohttpd" = "xyes"
3199 then
3200   AC_CHECK_HEADERS([microhttpd.h],
3201                    [with_libmicrohttpd="yes"],
3202                    [with_libmicrohttpd="no (<microhttpd.h> not found)"])
3203 fi
3204
3205 if test "x$with_libmicrohttpd" = "xyes"
3206 then
3207   AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
3208                [with_libmicrohttpd="yes"],
3209                [with_libmicrohttpd="no (libmicrohttpd not found)"])
3210 fi
3211
3212 CPPFLAGS="$SAVE_CPPFLAGS"
3213 LDFLAGS="$SAVE_LDFLAGS"
3214 LIBS="$SAVE_LIBS"
3215
3216 BUILD_WITH_LIBMICROHTTPD_CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
3217 BUILD_WITH_LIBMICROHTTPD_LDFLAGS="$with_libmicrohttpd_ldflags"
3218 BUILD_WITH_LIBMICROHTTPD_LIBS="$MICROHTTPD_LIBS"
3219 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_CPPFLAGS])
3220 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LDFLAGS])
3221 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LIBS])
3222 # }}}
3223
3224 # --with-libmodbus {{{
3225 with_libmodbus_config=""
3226 with_libmodbus_cflags=""
3227 with_libmodbus_libs=""
3228 AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
3229 [
3230         if test "x$withval" = "xno"
3231         then
3232                 with_libmodbus="no"
3233         else if test "x$withval" = "xyes"
3234         then
3235                 with_libmodbus="use_pkgconfig"
3236         else if test -d "$with_libmodbus/lib"
3237         then
3238                 AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
3239                 with_libmodbus_cflags="-I$withval/include"
3240                 with_libmodbus_libs="-L$withval/lib -lmodbus"
3241                 with_libmodbus="yes"
3242         fi; fi; fi
3243 ],
3244 [with_libmodbus="use_pkgconfig"])
3245
3246 # configure using pkg-config
3247 if test "x$with_libmodbus" = "xuse_pkgconfig"
3248 then
3249         AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
3250         $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
3251         if test $? -ne 0
3252         then
3253                 with_libmodbus="no (pkg-config doesn't know libmodbus)"
3254         fi
3255 fi
3256 if test "x$with_libmodbus" = "xuse_pkgconfig"
3257 then
3258         with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
3259         if test $? -ne 0
3260         then
3261                 with_libmodbus="no ($PKG_CONFIG failed)"
3262         fi
3263         with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
3264         if test $? -ne 0
3265         then
3266                 with_libmodbus="no ($PKG_CONFIG failed)"
3267         fi
3268 fi
3269 if test "x$with_libmodbus" = "xuse_pkgconfig"
3270 then
3271         with_libmodbus="yes"
3272 fi
3273
3274 # with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do
3275 # the actual checks.
3276 if test "x$with_libmodbus" = "xyes"
3277 then
3278         SAVE_CPPFLAGS="$CPPFLAGS"
3279         CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
3280
3281         AC_CHECK_HEADERS(modbus.h, [], [with_libmodbus="no (modbus.h not found)"])
3282
3283         CPPFLAGS="$SAVE_CPPFLAGS"
3284 fi
3285 if test "x$with_libmodbus" = "xyes"
3286 then
3287         SAVE_CPPFLAGS="$CPPFLAGS"
3288         SAVE_LDFLAGS="$LDFLAGS"
3289
3290         CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
3291         LDFLAGS="$LDFLAGS $with_libmodbus_libs"
3292
3293         AC_CHECK_LIB(modbus, modbus_connect,
3294                      [with_libmodbus="yes"],
3295                      [with_libmodbus="no (symbol modbus_connect not found)"])
3296
3297         CPPFLAGS="$SAVE_CPPFLAGS"
3298         LDFLAGS="$SAVE_LDFLAGS"
3299 fi
3300 if test "x$with_libmodbus" = "xyes"
3301 then
3302         BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
3303         BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
3304         AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS)
3305         AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS)
3306 fi
3307 # }}}
3308
3309 # --with-libmongoc {{{
3310 AC_ARG_WITH(libmongoc, [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
3311 [
3312  if test "x$withval" = "xyes"
3313  then
3314          with_libmongoc="yes"
3315  else if test "x$withval" = "xno"
3316  then
3317          with_libmongoc="no"
3318  else
3319          with_libmongoc="yes"
3320          LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
3321          LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
3322  fi; fi
3323 ],
3324 [with_libmongoc="yes"])
3325
3326 SAVE_CPPFLAGS="$CPPFLAGS"
3327 SAVE_LDFLAGS="$LDFLAGS"
3328
3329 CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
3330 LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
3331
3332 if test "x$with_libmongoc" = "xyes"
3333 then
3334         if test "x$LIBMONGOC_CPPFLAGS" != "x"
3335         then
3336                 AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
3337         fi
3338         AC_CHECK_HEADERS(mongo.h,
3339         [with_libmongoc="yes"],
3340         [with_libmongoc="no ('mongo.h' not found)"],
3341 [#if HAVE_STDINT_H
3342 # define MONGO_HAVE_STDINT 1
3343 #else
3344 # define MONGO_USE_LONG_LONG_INT 1
3345 #endif
3346 ])
3347 fi
3348 if test "x$with_libmongoc" = "xyes"
3349 then
3350         if test "x$LIBMONGOC_LDFLAGS" != "x"
3351         then
3352                 AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
3353         fi
3354         AC_CHECK_LIB(mongoc, mongo_run_command,
3355         [with_libmongoc="yes"],
3356         [with_libmongoc="no (symbol 'mongo_run_command' not found)"])
3357 fi
3358
3359 CPPFLAGS="$SAVE_CPPFLAGS"
3360 LDFLAGS="$SAVE_LDFLAGS"
3361
3362 if test "x$with_libmongoc" = "xyes"
3363 then
3364         BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
3365         BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
3366         AC_SUBST(BUILD_WITH_LIBMONGOC_CPPFLAGS)
3367         AC_SUBST(BUILD_WITH_LIBMONGOC_LDFLAGS)
3368 fi
3369 AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
3370 # }}}
3371
3372 # --with-libmosquitto {{{
3373 with_libmosquitto_cppflags=""
3374 with_libmosquitto_ldflags=""
3375 AC_ARG_WITH(libmosquitto, [AS_HELP_STRING([--with-libmosquitto@<:@=PREFIX@:>@], [Path to libmosquitto.])],
3376 [
3377         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3378         then
3379                 with_libmosquitto_cppflags="-I$withval/include"
3380                 with_libmosquitto_ldflags="-L$withval/lib"
3381                 with_libmosquitto="yes"
3382         else
3383                 with_libmosquitto="$withval"
3384         fi
3385 ],
3386 [
3387         with_libmosquitto="yes"
3388 ])
3389 if test "x$with_libmosquitto" = "xyes"
3390 then
3391         SAVE_CPPFLAGS="$CPPFLAGS"
3392         CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
3393
3394         AC_CHECK_HEADERS(mosquitto.h, [with_libmosquitto="yes"], [with_libmosquitto="no (mosquitto.h not found)"])
3395
3396         CPPFLAGS="$SAVE_CPPFLAGS"
3397 fi
3398 if test "x$with_libmosquitto" = "xyes"
3399 then
3400         SAVE_LDFLAGS="$LDFLAGS"
3401         SAVE_CPPFLAGS="$CPPFLAGS"
3402         LDFLAGS="$LDFLAGS $with_libmosquitto_ldflags"
3403         CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
3404
3405         AC_CHECK_LIB(mosquitto, mosquitto_connect, [with_libmosquitto="yes"], [with_libmosquitto="no (libmosquitto not found)"])
3406
3407         LDFLAGS="$SAVE_LDFLAGS"
3408         CPPFLAGS="$SAVE_CPPFLAGS"
3409 fi
3410 if test "x$with_libmosquitto" = "xyes"
3411 then
3412         BUILD_WITH_LIBMOSQUITTO_CPPFLAGS="$with_libmosquitto_cppflags"
3413         BUILD_WITH_LIBMOSQUITTO_LDFLAGS="$with_libmosquitto_ldflags"
3414         BUILD_WITH_LIBMOSQUITTO_LIBS="-lmosquitto"
3415         AC_SUBST(BUILD_WITH_LIBMOSQUITTO_CPPFLAGS)
3416         AC_SUBST(BUILD_WITH_LIBMOSQUITTO_LDFLAGS)
3417         AC_SUBST(BUILD_WITH_LIBMOSQUITTO_LIBS)
3418 fi
3419 # }}}
3420
3421 # --with-libmysql {{{
3422 with_mysql_config="mysql_config"
3423 with_mysql_cflags=""
3424 with_mysql_libs=""
3425 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
3426 [
3427         if test "x$withval" = "xno"
3428         then
3429                 with_libmysql="no"
3430         else if test "x$withval" = "xyes"
3431         then
3432                 with_libmysql="yes"
3433         else
3434                 if test -f "$withval" && test -x "$withval";
3435                 then
3436                         with_mysql_config="$withval"
3437                 else if test -x "$withval/bin/mysql_config"
3438                 then
3439                         with_mysql_config="$withval/bin/mysql_config"
3440                 fi; fi
3441                 with_libmysql="yes"
3442         fi; fi
3443 ],
3444 [
3445         with_libmysql="yes"
3446 ])
3447 if test "x$with_libmysql" = "xyes"
3448 then
3449         with_mysql_cflags=`$with_mysql_config --include 2>/dev/null`
3450         mysql_config_status=$?
3451
3452         if test $mysql_config_status -ne 0
3453         then
3454                 with_libmysql="no ($with_mysql_config failed)"
3455         else
3456                 SAVE_CPPFLAGS="$CPPFLAGS"
3457                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
3458
3459                 have_mysql_h="no"
3460                 have_mysql_mysql_h="no"
3461                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
3462
3463                 if test "x$have_mysql_h" = "xno"
3464                 then
3465                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
3466                 fi
3467
3468                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
3469                 then
3470                         with_libmysql="no (mysql.h not found)"
3471                 fi
3472
3473                 CPPFLAGS="$SAVE_CPPFLAGS"
3474         fi
3475 fi
3476 if test "x$with_libmysql" = "xyes"
3477 then
3478         with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
3479         mysql_config_status=$?
3480
3481         if test $mysql_config_status -ne 0
3482         then
3483                 with_libmysql="no ($with_mysql_config failed)"
3484         else
3485                 SAVE_CPPFLAGS="$CPPFLAGS"
3486                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
3487                 SAVE_LIBS="$LIBS"
3488                 LIBS="$with_mysql_libs"
3489                 AC_SEARCH_LIBS([mysql_get_server_version],
3490                  [],
3491                  [with_libmysql="yes"],
3492                  [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
3493                  [])
3494                 CPPFLAGS="$SAVE_CPPFLAGS"
3495                 LIBS="$SAVE_LIBS"
3496         fi
3497 fi
3498 if test "x$with_libmysql" = "xyes"
3499 then
3500         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
3501         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
3502         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
3503         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
3504 fi
3505 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
3506 # }}}
3507
3508 # --with-libmnl {{{
3509 with_libmnl_cflags=""
3510 with_libmnl_libs=""
3511 AC_ARG_WITH(libmnl, [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
3512 [
3513  echo "libmnl: withval = $withval"
3514  if test "x$withval" = "xyes"
3515  then
3516          with_libmnl="yes"
3517  else if test "x$withval" = "xno"
3518  then
3519          with_libmnl="no"
3520  else
3521          if test -d "$withval/include"
3522          then
3523                  with_libmnl_cflags="-I$withval/include"
3524                  with_libmnl_libs="-L$withval/lib -lmnl"
3525                  with_libmnl="yes"
3526          else
3527                  AC_MSG_ERROR("no such directory: $withval/include")
3528          fi
3529  fi; fi
3530 ],
3531 [
3532  if test "x$ac_system" = "xLinux"
3533  then
3534          with_libmnl="yes"
3535  else
3536          with_libmnl="no (Linux only library)"
3537  fi
3538 ])
3539 if test "x$with_libmnl" = "xyes"
3540 then
3541         if $PKG_CONFIG --exists libmnl 2>/dev/null; then
3542           with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
3543           with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
3544         fi
3545
3546         AC_CHECK_HEADERS(libmnl.h libmnl/libmnl.h,
3547         [
3548          with_libmnl="yes"
3549          break
3550         ], [],
3551 [#include <stdio.h>
3552 #include <sys/types.h>
3553 #include <asm/types.h>
3554 #include <sys/socket.h>
3555 #include <linux/netlink.h>
3556 #include <linux/rtnetlink.h>])
3557         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
3558 [#include <stdio.h>
3559 #include <sys/types.h>
3560 #include <asm/types.h>
3561 #include <sys/socket.h>])
3562
3563         AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3564 [[
3565 #include <stdio.h>
3566 #include <sys/types.h>
3567 #include <asm/types.h>
3568 #include <sys/socket.h>
3569 #include <linux/netlink.h>
3570 #include <linux/rtnetlink.h>
3571 ]],
3572 [[
3573 int retval = TCA_STATS2;
3574 return (retval);
3575 ]]
3576         )],
3577         [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])])
3578
3579         AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3580 [[
3581 #include <stdio.h>
3582 #include <sys/types.h>
3583 #include <asm/types.h>
3584 #include <sys/socket.h>
3585 #include <linux/netlink.h>
3586 #include <linux/rtnetlink.h>
3587 ]],
3588 [[
3589 int retval = TCA_STATS;
3590 return (retval);
3591 ]]
3592         )],
3593         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])])
3594 fi
3595 if test "x$with_libmnl" = "xyes"
3596 then
3597         AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
3598         [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
3599         [],
3600         [
3601         #include <linux/if_link.h>
3602         ])
3603 fi
3604 if test "x$with_libmnl" = "xyes"
3605 then
3606         AC_CHECK_LIB(mnl, mnl_nlmsg_get_payload,
3607                      [with_libmnl="yes"],
3608                      [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
3609                      [$with_libmnl_libs])
3610 fi
3611 if test "x$with_libmnl" = "xyes"
3612 then
3613         AC_DEFINE(HAVE_LIBMNL, 1, [Define if libmnl is present and usable.])
3614         BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
3615         BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
3616         AC_SUBST(BUILD_WITH_LIBMNL_CFLAGS)
3617         AC_SUBST(BUILD_WITH_LIBMNL_LIBS)
3618 fi
3619 AM_CONDITIONAL(BUILD_WITH_LIBMNL, test "x$with_libmnl" = "xyes")
3620 # }}}
3621
3622 # --with-libnetapp {{{
3623 AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
3624 AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
3625 AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
3626 LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS"
3627 LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS"
3628 LIBNETAPP_LIBS="$LIBNETAPP_LIBS"
3629 AC_ARG_WITH(libnetapp, [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
3630 [
3631  if test -d "$withval"
3632  then
3633          LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
3634          LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
3635          with_libnetapp="yes"
3636  else
3637          with_libnetapp="$withval"
3638  fi
3639 ],
3640 [
3641  with_libnetapp="yes"
3642 ])
3643
3644 SAVE_CPPFLAGS="$CPPFLAGS"
3645 SAVE_LDFLAGS="$LDFLAGS"
3646 CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
3647 LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
3648
3649 if test "x$with_libnetapp" = "xyes"
3650 then
3651         if test "x$LIBNETAPP_CPPFLAGS" != "x"
3652         then
3653                 AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
3654         fi
3655         AC_CHECK_HEADERS(netapp_api.h,
3656                 [with_libnetapp="yes"],
3657                 [with_libnetapp="no (netapp_api.h not found)"])
3658 fi
3659
3660 if test "x$with_libnetapp" = "xyes"
3661 then
3662         if test "x$LIBNETAPP_LDFLAGS" != "x"
3663         then
3664                 AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
3665         fi
3666
3667         if test "x$LIBNETAPP_LIBS" = "x"
3668         then
3669                 LIBNETAPP_LIBS="$PTHREAD_LIBS -lxml -ladt -lssl -lm -lcrypto -lz"
3670         fi
3671         AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
3672
3673         AC_CHECK_LIB(netapp, na_server_invoke_elem,
3674                 [with_libnetapp="yes"],
3675                 [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
3676                 [$LIBNETAPP_LIBS])
3677         LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
3678 fi
3679
3680 CPPFLAGS="$SAVE_CPPFLAGS"
3681 LDFLAGS="$SAVE_LDFLAGS"
3682
3683 if test "x$with_libnetapp" = "xyes"
3684 then
3685         AC_DEFINE(HAVE_LIBNETAPP, 1, [Define to 1 if you have the netapp library (-lnetapp).])
3686 fi
3687
3688 AC_SUBST(LIBNETAPP_CPPFLAGS)
3689 AC_SUBST(LIBNETAPP_LDFLAGS)
3690 AC_SUBST(LIBNETAPP_LIBS)
3691 AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
3692 # }}}
3693
3694 # --with-libnetsnmp {{{
3695 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
3696 [
3697         if test "x$withval" = "xno"
3698         then
3699                 with_libnetsnmp="no"
3700         else if test "x$withval" = "xyes"
3701         then
3702                 with_libnetsnmp="yes"
3703         else
3704                 with_libnetsnmp_cppflags="-I$withval/include"
3705                 with_libnetsnmp_ldflags="-I$withval/lib"
3706                 with_libnetsnmp="yes"
3707         fi; fi
3708 ],
3709 [with_libnetsnmp="yes"])
3710 if test "x$with_libnetsnmp" = "xyes"
3711 then
3712         SAVE_CPPFLAGS="$CPPFLAGS"
3713         CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
3714
3715         AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
3716
3717         CPPFLAGS="$SAVE_CPPFLAGS"
3718 fi
3719 if test "x$with_libnetsnmp" = "xyes"
3720 then
3721         SAVE_LDFLAGS="$LDFLAGS"
3722         LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
3723
3724         AC_CHECK_LIB(netsnmp, init_snmp,
3725                 [with_libnetsnmp="yes"],
3726                 [with_libnetsnmp="no (libnetsnmp not found)"],
3727                 [$with_snmp_libs])
3728
3729         LDFLAGS="$SAVE_LDFLAGS"
3730 fi
3731 if test "x$with_libnetsnmp" = "xyes"
3732 then
3733         BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
3734         BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
3735         BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
3736 fi
3737 AC_SUBST(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
3738 AC_SUBST(BUILD_WITH_LIBNETSNMP_LDFLAGS)
3739 AC_SUBST(BUILD_WITH_LIBNETSNMP_LIBS)
3740 # }}}
3741
3742 # --with-liboconfig {{{
3743 with_own_liboconfig="no"
3744 liboconfig_LDFLAGS="$LDFLAGS"
3745 liboconfig_CPPFLAGS="$CPPFLAGS"
3746 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
3747 [
3748         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3749         then
3750                 if test -d "$withval/lib"
3751                 then
3752                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
3753                 fi
3754                 if test -d "$withval/include"
3755                 then
3756                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
3757                 fi
3758         fi
3759         if test "x$withval" = "xno"
3760         then
3761                 AC_MSG_ERROR("liboconfig is required")
3762         fi
3763 ],
3764 [
3765         with_liboconfig="yes"
3766 ])
3767
3768 save_LDFLAGS="$LDFLAGS"
3769 save_CPPFLAGS="$CPPFLAGS"
3770 LDFLAGS="$liboconfig_LDFLAGS"
3771 CPPFLAGS="$liboconfig_CPPFLAGS"
3772 AC_CHECK_LIB(oconfig, oconfig_parse_file,
3773 [
3774         with_liboconfig="yes"
3775         with_own_liboconfig="no"
3776 ],
3777 [
3778         with_liboconfig="yes"
3779         with_own_liboconfig="yes"
3780         LDFLAGS="$save_LDFLAGS"
3781         CPPFLAGS="$save_CPPFLAGS"
3782 ])
3783
3784 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
3785 if test "x$with_own_liboconfig" = "xyes"
3786 then
3787         with_liboconfig="yes (shipped version)"
3788 fi
3789 # }}}
3790
3791 # --with-liboping {{{
3792 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
3793 [
3794  if test "x$withval" = "xyes"
3795  then
3796          with_liboping="yes"
3797  else if test "x$withval" = "xno"
3798  then
3799          with_liboping="no"
3800  else
3801          with_liboping="yes"
3802          LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
3803          LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
3804  fi; fi
3805 ],
3806 [with_liboping="yes"])
3807
3808 SAVE_CPPFLAGS="$CPPFLAGS"
3809 SAVE_LDFLAGS="$LDFLAGS"
3810
3811 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
3812 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
3813
3814 if test "x$with_liboping" = "xyes"
3815 then
3816         if test "x$LIBOPING_CPPFLAGS" != "x"
3817         then
3818                 AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
3819         fi
3820         AC_CHECK_HEADERS(oping.h,
3821         [with_liboping="yes"],
3822         [with_liboping="no (oping.h not found)"])
3823 fi
3824 if test "x$with_liboping" = "xyes"
3825 then
3826         if test "x$LIBOPING_LDFLAGS" != "x"
3827         then
3828                 AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
3829         fi
3830         AC_CHECK_LIB(oping, ping_construct,
3831         [with_liboping="yes"],
3832         [with_liboping="no (symbol 'ping_construct' not found)"])
3833 fi
3834
3835 CPPFLAGS="$SAVE_CPPFLAGS"
3836 LDFLAGS="$SAVE_LDFLAGS"
3837
3838 if test "x$with_liboping" = "xyes"
3839 then
3840         BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
3841         BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
3842         AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
3843         AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
3844 fi
3845 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
3846 # }}}
3847
3848 # --with-oracle {{{
3849 with_oracle_cppflags=""
3850 with_oracle_libs=""
3851 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
3852 [
3853         if test "x$withval" = "xyes"
3854         then
3855                 if test "x$ORACLE_HOME" = "x"
3856                 then
3857                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
3858                 fi
3859                 with_oracle="yes"
3860         else if test "x$withval" = "xno"
3861         then
3862                 with_oracle="no"
3863         else
3864                 with_oracle="yes"
3865                 ORACLE_HOME="$withval"
3866         fi; fi
3867 ],
3868 [
3869         if test "x$ORACLE_HOME" = "x"
3870         then
3871                 with_oracle="no (ORACLE_HOME is not set)"
3872         else
3873                 with_oracle="yes"
3874         fi
3875 ])
3876 if test "x$ORACLE_HOME" != "x"
3877 then
3878         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
3879
3880         if test -e "$ORACLE_HOME/lib/ldflags"
3881         then
3882                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
3883         fi
3884         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
3885         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
3886 fi
3887 if test "x$with_oracle" = "xyes"
3888 then
3889         SAVE_CPPFLAGS="$CPPFLAGS"
3890         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
3891
3892         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
3893
3894         CPPFLAGS="$SAVE_CPPFLAGS"
3895 fi
3896 if test "x$with_oracle" = "xyes"
3897 then
3898         SAVE_CPPFLAGS="$CPPFLAGS"
3899         SAVE_LIBS="$LIBS"
3900         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
3901         LIBS="$LIBS $with_oracle_libs"
3902
3903         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
3904
3905         CPPFLAGS="$SAVE_CPPFLAGS"
3906         LIBS="$SAVE_LIBS"
3907 fi
3908 if test "x$with_oracle" = "xyes"
3909 then
3910         BUILD_WITH_ORACLE_CPPFLAGS="$with_oracle_cppflags"
3911         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
3912         AC_SUBST(BUILD_WITH_ORACLE_CPPFLAGS)
3913         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
3914 fi
3915 # }}}
3916
3917 # --with-libowcapi {{{
3918 with_libowcapi_cppflags=""
3919 with_libowcapi_ldflags=""
3920 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
3921 [
3922         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3923         then
3924                 with_libowcapi_cppflags="-I$withval/include"
3925                 with_libowcapi_ldflags="-L$withval/lib"
3926                 with_libowcapi="yes"
3927         else
3928                 with_libowcapi="$withval"
3929         fi
3930 ],
3931 [
3932         with_libowcapi="yes"
3933 ])
3934 if test "x$with_libowcapi" = "xyes"
3935 then
3936         SAVE_CPPFLAGS="$CPPFLAGS"
3937         CPPFLAGS="$CPPFLAGS $with_libowcapi_cppflags"
3938
3939         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
3940
3941         CPPFLAGS="$SAVE_CPPFLAGS"
3942 fi
3943 if test "x$with_libowcapi" = "xyes"
3944 then
3945         SAVE_LDFLAGS="$LDFLAGS"
3946         SAVE_CPPFLAGS="$CPPFLAGS"
3947         LDFLAGS="$LDFLAGS $with_libowcapi_ldflags"
3948         CPPFLAGS="$with_libowcapi_cppflags"
3949
3950         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
3951
3952         LDFLAGS="$SAVE_LDFLAGS"
3953         CPPFLAGS="$SAVE_CPPFLAGS"
3954 fi
3955 if test "x$with_libowcapi" = "xyes"
3956 then
3957         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
3958         BUILD_WITH_LIBOWCAPI_LDFLAGS="$with_libowcapi_ldflags"
3959         BUILD_WITH_LIBOWCAPI_LIBS="-lowcapi"
3960         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
3961         AC_SUBST(BUILD_WITH_LIBOWCAPI_LDFLAGS)
3962         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
3963 fi
3964 # }}}
3965
3966 # --with-libpcap {{{
3967 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
3968 [
3969         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3970         then
3971                 LDFLAGS="$LDFLAGS -L$withval/lib"
3972                 CPPFLAGS="$CPPFLAGS -I$withval/include"
3973                 with_libpcap="yes"
3974         else
3975                 with_libpcap="$withval"
3976         fi
3977 ],
3978 [
3979         with_libpcap="yes"
3980 ])
3981 if test "x$with_libpcap" = "xyes"
3982 then
3983         AC_CHECK_LIB(pcap, pcap_open_live,
3984         [
3985                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
3986         ], [with_libpcap="no (libpcap not found)"])
3987 fi
3988 if test "x$with_libpcap" = "xyes"
3989 then
3990         AC_CHECK_HEADERS(pcap.h,,
3991                          [with_libpcap="no (pcap.h not found)"])
3992 fi
3993 if test "x$with_libpcap" = "xyes"
3994 then
3995         AC_CACHE_CHECK([whether libpcap has PCAP_ERROR_IFACE_NOT_UP],
3996                        [c_cv_libpcap_have_pcap_error_iface_not_up],
3997                        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3998 [[[
3999 #include <pcap.h>
4000 ]]],
4001 [[[
4002   int val = PCAP_ERROR_IFACE_NOT_UP;
4003   return(val);
4004 ]]]
4005                        )],
4006                        [c_cv_libpcap_have_pcap_error_iface_not_up="yes"],
4007                        [c_cv_libpcap_have_pcap_error_iface_not_up="no"]))
4008 fi
4009 if test "x$c_cv_libpcap_have_pcap_error_iface_not_up" != "xyes"
4010 then
4011                 with_libpcap="no (pcap.h misses PCAP_ERROR_IFACE_NOT_UP)"
4012 fi
4013 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
4014 # }}}
4015
4016 # --with-libperl {{{
4017 perl_interpreter="perl"
4018 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
4019 [
4020         if test -f "$withval" && test -x "$withval"
4021         then
4022                 perl_interpreter="$withval"
4023                 with_libperl="yes"
4024         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
4025         then
4026                 LDFLAGS="$LDFLAGS -L$withval/lib"
4027                 CPPFLAGS="$CPPFLAGS -I$withval/include"
4028                 perl_interpreter="$withval/bin/perl"
4029                 with_libperl="yes"
4030         else
4031                 with_libperl="$withval"
4032         fi; fi
4033 ],
4034 [
4035         with_libperl="yes"
4036 ])
4037
4038 AC_MSG_CHECKING([for perl])
4039 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
4040 if test -x "$perl_interpreter"
4041 then
4042         AC_MSG_RESULT([yes ($perl_interpreter)])
4043 else
4044         perl_interpreter=""
4045         AC_MSG_RESULT([no])
4046 fi
4047
4048 AC_SUBST(PERL, "$perl_interpreter")
4049
4050 if test "x$with_libperl" = "xyes" \
4051         && test -n "$perl_interpreter"
4052 then
4053   SAVE_CFLAGS="$CFLAGS"
4054   SAVE_LIBS="$LIBS"
4055 dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
4056   PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e perl_inc`
4057   PERL_LIBS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
4058   CFLAGS="$CFLAGS $PERL_CFLAGS"
4059   LIBS="$LIBS $PERL_LIBS"
4060
4061   AC_CACHE_CHECK([for libperl],
4062     [c_cv_have_libperl],
4063     AC_LINK_IFELSE([AC_LANG_PROGRAM(
4064 [[[
4065 #define PERL_NO_GET_CONTEXT
4066 #include <EXTERN.h>
4067 #include <perl.h>
4068 #include <XSUB.h>
4069 ]]],
4070 [[[
4071        dTHX;
4072        load_module (PERL_LOADMOD_NOIMPORT,
4073                          newSVpv ("Collectd::Plugin::FooBar", 24),
4074                          Nullsv);
4075 ]]]
4076       )],
4077       [c_cv_have_libperl="yes"],
4078       [c_cv_have_libperl="no"]
4079     )
4080   )
4081
4082   if test "x$c_cv_have_libperl" = "xyes"
4083   then
4084           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
4085           AC_SUBST(PERL_CFLAGS)
4086           AC_SUBST(PERL_LIBS)
4087   else
4088           with_libperl="no"
4089   fi
4090
4091   CFLAGS="$SAVE_CFLAGS"
4092   LIBS="$SAVE_LIBS"
4093 else if test -z "$perl_interpreter"; then
4094   with_libperl="no (no perl interpreter found)"
4095   c_cv_have_libperl="no"
4096 fi; fi
4097 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
4098
4099 if test "x$with_libperl" = "xyes"
4100 then
4101         SAVE_CFLAGS="$CFLAGS"
4102         SAVE_LIBS="$LIBS"
4103         CFLAGS="$CFLAGS $PERL_CFLAGS"
4104         LIBS="$LIBS $PERL_LIBS"
4105
4106         AC_CACHE_CHECK([if perl supports ithreads],
4107                 [c_cv_have_perl_ithreads],
4108                 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4109 [[[
4110 #include <EXTERN.h>
4111 #include <perl.h>
4112 #include <XSUB.h>
4113
4114 #if !defined(USE_ITHREADS)
4115 # error "Perl does not support ithreads!"
4116 #endif /* !defined(USE_ITHREADS) */
4117 ]]],
4118 [[[ ]]]
4119                         )],
4120                         [c_cv_have_perl_ithreads="yes"],
4121                         [c_cv_have_perl_ithreads="no"]
4122                 )
4123         )
4124
4125         if test "x$c_cv_have_perl_ithreads" = "xyes"
4126         then
4127                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
4128         fi
4129
4130         CFLAGS="$SAVE_CFLAGS"
4131         LIBS="$SAVE_LIBS"
4132 fi
4133
4134 if test "x$with_libperl" = "xyes"
4135 then
4136         SAVE_CFLAGS="$CFLAGS"
4137         SAVE_LIBS="$LIBS"
4138         # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
4139         # (see issues #41 and #42)
4140         CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
4141         LIBS="$LIBS $PERL_LIBS"
4142
4143         AC_CACHE_CHECK([for broken Perl_load_module()],
4144                 [c_cv_have_broken_perl_load_module],
4145                 AC_LINK_IFELSE([AC_LANG_PROGRAM(
4146 [[[
4147 #define PERL_NO_GET_CONTEXT
4148 #include <EXTERN.h>
4149 #include <perl.h>
4150 #include <XSUB.h>
4151 ]]],
4152 [[[
4153                          dTHX;
4154                          load_module (PERL_LOADMOD_NOIMPORT,
4155                              newSVpv ("Collectd::Plugin::FooBar", 24),
4156                              Nullsv);
4157 ]]]
4158                         )],
4159                         [c_cv_have_broken_perl_load_module="no"],
4160                         [c_cv_have_broken_perl_load_module="yes"]
4161                 )
4162         )
4163
4164         CFLAGS="$SAVE_CFLAGS"
4165         LIBS="$SAVE_LIBS"
4166 fi
4167 AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
4168                 test "x$c_cv_have_broken_perl_load_module" = "xyes")
4169
4170 if test "x$with_libperl" = "xyes"
4171 then
4172         SAVE_CFLAGS="$CFLAGS"
4173         SAVE_LIBS="$LIBS"
4174         CFLAGS="$CFLAGS $PERL_CFLAGS"
4175         LIBS="$LIBS $PERL_LIBS"
4176
4177         AC_CHECK_MEMBER(
4178                 [struct mgvtbl.svt_local],
4179                 [have_struct_mgvtbl_svt_local="yes"],
4180                 [have_struct_mgvtbl_svt_local="no"],
4181                 [
4182 #include <EXTERN.h>
4183 #include <perl.h>
4184 #include <XSUB.h>
4185                 ])
4186
4187         if test "x$have_struct_mgvtbl_svt_local" = "xyes"
4188         then
4189                 AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
4190                                   [Define if Perl's struct mgvtbl has member svt_local.])
4191         fi
4192
4193         CFLAGS="$SAVE_CFLAGS"
4194         LIBS="$SAVE_LIBS"
4195 fi
4196 # }}}
4197
4198 # --with-libpq {{{
4199 with_pg_config="pg_config"
4200 with_libpq_includedir=""
4201 with_libpq_libdir=""
4202 with_libpq_cppflags=""
4203 with_libpq_ldflags=""
4204 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
4205         [Path to libpq.])],
4206 [
4207         if test "x$withval" = "xno"
4208         then
4209                 with_libpq="no"
4210         else if test "x$withval" = "xyes"
4211         then
4212                 with_libpq="yes"
4213         else
4214                 if test -f "$withval" && test -x "$withval";
4215                 then
4216                         with_pg_config="$withval"
4217                 else if test -x "$withval/bin/pg_config"
4218                 then
4219                         with_pg_config="$withval/bin/pg_config"
4220                 fi; fi
4221                 with_libpq="yes"
4222         fi; fi
4223 ],
4224 [
4225         with_libpq="yes"
4226 ])
4227 if test "x$with_libpq" = "xyes"
4228 then
4229         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
4230         pg_config_status=$?
4231
4232         if test $pg_config_status -eq 0
4233         then
4234                 if test -n "$with_libpq_includedir"; then
4235                         for dir in $with_libpq_includedir; do
4236                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
4237                         done
4238                 fi
4239         else
4240                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
4241         fi
4242
4243         SAVE_CPPFLAGS="$CPPFLAGS"
4244         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
4245
4246         AC_CHECK_HEADERS(libpq-fe.h, [],
4247                 [with_libpq="no (libpq-fe.h not found)"], [])
4248
4249         CPPFLAGS="$SAVE_CPPFLAGS"
4250 fi
4251 if test "x$with_libpq" = "xyes"
4252 then
4253         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
4254         pg_config_status=$?
4255
4256         if test $pg_config_status -eq 0
4257         then
4258                 if test -n "$with_libpq_libdir"; then
4259                         for dir in $with_libpq_libdir; do
4260                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
4261                         done
4262                 fi
4263         else
4264                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
4265         fi
4266
4267         SAVE_LDFLAGS="$LDFLAGS"
4268         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
4269
4270         AC_CHECK_LIB(pq, PQconnectdb,
4271                 [with_libpq="yes"],
4272                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
4273
4274         AC_CHECK_LIB(pq, PQserverVersion,
4275                 [with_libpq="yes"],
4276                 [with_libpq="no (symbol 'PQserverVersion' not found)"])
4277
4278         LDFLAGS="$SAVE_LDFLAGS"
4279 fi
4280 if test "x$with_libpq" = "xyes"
4281 then
4282         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
4283         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
4284         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
4285         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
4286 fi
4287 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
4288 # }}}
4289
4290 # --with-libpqos {{{
4291 with_libpqos_cppflags=""
4292 with_libpqos_ldflags=""
4293 AC_ARG_WITH(libpqos, [AS_HELP_STRING([--with-libpqos@<:@=PREFIX@:>@], [Path to libpqos.])],
4294 [
4295         if test "x$withval" != "xno" && test "x$withval" != "xyes"
4296         then
4297                 with_libpqos_cppflags="-I$withval/include"
4298                 with_libpqos_ldflags="-L$withval/lib"
4299                 with_libpqos="yes"
4300         else
4301                 with_libpqos="$withval"
4302         fi
4303 ],
4304 [
4305         with_libpqos="yes"
4306 ])
4307 if test "x$with_libpqos" = "xyes"
4308 then
4309         SAVE_CPPFLAGS="$CPPFLAGS"
4310         CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4311
4312         AC_CHECK_HEADERS(pqos.h, [with_libpqos="yes"], [with_libpqos="no (pqos.h not found)"])
4313
4314         CPPFLAGS="$SAVE_CPPFLAGS"
4315 fi
4316 if test "x$with_libpqos" = "xyes"
4317 then
4318         SAVE_CPPFLAGS="$CPPFLAGS"
4319         SAVE_LDFLAGS="$LDFLAGS"
4320         CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4321         LDFLAGS="$LDFLAGS $with_libpqos_ldflags"
4322
4323         AC_CHECK_LIB(pqos, pqos_init, [with_libpqos="yes"], [with_libpqos="no (Can't find libpqos)"])
4324
4325         CPPFLAGS="$SAVE_CPPFLAGS"
4326         LDFLAGS="$SAVE_LDFLAGS"
4327 fi
4328 if test "x$with_libpqos" = "xyes"
4329 then
4330   SAVE_CPPFLAGS="$CPPFLAGS"
4331   CPPFLAGS="$CPPFLAGS $with_libpqos_cppflags"
4332   AC_RUN_IFELSE([AC_LANG_PROGRAM(
4333     [[#include <pqos.h>]],
4334     [[return !(PQOS_VERSION >= 106)]])],
4335     [with_libpqos="yes"], [with_libpqos="no (pqos library version 1.06 or higher is required)"])
4336   CPPFLAGS="$SAVE_CPPFLAGS"
4337 fi
4338 if test "x$with_libpqos" = "xyes"
4339 then
4340         BUILD_WITH_LIBPQOS_CPPFLAGS="$with_libpqos_cppflags"
4341         BUILD_WITH_LIBPQOS_LDFLAGS="$with_libpqos_ldflags"
4342         BUILD_WITH_LIBPQOS_LIBS="-lpqos"
4343         AC_SUBST(BUILD_WITH_LIBPQOS_CPPFLAGS)
4344         AC_SUBST(BUILD_WITH_LIBPQOS_LDFLAGS)
4345         AC_SUBST(BUILD_WITH_LIBPQOS_LIBS)
4346 fi
4347 # }}}
4348
4349 # --with-libprotobuf {{{
4350 with_libprotobuf_cppflags=""
4351 with_libprotobuf_ldflags=""
4352 AC_ARG_WITH([libprotobuf], [AS_HELP_STRING([--with-libprotobuf@<:@=PREFIX@:>@], [Path to libprotobuf.])],
4353   [
4354     if test "x$withval" != "xno" && test "x$withval" != "xyes"
4355     then
4356       with_libprotobuf_cppflags="-I$withval/include"
4357       with_libprotobuf_ldflags="-L$withval/lib"
4358       with_libprotobuf="yes"
4359     fi
4360     if test "x$withval" = "xno"
4361     then
4362       with_libprotobuf="no (disabled on command line)"
4363     fi
4364   ],
4365   [withval="yes"]
4366 )
4367 if test "x$withval" = "xyes"
4368 then
4369 PKG_CHECK_MODULES([PROTOBUF], [protobuf],
4370   [with_libprotobuf="yes"],
4371   [with_libprotobuf="no (pkg-config could not find libprotobuf)"]
4372 )
4373 fi
4374
4375 if test "x$withval" != "xno"
4376 then
4377   SAVE_LDFLAGS="$LDFLAGS"
4378   SAVE_LIBS="$LIBS"
4379   LDFLAGS="$with_libprotobuf_ldflags"
4380   LIBS="$PROTOBUF_LIBS $LIBS"
4381   AC_LANG_PUSH([C++])
4382   AC_CHECK_LIB([protobuf], [main],
4383     [
4384       SAVE_CPPFLAGS="$CPPFLAGS"
4385       CPPFLAGS="$with_libprotobuf_cppflags $PROTOBUF_CFLAGS"
4386       if test "x$PROTOBUF_LIBS" = "x"
4387       then
4388         PROTOBUF_LIBS="-lprotobuf"
4389       fi
4390       AC_CHECK_HEADERS([google/protobuf/util/time_util.h],
4391         [with_libprotobuf="yes"],
4392         [with_libprotobuf="no (<google/protobuf/util/time_util.h> not found)"]
4393       )
4394       CPPFLAGS="$SAVE_CPPFLAGS"
4395     ],
4396     [with_libprotobuf="no (libprotobuf not found)"]
4397   )
4398   AC_LANG_POP([C++])
4399   LDFLAGS="$SAVE_LDFLAGS"
4400   LIBS="$SAVE_LIBS"
4401 fi
4402 BUILD_WITH_LIBPROTOBUF_CPPFLAGS="$with_libprotobuf_cppflags $PROTOBUF_CFLAGS"
4403 BUILD_WITH_LIBPROTOBUF_LDFLAGS="$with_libprotobuf_ldflags"
4404 BUILD_WITH_LIBPROTOBUF_LIBS="$PROTOBUF_LIBS"
4405 AC_SUBST([BUILD_WITH_LIBPROTOBUF_CPPFLAGS])
4406 AC_SUBST([BUILD_WITH_LIBPROTOBUF_LDFLAGS])
4407 AC_SUBST([BUILD_WITH_LIBPROTOBUF_LIBS])
4408 # }}}
4409
4410 # --with-libprotobuf-c {{{
4411 with_libprotobuf_c_cppflags=""
4412 with_libprotobuf_c_ldflags=""
4413 AC_ARG_WITH([libprotobuf-c], [AS_HELP_STRING([--with-libprotobuf-c@<:@=PREFIX@:>@], [Path to libprotobuf-c.])],
4414   [
4415     if test "x$withval" != "xno" && test "x$withval" != "xyes"
4416     then
4417       with_libprotobuf_c_cppflags="-I$withval/include"
4418       with_libprotobuf_c_ldflags="-L$withval/lib"
4419       with_libprotobuf_c="yes"
4420     fi
4421     if test "x$withval" = "xno"
4422     then
4423       with_libprotobuf_c="no (disabled on command line)"
4424     fi
4425   ],
4426   [withval="yes"]
4427 )
4428 if test "x$withval" = "xyes"
4429 then
4430 PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c],
4431   [with_libprotobuf_c="yes"],
4432   [with_libprotobuf_c="no (pkg-config could not find libprotobuf-c)"]
4433 )
4434 fi
4435
4436 if test "x$withval" != "xno"
4437 then
4438   SAVE_LDFLAGS="$LDFLAGS"
4439   SAVE_LIBS="$LIBS"
4440   LDFLAGS="$with_libprotobuf_c_ldflags"
4441   LIBS="$PROTOBUF_C_LIBS $LIBS"
4442   AC_CHECK_LIB([protobuf-c], [protobuf_c_message_pack],
4443     [
4444       SAVE_CPPFLAGS="$CPPFLAGS"
4445       CPPFLAGS="$with_libprotobuf_c_cppflags $PROTOBUF_C_CFLAGS"
4446       if test "x$PROTOBUF_C_LIBS" = "x"
4447       then
4448         PROTOBUF_C_LIBS="-lprotobuf-c"
4449       fi
4450       AC_CHECK_HEADERS([protobuf-c/protobuf-c.h google/protobuf-c/protobuf-c.h],
4451         [
4452           with_libprotobuf_c="yes"
4453           break
4454         ],
4455         [with_libprotobuf_c="no (<protobuf-c.h> not found)"]
4456       )
4457       CPPFLAGS="$SAVE_CPPFLAGS"
4458     ],
4459     [with_libprotobuf_c="no (libprotobuf-c not found)"]
4460   )
4461   LDFLAGS="$SAVE_LDFLAGS"
4462   LIBS="$SAVE_LIBS"
4463 fi
4464 BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS="$with_libprotobuf_c_cppflags $PROTOBUF_C_CFLAGS"
4465 BUILD_WITH_LIBPROTOBUF_C_LDFLAGS="$with_libprotobuf_c_ldflags"
4466 BUILD_WITH_LIBPROTOBUF_C_LIBS="$PROTOBUF_C_LIBS"
4467 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_CPPFLAGS])
4468 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_LDFLAGS])
4469 AC_SUBST([BUILD_WITH_LIBPROTOBUF_C_LIBS])
4470 # }}}
4471
4472 # --with-libpython {{{
4473 AC_ARG_VAR([LIBPYTHON_CPPFLAGS], [Preprocessor flags for libpython])
4474 AC_ARG_VAR([LIBPYTHON_LDFLAGS], [Linker flags for libpython])
4475 AC_ARG_VAR([LIBPYTHON_LIBS], [Libraries for libpython])
4476
4477 AC_ARG_WITH([libpython],
4478   [AS_HELP_STRING([--with-libpython],
4479     [if we should build with libpython @<:@default=yes@:>@])
4480   ],
4481   [with_libpython="$withval"],
4482   [with_libpython="check"]
4483 )
4484 if test "$with_libpython" != "no"; then
4485   if test "$LIBPYTHON_CPPFLAGS" = "" && test "$LIBPYTHON_LDFLAGS" = ""; then
4486     AC_ARG_VAR([PYTHON_CONFIG], [path to python-config])
4487     AC_PATH_PROGS([PYTHON_CONFIG],
4488       [python3-config python2-config python-config]
4489     )
4490     if test "$PYTHON_CONFIG" = ""; then
4491       if test "$with_libpython" = "yes"; then
4492         AC_MSG_ERROR([Unable to find python-config])
4493       fi
4494       with_libpython="no"
4495     fi
4496   fi
4497 fi
4498
4499 if test "$PYTHON_CONFIG" != ""; then
4500   LIBPYTHON_CPPFLAGS="`${PYTHON_CONFIG} --includes`"
4501   if test $? -ne 0; then
4502     with_libpython="no"
4503   fi
4504   LIBPYTHON_LDFLAGS="`${PYTHON_CONFIG} --ldflags`"
4505   if test $? -ne 0; then
4506     with_libpython="no"
4507   fi
4508   LIBPYTHON_LIBS="`${PYTHON_CONFIG} --libs`"
4509   if test $? -ne 0; then
4510     with_libpython="no"
4511   fi
4512 fi
4513
4514 if test "$with_libpython" != "xno"; then
4515   SAVE_CPPFLAGS="$CPPFLAGS"
4516   SAVE_LDFLAGS="$LDFLAGS"
4517   SAVE_LIBS="$LIBS"
4518   CPPFLAGS="$LIBPYTHON_CPPFLAGS $CPPFLAGS"
4519   LDFLAGS="$LIBPYTHON_LDFLAGS $LDFLAGS"
4520   LIBS="$LIBPYTHON_LIBS $LIBS"
4521   AC_CHECK_HEADERS([Python.h],
4522     [
4523       AC_MSG_CHECKING([for libpython])
4524       AC_LINK_IFELSE([AC_LANG_PROGRAM(
4525           [[#include <Python.h>]],
4526           [[Py_Initialize();]])
4527         ],
4528         [with_libpython="yes"],
4529         [with_libpython="no"]
4530       )
4531       AC_MSG_RESULT([$with_libpython])
4532     ],
4533     [with_libpython="no"]
4534   )
4535   CPPFLAGS="$SAVE_CPPFLAGS"
4536   LDFLAGS="$SAVE_LDFLAGS"
4537   LIBS="$SAVE_LIBS"
4538 fi
4539 # }}} --with-libpython
4540
4541 # --with-librabbitmq {{{
4542 with_librabbitmq_cppflags=""
4543 with_librabbitmq_ldflags=""
4544 AC_ARG_WITH(librabbitmq, [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
4545 [
4546         if test "x$withval" != "xno" && test "x$withval" != "xyes"
4547         then
4548                 with_librabbitmq_cppflags="-I$withval/include"
4549                 with_librabbitmq_ldflags="-L$withval/lib"
4550                 with_librabbitmq="yes"
4551         else
4552                 with_librabbitmq="$withval"
4553         fi
4554 ],
4555 [
4556         with_librabbitmq="yes"
4557 ])
4558 SAVE_CPPFLAGS="$CPPFLAGS"
4559 SAVE_LDFLAGS="$LDFLAGS"
4560 CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4561 LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
4562 if test "x$with_librabbitmq" = "xyes"
4563 then
4564         AC_CHECK_HEADERS(amqp.h, [with_librabbitmq="yes"], [with_librabbitmq="no (amqp.h not found)"])
4565 fi
4566 if test "x$with_librabbitmq" = "xyes"
4567 then
4568         # librabbitmq up to version 0.9.1 provides "library_errno", later
4569         # versions use "library_error". The library does not provide a version
4570         # macro :( Use "AC_CHECK_MEMBERS" (plural) for automatic defines.
4571         AC_CHECK_MEMBERS([amqp_rpc_reply_t.library_errno],,,
4572                          [
4573 #if HAVE_STDLIB_H
4574 # include <stdlib.h>
4575 #endif
4576 #if HAVE_STDIO_H
4577 # include <stdio.h>
4578 #endif
4579 #if HAVE_STDINT_H
4580 # include <stdint.h>
4581 #endif
4582 #if HAVE_INTTYPES_H
4583 # include <inttypes.h>
4584 #endif
4585 #include <amqp.h>
4586                          ])
4587 fi
4588 if test "x$with_librabbitmq" = "xyes"
4589 then
4590         AC_CHECK_LIB(rabbitmq, amqp_basic_publish, [with_librabbitmq="yes"], [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"])
4591 fi
4592 if test "x$with_librabbitmq" = "xyes"
4593 then
4594         BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
4595         BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
4596         BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
4597         AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
4598         AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
4599         AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
4600         AC_DEFINE(HAVE_LIBRABBITMQ, 1, [Define if librabbitmq is present and usable.])
4601 fi
4602 CPPFLAGS="$SAVE_CPPFLAGS"
4603 LDFLAGS="$SAVE_LDFLAGS"
4604 AM_CONDITIONAL(BUILD_WITH_LIBRABBITMQ, test "x$with_librabbitmq" = "xyes")
4605
4606 with_amqp_tcp_socket="no"
4607 if test "x$with_librabbitmq" = "xyes"
4608 then
4609         SAVE_CPPFLAGS="$CPPFLAGS"
4610         SAVE_LDFLAGS="$LDFLAGS"
4611         SAVE_LIBS="$LIBS"
4612         CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
4613         LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
4614         LIBS="-lrabbitmq"
4615
4616         AC_CHECK_HEADERS(amqp_tcp_socket.h amqp_socket.h)
4617         AC_CHECK_FUNC(amqp_tcp_socket_new, [with_amqp_tcp_socket="yes"], [with_amqp_tcp_socket="no"])
4618         if test "x$with_amqp_tcp_socket" = "xyes"
4619         then
4620                 AC_DEFINE(HAVE_AMQP_TCP_SOCKET, 1,
4621                                 [Define if librabbitmq provides the new TCP socket interface.])
4622         fi
4623
4624         AC_CHECK_DECLS(amqp_socket_close,
4625                                 [amqp_socket_close_decl="yes"], [amqp_socket_close_decl="no"],
4626                                 [[
4627 #include <amqp.h>
4628 #ifdef HAVE_AMQP_TCP_SOCKET_H
4629 # include <amqp_tcp_socket.h>
4630 #endif
4631 #ifdef HAVE_AMQP_SOCKET_H
4632 # include <amqp_socket.h>
4633 #endif
4634                                 ]])
4635
4636         CPPFLAGS="$SAVE_CPPFLAGS"
4637         LDFLAGS="$SAVE_LDFLAGS"
4638         LIBS="$SAVE_LIBS"
4639 fi
4640 # }}}
4641
4642 # --with-librdkafka {{{
4643 AC_ARG_WITH(librdkafka, [AS_HELP_STRING([--with-librdkafka@<:@=PREFIX@:>@], [Path to librdkafka.])],
4644 [
4645   if test "x$withval" != "xno" && test "x$withval" != "xyes"
4646   then
4647     with_librdkafka_cppflags="-I$withval/include"
4648     with_librdkafka_ldflags="-L$withval/lib"
4649     with_librdkafka_rpath="$withval/lib"
4650     with_librdkafka="yes"
4651   else
4652     with_librdkafka="$withval"
4653   fi
4654 ],
4655 [
4656   with_librdkafka="yes"
4657 ])
4658 SAVE_CPPFLAGS="$CPPFLAGS"
4659 SAVE_LDFLAGS="$LDFLAGS"
4660
4661 CPPFLAGS="$CPPFLAGS $with_librdkafka_cppflags"
4662 LDFLAGS="$LDFLAGS $with_librdkafka_ldflags"
4663
4664 if test "x$with_librdkafka" = "xyes"
4665 then
4666         AC_CHECK_HEADERS(librdkafka/rdkafka.h, [with_librdkafka="yes"], [with_librdkafka="no (librdkafka/rdkafka.h not found)"])
4667 fi
4668
4669 if test "x$with_librdkafka" = "xyes"
4670 then
4671         AC_CHECK_LIB(rdkafka, rd_kafka_new, [with_librdkafka="yes"], [with_librdkafka="no (Symbol 'rd_kafka_new' not found)"])
4672   AC_CHECK_LIB(rdkafka, rd_kafka_conf_set_log_cb, [with_librdkafka_log_cb="yes"], [with_librdkafka_log_cb="no"])
4673   AC_CHECK_LIB(rdkafka, rd_kafka_set_logger, [with_librdkafka_logger="yes"], [with_librdkafka_logger="no"])
4674 fi
4675 if test "x$with_librdkafka" = "xyes"
4676 then
4677         BUILD_WITH_LIBRDKAFKA_CPPFLAGS="$with_librdkafka_cppflags"
4678         BUILD_WITH_LIBRDKAFKA_LDFLAGS="$with_librdkafka_ldflags"
4679         if test "x$with_librdkafka_rpath" != "x"
4680         then
4681                 BUILD_WITH_LIBRDKAFKA_LIBS="-Wl,-rpath,$with_librdkafka_rpath -lrdkafka"
4682         else
4683                 BUILD_WITH_LIBRDKAFKA_LIBS="-lrdkafka"
4684         fi
4685         AC_SUBST(BUILD_WITH_LIBRDKAFKA_CPPFLAGS)
4686         AC_SUBST(BUILD_WITH_LIBRDKAFKA_LDFLAGS)
4687         AC_SUBST(BUILD_WITH_LIBRDKAFKA_LIBS)
4688         AC_DEFINE(HAVE_LIBRDKAFKA, 1, [Define if librdkafka is present and usable.])
4689   if test "x$with_librdkafka_log_cb" = "xyes"
4690   then
4691         AC_DEFINE(HAVE_LIBRDKAFKA_LOG_CB, 1, [Define if librdkafka log facility is present and usable.])
4692   else if test "x$with_librdkafka_logger" = "xyes"
4693   then
4694         AC_DEFINE(HAVE_LIBRDKAFKA_LOGGER, 1, [Define if librdkafka log facility is present and usable.])
4695   fi; fi
4696 fi
4697 CPPFLAGS="$SAVE_CPPFLAGS"
4698 LDFLAGS="$SAVE_LDFLAGS"
4699 AM_CONDITIONAL(BUILD_WITH_LIBRDKAFKA, test "x$with_librdkafka" = "xyes")
4700
4701 # }}}
4702
4703 # --with-librouteros {{{
4704 AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
4705 [
4706  if test "x$withval" = "xyes"
4707  then
4708          with_librouteros="yes"
4709  else if test "x$withval" = "xno"
4710  then
4711          with_librouteros="no"
4712  else
4713          with_librouteros="yes"
4714          LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS -I$withval/include"
4715          LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS -L$withval/lib"
4716  fi; fi
4717 ],
4718 [with_librouteros="yes"])
4719
4720 SAVE_CPPFLAGS="$CPPFLAGS"
4721 SAVE_LDFLAGS="$LDFLAGS"
4722
4723 CPPFLAGS="$CPPFLAGS $LIBROUTEROS_CPPFLAGS"
4724 LDFLAGS="$LDFLAGS $LIBROUTEROS_LDFLAGS"
4725
4726 if test "x$with_librouteros" = "xyes"
4727 then
4728         if test "x$LIBROUTEROS_CPPFLAGS" != "x"
4729         then
4730                 AC_MSG_NOTICE([librouteros CPPFLAGS: $LIBROUTEROS_CPPFLAGS])
4731         fi
4732         AC_CHECK_HEADERS(routeros_api.h,
4733         [with_librouteros="yes"],
4734         [with_librouteros="no (routeros_api.h not found)"])
4735 fi
4736 if test "x$with_librouteros" = "xyes"
4737 then
4738         if test "x$LIBROUTEROS_LDFLAGS" != "x"
4739         then
4740                 AC_MSG_NOTICE([librouteros LDFLAGS: $LIBROUTEROS_LDFLAGS])
4741         fi
4742         AC_CHECK_LIB(routeros, ros_interface,
4743         [with_librouteros="yes"],
4744         [with_librouteros="no (symbol 'ros_interface' not found)"])
4745 fi
4746
4747 CPPFLAGS="$SAVE_CPPFLAGS"
4748 LDFLAGS="$SAVE_LDFLAGS"
4749
4750 if test "x$with_librouteros" = "xyes"
4751 then
4752         BUILD_WITH_LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS"
4753         BUILD_WITH_LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS"
4754         AC_SUBST(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
4755         AC_SUBST(BUILD_WITH_LIBROUTEROS_LDFLAGS)
4756 fi
4757 AM_CONDITIONAL(BUILD_WITH_LIBROUTEROS, test "x$with_librouteros" = "xyes")
4758 # }}}
4759
4760 # --with-librrd {{{
4761 librrd_cflags=""
4762 librrd_ldflags=""
4763 librrd_threadsafe="no"
4764 librrd_rrdc_update="no"
4765 AC_ARG_WITH(librrd,
4766   [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
4767   [
4768     if test "x$withval" != "xno" && test "x$withval" != "xyes"
4769     then
4770       librrd_cflags="-I$withval/include"
4771       librrd_ldflags="-L$withval/lib"
4772       with_librrd="yes"
4773     else
4774       with_librrd="$withval"
4775     fi
4776   ],
4777   [with_librrd="yes"]
4778 )
4779
4780 if test "x$with_librrd" = "xyes"
4781 then
4782   SAVE_LDFLAGS="$LDFLAGS"
4783   LDFLAGS="$LDFLAGS $librrd_ldflags"
4784   PKG_CHECK_MODULES([RRD], [librrd >= 1.6.0],
4785     [
4786       AC_CHECK_LIB([rrd], [rrd_update_r],
4787         [librrd_threadsafe="yes"],
4788         [:]
4789       )
4790       AC_CHECK_LIB([rrd], [rrdc_update],
4791         [librrd_rrdc_update="yes"],
4792         [:]
4793       )
4794     ],[:]
4795   )
4796   LDFLAGS="$SAVE_LDFLAGS"
4797
4798   SAVE_CPPFLAGS="$CPPFLAGS"
4799   CPPFLAGS="$CPPFLAGS $RRD_CFLAGS $librrd_cflags"
4800
4801   AC_CHECK_HEADERS([rrd.h],, [with_librrd="no (rrd.h not found)"])
4802
4803   CPPFLAGS="$SAVE_CPPFLAGS"
4804 fi
4805
4806 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"
4807 then
4808   SAVE_LDFLAGS="$LDFLAGS"
4809   LDFLAGS="$LDFLAGS $librrd_ldflags"
4810
4811   AC_CHECK_LIB([rrd_th], [rrd_update_r],
4812     [
4813       librrd_ldflags="$librrd_ldflags -lrrd_th"
4814       librrd_threadsafe="yes"
4815       AC_CHECK_LIB([rrd_th], [rrdc_update],
4816         [librrd_rrdc_update="yes"],
4817         [:],
4818       )
4819     ],
4820     [:]
4821   )
4822   LDFLAGS="$SAVE_LDFLAGS"
4823 fi
4824
4825 if test "x$with_librrd" = "xyes" && test "x$librrd_threadsafe" = "xno"
4826 then
4827   SAVE_LDFLAGS="$LDFLAGS"
4828   LDFLAGS="$LDFLAGS $librrd_ldflags"
4829
4830   AC_CHECK_LIB([rrd], [rrd_update],
4831     [
4832       librrd_ldflags="$librrd_ldflags -lrrd"
4833       AC_CHECK_LIB([rrd], [rrdc_update],
4834         [librrd_rrdc_update="yes"],
4835         [:]
4836       )
4837     ],
4838     [with_librrd="no (symbol 'rrd_update' not found)"]
4839   )
4840   LDFLAGS="$SAVE_LDFLAGS"
4841 fi
4842
4843 if test "x$with_librrd" = "xyes"
4844 then
4845   BUILD_WITH_LIBRRD_CFLAGS="$RRD_CFLAGS $librrd_cflags"
4846   BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
4847   BUILD_WITH_LIBRRD_LIBS="$RRD_LIBS"
4848   AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
4849   AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
4850   AC_SUBST(BUILD_WITH_LIBRRD_LIBS)
4851 fi
4852 if test "x$librrd_threadsafe" = "xyes"
4853 then
4854   AC_DEFINE([HAVE_THREADSAFE_LIBRRD], [1],
4855     [Define to 1 if the rrd library is thread-safe]
4856   )
4857 fi
4858 # }}}
4859
4860 # --with-libsensors {{{
4861 with_sensors_cflags=""
4862 with_sensors_ldflags=""
4863 AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
4864 [
4865         if test "x$withval" = "xno"
4866         then
4867                 with_libsensors="no"
4868         else
4869                 with_libsensors="yes"
4870                 if test "x$withval" != "xyes"
4871                 then
4872                         with_sensors_cflags="-I$withval/include"
4873                         with_sensors_ldflags="-L$withval/lib"
4874                         with_libsensors="yes"
4875                 fi
4876         fi
4877 ],
4878 [
4879         if test "x$ac_system" = "xLinux"
4880         then
4881                 with_libsensors="yes"
4882         else
4883                 with_libsensors="no (Linux only library)"
4884         fi
4885 ])
4886 if test "x$with_libsensors" = "xyes"
4887 then
4888         SAVE_CPPFLAGS="$CPPFLAGS"
4889         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
4890
4891         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
4892
4893         CPPFLAGS="$SAVE_CPPFLAGS"
4894 fi
4895 if test "x$with_libsensors" = "xyes"
4896 then
4897         SAVE_CPPFLAGS="$CPPFLAGS"
4898         SAVE_LDFLAGS="$LDFLAGS"
4899         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
4900         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
4901
4902         AC_CHECK_LIB(sensors, sensors_init,
4903         [
4904                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
4905         ],
4906         [with_libsensors="no (libsensors not found)"])
4907
4908         CPPFLAGS="$SAVE_CPPFLAGS"
4909         LDFLAGS="$SAVE_LDFLAGS"
4910 fi
4911 if test "x$with_libsensors" = "xyes"
4912 then
4913         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
4914         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
4915         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
4916         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
4917 fi
4918 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
4919 # }}}
4920
4921 # libsigrok {{{
4922 AC_SUBST([LIBSIGROK_CFLAGS])
4923 AC_SUBST([LIBSIGROK_LIBS])
4924 PKG_CHECK_MODULES([LIBSIGROK], [libsigrok < 0.4],
4925   [with_libsigrok="yes"],
4926   [with_libsigrok="no (pkg-config could not find libsigrok)"]
4927 )
4928 # }}}
4929
4930 # --with-libstatgrab {{{
4931 with_libstatgrab_cflags=""
4932 with_libstatgrab_ldflags=""
4933 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
4934 [
4935  if test "x$withval" != "xno" \
4936    && test "x$withval" != "xyes"
4937  then
4938    with_libstatgrab_cflags="-I$withval/include"
4939    with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
4940    with_libstatgrab="yes"
4941    with_libstatgrab_pkg_config="no"
4942  else
4943    with_libstatgrab="$withval"
4944    with_libstatgrab_pkg_config="yes"
4945  fi
4946  ],
4947 [
4948  with_libstatgrab="yes"
4949  with_libstatgrab_pkg_config="yes"
4950 ])
4951
4952 if test "x$with_libstatgrab" = "xyes" \
4953   && test "x$with_libstatgrab_pkg_config" = "xyes"
4954 then
4955   AC_MSG_CHECKING([pkg-config for libstatgrab])
4956   temp_result="found"
4957   $PKG_CONFIG --exists libstatgrab 2>/dev/null
4958   if test "$?" != "0"
4959   then
4960     with_libstatgrab_pkg_config="no"
4961     with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
4962     temp_result="not found"
4963   fi
4964   AC_MSG_RESULT([$temp_result])
4965 fi
4966
4967 if test "x$with_libstatgrab" = "xyes" \
4968   && test "x$with_libstatgrab_pkg_config" = "xyes" \
4969   && test "x$with_libstatgrab_cflags" = "x"
4970 then
4971   AC_MSG_CHECKING([for libstatgrab CFLAGS])
4972   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
4973   if test "$?" = "0"
4974   then
4975     with_libstatgrab_cflags="$temp_result"
4976   else
4977     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
4978     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
4979   fi
4980   AC_MSG_RESULT([$temp_result])
4981 fi
4982
4983 if test "x$with_libstatgrab" = "xyes" \
4984   && test "x$with_libstatgrab_pkg_config" = "xyes" \
4985   && test "x$with_libstatgrab_ldflags" = "x"
4986 then
4987   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
4988   temp_result="`$PKG_CONFIG --libs libstatgrab`"
4989   if test "$?" = "0"
4990   then
4991     with_libstatgrab_ldflags="$temp_result"
4992   else
4993     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
4994     temp_result="$PKG_CONFIG --libs libstatgrab failed"
4995   fi
4996   AC_MSG_RESULT([$temp_result])
4997 fi
4998
4999 if test "x$with_libstatgrab" = "xyes"
5000 then
5001   SAVE_CPPFLAGS="$CPPFLAGS"
5002   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
5003
5004   AC_CHECK_HEADERS(statgrab.h,
5005                    [with_libstatgrab="yes"],
5006                    [with_libstatgrab="no (statgrab.h not found)"])
5007
5008   CPPFLAGS="$SAVE_CPPFLAGS"
5009 fi
5010
5011 if test "x$with_libstatgrab" = "xyes"
5012 then
5013   SAVE_CFLAGS="$CFLAGS"
5014   SAVE_LDFLAGS="$LDFLAGS"
5015
5016   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
5017   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5018
5019   AC_CHECK_LIB(statgrab, sg_init,
5020                [with_libstatgrab="yes"],
5021                [with_libstatgrab="no (symbol sg_init not found)"])
5022
5023   CFLAGS="$SAVE_CFLAGS"
5024   LDFLAGS="$SAVE_LDFLAGS"
5025 fi
5026
5027 if test "x$with_libstatgrab" = "xyes"
5028 then
5029   SAVE_CFLAGS="$CFLAGS"
5030   SAVE_LDFLAGS="$LDFLAGS"
5031   SAVE_LIBS="$LIBS"
5032
5033   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
5034   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
5035   LIBS="-lstatgrab $LIBS"
5036
5037   AC_CACHE_CHECK([if libstatgrab >= 0.90],
5038           [c_cv_have_libstatgrab_0_90],
5039           AC_LINK_IFELSE([AC_LANG_PROGRAM(
5040 [[[
5041 #include <stdio.h>
5042 #include <statgrab.h>
5043 ]]],
5044 [[[
5045       if (sg_init()) return 0;
5046 ]]]
5047     )],
5048     [c_cv_have_libstatgrab_0_90="no"],
5049     [c_cv_have_libstatgrab_0_90="yes"]
5050           )
5051   )
5052
5053   CFLAGS="$SAVE_CFLAGS"
5054   LDFLAGS="$SAVE_LDFLAGS"
5055   LIBS="$SAVE_LIBS"
5056 fi
5057
5058 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
5059 if test "x$with_libstatgrab" = "xyes"
5060 then
5061   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
5062   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
5063   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
5064   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
5065   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
5066   if test "x$c_cv_have_libstatgrab_0_90" = "xyes"
5067   then
5068         AC_DEFINE(HAVE_LIBSTATGRAB_0_90, 1, [Define to 1 if libstatgrab version >= 0.90])
5069   fi
5070 fi
5071 # }}}
5072
5073 # --with-libtokyotyrant {{{
5074 with_libtokyotyrant_cppflags=""
5075 with_libtokyotyrant_ldflags=""
5076 with_libtokyotyrant_libs=""
5077 AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
5078 [
5079   if test "x$withval" = "xno"
5080   then
5081     with_libtokyotyrant="no"
5082   else if test "x$withval" = "xyes"
5083   then
5084     with_libtokyotyrant="yes"
5085   else
5086     with_libtokyotyrant_cppflags="-I$withval/include"
5087     with_libtokyotyrant_ldflags="-L$withval/include"
5088     with_libtokyotyrant_libs="-ltokyotyrant"
5089     with_libtokyotyrant="yes"
5090   fi; fi
5091 ],
5092 [
5093   with_libtokyotyrant="yes"
5094 ])
5095
5096 if test "x$with_libtokyotyrant" = "xyes"
5097 then
5098   if $PKG_CONFIG --exists tokyotyrant
5099   then
5100     with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
5101     with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `$PKG_CONFIG --libs-only-L tokyotyrant`"
5102     with_libtokyotyrant_libs="$with_libtokyotyrant_libs `$PKG_CONFIG --libs-only-l tokyotyrant`"
5103   fi
5104 fi
5105
5106 SAVE_CPPFLAGS="$CPPFLAGS"
5107 SAVE_LDFLAGS="$LDFLAGS"
5108 CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
5109 LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
5110
5111 if test "x$with_libtokyotyrant" = "xyes"
5112 then
5113   AC_CHECK_HEADERS(tcrdb.h,
5114   [
5115           AC_DEFINE(HAVE_TCRDB_H, 1,
5116                     [Define to 1 if you have the <tcrdb.h> header file.])
5117   ], [with_libtokyotyrant="no (tcrdb.h not found)"])
5118 fi
5119
5120 if test "x$with_libtokyotyrant" = "xyes"
5121 then
5122   AC_CHECK_LIB(tokyotyrant, tcrdbrnum,
5123   [
5124           AC_DEFINE(HAVE_LIBTOKYOTYRANT, 1,
5125                     [Define to 1 if you have the tokyotyrant library (-ltokyotyrant).])
5126   ],
5127   [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
5128   [$with_libtokyotyrant_libs])
5129 fi
5130
5131 CPPFLAGS="$SAVE_CPPFLAGS"
5132 LDFLAGS="$SAVE_LDFLAGS"
5133
5134 if test "x$with_libtokyotyrant" = "xyes"
5135 then
5136   BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
5137   BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
5138   BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
5139   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
5140   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
5141   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS)
5142 fi
5143 AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes")
5144 # }}}
5145
5146 # --with-libudev {{{
5147 with_libudev_cflags=""
5148 with_libudev_ldflags=""
5149 AC_ARG_WITH(libudev, [AS_HELP_STRING([--with-libudev@<:@=PREFIX@:>@], [Path to libudev.])],
5150 [
5151         if test "x$withval" = "xno"
5152         then
5153                 with_libudev="no"
5154         else
5155                 with_libudev="yes"
5156                 if test "x$withval" != "xyes"
5157                 then
5158                         with_libudev_cflags="-I$withval/include"
5159                         with_libudev_ldflags="-L$withval/lib"
5160                         with_libudev="yes"
5161                 fi
5162         fi
5163 ],
5164 [
5165         if test "x$ac_system" = "xLinux"
5166         then
5167                 with_libudev="yes"
5168         else
5169                 with_libudev="no (Linux only library)"
5170         fi
5171 ])
5172 if test "x$with_libudev" = "xyes"
5173 then
5174         SAVE_CPPFLAGS="$CPPFLAGS"
5175         CPPFLAGS="$CPPFLAGS $with_libudev_cflags"
5176
5177         AC_CHECK_HEADERS(libudev.h, [], [with_libudev="no (libudev.h not found)"])
5178
5179         CPPFLAGS="$SAVE_CPPFLAGS"
5180 fi
5181 if test "x$with_libudev" = "xyes"
5182 then
5183         SAVE_CPPFLAGS="$CPPFLAGS"
5184         SAVE_LDFLAGS="$LDFLAGS"
5185         CPPFLAGS="$CPPFLAGS $with_libudev_cflags"
5186         LDFLAGS="$LDFLAGS $with_libudev_ldflags"
5187
5188         AC_CHECK_LIB(udev, udev_new,
5189         [
5190                 AC_DEFINE(HAVE_LIBUDEV, 1, [Define to 1 if you have the udev library (-ludev).])
5191         ],
5192         [with_libudev="no (libudev not found)"])
5193
5194         CPPFLAGS="$SAVE_CPPFLAGS"
5195         LDFLAGS="$SAVE_LDFLAGS"
5196 fi
5197 if test "x$with_libudev" = "xyes"
5198 then
5199         BUILD_WITH_LIBUDEV_CFLAGS="$with_libudev_cflags"
5200         BUILD_WITH_LIBUDEV_LDFLAGS="$with_libudev_ldflags"
5201         BUILD_WITH_LIBUDEV_LIBS="-ludev"
5202         AC_SUBST(BUILD_WITH_LIBUDEV_CFLAGS)
5203         AC_SUBST(BUILD_WITH_LIBUDEV_LDFLAGS)
5204         AC_SUBST(BUILD_WITH_LIBUDEV_LIBS)
5205 fi
5206 AM_CONDITIONAL(BUILD_WITH_LIBUDEV, test "x$with_libudev" = "xyes")
5207 # }}}
5208
5209 # --with-libupsclient {{{
5210 with_libupsclient_config=""
5211 with_libupsclient_cflags=""
5212 with_libupsclient_libs=""
5213 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
5214 [
5215         if test "x$withval" = "xno"
5216         then
5217                 with_libupsclient="no"
5218         else if test "x$withval" = "xyes"
5219         then
5220                 with_libupsclient="use_pkgconfig"
5221         else
5222                 if test -x "$withval"
5223                 then
5224                         with_libupsclient_config="$withval"
5225                         with_libupsclient="use_libupsclient_config"
5226                 else if test -x "$withval/bin/libupsclient-config"
5227                 then
5228                         with_libupsclient_config="$withval/bin/libupsclient-config"
5229                         with_libupsclient="use_libupsclient_config"
5230                 else
5231                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
5232                         with_libupsclient_cflags="-I$withval/include"
5233                         with_libupsclient_libs="-L$withval/lib -lupsclient"
5234                         with_libupsclient="yes"
5235                 fi; fi
5236         fi; fi
5237 ],
5238 [with_libupsclient="use_pkgconfig"])
5239
5240 # configure using libupsclient-config
5241 if test "x$with_libupsclient" = "xuse_libupsclient_config"
5242 then
5243         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
5244         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
5245         if test $? -ne 0
5246         then
5247                 with_libupsclient="no ($with_libupsclient_config failed)"
5248         fi
5249         with_libupsclient_libs="`$with_libupsclient_config --libs`"
5250         if test $? -ne 0
5251         then
5252                 with_libupsclient="no ($with_libupsclient_config failed)"
5253         fi
5254 fi
5255 if test "x$with_libupsclient" = "xuse_libupsclient_config"
5256 then
5257         with_libupsclient="yes"
5258 fi
5259
5260 # configure using pkg-config
5261 if test "x$with_libupsclient" = "xuse_pkgconfig"
5262 then
5263         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
5264         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
5265         if test $? -ne 0
5266         then
5267                 with_libupsclient="no (pkg-config doesn't know libupsclient)"
5268         fi
5269 fi
5270 if test "x$with_libupsclient" = "xuse_pkgconfig"
5271 then
5272         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
5273         if test $? -ne 0
5274         then
5275                 with_libupsclient="no ($PKG_CONFIG failed)"
5276         fi
5277         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
5278         if test $? -ne 0
5279         then
5280                 with_libupsclient="no ($PKG_CONFIG failed)"
5281         fi
5282 fi
5283 if test "x$with_libupsclient" = "xuse_pkgconfig"
5284 then
5285         with_libupsclient="yes"
5286 fi
5287
5288 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
5289 # the actual checks.
5290 if test "x$with_libupsclient" = "xyes"
5291 then
5292         SAVE_CPPFLAGS="$CPPFLAGS"
5293         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5294
5295         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
5296
5297         CPPFLAGS="$SAVE_CPPFLAGS"
5298 fi
5299 if test "x$with_libupsclient" = "xyes"
5300 then
5301         SAVE_CPPFLAGS="$CPPFLAGS"
5302         SAVE_LDFLAGS="$LDFLAGS"
5303
5304         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5305         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
5306
5307         AC_CHECK_LIB(upsclient, upscli_connect,
5308                      [with_libupsclient="yes"],
5309                      [with_libupsclient="no (symbol upscli_connect not found)"])
5310
5311         CPPFLAGS="$SAVE_CPPFLAGS"
5312         LDFLAGS="$SAVE_LDFLAGS"
5313 fi
5314 if test "x$with_libupsclient" = "xyes"
5315 then
5316         SAVE_CPPFLAGS="$CPPFLAGS"
5317         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
5318
5319         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
5320 [#include <stdlib.h>
5321 #include <stdio.h>
5322 #include <upsclient.h>])
5323
5324         CPPFLAGS="$SAVE_CPPFLAGS"
5325 fi
5326 if test "x$with_libupsclient" = "xyes"
5327 then
5328         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
5329         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
5330         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
5331         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
5332 fi
5333 # }}}
5334
5335 # --with-libxenctrl {{{
5336 with_libxenctrl_cppflags=""
5337 with_libxenctrl_ldflags=""
5338 AC_ARG_WITH(libxenctrl, [AS_HELP_STRING([--with-libxenctrl@<:@=PREFIX@:>@], [Path to libxenctrl.])],
5339 [
5340         if test "x$withval" != "xno" && test "x$withval" != "xyes"
5341         then
5342                 with_libxenctrl_cppflags="-I$withval/include"
5343                 with_libxenctrl_ldflags="-L$withval/lib"
5344                 with_libxenctrl="yes"
5345         else
5346                 with_libxenctrl="$withval"
5347         fi
5348 ],
5349 [
5350         with_libxenctrl="yes"
5351 ])
5352 if test "x$with_libxenctrl" = "xyes"
5353 then
5354         SAVE_CPPFLAGS="$CPPFLAGS"
5355         CPPFLAGS="$CPPFLAGS $with_libxenctrl_cppflags"
5356
5357         AC_CHECK_HEADERS(xenctrl.h, [with_libxenctrl="yes"], [with_libxenctrl="no (xenctrl.h not found)"])
5358
5359         CPPFLAGS="$SAVE_CPPFLAGS"
5360 fi
5361 if test "x$with_libxenctrl" = "xyes"
5362 then
5363         SAVE_CPPFLAGS="$CPPFLAGS"
5364         SAVE_LDFLAGS="$LDFLAGS"
5365         CPPFLAGS="$CPPFLAGS $with_libxenctrl_cppflags"
5366         LDFLAGS="$LDFLAGS $with_libxenctrl_ldflags"
5367
5368         #Xen versions older than 3.4 has no xc_getcpuinfo()
5369         AC_CHECK_LIB(xenctrl, xc_getcpuinfo, [with_libxenctrl="yes"], [with_libxenctrl="no (symbol 'xc_getcpuinfo' not found)"], [])
5370
5371         CPPFLAGS="$SAVE_CPPFLAGS"
5372         LDFLAGS="$SAVE_LDFLAGS"
5373         LIBXENCTL_CPPFLAGS="$with_libxenctl_cppflags"
5374         LIBXENCTL_LDFLAGS="$with_libxenctl_ldflags"
5375         AC_SUBST(LIBXENCTL_CPPFLAGS)
5376         AC_SUBST(LIBXENCTL_LDFLAGS)
5377 fi
5378 # }}}
5379
5380 # --with-libxmms {{{
5381 with_xmms_config="xmms-config"
5382 with_xmms_cflags=""
5383 with_xmms_libs=""
5384 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
5385 [
5386         if test "x$withval" != "xno" \
5387                 && test "x$withval" != "xyes"
5388         then
5389                 if test -f "$withval" && test -x "$withval";
5390                 then
5391                         with_xmms_config="$withval"
5392                 else if test -x "$withval/bin/xmms-config"
5393                 then
5394                         with_xmms_config="$withval/bin/xmms-config"
5395                 fi; fi
5396                 with_libxmms="yes"
5397         else if test "x$withval" = "xno"
5398         then
5399                 with_libxmms="no"
5400         else
5401                 with_libxmms="yes"
5402         fi; fi
5403 ],
5404 [
5405         with_libxmms="yes"
5406 ])
5407 if test "x$with_libxmms" = "xyes"
5408 then
5409         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
5410         xmms_config_status=$?
5411
5412         if test $xmms_config_status -ne 0
5413         then
5414                 with_libxmms="no"
5415         fi
5416 fi
5417 if test "x$with_libxmms" = "xyes"
5418 then
5419         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
5420         xmms_config_status=$?
5421
5422         if test $xmms_config_status -ne 0
5423         then
5424                 with_libxmms="no"
5425         fi
5426 fi
5427 if test "x$with_libxmms" = "xyes"
5428 then
5429         AC_CHECK_LIB(xmms, xmms_remote_get_info,
5430         [
5431                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
5432                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
5433                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
5434                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
5435         ],
5436         [
5437                 with_libxmms="no"
5438         ],
5439         [$with_xmms_libs])
5440 fi
5441 with_libxmms_numeric=0
5442 if test "x$with_libxmms" = "xyes"
5443 then
5444         with_libxmms_numeric=1
5445 fi
5446 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
5447 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
5448 # }}}
5449
5450 # --with-libyajl {{{
5451 with_libyajl_cppflags=""
5452 with_libyajl_ldflags=""
5453 AC_ARG_WITH(libyajl, [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
5454 [
5455         if test "x$withval" != "xno" && test "x$withval" != "xyes"
5456         then
5457                 with_libyajl_cppflags="-I$withval/include"
5458                 with_libyajl_ldflags="-L$withval/lib"
5459                 with_libyajl="yes"
5460         else
5461                 with_libyajl="$withval"
5462         fi
5463 ],
5464 [
5465         with_libyajl="yes"
5466 ])
5467 if test "x$with_libyajl" = "xyes"
5468 then
5469         SAVE_CPPFLAGS="$CPPFLAGS"
5470         CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
5471
5472         AC_CHECK_HEADERS(yajl/yajl_parse.h, [with_libyajl="yes"], [with_libyajl="no (yajl/yajl_parse.h not found)"])
5473         AC_CHECK_HEADERS(yajl/yajl_version.h)
5474
5475         CPPFLAGS="$SAVE_CPPFLAGS"
5476 fi
5477 if test "x$with_libyajl" = "xyes"
5478 then
5479         SAVE_CPPFLAGS="$CPPFLAGS"
5480         SAVE_LDFLAGS="$LDFLAGS"
5481         CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
5482         LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
5483
5484         AC_CHECK_LIB(yajl, yajl_alloc, [with_libyajl="yes"], [with_libyajl="no (Symbol 'yajl_alloc' not found)"])
5485
5486         CPPFLAGS="$SAVE_CPPFLAGS"
5487         LDFLAGS="$SAVE_LDFLAGS"
5488 fi
5489 if test "x$with_libyajl" = "xyes"
5490 then
5491         BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
5492         BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
5493         BUILD_WITH_LIBYAJL_LIBS="-lyajl"
5494         AC_SUBST(BUILD_WITH_LIBYAJL_CPPFLAGS)
5495         AC_SUBST(BUILD_WITH_LIBYAJL_LDFLAGS)
5496         AC_SUBST(BUILD_WITH_LIBYAJL_LIBS)
5497         AC_DEFINE(HAVE_LIBYAJL, 1, [Define if libyajl is present and usable.])
5498 fi
5499 AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
5500 # }}}
5501
5502 # --with-mic {{{
5503 with_mic_cflags="-I/opt/intel/mic/sysmgmt/sdk/include"
5504 with_mic_ldpath="-L/opt/intel/mic/sysmgmt/sdk/lib/Linux"
5505 with_mic_libs=""
5506 AC_ARG_WITH(mic,[AS_HELP_STRING([--with-mic@<:@=PREFIX@:>@], [Path to Intel MIC Access API.])],
5507 [
5508         if test "x$withval" = "xno"
5509         then
5510                 with_mic="no"
5511         else if test "x$withval" = "xyes"
5512         then
5513                 with_mic="yes"
5514         else if test -d "$with_mic/lib"
5515         then
5516                 AC_MSG_NOTICE([Not checking for Intel Mic: Manually configured])
5517                 with_mic_cflags="-I$withval/include"
5518                 with_mic_ldpath="-L$withval/lib/Linux"
5519                 with_mic_libs="$PTHREAD_LIBS -lMicAccessSDK -lscif"
5520                 with_mic="yes"
5521         fi; fi; fi
5522 ],
5523 [with_mic="yes"])
5524 if test "x$with_mic" = "xyes"
5525 then
5526         SAVE_CPPFLAGS="$CPPFLAGS"
5527         CPPFLAGS="$CPPFLAGS $with_mic_cflags"
5528         AC_CHECK_HEADERS(MicAccessApi.h,[],[with_mic="no (MicAccessApi not found)"])
5529         CPPFLAGS="$SAVE_CPPFLAGS"
5530 fi
5531 if test "x$with_mic" = "xyes"
5532 then
5533         SAVE_CPPFLAGS="$CPPFLAGS"
5534         SAVE_LDFLAGS="$LDFLAGS"
5535
5536         CPPFLAGS="$CPPFLAGS $with_mic_cflags"
5537         LDFLAGS="$LDFLAGS $with_mic_ldpath"
5538
5539         AC_CHECK_LIB(MicAccessSDK, MicInitAPI,
5540                         [with_mic_ldpath="$with_mic_ldpath"
5541                         with_mic_libs="$PTHREAD_LIBS -lMicAccessSDK -lscif"],
5542                         [with_mic="no (symbol MicInitAPI not found)"],[$PTHREAD_LIBS -lscif])
5543
5544         CPPFLAGS="$SAVE_CPPFLAGS"
5545         LDFLAGS="$SAVE_LDFLAGS"
5546 fi
5547
5548 if test "x$with_mic" = "xyes"
5549 then
5550         BUILD_WITH_MIC_CPPFLAGS="$with_mic_cflags"
5551         BUILD_WITH_MIC_LIBPATH="$with_mic_ldpath"
5552         BUILD_WITH_MIC_LDADD="$with_mic_libs"
5553         AC_SUBST(BUILD_WITH_MIC_CPPFLAGS)
5554         AC_SUBST(BUILD_WITH_MIC_LIBPATH)
5555         AC_SUBST(BUILD_WITH_MIC_LDADD)
5556 fi
5557 #}}}
5558
5559 # --with-libvarnish {{{
5560 with_libvarnish_cppflags=""
5561 with_libvarnish_cflags=""
5562 with_libvarnish_libs=""
5563 AC_ARG_WITH(libvarnish, [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
5564 [
5565         if test "x$withval" = "xno"
5566         then
5567                 with_libvarnish="no"
5568         else if test "x$withval" = "xyes"
5569         then
5570                 with_libvarnish="use_pkgconfig"
5571         else if test -d "$with_libvarnish/lib"
5572         then
5573                 AC_MSG_NOTICE([Not checking for libvarnish: Manually configured])
5574                 with_libvarnish_cflags="-I$withval/include"
5575                 with_libvarnish_libs="-L$withval/lib -lvarnishapi"
5576                 with_libvarnish="yes"
5577         fi; fi; fi
5578 ],
5579 [with_libvarnish="use_pkgconfig"])
5580
5581 # configure using pkg-config
5582 if test "x$with_libvarnish" = "xuse_pkgconfig"
5583 then
5584         AC_MSG_NOTICE([Checking for varnishapi using $PKG_CONFIG])
5585         $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
5586         if test $? -ne 0
5587         then
5588                 with_libvarnish="no (pkg-config doesn't know varnishapi)"
5589         fi
5590 fi
5591 if test "x$with_libvarnish" = "xuse_pkgconfig"
5592 then
5593         with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
5594         if test $? -ne 0
5595         then
5596                 with_libvarnish="no ($PKG_CONFIG failed)"
5597         fi
5598         with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
5599         if test $? -ne 0
5600         then
5601                 with_libvarnish="no ($PKG_CONFIG failed)"
5602         fi
5603 fi
5604 if test "x$with_libvarnish" = "xuse_pkgconfig"
5605 then
5606         with_libvarnish="yes"
5607 fi
5608
5609 # with_libvarnish_cflags and with_libvarnish_libs are set up now, let's do
5610 # the actual checks.
5611 if test "x$with_libvarnish" = "xyes"
5612 then
5613         SAVE_CPPFLAGS="$CPPFLAGS"
5614
5615         CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
5616
5617         AC_CHECK_HEADERS(vapi/vsc.h,
5618                 [AC_DEFINE([HAVE_VARNISH_V4], [1], [Varnish 4 API support])],
5619                 [AC_CHECK_HEADERS(vsc.h,
5620                         [AC_DEFINE([HAVE_VARNISH_V3], [1], [Varnish 3 API support])],
5621                         [AC_CHECK_HEADERS(varnishapi.h,
5622                                 [AC_DEFINE([HAVE_VARNISH_V2], [1], [Varnish 2 API support])],
5623                                 [with_libvarnish="no (found none of the varnish header files)"])])])
5624
5625         CPPFLAGS="$SAVE_CPPFLAGS"
5626 fi
5627 if test "x$with_libvarnish" = "xyes"
5628 then
5629         BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
5630         BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
5631         AC_SUBST(BUILD_WITH_LIBVARNISH_CFLAGS)
5632         AC_SUBST(BUILD_WITH_LIBVARNISH_LIBS)
5633 fi
5634 # }}}
5635
5636 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
5637 with_libxml2="no (pkg-config isn't available)"
5638 with_libxml2_cflags=""
5639 with_libxml2_ldflags=""
5640 with_libvirt="no (pkg-config isn't available)"
5641 with_libvirt_cflags=""
5642 with_libvirt_ldflags=""
5643 $PKG_CONFIG --exists 'libxml-2.0' 2>/dev/null
5644 if test "$?" = "0"
5645 then
5646         with_libxml2="yes"
5647 else
5648         with_libxml2="no (pkg-config doesn't know libxml-2.0)"
5649 fi
5650
5651 $PKG_CONFIG --exists libvirt 2>/dev/null
5652 if test "$?" = "0"
5653 then
5654         with_libvirt="yes"
5655 else
5656         with_libvirt="no (pkg-config doesn't know libvirt)"
5657 fi
5658 if test "x$with_libxml2" = "xyes"
5659 then
5660         with_libxml2_cflags="`$PKG_CONFIG --cflags libxml-2.0`"
5661         if test $? -ne 0
5662         then
5663                 with_libxml2="no"
5664         fi
5665         with_libxml2_ldflags="`$PKG_CONFIG --libs libxml-2.0`"
5666         if test $? -ne 0
5667         then
5668                 with_libxml2="no"
5669         fi
5670 fi
5671 if test "x$with_libxml2" = "xyes"
5672 then
5673         SAVE_CPPFLAGS="$CPPFLAGS"
5674         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
5675
5676         AC_CHECK_HEADERS(libxml/parser.h, [],
5677                       [with_libxml2="no (libxml/parser.h not found)"])
5678
5679         CPPFLAGS="$SAVE_CPPFLAGS"
5680 fi
5681 if test "x$with_libxml2" = "xyes"
5682 then
5683         SAVE_CFLAGS="$CFLAGS"
5684         SAVE_LDFLAGS="$LDFLAGS"
5685
5686         CFLAGS="$CFLAGS $with_libxml2_cflags"
5687         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
5688
5689         AC_CHECK_LIB(xml2, xmlXPathEval,
5690                      [with_libxml2="yes"],
5691                      [with_libxml2="no (symbol xmlXPathEval not found)"])
5692
5693         CFLAGS="$SAVE_CFLAGS"
5694         LDFLAGS="$SAVE_LDFLAGS"
5695 fi
5696 dnl Add the right compiler flags and libraries.
5697 if test "x$with_libxml2" = "xyes"; then
5698         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
5699         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
5700         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
5701         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
5702 fi
5703 if test "x$with_libvirt" = "xyes"
5704 then
5705         with_libvirt_cflags="`$PKG_CONFIG --cflags libvirt`"
5706         if test $? -ne 0
5707         then
5708                 with_libvirt="no"
5709         fi
5710         with_libvirt_ldflags="`$PKG_CONFIG --libs libvirt`"
5711         if test $? -ne 0
5712         then
5713                 with_libvirt="no"
5714         fi
5715 fi
5716 if test "x$with_libvirt" = "xyes"
5717 then
5718         SAVE_CPPFLAGS="$CPPFLAGS"
5719         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
5720
5721         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
5722                       [with_libvirt="no (libvirt/libvirt.h not found)"])
5723
5724         CPPFLAGS="$SAVE_CPPFLAGS"
5725 fi
5726 if test "x$with_libvirt" = "xyes"
5727 then
5728         SAVE_CFLAGS="$CFLAGS"
5729         SAVE_LDFLAGS="$LDFLAGS"
5730
5731         CFLAGS="$CFLAGS $with_libvirt_cflags"
5732         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
5733
5734         AC_CHECK_LIB(virt, virDomainBlockStats,
5735                      [with_libvirt="yes"],
5736                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
5737
5738         CFLAGS="$SAVE_CFLAGS"
5739         LDFLAGS="$SAVE_LDFLAGS"
5740 fi
5741 dnl Add the right compiler flags and libraries.
5742 if test "x$with_libvirt" = "xyes"; then
5743         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
5744         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
5745         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
5746         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
5747 fi
5748 # }}}
5749
5750 # $PKG_CONFIG --exists OpenIPMIpthread {{{
5751 with_libopenipmipthread="yes"
5752 with_libopenipmipthread_cflags=""
5753 with_libopenipmipthread_libs=""
5754
5755 if test "x$with_libopenipmipthread" = "xyes"
5756 then
5757         AC_MSG_CHECKING([for libOpenIPMIpthread])
5758         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
5759         if test "$?" != "0"
5760         then
5761                 with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
5762         fi
5763         AC_MSG_RESULT([$with_libopenipmipthread])
5764 fi
5765
5766 if test "x$with_libopenipmipthread" = "xyes"
5767 then
5768         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
5769         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
5770         if test "$?" = "0"
5771         then
5772                 with_libopenipmipthread_cflags="$temp_result"
5773         else
5774                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
5775                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
5776         fi
5777         AC_MSG_RESULT([$temp_result])
5778 fi
5779
5780 if test "x$with_libopenipmipthread" = "xyes"
5781 then
5782         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
5783         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
5784         if test "$?" = "0"
5785         then
5786                 with_libopenipmipthread_ldflags="$temp_result"
5787         else
5788                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
5789                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
5790         fi
5791         AC_MSG_RESULT([$temp_result])
5792 fi
5793
5794 if test "x$with_libopenipmipthread" = "xyes"
5795 then
5796         SAVE_CPPFLAGS="$CPPFLAGS"
5797         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
5798
5799         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
5800                          [with_libopenipmipthread="yes"],
5801                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
5802 [#include <OpenIPMI/ipmiif.h>
5803 #include <OpenIPMI/ipmi_err.h>
5804 #include <OpenIPMI/ipmi_posix.h>
5805 #include <OpenIPMI/ipmi_conn.h>
5806 ])
5807
5808         CPPFLAGS="$SAVE_CPPFLAGS"
5809 fi
5810
5811 if test "x$with_libopenipmipthread" = "xyes"
5812 then
5813         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
5814         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
5815         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
5816         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
5817 fi
5818 # }}}
5819
5820 # --with-libatasmart {{{
5821 with_libatasmart_cppflags=""
5822 with_libatasmart_ldflags=""
5823 AC_ARG_WITH(libatasmart, [AS_HELP_STRING([--with-libatasmart@<:@=PREFIX@:>@], [Path to libatasmart.])],
5824 [
5825         if test "x$withval" != "xno" && test "x$withval" != "xyes"
5826         then
5827                 with_libatasmart_cppflags="-I$withval/include"
5828                 with_libatasmart_ldflags="-L$withval/lib"
5829                 with_libatasmart="yes"
5830         else
5831                 with_libatasmart="$withval"
5832         fi
5833 ],
5834 [
5835         if test "x$ac_system" = "xLinux"
5836         then
5837                 with_libatasmart="yes"
5838         else
5839                 with_libatasmart="no (Linux only library)"
5840         fi
5841 ])
5842 if test "x$with_libatasmart" = "xyes"
5843 then
5844         SAVE_CPPFLAGS="$CPPFLAGS"
5845         CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
5846
5847         AC_CHECK_HEADERS(atasmart.h, [with_libatasmart="yes"], [with_libatasmart="no (atasmart.h not found)"])
5848
5849         CPPFLAGS="$SAVE_CPPFLAGS"
5850 fi
5851 if test "x$with_libatasmart" = "xyes"
5852 then
5853         SAVE_CPPFLAGS="$CPPFLAGS"
5854         SAVE_LDFLAGS="$LDFLAGS"
5855         CPPFLAGS="$CPPFLAGS $with_libatasmart_cppflags"
5856         LDFLAGS="$LDFLAGS $with_libatasmart_ldflags"
5857
5858         AC_CHECK_LIB(atasmart, sk_disk_open, [with_libatasmart="yes"], [with_libatasmart="no (Symbol 'sk_disk_open' not found)"])
5859
5860         CPPFLAGS="$SAVE_CPPFLAGS"
5861         LDFLAGS="$SAVE_LDFLAGS"
5862 fi
5863 if test "x$with_libatasmart" = "xyes"
5864 then
5865         BUILD_WITH_LIBATASMART_CPPFLAGS="$with_libatasmart_cppflags"
5866         BUILD_WITH_LIBATASMART_LDFLAGS="$with_libatasmart_ldflags"
5867         BUILD_WITH_LIBATASMART_LIBS="-latasmart"
5868         AC_SUBST(BUILD_WITH_LIBATASMART_CPPFLAGS)
5869         AC_SUBST(BUILD_WITH_LIBATASMART_LDFLAGS)
5870         AC_SUBST(BUILD_WITH_LIBATASMART_LIBS)
5871         AC_DEFINE(HAVE_LIBATASMART, 1, [Define if libatasmart is present and usable.])
5872 fi
5873 AM_CONDITIONAL(BUILD_WITH_LIBATASMART, test "x$with_libatasmart" = "xyes")
5874 # }}}
5875
5876 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
5877                 [with_libnotify="yes"],
5878                 [with_libnotify="no (pkg-config doesn't know libnotify)"]
5879 )
5880
5881 PKG_CHECK_MODULES([LIBRIEMANN_CLIENT], [riemann-client >= 1.6.0],
5882  [with_libriemann_client="yes"],
5883  [with_libriemann_client="no (pkg-config doesn't know libriemann-client)"])
5884
5885 # Check for enabled/disabled features
5886 #
5887
5888 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
5889 # ------------------------------------------------------------
5890 dnl
5891 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
5892 dnl
5893 AC_DEFUN(
5894         [AC_COLLECTD],
5895         [
5896         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
5897         m4_if(
5898                 [$2],
5899                 [enable],
5900                 [dnl
5901                 m4_define([EnDis],[disabled])dnl
5902                 m4_define([YesNo],[no])dnl
5903                 ],dnl
5904                 [m4_if(
5905                         [$2],
5906                         [disable],
5907                         [dnl
5908                         m4_define([EnDis],[enabled])dnl
5909                         m4_define([YesNo],[yes])dnl
5910                         ],
5911                         [dnl
5912                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
5913                         ]dnl
5914                 )]dnl
5915         )dnl
5916         m4_if([$3], [feature], [],
5917                 [m4_if(
5918                         [$3], [module], [],
5919                         [dnl
5920                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
5921                         ]dnl
5922                 )]dnl
5923         )dnl
5924         AC_ARG_ENABLE(
5925                 [$1],
5926                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
5927                 [],
5928                 enable_$1='[YesNo]'dnl
5929         )# AC_ARG_ENABLE
5930 if test "x$enable_$1" = "xno"
5931 then
5932         collectd_$1=0
5933 else
5934         if test "x$enable_$1" = "xyes"
5935         then
5936                 collectd_$1=1
5937         else
5938                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
5939                 collectd_$1=1
5940                 enable_$1='yes'
5941         fi
5942 fi
5943         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
5944         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
5945         ]dnl
5946 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
5947
5948 # AC_PLUGIN(name, default, info)
5949 # ------------------------------------------------------------
5950 dnl
5951 AC_DEFUN(
5952   [AC_PLUGIN],
5953   [
5954     enable_plugin="no"
5955     force="no"
5956     AC_ARG_ENABLE([$1], AS_HELP_STRING([--enable-$1],[$3]),
5957     [
5958      if test "x$enableval" = "xyes"
5959      then
5960              enable_plugin="yes"
5961      else if test "x$enableval" = "xforce"
5962      then
5963              enable_plugin="yes"
5964              force="yes"
5965      else
5966              enable_plugin="no (disabled on command line)"
5967      fi; fi
5968     ],
5969     [
5970          if test "x$enable_all_plugins" = "xauto"
5971          then
5972              if test "x$2" = "xyes"
5973              then
5974                      enable_plugin="yes"
5975              else
5976                      enable_plugin="$2"
5977              fi
5978          else
5979              enable_plugin="$enable_all_plugins"
5980          fi
5981     ])
5982     if test "x$enable_plugin" = "xyes"
5983     then
5984             if test "x$2" = "xyes" || test "x$force" = "xyes"
5985             then
5986                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
5987                     if test "x$2" != "xyes"
5988                     then
5989                             dependency_warning="yes"
5990                     fi
5991             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
5992                     dependency_error="yes"
5993                     enable_plugin="$2 (dependency error)"
5994             fi
5995     fi
5996     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
5997     enable_$1="$enable_plugin"
5998   ]
5999 )# AC_PLUGIN(name, default, info)
6000
6001 m4_divert_once([HELP_ENABLE], [
6002 collectd features:])
6003 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
6004 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
6005 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
6006 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
6007 AC_COLLECTD([werror],    [disable], [feature], [building with -Werror])
6008
6009 dependency_warning="no"
6010 dependency_error="no"
6011
6012 plugin_ascent="no"
6013 plugin_barometer="no"
6014 plugin_battery="no"
6015 plugin_bind="no"
6016 plugin_ceph="no"
6017 plugin_cgroups="no"
6018 plugin_conntrack="no"
6019 plugin_contextswitch="no"
6020 plugin_cpu="no"
6021 plugin_cpufreq="no"
6022 plugin_cpusleep="no"
6023 plugin_curl_json="no"
6024 plugin_curl_xml="no"
6025 plugin_df="no"
6026 plugin_disk="no"
6027 plugin_drbd="no"
6028 plugin_dpdkstat="no"
6029 plugin_entropy="no"
6030 plugin_ethstat="no"
6031 plugin_fhcount="no"
6032 plugin_fscache="no"
6033 plugin_gps="no"
6034 plugin_grpc="no"
6035 plugin_hugepages="no"
6036 plugin_intel_rdt="no"
6037 plugin_interface="no"
6038 plugin_ipmi="no"
6039 plugin_ipvs="no"
6040 plugin_irq="no"
6041 plugin_load="no"
6042 plugin_log_logstash="no"
6043 plugin_memory="no"
6044 plugin_multimeter="no"
6045 plugin_nfs="no"
6046 plugin_numa="no"
6047 plugin_perl="no"
6048 plugin_pinba="no"
6049 plugin_processes="no"
6050 plugin_protocols="no"
6051 plugin_python="no"
6052 plugin_serial="no"
6053 plugin_smart="no"
6054 plugin_swap="no"
6055 plugin_tape="no"
6056 plugin_tcpconns="no"
6057 plugin_ted="no"
6058 plugin_thermal="no"
6059 plugin_turbostat="no"
6060 plugin_uptime="no"
6061 plugin_users="no"
6062 plugin_virt="no"
6063 plugin_vmem="no"
6064 plugin_vserver="no"
6065 plugin_wireless="no"
6066 plugin_write_prometheus="no"
6067 plugin_xencpu="no"
6068 plugin_zfs_arc="no"
6069 plugin_zone="no"
6070 plugin_zookeeper="no"
6071
6072 # Linux
6073 if test "x$ac_system" = "xLinux"
6074 then
6075         plugin_battery="yes"
6076         plugin_cgroups="yes"
6077         plugin_conntrack="yes"
6078         plugin_contextswitch="yes"
6079         plugin_cpu="yes"
6080         plugin_cpufreq="yes"
6081         plugin_disk="yes"
6082         plugin_drbd="yes"
6083         plugin_entropy="yes"
6084         plugin_fhcount="yes"
6085         plugin_fscache="yes"
6086         plugin_hugepages="yes"
6087         plugin_interface="yes"
6088         plugin_ipc="yes"
6089         plugin_irq="yes"
6090         plugin_load="yes"
6091         plugin_lvm="yes"
6092         plugin_memory="yes"
6093         plugin_nfs="yes"
6094         plugin_numa="yes"
6095         plugin_processes="yes"
6096         plugin_protocols="yes"
6097         plugin_serial="yes"
6098         plugin_swap="yes"
6099         plugin_tcpconns="yes"
6100         plugin_thermal="yes"
6101         plugin_uptime="yes"
6102         plugin_vmem="yes"
6103         plugin_vserver="yes"
6104         plugin_wireless="yes"
6105         plugin_zfs_arc="yes"
6106
6107         if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
6108         then
6109                 plugin_ipvs="yes"
6110         fi
6111         if test "x$c_cv_have_usable_asm_msrindex_h" = "xyes" && test "x$have_cpuid_h" = "xyes"
6112         then
6113                 plugin_turbostat="yes"
6114         fi
6115         
6116         if test "x$c_cv_have_clock_boottime_monotonic" = "xyes"
6117         then
6118                 plugin_cpusleep="yes"
6119         fi
6120 fi
6121
6122 if test "x$ac_system" = "xOpenBSD"
6123 then
6124         plugin_tcpconns="yes"
6125 fi
6126
6127 if test "x$ac_system" = "xNetBSD"
6128 then
6129         plugin_disk="yes"
6130         plugin_entropy="yes"
6131         plugin_irq="yes"
6132         plugin_processes="yes"
6133 fi
6134
6135 # Mac OS X devices
6136 if test "x$with_libiokit" = "xyes"
6137 then
6138         plugin_battery="yes"
6139         plugin_disk="yes"
6140 fi
6141
6142 # AIX
6143
6144 if test "x$ac_system" = "xAIX"
6145 then
6146         plugin_ipc="yes"
6147         plugin_tcpconns="yes"
6148 fi
6149
6150 # FreeBSD
6151
6152 if test "x$ac_system" = "xFreeBSD"
6153 then
6154         plugin_disk="yes"
6155         plugin_zfs_arc="yes"
6156 fi
6157
6158
6159 if test "x$with_perfstat" = "xyes"
6160 then
6161         plugin_contextswitch="yes"
6162         plugin_cpu="yes"
6163         plugin_disk="yes"
6164         plugin_interface="yes"
6165         plugin_load="yes"
6166         plugin_memory="yes"
6167         plugin_swap="yes"
6168         plugin_uptime="yes"
6169 fi
6170
6171 if test "x$with_procinfo" = "xyes"
6172 then
6173         plugin_processes="yes"
6174 fi
6175
6176 # Solaris
6177 if test "x$with_kstat" = "xyes"
6178 then
6179         plugin_nfs="yes"
6180         plugin_processes="yes"
6181         plugin_uptime="yes"
6182         plugin_zfs_arc="yes"
6183         plugin_zone="yes"
6184 fi
6185
6186 if test "x$with_devinfo$with_kstat" = "xyesyes"
6187 then
6188         plugin_cpu="yes"
6189         plugin_disk="yes"
6190         plugin_interface="yes"
6191         plugin_memory="yes"
6192         plugin_tape="yes"
6193 fi
6194
6195 # libi2c-dev
6196 if test "x$ac_system" = "xLinux"
6197 then
6198 AC_CHECK_DECL(i2c_smbus_read_i2c_block_data,
6199         [with_libi2c="yes"],
6200         [with_libi2c="no (symbol i2c_smbus_read_i2c_block_data not found - have you installed libi2c-dev ?)"],
6201         [[#include <stdlib.h>
6202         #include <linux/i2c-dev.h>]])
6203 else
6204         with_libi2c="no (Linux only)"
6205 fi
6206
6207 if test "x$with_libi2c" = "xyes"
6208 then
6209         plugin_barometer="yes"
6210 fi
6211
6212
6213 # libstatgrab
6214 if test "x$with_libstatgrab" = "xyes"
6215 then
6216         plugin_cpu="yes"
6217         plugin_disk="yes"
6218         plugin_interface="yes"
6219         plugin_load="yes"
6220         plugin_memory="yes"
6221         plugin_swap="yes"
6222         plugin_users="yes"
6223 fi
6224
6225 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
6226 then
6227         plugin_ascent="yes"
6228         if test "x$have_strptime" = "xyes"
6229         then
6230                 plugin_bind="yes"
6231         fi
6232 fi
6233
6234 if test "x$with_libopenipmipthread" = "xyes"
6235 then
6236         plugin_ipmi="yes"
6237 fi
6238
6239 if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"
6240 then
6241         plugin_curl_json="yes"
6242 fi
6243
6244 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
6245 then
6246         plugin_curl_xml="yes"
6247 fi
6248
6249 if test "x$with_libyajl" = "xyes"
6250 then
6251         plugin_ceph="yes"
6252 fi
6253
6254 if test "x$have_processor_info" = "xyes"
6255 then
6256         plugin_cpu="yes"
6257 fi
6258 if test "x$have_sysctl" = "xyes"
6259 then
6260         plugin_cpu="yes"
6261         plugin_memory="yes"
6262         plugin_uptime="yes"
6263         if test "x$ac_system" = "xDarwin"
6264         then
6265                 plugin_swap="yes"
6266         fi
6267 fi
6268 if test "x$have_sysctlbyname" = "xyes"
6269 then
6270         plugin_contextswitch="yes"
6271         plugin_cpu="yes"
6272         plugin_memory="yes"
6273         plugin_tcpconns="yes"
6274 fi
6275
6276 # Df plugin: Check if we know how to determine mount points first.
6277 #if test "x$have_listmntent" = "xyes"; then
6278 #       plugin_df="yes"
6279 #fi
6280 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
6281 then
6282         plugin_df="yes"
6283 fi
6284 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
6285 then
6286         plugin_df="yes"
6287 fi
6288 #if test "x$have_getmntent" = "xseq"
6289 #then
6290 #       plugin_df="yes"
6291 #fi
6292 if test "x$c_cv_have_one_getmntent" = "xyes"
6293 then
6294         plugin_df="yes"
6295 fi
6296
6297 if test "x$c_cv_have_getmntent_r" = "xyes"
6298 then
6299         plugin_df="yes"
6300 fi
6301
6302 # Df plugin: Check if we have either `statfs' or `statvfs' second.
6303 if test "x$plugin_df" = "xyes"
6304 then
6305         plugin_df="no"
6306         if test "x$have_statfs" = "xyes"
6307         then
6308                 plugin_df="yes"
6309         fi
6310         if test "x$have_statvfs" = "xyes"
6311         then
6312                 plugin_df="yes"
6313         fi
6314 fi
6315
6316 if test "x$have_linux_sockios_h$have_linux_ethtool_h" = "xyesyes"
6317 then
6318         plugin_ethstat="yes"
6319 fi
6320
6321 if test "x$with_libgrpcpp" = "xyes" && test "x$with_libprotobuf" = "xyes" && test "x$have_protoc3" = "xyes" && test "x$GRPC_CPP_PLUGIN" != "x"
6322 then
6323         plugin_grpc="yes"
6324 fi
6325
6326 if test "x$have_getifaddrs" = "xyes"
6327 then
6328         plugin_interface="yes"
6329 fi
6330
6331 if test "x$with_libgps" = "xyes"
6332 then
6333         plugin_gps="yes"
6334 fi
6335
6336 if test "x$have_getloadavg" = "xyes"
6337 then
6338         plugin_load="yes"
6339 fi
6340
6341 if test "x$with_libyajl" = "xyes"
6342 then
6343         plugin_log_logstash="yes"
6344 fi
6345
6346 if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
6347 then
6348         plugin_perl="yes"
6349 fi
6350
6351 if test "x$have_protoc_c" = "xyes" && test "x$with_libprotobuf_c" = "xyes"
6352 then
6353         plugin_pinba="yes"
6354         if test "x$with_libmicrohttpd" = "xyes"
6355         then
6356                 plugin_write_prometheus="yes"
6357         fi
6358 fi
6359
6360 # Mac OS X memory interface
6361 if test "x$have_host_statistics" = "xyes"
6362 then
6363         plugin_memory="yes"
6364 fi
6365
6366 if test "x$have_termios_h" = "xyes"
6367 then
6368         if test "x$ac_system" != "xAIX"
6369         then
6370                 plugin_multimeter="yes"
6371         fi
6372         plugin_ted="yes"
6373 fi
6374
6375 if test "x$have_thread_info" = "xyes"
6376 then
6377         plugin_processes="yes"
6378 fi
6379
6380 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
6381 then
6382         plugin_processes="yes"
6383 fi
6384
6385 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_openbsd" = "xyes"
6386 then
6387         plugin_processes="yes"
6388 fi
6389
6390 if test "x$with_libpython" != "xno"
6391 then
6392         plugin_python="yes"
6393 fi
6394
6395 if test "x$with_libatasmart" = "xyes" && test "x$with_libudev" = "xyes"
6396 then
6397         plugin_smart="yes"
6398 fi
6399
6400 if test "x$with_kvm_getswapinfo" = "xyes"
6401 then
6402         plugin_swap="yes"
6403 fi
6404
6405 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"
6406 then
6407         plugin_swap="yes"
6408 fi
6409
6410 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_three_args" = "xyes"
6411 then
6412         plugin_swap="yes"
6413 fi
6414
6415 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
6416 then
6417         plugin_tcpconns="yes"
6418 fi
6419
6420 if test "x$have_getutent" = "xyes"
6421 then
6422         plugin_users="yes"
6423 fi
6424 if test "x$have_getutxent" = "xyes"
6425 then
6426         plugin_users="yes"
6427 fi
6428
6429 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
6430 then
6431         plugin_virt="yes"
6432 fi
6433
6434 if test "x$with_libxenctrl" = "xyes"
6435 then
6436   plugin_xencpu="yes"
6437 fi
6438
6439 if test "x$with_libdpdk" = "xyes"
6440 then
6441   plugin_dpdkstat="yes"
6442 fi
6443
6444 m4_divert_once([HELP_ENABLE], [
6445 collectd plugins:])
6446
6447 AC_ARG_ENABLE([all-plugins],
6448                 AS_HELP_STRING([--enable-all-plugins],[enable all plugins (auto by def)]),
6449                 [
6450                  if test "x$enableval" = "xyes"
6451                  then
6452                          enable_all_plugins="yes"
6453                  else if test "x$enableval" = "xauto"
6454                  then
6455                          enable_all_plugins="auto"
6456                  else
6457                          enable_all_plugins="no"
6458                  fi; fi
6459                 ],
6460                 [enable_all_plugins="auto"])
6461
6462 m4_divert_once([HELP_ENABLE], [])
6463
6464 AC_PLUGIN([aggregation],         [yes],                     [Aggregation plugin])
6465 AC_PLUGIN([amqp],                [$with_librabbitmq],       [AMQP output plugin])
6466 AC_PLUGIN([apache],              [$with_libcurl],           [Apache httpd statistics])
6467 AC_PLUGIN([apcups],              [yes],                     [Statistics of UPSes by APC])
6468 AC_PLUGIN([apple_sensors],       [$with_libiokit],          [Apple hardware sensors])
6469 AC_PLUGIN([aquaero],             [$with_libaquaero5],       [Aquaero hardware sensors])
6470 AC_PLUGIN([ascent],              [$plugin_ascent],          [AscentEmu player statistics])
6471 AC_PLUGIN([barometer],           [$plugin_barometer],       [Barometer sensor on I2C])
6472 AC_PLUGIN([battery],             [$plugin_battery],         [Battery statistics])
6473 AC_PLUGIN([bind],                [$plugin_bind],            [ISC Bind nameserver statistics])
6474 AC_PLUGIN([ceph],                [$plugin_ceph],            [Ceph daemon statistics])
6475 AC_PLUGIN([cgroups],             [$plugin_cgroups],         [CGroups CPU usage accounting])
6476 AC_PLUGIN([chrony],              [yes],                     [Chrony statistics])
6477 AC_PLUGIN([conntrack],           [$plugin_conntrack],       [nf_conntrack statistics])
6478 AC_PLUGIN([contextswitch],       [$plugin_contextswitch],   [context switch statistics])
6479 AC_PLUGIN([cpu],                 [$plugin_cpu],             [CPU usage statistics])
6480 AC_PLUGIN([cpufreq],             [$plugin_cpufreq],         [CPU frequency statistics])
6481 AC_PLUGIN([cpusleep],            [$plugin_cpusleep],        [CPU sleep statistics])
6482 AC_PLUGIN([csv],                 [yes],                     [CSV output plugin])
6483 AC_PLUGIN([curl],                [$with_libcurl],           [CURL generic web statistics])
6484 AC_PLUGIN([curl_json],           [$plugin_curl_json],       [CouchDB statistics])
6485 AC_PLUGIN([curl_xml],            [$plugin_curl_xml],        [CURL generic xml statistics])
6486 AC_PLUGIN([dbi],                 [$with_libdbi],            [General database statistics])
6487 AC_PLUGIN([df],                  [$plugin_df],              [Filesystem usage statistics])
6488 AC_PLUGIN([disk],                [$plugin_disk],            [Disk usage statistics])
6489 AC_PLUGIN([dns],                 [$with_libpcap],           [DNS traffic analysis])
6490 AC_PLUGIN([dpdkstat],            [$plugin_dpdkstat],        [Stats & Status from DPDK])
6491 AC_PLUGIN([drbd],                [$plugin_drbd],            [DRBD statistics])
6492 AC_PLUGIN([email],               [yes],                     [EMail statistics])
6493 AC_PLUGIN([entropy],             [$plugin_entropy],         [Entropy statistics])
6494 AC_PLUGIN([ethstat],             [$plugin_ethstat],         [Stats from NIC driver])
6495 AC_PLUGIN([exec],                [yes],                     [Execution of external programs])
6496 AC_PLUGIN([fhcount],             [$plugin_fhcount],         [File handles statistics])
6497 AC_PLUGIN([filecount],           [yes],                     [Count files in directories])
6498 AC_PLUGIN([fscache],             [$plugin_fscache],         [fscache statistics])
6499 AC_PLUGIN([gmond],               [$with_libganglia],        [Ganglia plugin])
6500 AC_PLUGIN([gps],                 [$plugin_gps],             [GPS plugin])
6501 AC_PLUGIN([grpc],                [$plugin_grpc],            [gRPC plugin])
6502 AC_PLUGIN([hddtemp],             [yes],                     [Query hddtempd])
6503 AC_PLUGIN([hugepages],           [$plugin_hugepages],       [Hugepages statistics])
6504 AC_PLUGIN([intel_rdt],           [$with_libpqos],           [Intel RDT monitor plugin])
6505 AC_PLUGIN([interface],           [$plugin_interface],       [Interface traffic statistics])
6506 AC_PLUGIN([ipc],                 [$plugin_ipc],             [IPC statistics])
6507 AC_PLUGIN([ipmi],                [$plugin_ipmi],            [IPMI sensor statistics])
6508 AC_PLUGIN([iptables],            [$with_libiptc],           [IPTables rule counters])
6509 AC_PLUGIN([ipvs],                [$plugin_ipvs],            [IPVS connection statistics])
6510 AC_PLUGIN([irq],                 [$plugin_irq],             [IRQ statistics])
6511 AC_PLUGIN([java],                [$with_java],              [Embed the Java Virtual Machine])
6512 AC_PLUGIN([load],                [$plugin_load],            [System load])
6513 AC_PLUGIN([log_logstash],        [$plugin_log_logstash],    [Logstash json_event compatible logging])
6514 AC_PLUGIN([logfile],             [yes],                     [File logging plugin])
6515 AC_PLUGIN([lpar],                [$with_perfstat],          [AIX logical partitions statistics])
6516 AC_PLUGIN([lua],                 [$with_liblua],            [Lua plugin])
6517 AC_PLUGIN([lvm],                 [$with_liblvm2app],        [LVM statistics])
6518 AC_PLUGIN([madwifi],             [$have_linux_wireless_h],  [Madwifi wireless statistics])
6519 AC_PLUGIN([match_empty_counter], [yes],                     [The empty counter match])
6520 AC_PLUGIN([match_hashed],        [yes],                     [The hashed match])
6521 AC_PLUGIN([match_regex],         [yes],                     [The regex match])
6522 AC_PLUGIN([match_timediff],      [yes],                     [The timediff match])
6523 AC_PLUGIN([match_value],         [yes],                     [The value match])
6524 AC_PLUGIN([mbmon],               [yes],                     [Query mbmond])
6525 AC_PLUGIN([md],                  [$have_linux_raid_md_u_h], [md (Linux software RAID) devices])
6526 AC_PLUGIN([memcachec],           [$with_libmemcached],      [memcachec statistics])
6527 AC_PLUGIN([memcached],           [yes],                     [memcached statistics])
6528 AC_PLUGIN([memory],              [$plugin_memory],          [Memory usage])
6529 AC_PLUGIN([mic],                 [$with_mic],               [Intel Many Integrated Core stats])
6530 AC_PLUGIN([modbus],              [$with_libmodbus],         [Modbus plugin])
6531 AC_PLUGIN([mqtt],                [$with_libmosquitto],      [MQTT output plugin])
6532 AC_PLUGIN([multimeter],          [$plugin_multimeter],      [Read multimeter values])
6533 AC_PLUGIN([mysql],               [$with_libmysql],          [MySQL statistics])
6534 AC_PLUGIN([netapp],              [$with_libnetapp],         [NetApp plugin])
6535 AC_PLUGIN([netlink],             [$with_libmnl],            [Enhanced Linux network statistics])
6536 AC_PLUGIN([network],             [yes],                     [Network communication plugin])
6537 AC_PLUGIN([nfs],                 [$plugin_nfs],             [NFS statistics])
6538 AC_PLUGIN([nginx],               [$with_libcurl],           [nginx statistics])
6539 AC_PLUGIN([notify_desktop],      [$with_libnotify],         [Desktop notifications])
6540 AC_PLUGIN([notify_email],        [$with_libesmtp],          [Email notifier])
6541 AC_PLUGIN([notify_nagios],       [yes],                     [Nagios notification plugin])
6542 AC_PLUGIN([ntpd],                [yes],                     [NTPd statistics])
6543 AC_PLUGIN([numa],                [$plugin_numa],            [NUMA virtual memory statistics])
6544 AC_PLUGIN([nut],                 [$with_libupsclient],      [Network UPS tools statistics])
6545 AC_PLUGIN([olsrd],               [yes],                     [olsrd statistics])
6546 AC_PLUGIN([onewire],             [$with_libowcapi],         [OneWire sensor statistics])
6547 AC_PLUGIN([openldap],            [$with_libldap],           [OpenLDAP statistics])
6548 AC_PLUGIN([openvpn],             [yes],                     [OpenVPN client statistics])
6549 AC_PLUGIN([oracle],              [$with_oracle],            [Oracle plugin])
6550 AC_PLUGIN([perl],                [$plugin_perl],            [Embed a Perl interpreter])
6551 AC_PLUGIN([pf],                  [$have_net_pfvar_h],       [BSD packet filter (PF) statistics])
6552 # FIXME: Check for libevent, too.
6553 AC_PLUGIN([pinba],               [$plugin_pinba],           [Pinba statistics])
6554 AC_PLUGIN([ping],                [$with_liboping],          [Network latency statistics])
6555 AC_PLUGIN([postgresql],          [$with_libpq],             [PostgreSQL database statistics])
6556 AC_PLUGIN([powerdns],            [yes],                     [PowerDNS statistics])
6557 AC_PLUGIN([processes],           [$plugin_processes],       [Process statistics])
6558 AC_PLUGIN([protocols],           [$plugin_protocols],       [Protocol (IP, TCP, ...) statistics])
6559 AC_PLUGIN([python],              [$plugin_python],          [Embed a Python interpreter])
6560 AC_PLUGIN([redis],               [$with_libhiredis],        [Redis plugin])
6561 AC_PLUGIN([routeros],            [$with_librouteros],       [RouterOS plugin])
6562 AC_PLUGIN([rrdcached],           [$librrd_rrdc_update],     [RRDTool output plugin])
6563 AC_PLUGIN([rrdtool],             [$with_librrd],            [RRDTool output plugin])
6564 AC_PLUGIN([sensors],             [$with_libsensors],        [lm_sensors statistics])
6565 AC_PLUGIN([serial],              [$plugin_serial],          [serial port traffic])
6566 AC_PLUGIN([sigrok],              [$with_libsigrok],         [sigrok acquisition sources])
6567 AC_PLUGIN([smart],               [$plugin_smart],           [SMART statistics])
6568 AC_PLUGIN([snmp],                [$with_libnetsnmp],        [SNMP querying plugin])
6569 AC_PLUGIN([statsd],              [yes],                     [StatsD plugin])
6570 AC_PLUGIN([swap],                [$plugin_swap],            [Swap usage statistics])
6571 AC_PLUGIN([syslog],              [$have_syslog],            [Syslog logging plugin])
6572 AC_PLUGIN([table],               [yes],                     [Parsing of tabular data])
6573 AC_PLUGIN([tail],                [yes],                     [Parsing of logfiles])
6574 AC_PLUGIN([tail_csv],            [yes],                     [Parsing of CSV files])
6575 AC_PLUGIN([tape],                [$plugin_tape],            [Tape drive statistics])
6576 AC_PLUGIN([target_notification], [yes],                     [The notification target])
6577 AC_PLUGIN([target_replace],      [yes],                     [The replace target])
6578 AC_PLUGIN([target_scale],        [yes],                     [The scale target])
6579 AC_PLUGIN([target_set],          [yes],                     [The set target])
6580 AC_PLUGIN([target_v5upgrade],    [yes],                     [The v5upgrade target])
6581 AC_PLUGIN([tcpconns],            [$plugin_tcpconns],        [TCP connection statistics])
6582 AC_PLUGIN([teamspeak2],          [yes],                     [TeamSpeak2 server statistics])
6583 AC_PLUGIN([ted],                 [$plugin_ted],             [Read The Energy Detective values])
6584 AC_PLUGIN([thermal],             [$plugin_thermal],         [Linux ACPI thermal zone statistics])
6585 AC_PLUGIN([threshold],           [yes],                     [Threshold checking plugin])
6586 AC_PLUGIN([tokyotyrant],         [$with_libtokyotyrant],    [TokyoTyrant database statistics])
6587 AC_PLUGIN([turbostat],           [$plugin_turbostat],       [Advanced statistic on Intel cpu states])
6588 AC_PLUGIN([unixsock],            [yes],                     [Unixsock communication plugin])
6589 AC_PLUGIN([uptime],              [$plugin_uptime],          [Uptime statistics])
6590 AC_PLUGIN([users],               [$plugin_users],           [User statistics])
6591 AC_PLUGIN([uuid],                [yes],                     [UUID as hostname plugin])
6592 AC_PLUGIN([varnish],             [$with_libvarnish],        [Varnish cache statistics])
6593 AC_PLUGIN([virt],                [$plugin_virt],            [Virtual machine statistics])
6594 AC_PLUGIN([vmem],                [$plugin_vmem],            [Virtual memory statistics])
6595 AC_PLUGIN([vserver],             [$plugin_vserver],         [Linux VServer statistics])
6596 AC_PLUGIN([wireless],            [$plugin_wireless],        [Wireless statistics])
6597 AC_PLUGIN([write_graphite],      [yes],                     [Graphite / Carbon output plugin])
6598 AC_PLUGIN([write_http],          [$with_libcurl],           [HTTP output plugin])
6599 AC_PLUGIN([write_kafka],         [$with_librdkafka],        [Kafka output plugin])
6600 AC_PLUGIN([write_log],           [yes],                     [Log output plugin])
6601 AC_PLUGIN([write_mongodb],       [$with_libmongoc],         [MongoDB output plugin])
6602 AC_PLUGIN([write_prometheus],    [$plugin_write_prometheus], [Prometheus write plugin])
6603 AC_PLUGIN([write_redis],         [$with_libhiredis],        [Redis output plugin])
6604 AC_PLUGIN([write_riemann],       [$with_libriemann_client], [Riemann output plugin])
6605 AC_PLUGIN([write_sensu],         [yes],                     [Sensu output plugin])
6606 AC_PLUGIN([write_tsdb],          [yes],                     [TSDB output plugin])
6607 AC_PLUGIN([xencpu],              [$plugin_xencpu],          [Xen Host CPU usage])
6608 AC_PLUGIN([xmms],                [$with_libxmms],           [XMMS statistics])
6609 AC_PLUGIN([zfs_arc],             [$plugin_zfs_arc],         [ZFS ARC statistics])
6610 AC_PLUGIN([zone],                [$plugin_zone],            [Solaris container statistics])
6611 AC_PLUGIN([zookeeper],           [yes],                     [Zookeeper statistics])
6612
6613 dnl Default configuration file
6614 # Load either syslog or logfile
6615 LOAD_PLUGIN_SYSLOG=""
6616 LOAD_PLUGIN_LOGFILE=""
6617 LOAD_PLUGIN_LOG_LOGSTASH=""
6618
6619 AC_MSG_CHECKING([which default log plugin to load])
6620 default_log_plugin="none"
6621 if test "x$enable_syslog" = "xyes"
6622 then
6623         default_log_plugin="syslog"
6624 else
6625         LOAD_PLUGIN_SYSLOG="##"
6626 fi
6627
6628 if test "x$enable_logfile" = "xyes"
6629 then
6630         if test "x$default_log_plugin" = "xnone"
6631         then
6632                 default_log_plugin="logfile"
6633         else
6634                 LOAD_PLUGIN_LOGFILE="#"
6635         fi
6636 else
6637         LOAD_PLUGIN_LOGFILE="##"
6638 fi
6639
6640 if test "x$enable_log_logstash" = "xyes"
6641 then
6642   LOAD_PLUGIN_LOG_LOGSTASH="#"
6643 else
6644   LOAD_PLUGIN_LOG_LOGSTASH="##"
6645 fi
6646
6647
6648 AC_MSG_RESULT([$default_log_plugin])
6649
6650 AC_SUBST(LOAD_PLUGIN_SYSLOG)
6651 AC_SUBST(LOAD_PLUGIN_LOGFILE)
6652 AC_SUBST(LOAD_PLUGIN_LOG_LOGSTASH)
6653
6654 DEFAULT_LOG_LEVEL="info"
6655 if test "x$enable_debug" = "xyes"
6656 then
6657         DEFAULT_LOG_LEVEL="debug"
6658 fi
6659 AC_SUBST(DEFAULT_LOG_LEVEL)
6660
6661 # Load only one of rrdtool, network, csv in the default config.
6662 LOAD_PLUGIN_RRDTOOL=""
6663 LOAD_PLUGIN_NETWORK=""
6664 LOAD_PLUGIN_CSV=""
6665
6666 AC_MSG_CHECKING([which default write plugin to load])
6667 default_write_plugin="none"
6668 if test "x$enable_rrdtool" = "xyes"
6669 then
6670         default_write_plugin="rrdtool"
6671 else
6672         LOAD_PLUGIN_RRDTOOL="##"
6673 fi
6674
6675 if test "x$enable_network" = "xyes"
6676 then
6677         if test "x$default_write_plugin" = "xnone"
6678         then
6679                 default_write_plugin="network"
6680         else
6681                 LOAD_PLUGIN_NETWORK="#"
6682         fi
6683 else
6684         LOAD_PLUGIN_NETWORK="##"
6685 fi
6686
6687 if test "x$enable_csv" = "xyes"
6688 then
6689         if test "x$default_write_plugin" = "xnone"
6690         then
6691                 default_write_plugin="csv"
6692         else
6693                 LOAD_PLUGIN_CSV="#"
6694         fi
6695 else
6696         LOAD_PLUGIN_CSV="##"
6697 fi
6698 AC_MSG_RESULT([$default_write_plugin])
6699
6700 AC_SUBST(LOAD_PLUGIN_RRDTOOL)
6701 AC_SUBST(LOAD_PLUGIN_NETWORK)
6702 AC_SUBST(LOAD_PLUGIN_CSV)
6703
6704 dnl ip_vs.h
6705 if test "x$ac_system" = "xLinux" \
6706         && test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono"
6707 then
6708         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
6709 fi
6710
6711 if test "x$ip_vs_h_needs_kernel_cflags" = "xyes"
6712 then
6713         enable_ipvs="$enable_ipvs (needs $KERNEL_CFLAGS)"
6714 fi
6715
6716 dnl Perl bindings
6717 PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
6718 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
6719 [
6720         if test "x$withval" != "xno" && test "x$withval" != "xyes"
6721         then
6722                 PERL_BINDINGS_OPTIONS="$withval"
6723                 with_perl_bindings="yes"
6724         else
6725                 with_perl_bindings="$withval"
6726         fi
6727 ],
6728 [
6729         if test -n "$perl_interpreter"
6730         then
6731                 with_perl_bindings="yes"
6732         else
6733                 with_perl_bindings="no (no perl interpreter found)"
6734         fi
6735 ])
6736
6737 if test "x$with_perl_bindings" = "xyes"
6738 then
6739         AC_MSG_CHECKING([for the ExtUtils::MakeMaker module])
6740         if $PERL -MExtUtils::MakeMaker -e '' 2>/dev/null; then
6741                 AC_MSG_RESULT([yes])
6742         else
6743                 AC_MSG_RESULT([no])
6744                 with_perl_bindings="no (ExtUtils::MakeMaker not found)"
6745         fi
6746 fi
6747
6748 if test "x$with_perl_bindings" = "xyes"
6749 then
6750         PERL_BINDINGS="perl"
6751 else
6752         PERL_BINDINGS=""
6753 fi
6754 AC_SUBST(PERL_BINDINGS)
6755 AC_SUBST(PERL_BINDINGS_OPTIONS)
6756
6757 dnl libcollectdclient
6758 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
6759 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
6760 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
6761
6762 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
6763
6764 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
6765
6766 AC_SUBST(LCC_VERSION_MAJOR)
6767 AC_SUBST(LCC_VERSION_MINOR)
6768 AC_SUBST(LCC_VERSION_PATCH)
6769 AC_SUBST(LCC_VERSION_EXTRA)
6770 AC_SUBST(LCC_VERSION_STRING)
6771
6772 AC_CONFIG_FILES(src/libcollectdclient/collectd/lcc_features.h)
6773
6774 AM_CFLAGS="-Wall"
6775 AM_CXXFLAGS="-Wall"
6776 if test "x$enable_werror" != "xno"
6777 then
6778         AM_CFLAGS="$AM_CFLAGS -Werror"
6779         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
6780 fi
6781 AC_SUBST([AM_CFLAGS])
6782 AC_SUBST([AM_CXXFLAGS])
6783
6784 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])
6785 AC_OUTPUT
6786
6787 if test "x$with_librrd" = "xyes" \
6788         && test "x$librrd_threadsafe" != "xyes"
6789 then
6790         with_librrd="yes (warning: librrd is not thread-safe)"
6791 fi
6792
6793 if test "x$with_libperl" = "xyes"
6794 then
6795         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
6796 else
6797         enable_perl="no (needs libperl)"
6798 fi
6799
6800 if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"
6801 then
6802         enable_perl="no (libperl doesn't support ithreads)"
6803 fi
6804
6805 if test "x$with_perl_bindings" = "xyes" \
6806         && test "x$PERL_BINDINGS_OPTIONS" != "x"
6807 then
6808         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
6809 fi
6810
6811 AC_MSG_RESULT()
6812 AC_MSG_RESULT([Configuration:])
6813 AC_MSG_RESULT([  Build:])
6814 AC_MSG_RESULT([    Platform  . . . . . . $ac_system])
6815 AC_MSG_RESULT([    CC  . . . . . . . . . $CC])
6816 AC_MSG_RESULT([    CFLAGS  . . . . . . . $AM_CFLAGS $CFLAGS])
6817 AC_MSG_RESULT([    CXXFLAGS  . . . . . . $AM_CXXFLAGS $CXXFLAGS])
6818 AC_MSG_RESULT([    CPP . . . . . . . . . $CPP])
6819 AC_MSG_RESULT([    CPPFLAGS  . . . . . . $CPPFLAGS])
6820 AC_MSG_RESULT([    GRPC_CPP_PLUGIN . . . $GRPC_CPP_PLUGIN])
6821 AC_MSG_RESULT([    LD  . . . . . . . . . $LD])
6822 AC_MSG_RESULT([    LDFLAGS . . . . . . . $LDFLAGS])
6823 AC_MSG_RESULT([    PROTOC  . . . . . . . $PROTOC])
6824 AC_MSG_RESULT([    YACC  . . . . . . . . $YACC])
6825 AC_MSG_RESULT([    YFLAGS  . . . . . . . $YFLAGS])
6826 AC_MSG_RESULT()
6827 AC_MSG_RESULT([  Libraries:])
6828 AC_MSG_RESULT([    intel mic . . . . . . $with_mic])
6829 AC_MSG_RESULT([    libaquaero5 . . . . . $with_libaquaero5])
6830 AC_MSG_RESULT([    libatasmart . . . . . $with_libatasmart])
6831 AC_MSG_RESULT([    libcurl . . . . . . . $with_libcurl])
6832 AC_MSG_RESULT([    libdbi  . . . . . . . $with_libdbi])
6833 AC_MSG_RESULT([    libdpdk . . . . . . . $with_libdpdk])
6834 AC_MSG_RESULT([    libesmtp  . . . . . . $with_libesmtp])
6835 AC_MSG_RESULT([    libganglia  . . . . . $with_libganglia])
6836 AC_MSG_RESULT([    libgcrypt . . . . . . $with_libgcrypt])
6837 AC_MSG_RESULT([    libgps  . . . . . . . $with_libgps])
6838 AC_MSG_RESULT([    libgrpc++ . . . . . . $with_libgrpcpp])
6839 AC_MSG_RESULT([    libhal  . . . . . . . $with_libhal])
6840 AC_MSG_RESULT([    libhiredis  . . . . . $with_libhiredis])
6841 AC_MSG_RESULT([    libi2c-dev  . . . . . $with_libi2c])
6842 AC_MSG_RESULT([    libiokit  . . . . . . $with_libiokit])
6843 AC_MSG_RESULT([    libiptc . . . . . . . $with_libiptc])
6844 AC_MSG_RESULT([    libjvm  . . . . . . . $with_java])
6845 AC_MSG_RESULT([    libkstat  . . . . . . $with_kstat])
6846 AC_MSG_RESULT([    libkvm  . . . . . . . $with_libkvm])
6847 AC_MSG_RESULT([    libldap . . . . . . . $with_libldap])
6848 AC_MSG_RESULT([    liblua  . . . . . . . $with_liblua])
6849 AC_MSG_RESULT([    liblvm2app  . . . . . $with_liblvm2app])
6850 AC_MSG_RESULT([    libmemcached  . . . . $with_libmemcached])
6851 AC_MSG_RESULT([    libmicrohttpd . . . . $with_libmicrohttpd])
6852 AC_MSG_RESULT([    libmnl  . . . . . . . $with_libmnl])
6853 AC_MSG_RESULT([    libmodbus . . . . . . $with_libmodbus])
6854 AC_MSG_RESULT([    libmongoc . . . . . . $with_libmongoc])
6855 AC_MSG_RESULT([    libmosquitto  . . . . $with_libmosquitto])
6856 AC_MSG_RESULT([    libmysql  . . . . . . $with_libmysql])
6857 AC_MSG_RESULT([    libnetapp . . . . . . $with_libnetapp])
6858 AC_MSG_RESULT([    libnetsnmp  . . . . . $with_libnetsnmp])
6859 AC_MSG_RESULT([    libnotify . . . . . . $with_libnotify])
6860 AC_MSG_RESULT([    liboconfig  . . . . . $with_liboconfig])
6861 AC_MSG_RESULT([    libopenipmi . . . . . $with_libopenipmipthread])
6862 AC_MSG_RESULT([    liboping  . . . . . . $with_liboping])
6863 AC_MSG_RESULT([    libowcapi . . . . . . $with_libowcapi])
6864 AC_MSG_RESULT([    libpcap . . . . . . . $with_libpcap])
6865 AC_MSG_RESULT([    libperfstat . . . . . $with_perfstat])
6866 AC_MSG_RESULT([    libperl . . . . . . . $with_libperl])
6867 AC_MSG_RESULT([    libpq . . . . . . . . $with_libpq])
6868 AC_MSG_RESULT([    libpqos . . . . . . . $with_libpqos])
6869 AC_MSG_RESULT([    libprotobuf . . . . . $with_libprotobuf])
6870 AC_MSG_RESULT([    libprotobuf-c . . . . $with_libprotobuf_c])
6871 AC_MSG_RESULT([    libpython . . . . . . $with_libpython])
6872 AC_MSG_RESULT([    librabbitmq . . . . . $with_librabbitmq])
6873 AC_MSG_RESULT([    libriemann-client . . $with_libriemann_client])
6874 AC_MSG_RESULT([    librdkafka  . . . . . $with_librdkafka])
6875 AC_MSG_RESULT([    librouteros . . . . . $with_librouteros])
6876 AC_MSG_RESULT([    librrd  . . . . . . . $with_librrd])
6877 AC_MSG_RESULT([    libsensors  . . . . . $with_libsensors])
6878 AC_MSG_RESULT([    libsigrok   . . . . . $with_libsigrok])
6879 AC_MSG_RESULT([    libstatgrab . . . . . $with_libstatgrab])
6880 AC_MSG_RESULT([    libtokyotyrant  . . . $with_libtokyotyrant])
6881 AC_MSG_RESULT([    libudev . . . . . . . $with_libudev])
6882 AC_MSG_RESULT([    libupsclient  . . . . $with_libupsclient])
6883 AC_MSG_RESULT([    libvarnish  . . . . . $with_libvarnish])
6884 AC_MSG_RESULT([    libvirt . . . . . . . $with_libvirt])
6885 AC_MSG_RESULT([    libxenctrl  . . . . . $with_libxenctrl])
6886 AC_MSG_RESULT([    libxml2 . . . . . . . $with_libxml2])
6887 AC_MSG_RESULT([    libxmms . . . . . . . $with_libxmms])
6888 AC_MSG_RESULT([    libyajl . . . . . . . $with_libyajl])
6889 AC_MSG_RESULT([    oracle  . . . . . . . $with_oracle])
6890 AC_MSG_RESULT([    protobuf-c  . . . . . $have_protoc_c])
6891 AC_MSG_RESULT([    protoc 3  . . . . . . $have_protoc3])
6892 AC_MSG_RESULT()
6893 AC_MSG_RESULT([  Features:])
6894 AC_MSG_RESULT([    daemon mode . . . . . $enable_daemon])
6895 AC_MSG_RESULT([    debug . . . . . . . . $enable_debug])
6896 AC_MSG_RESULT()
6897 AC_MSG_RESULT([  Bindings:])
6898 AC_MSG_RESULT([    perl  . . . . . . . . $with_perl_bindings])
6899 AC_MSG_RESULT()
6900 AC_MSG_RESULT([  Modules:])
6901 AC_MSG_RESULT([    aggregation . . . . . $enable_aggregation])
6902 AC_MSG_RESULT([    amqp    . . . . . . . $enable_amqp])
6903 AC_MSG_RESULT([    apache  . . . . . . . $enable_apache])
6904 AC_MSG_RESULT([    apcups  . . . . . . . $enable_apcups])
6905 AC_MSG_RESULT([    apple_sensors . . . . $enable_apple_sensors])
6906 AC_MSG_RESULT([    aquaero . . . . . . . $enable_aquaero])
6907 AC_MSG_RESULT([    ascent  . . . . . . . $enable_ascent])
6908 AC_MSG_RESULT([    barometer . . . . . . $enable_barometer])
6909 AC_MSG_RESULT([    battery . . . . . . . $enable_battery])
6910 AC_MSG_RESULT([    bind  . . . . . . . . $enable_bind])
6911 AC_MSG_RESULT([    ceph  . . . . . . . . $enable_ceph])
6912 AC_MSG_RESULT([    cgroups . . . . . . . $enable_cgroups])
6913 AC_MSG_RESULT([    chrony. . . . . . . . $enable_chrony])
6914 AC_MSG_RESULT([    conntrack . . . . . . $enable_conntrack])
6915 AC_MSG_RESULT([    contextswitch . . . . $enable_contextswitch])
6916 AC_MSG_RESULT([    cpu . . . . . . . . . $enable_cpu])
6917 AC_MSG_RESULT([    cpufreq . . . . . . . $enable_cpufreq])
6918 AC_MSG_RESULT([    cpusleep  . . . . . . $enable_cpusleep])
6919 AC_MSG_RESULT([    csv . . . . . . . . . $enable_csv])
6920 AC_MSG_RESULT([    curl  . . . . . . . . $enable_curl])
6921 AC_MSG_RESULT([    curl_json . . . . . . $enable_curl_json])
6922 AC_MSG_RESULT([    curl_xml  . . . . . . $enable_curl_xml])
6923 AC_MSG_RESULT([    dbi . . . . . . . . . $enable_dbi])
6924 AC_MSG_RESULT([    df  . . . . . . . . . $enable_df])
6925 AC_MSG_RESULT([    disk  . . . . . . . . $enable_disk])
6926 AC_MSG_RESULT([    dns . . . . . . . . . $enable_dns])
6927 AC_MSG_RESULT([    dpdkstat  . . . . . . $enable_dpdkstat])
6928 AC_MSG_RESULT([    drbd  . . . . . . . . $enable_drbd])
6929 AC_MSG_RESULT([    email . . . . . . . . $enable_email])
6930 AC_MSG_RESULT([    entropy . . . . . . . $enable_entropy])
6931 AC_MSG_RESULT([    ethstat . . . . . . . $enable_ethstat])
6932 AC_MSG_RESULT([    exec  . . . . . . . . $enable_exec])
6933 AC_MSG_RESULT([    fhcount . . . . . . . $enable_fhcount])
6934 AC_MSG_RESULT([    filecount . . . . . . $enable_filecount])
6935 AC_MSG_RESULT([    fscache . . . . . . . $enable_fscache])
6936 AC_MSG_RESULT([    gmond . . . . . . . . $enable_gmond])
6937 AC_MSG_RESULT([    gps . . . . . . . . . $enable_gps])
6938 AC_MSG_RESULT([    grpc  . . . . . . . . $enable_grpc])
6939 AC_MSG_RESULT([    hddtemp . . . . . . . $enable_hddtemp])
6940 AC_MSG_RESULT([    hugepages . . . . . . $enable_hugepages])
6941 AC_MSG_RESULT([    intel_rdt. . . . .  . $enable_intel_rdt])
6942 AC_MSG_RESULT([    interface . . . . . . $enable_interface])
6943 AC_MSG_RESULT([    ipc . . . . . . . . . $enable_ipc])
6944 AC_MSG_RESULT([    ipmi  . . . . . . . . $enable_ipmi])
6945 AC_MSG_RESULT([    iptables  . . . . . . $enable_iptables])
6946 AC_MSG_RESULT([    ipvs  . . . . . . . . $enable_ipvs])
6947 AC_MSG_RESULT([    irq . . . . . . . . . $enable_irq])
6948 AC_MSG_RESULT([    java  . . . . . . . . $enable_java])
6949 AC_MSG_RESULT([    load  . . . . . . . . $enable_load])
6950 AC_MSG_RESULT([    logfile . . . . . . . $enable_logfile])
6951 AC_MSG_RESULT([    log_logstash  . . . . $enable_log_logstash])
6952 AC_MSG_RESULT([    lpar  . . . . . . . . $enable_lpar])
6953 AC_MSG_RESULT([    lua . . . . . . . . . $enable_lua])
6954 AC_MSG_RESULT([    lvm . . . . . . . . . $enable_lvm])
6955 AC_MSG_RESULT([    madwifi . . . . . . . $enable_madwifi])
6956 AC_MSG_RESULT([    match_empty_counter . $enable_match_empty_counter])
6957 AC_MSG_RESULT([    match_hashed  . . . . $enable_match_hashed])
6958 AC_MSG_RESULT([    match_regex . . . . . $enable_match_regex])
6959 AC_MSG_RESULT([    match_timediff  . . . $enable_match_timediff])
6960 AC_MSG_RESULT([    match_value . . . . . $enable_match_value])
6961 AC_MSG_RESULT([    mbmon . . . . . . . . $enable_mbmon])
6962 AC_MSG_RESULT([    md  . . . . . . . . . $enable_md])
6963 AC_MSG_RESULT([    memcachec . . . . . . $enable_memcachec])
6964 AC_MSG_RESULT([    memcached . . . . . . $enable_memcached])
6965 AC_MSG_RESULT([    memory  . . . . . . . $enable_memory])
6966 AC_MSG_RESULT([    mic . . . . . . . . . $enable_mic])
6967 AC_MSG_RESULT([    modbus  . . . . . . . $enable_modbus])
6968 AC_MSG_RESULT([    mqtt  . . . . . . . . $enable_mqtt])
6969 AC_MSG_RESULT([    multimeter  . . . . . $enable_multimeter])
6970 AC_MSG_RESULT([    mysql . . . . . . . . $enable_mysql])
6971 AC_MSG_RESULT([    netapp  . . . . . . . $enable_netapp])
6972 AC_MSG_RESULT([    netlink . . . . . . . $enable_netlink])
6973 AC_MSG_RESULT([    network . . . . . . . $enable_network])
6974 AC_MSG_RESULT([    nfs . . . . . . . . . $enable_nfs])
6975 AC_MSG_RESULT([    nginx . . . . . . . . $enable_nginx])
6976 AC_MSG_RESULT([    notify_desktop  . . . $enable_notify_desktop])
6977 AC_MSG_RESULT([    notify_email  . . . . $enable_notify_email])
6978 AC_MSG_RESULT([    notify_nagios . . . . $enable_notify_nagios])
6979 AC_MSG_RESULT([    ntpd  . . . . . . . . $enable_ntpd])
6980 AC_MSG_RESULT([    numa  . . . . . . . . $enable_numa])
6981 AC_MSG_RESULT([    nut . . . . . . . . . $enable_nut])
6982 AC_MSG_RESULT([    olsrd . . . . . . . . $enable_olsrd])
6983 AC_MSG_RESULT([    onewire . . . . . . . $enable_onewire])
6984 AC_MSG_RESULT([    openldap  . . . . . . $enable_openldap])
6985 AC_MSG_RESULT([    openvpn . . . . . . . $enable_openvpn])
6986 AC_MSG_RESULT([    oracle  . . . . . . . $enable_oracle])
6987 AC_MSG_RESULT([    perl  . . . . . . . . $enable_perl])
6988 AC_MSG_RESULT([    pf  . . . . . . . . . $enable_pf])
6989 AC_MSG_RESULT([    pinba . . . . . . . . $enable_pinba])
6990 AC_MSG_RESULT([    ping  . . . . . . . . $enable_ping])
6991 AC_MSG_RESULT([    postgresql  . . . . . $enable_postgresql])
6992 AC_MSG_RESULT([    powerdns  . . . . . . $enable_powerdns])
6993 AC_MSG_RESULT([    processes . . . . . . $enable_processes])
6994 AC_MSG_RESULT([    protocols . . . . . . $enable_protocols])
6995 AC_MSG_RESULT([    python  . . . . . . . $enable_python])
6996 AC_MSG_RESULT([    redis . . . . . . . . $enable_redis])
6997 AC_MSG_RESULT([    routeros  . . . . . . $enable_routeros])
6998 AC_MSG_RESULT([    rrdcached . . . . . . $enable_rrdcached])
6999 AC_MSG_RESULT([    rrdtool . . . . . . . $enable_rrdtool])
7000 AC_MSG_RESULT([    sensors . . . . . . . $enable_sensors])
7001 AC_MSG_RESULT([    serial  . . . . . . . $enable_serial])
7002 AC_MSG_RESULT([    sigrok  . . . . . . . $enable_sigrok])
7003 AC_MSG_RESULT([    smart . . . . . . . . $enable_smart])
7004 AC_MSG_RESULT([    snmp  . . . . . . . . $enable_snmp])
7005 AC_MSG_RESULT([    statsd  . . . . . . . $enable_statsd])
7006 AC_MSG_RESULT([    swap  . . . . . . . . $enable_swap])
7007 AC_MSG_RESULT([    syslog  . . . . . . . $enable_syslog])
7008 AC_MSG_RESULT([    table . . . . . . . . $enable_table])
7009 AC_MSG_RESULT([    tail_csv  . . . . . . $enable_tail_csv])
7010 AC_MSG_RESULT([    tail  . . . . . . . . $enable_tail])
7011 AC_MSG_RESULT([    tape  . . . . . . . . $enable_tape])
7012 AC_MSG_RESULT([    target_notification . $enable_target_notification])
7013 AC_MSG_RESULT([    target_replace  . . . $enable_target_replace])
7014 AC_MSG_RESULT([    target_scale  . . . . $enable_target_scale])
7015 AC_MSG_RESULT([    target_set  . . . . . $enable_target_set])
7016 AC_MSG_RESULT([    target_v5upgrade  . . $enable_target_v5upgrade])
7017 AC_MSG_RESULT([    tcpconns  . . . . . . $enable_tcpconns])
7018 AC_MSG_RESULT([    teamspeak2  . . . . . $enable_teamspeak2])
7019 AC_MSG_RESULT([    ted . . . . . . . . . $enable_ted])
7020 AC_MSG_RESULT([    thermal . . . . . . . $enable_thermal])
7021 AC_MSG_RESULT([    threshold . . . . . . $enable_threshold])
7022 AC_MSG_RESULT([    tokyotyrant . . . . . $enable_tokyotyrant])
7023 AC_MSG_RESULT([    turbostat . . . . . . $enable_turbostat])
7024 AC_MSG_RESULT([    unixsock  . . . . . . $enable_unixsock])
7025 AC_MSG_RESULT([    uptime  . . . . . . . $enable_uptime])
7026 AC_MSG_RESULT([    users . . . . . . . . $enable_users])
7027 AC_MSG_RESULT([    uuid  . . . . . . . . $enable_uuid])
7028 AC_MSG_RESULT([    varnish . . . . . . . $enable_varnish])
7029 AC_MSG_RESULT([    virt  . . . . . . . . $enable_virt])
7030 AC_MSG_RESULT([    vmem  . . . . . . . . $enable_vmem])
7031 AC_MSG_RESULT([    vserver . . . . . . . $enable_vserver])
7032 AC_MSG_RESULT([    wireless  . . . . . . $enable_wireless])
7033 AC_MSG_RESULT([    write_graphite  . . . $enable_write_graphite])
7034 AC_MSG_RESULT([    write_http  . . . . . $enable_write_http])
7035 AC_MSG_RESULT([    write_kafka . . . . . $enable_write_kafka])
7036 AC_MSG_RESULT([    write_log . . . . . . $enable_write_log])
7037 AC_MSG_RESULT([    write_mongodb . . . . $enable_write_mongodb])
7038 AC_MSG_RESULT([    write_prometheus. . . $enable_write_prometheus])
7039 AC_MSG_RESULT([    write_redis . . . . . $enable_write_redis])
7040 AC_MSG_RESULT([    write_riemann . . . . $enable_write_riemann])
7041 AC_MSG_RESULT([    write_sensu . . . . . $enable_write_sensu])
7042 AC_MSG_RESULT([    write_tsdb  . . . . . $enable_write_tsdb])
7043 AC_MSG_RESULT([    xencpu  . . . . . . . $enable_xencpu])
7044 AC_MSG_RESULT([    xmms  . . . . . . . . $enable_xmms])
7045 AC_MSG_RESULT([    zfs_arc . . . . . . . $enable_zfs_arc])
7046 AC_MSG_RESULT([    zone  . . . . . . . . $enable_zone])
7047 AC_MSG_RESULT([    zookeeper . . . . . . $enable_zookeeper])
7048 AC_MSG_RESULT()
7049
7050 if test "x$dependency_error" = "xyes"; then
7051         AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
7052 fi
7053
7054 if test "x$dependency_warning" = "xyes"; then
7055         AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
7056 fi
7057
7058 # vim: set fdm=marker :