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