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