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