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