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