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