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