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