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