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