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