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