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