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