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