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