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