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