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