Merge branch 'collectd-4.4'
[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 AM_INIT_AUTOMAKE(dist-bzip2)
6 AC_LANG(C)
7
8 AC_PREFIX_DEFAULT("/opt/collectd")
9
10 AC_SYS_LARGEFILE
11
12 #
13 # Checks for programs.
14 #
15 AC_PROG_CC
16 AC_PROG_CPP
17 AC_PROG_INSTALL
18 AC_PROG_LN_S
19 AC_PROG_MAKE_SET
20 AM_PROG_CC_C_O
21 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
22
23 dnl configure libtool
24 AC_DISABLE_STATIC
25 AC_LIBLTDL_CONVENIENCE
26 AC_SUBST(LTDLINCL)
27 AC_SUBST(LIBLTDL)
28 AC_LIBTOOL_DLOPEN
29 AC_PROG_LIBTOOL
30 AC_PROG_LEX
31 AC_PROG_YACC
32 PKG_PROG_PKG_CONFIG
33 AC_CONFIG_SUBDIRS(libltdl)
34
35 AC_MSG_CHECKING([for kernel type ($host_os)])
36 case $host_os in
37         *linux*)
38         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
39         ac_system="Linux"
40         ;;
41         *solaris*)
42         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
43         ac_system="Solaris"
44         ;;
45         *darwin*)
46         ac_system="Darwin"
47         ;;
48         *)
49         ac_system="unknown"
50 esac
51 AC_MSG_RESULT([$ac_system])
52
53 #
54 # Checks for header files.
55 #
56 AC_HEADER_STDC
57 AC_HEADER_SYS_WAIT
58 AC_HEADER_DIRENT
59
60 AC_CHECK_HEADERS(stdio.h stdint.h stdbool.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)
61
62 # For ping library
63 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
64 [#if HAVE_STDINT_H
65 # include <stdint.h>
66 #endif
67 #if HAVE_SYS_TYPES_H
68 # include <sys/types.h>
69 #endif
70 ])
71 AC_CHECK_HEADERS(netinet/in.h, [], [],
72 [#if HAVE_STDINT_H
73 # include <stdint.h>
74 #endif
75 #if HAVE_SYS_TYPES_H
76 # include <sys/types.h>
77 #endif
78 #if HAVE_NETINET_IN_SYSTM_H
79 # include <netinet/in_systm.h>
80 #endif
81 ])
82 AC_CHECK_HEADERS(netinet/ip.h, [], [],
83 [#if HAVE_STDINT_H
84 # include <stdint.h>
85 #endif
86 #if HAVE_SYS_TYPES_H
87 # include <sys/types.h>
88 #endif
89 #if HAVE_NETINET_IN_SYSTM_H
90 # include <netinet/in_systm.h>
91 #endif
92 #if HAVE_NETINET_IN_H
93 # include <netinet/in.h>
94 #endif
95 ])
96 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
97 [#if HAVE_STDINT_H
98 # include <stdint.h>
99 #endif
100 #if HAVE_SYS_TYPES_H
101 # include <sys/types.h>
102 #endif
103 #if HAVE_NETINET_IN_SYSTM_H
104 # include <netinet/in_systm.h>
105 #endif
106 #if HAVE_NETINET_IN_H
107 # include <netinet/in.h>
108 #endif
109 #if HAVE_NETINET_IP_H
110 # include <netinet/ip.h>
111 #endif
112 ])
113 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
114 [#if HAVE_STDINT_H
115 # include <stdint.h>
116 #endif
117 #if HAVE_SYS_TYPES_H
118 # include <sys/types.h>
119 #endif
120 #if HAVE_NETINET_IN_SYSTM_H
121 # include <netinet/in_systm.h>
122 #endif
123 #if HAVE_NETINET_IN_H
124 # include <netinet/in.h>
125 #endif
126 #if HAVE_NETINET_IP_H
127 # include <netinet/ip.h>
128 #endif
129 ])
130 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
131 [#if HAVE_STDINT_H
132 # include <stdint.h>
133 #endif
134 #if HAVE_SYS_TYPES_H
135 # include <sys/types.h>
136 #endif
137 #if HAVE_NETINET_IN_SYSTM_H
138 # include <netinet/in_systm.h>
139 #endif
140 #if HAVE_NETINET_IN_H
141 # include <netinet/in.h>
142 #endif
143 ])
144 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
145 [#if HAVE_STDINT_H
146 # include <stdint.h>
147 #endif
148 #if HAVE_SYS_TYPES_H
149 # include <sys/types.h>
150 #endif
151 #if HAVE_NETINET_IN_SYSTM_H
152 # include <netinet/in_systm.h>
153 #endif
154 #if HAVE_NETINET_IN_H
155 # include <netinet/in.h>
156 #endif
157 #if HAVE_NETINET_IP6_H
158 # include <netinet/ip6.h>
159 #endif
160 ])
161 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
162 [#if HAVE_STDINT_H
163 # include <stdint.h>
164 #endif
165 #if HAVE_SYS_TYPES_H
166 # include <sys/types.h>
167 #endif
168 #if HAVE_NETINET_IN_SYSTM_H
169 # include <netinet/in_systm.h>
170 #endif
171 #if HAVE_NETINET_IN_H
172 # include <netinet/in.h>
173 #endif
174 #if HAVE_NETINET_IP_H
175 # include <netinet/ip.h>
176 #endif
177 ])
178 AC_CHECK_HEADERS(netinet/udp.h, [], [],
179 [#if HAVE_STDINT_H
180 # include <stdint.h>
181 #endif
182 #if HAVE_SYS_TYPES_H
183 # include <sys/types.h>
184 #endif
185 #if HAVE_NETINET_IN_SYSTM_H
186 # include <netinet/in_systm.h>
187 #endif
188 #if HAVE_NETINET_IN_H
189 # include <netinet/in.h>
190 #endif
191 #if HAVE_NETINET_IP_H
192 # include <netinet/ip.h>
193 #endif
194 ])
195
196 # For cpu modules
197 AC_CHECK_HEADERS(sys/dkstat.h)
198 if test "x$ac_system" = "xDarwin"
199 then
200         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)
201         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
202 fi
203 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
204 [
205 #if HAVE_SYS_TYPES_H
206 #  include <sys/types.h>
207 #endif
208 #if HAVE_SYS_PARAM_H
209 # include <sys/param.h>
210 #endif
211 ])
212
213 # For hddtemp module
214 AC_CHECK_HEADERS(linux/major.h libgen.h)
215
216 # For the battery plugin
217 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
218 [
219 #if HAVE_IOKIT_IOKITLIB_H
220 #  include <IOKit/IOKitLib.h>
221 #endif
222 #if HAVE_IOKIT_IOTYPES_H
223 #  include <IOKit/IOTypes.h>
224 #endif
225 ])
226
227 # For the swap module
228 AC_CHECK_HEADERS(sys/swap.h, [], [],
229 [
230 #if HAVE_SYS_TYPES_H
231 #  include <sys/types.h>
232 #endif
233 #if HAVE_SYS_PARAM_H
234 # include <sys/param.h>
235 #endif
236 ])
237
238 # For load module
239 # For the processes plugin
240 # For users module
241 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
242
243 # For interface plugin
244 AC_CHECK_HEADERS(ifaddrs.h)
245 AC_CHECK_HEADERS(net/if.h, [], [],
246 [
247 #if HAVE_SYS_TYPES_H
248 #  include <sys/types.h>
249 #endif
250 #if HAVE_SYS_SOCKET_H
251 #  include <sys/socket.h>
252 #endif
253 ])
254 AC_CHECK_HEADERS(linux/if.h, [], [],
255 [
256 #if HAVE_SYS_TYPES_H
257 #  include <sys/types.h>
258 #endif
259 #if HAVE_SYS_SOCKET_H
260 #  include <sys/socket.h>
261 #endif
262 ])
263 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
264 [
265 #if HAVE_SYS_TYPES_H
266 #  include <sys/types.h>
267 #endif
268 #if HAVE_SYS_SOCKET_H
269 #  include <sys/socket.h>
270 #endif
271 #if HAVE_LINUX_IF_H
272 # include <linux/if.h>
273 #endif
274 ])
275
276 # For ipvs module
277 have_net_ip_vs_h="no"
278 have_ip_vs_h="no"
279 if test "x$ac_system" = "xLinux"
280 then
281         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
282         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
283 fi
284
285 # For quota module
286 AC_CHECK_HEADERS(sys/ucred.h, [], [],
287 [
288 #if HAVE_SYS_TYPES_H
289 #  include <sys/types.h>
290 #endif
291 #if HAVE_SYS_PARAM_H
292 # include <sys/param.h>
293 #endif
294 ])
295
296 # For mount interface
297 AC_CHECK_HEADERS(sys/mount.h, [], [],
298 [
299 #if HAVE_SYS_TYPES_H
300 #  include <sys/types.h>
301 #endif
302 #if HAVE_SYS_PARAM_H
303 # include <sys/param.h>
304 #endif
305 ])
306
307 # For the email plugin
308 AC_CHECK_HEADERS(linux/un.h, [], [],
309 [
310 #if HAVE_SYS_SOCKET_H
311 #       include <sys/socket.h>
312 #endif
313 ])
314
315 AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h sys/quota.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)
316
317 # For the dns plugin
318 AC_CHECK_HEADERS(arpa/nameser.h)
319 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
320 [
321 #if HAVE_ARPA_NAMESER_H
322 # include <arpa/nameser.h>
323 #endif
324 ])
325
326 AC_CHECK_HEADERS(net/if_arp.h, [], [],
327 [#if HAVE_SYS_SOCKET_H
328 # include <sys/socket.h>
329 #endif
330 ])
331 AC_CHECK_HEADERS(net/ppp_defs.h)
332 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
333 [#if HAVE_NET_PPP_DEFS_H
334 # include <net/ppp_defs.h>
335 #endif
336 ])
337 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
338 [#if HAVE_STDINT_H
339 # include <stdint.h>
340 #endif
341 #if HAVE_SYS_TYPES_H
342 # include <sys/types.h>
343 #endif
344 #if HAVE_SYS_SOCKET_H
345 # include <sys/socket.h>
346 #endif
347 #if HAVE_NET_IF_H
348 # include <net/if.h>
349 #endif
350 #if HAVE_NETINET_IN_H
351 # include <netinet/in.h>
352 #endif
353 ])
354
355 # For the multimeter plugin
356 have_termios_h="no"
357 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
358
359 #
360 # Checks for typedefs, structures, and compiler characteristics.
361 #
362 AC_C_CONST
363 AC_TYPE_PID_T
364 AC_TYPE_SIZE_T
365 AC_TYPE_UID_T
366 AC_HEADER_TIME
367
368 #
369 # Checks for library functions.
370 #
371 AC_PROG_GCC_TRADITIONAL
372 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog)
373
374 AC_FUNC_STRERROR_R
375
376 AC_CACHE_CHECK([for strtok_r],
377   [have_strtok_r_default],
378   AC_LINK_IFELSE(
379     AC_LANG_PROGRAM(
380     [[[[
381 #include <stdlib.h>
382 #include <stdio.h>
383 #include <string.h>
384     ]]]],
385     [[[[
386       char buffer[] = "foo,bar,baz";
387       char *token;
388       char *dummy;
389       char *saveptr;
390
391       dummy = buffer;
392       saveptr = NULL;
393       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
394       {
395         dummy = NULL;
396         printf ("token = %s;\n", token);
397       }
398     ]]]]),
399     [have_strtok_r_default="yes"],
400     [have_strtok_r_default="no"]
401   )
402 )
403
404 if test "x$have_strtok_r_default" = "xno"
405 then
406   SAVE_CFLAGS="$CFLAGS"
407   CFLAGS="$CFLAGS -D_REENTRANT=1"
408
409   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
410     [have_strtok_r_reentrant],
411     AC_LINK_IFELSE(
412       AC_LANG_PROGRAM(
413       [[[[
414 #include <stdlib.h>
415 #include <stdio.h>
416 #include <string.h>
417       ]]]],
418       [[[[
419         char buffer[] = "foo,bar,baz";
420         char *token;
421         char *dummy;
422         char *saveptr;
423
424         dummy = buffer;
425         saveptr = NULL;
426         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
427         {
428           dummy = NULL;
429           printf ("token = %s;\n", token);
430         }
431       ]]]]),
432       [have_strtok_r_reentrant="yes"],
433       [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
434     )
435   )
436 fi
437
438 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
439
440 socket_needs_socket="no"
441 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
442 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
443
444 nanosleep_needs_rt="no"
445 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
446 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
447
448 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
449 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
450 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
451 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
452 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
453 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
454 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
455 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
456 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
457 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
458
459 # For load module
460 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
461
462 # Check for NAN
463 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
464 [
465  if test "x$withval" = "xno"; then
466          nan_type="none"
467  else if test "x$withval" = "xyes"; then
468          nan_type="zero"
469  else
470          nan_type="$withval"
471  fi; fi
472 ],
473 [nan_type="none"])
474 if test "x$nan_type" = "xnone"; then
475   AC_CACHE_CHECK([whether NAN is defined by default],
476     [have_nan_default],
477     AC_COMPILE_IFELSE(
478       AC_LANG_PROGRAM(
479       [[
480 #include <stdlib.h>
481 #include <math.h>
482 static float foo = NAN;
483       ]],
484       [[
485        if (isnan (foo))
486         return 0;
487        else
488         return 1;
489       ]]),
490       [have_nan_default="yes"],
491       [have_nan_default="no"]
492     )
493   )
494   if test "x$have_nan_default" = "xyes"
495   then
496     nan_type="default"
497   fi
498 fi
499 if test "x$nan_type" = "xnone"; then
500   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
501     [have_nan_isoc],
502     AC_COMPILE_IFELSE(
503       AC_LANG_PROGRAM(
504       [[
505 #include <stdlib.h>
506 #define __USE_ISOC99 1
507 #include <math.h>
508 static float foo = NAN;
509       ]],
510       [[
511        if (isnan (foo))
512         return 0;
513        else
514         return 1;
515       ]]),
516       [have_nan_isoc="yes"],
517       [have_nan_isoc="no"]
518     )
519   )
520   if test "x$have_nan_isoc" = "xyes"
521   then
522     nan_type="isoc99"
523   fi
524 fi
525 if test "x$nan_type" = "xnone"; then
526   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
527     [have_nan_zero],
528     AC_RUN_IFELSE(
529       AC_LANG_PROGRAM(
530       [[
531 #include <stdlib.h>
532 #include <math.h>
533 #ifdef NAN
534 # undef NAN
535 #endif
536 #define NAN (0.0 / 0.0)
537 #ifndef isnan
538 # define isnan(f) ((f) != (f))
539 #endif
540 static float foo = NAN;
541       ]],
542       [[
543        if (isnan (foo))
544         return 0;
545        else
546         return 1;
547       ]]),
548       [have_nan_zero="yes"],
549       [have_nan_zero="no"]
550     )
551   )
552   if test "x$have_nan_zero" = "xyes"
553   then
554     nan_type="zero"
555   fi
556 fi
557
558 if test "x$nan_type" = "xdefault"; then
559   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
560     [Define if NAN is defined by default and can initialize static variables.])
561 else if test "x$nan_type" = "xisoc99"; then
562   AC_DEFINE(NAN_STATIC_ISOC, 1,
563     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
564 else if test "x$nan_type" = "xzero"; then
565   AC_DEFINE(NAN_ZERO_ZERO, 1,
566     [Define if NAN can be defined as (0.0 / 0.0)])
567 else
568   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
569 fi; fi; fi
570
571 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
572 [
573  if test "x$withval" = "xnothing"; then
574         fp_layout_type="nothing"
575  else if test "x$withval" = "xendianflip"; then
576         fp_layout_type="endianflip"
577  else if test "x$withval" = "xintswap"; then
578         fp_layout_type="intswap"
579  else
580         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
581 fi; fi; fi
582 ],
583 [fp_layout_type="unknown"])
584
585 if test "x$fp_layout_type" = "xunknown"; then
586   AC_CACHE_CHECK([if doubles are stored in x86 representation],
587     [fp_layout_need_nothing],
588     AC_RUN_IFELSE(
589       AC_LANG_PROGRAM(
590       [[[[
591 #include <stdlib.h>
592 #include <stdio.h>
593 #include <stdint.h>
594 #include <string.h>
595       ]]]],
596       [[[[
597         uint64_t i0;
598         uint64_t i1;
599         uint8_t c[8];
600         double d;
601
602         d = 8.642135e130; 
603         memcpy ((void *) &i0, (void *) &d, 8);
604
605         i1 = i0;
606         memcpy ((void *) c, (void *) &i1, 8);
607
608         if ((c[0] == 0x2f) && (c[1] == 0x25)
609                         && (c[2] == 0xc0) && (c[3] == 0xc7)
610                         && (c[4] == 0x43) && (c[5] == 0x2b)
611                         && (c[6] == 0x1f) && (c[7] == 0x5b))
612                 return (0);
613         else
614                 return (1);
615       ]]]]),
616       [fp_layout_need_nothing="yes"],
617       [fp_layout_need_nothing="no"]
618     )
619   )
620   if test "x$fp_layout_need_nothing" = "xyes"; then
621     fp_layout_type="nothing"
622   fi
623 fi
624 if test "x$fp_layout_type" = "xunknown"; then
625   AC_CACHE_CHECK([if endianflip converts to x86 representation],
626     [fp_layout_need_endianflip],
627     AC_RUN_IFELSE(
628       AC_LANG_PROGRAM(
629       [[[[
630 #include <stdlib.h>
631 #include <stdio.h>
632 #include <stdint.h>
633 #include <string.h>
634 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
635                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
636                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
637                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
638                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
639                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
640                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
641                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
642       ]]]],
643       [[[[
644         uint64_t i0;
645         uint64_t i1;
646         uint8_t c[8];
647         double d;
648
649         d = 8.642135e130; 
650         memcpy ((void *) &i0, (void *) &d, 8);
651
652         i1 = endianflip (i0);
653         memcpy ((void *) c, (void *) &i1, 8);
654
655         if ((c[0] == 0x2f) && (c[1] == 0x25)
656                         && (c[2] == 0xc0) && (c[3] == 0xc7)
657                         && (c[4] == 0x43) && (c[5] == 0x2b)
658                         && (c[6] == 0x1f) && (c[7] == 0x5b))
659                 return (0);
660         else
661                 return (1);
662       ]]]]),
663       [fp_layout_need_endianflip="yes"],
664       [fp_layout_need_endianflip="no"]
665     )
666   )
667   if test "x$fp_layout_need_endianflip" = "xyes"; then
668     fp_layout_type="endianflip"
669   fi
670 fi
671 if test "x$fp_layout_type" = "xunknown"; then
672   AC_CACHE_CHECK([if intswap converts to x86 representation],
673     [fp_layout_need_intswap],
674     AC_RUN_IFELSE(
675       AC_LANG_PROGRAM(
676       [[[[
677 #include <stdlib.h>
678 #include <stdio.h>
679 #include <stdint.h>
680 #include <string.h>
681 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
682                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
683       ]]]],
684       [[[[
685         uint64_t i0;
686         uint64_t i1;
687         uint8_t c[8];
688         double d;
689
690         d = 8.642135e130; 
691         memcpy ((void *) &i0, (void *) &d, 8);
692
693         i1 = intswap (i0);
694         memcpy ((void *) c, (void *) &i1, 8);
695
696         if ((c[0] == 0x2f) && (c[1] == 0x25)
697                         && (c[2] == 0xc0) && (c[3] == 0xc7)
698                         && (c[4] == 0x43) && (c[5] == 0x2b)
699                         && (c[6] == 0x1f) && (c[7] == 0x5b))
700                 return (0);
701         else
702                 return (1);
703       ]]]]),
704       [fp_layout_need_intswap="yes"],
705       [fp_layout_need_intswap="no"]
706     )
707   )
708   if test "x$fp_layout_need_intswap" = "xyes"; then
709     fp_layout_type="intswap"
710   fi
711 fi
712
713 if test "x$fp_layout_type" = "xnothing"; then
714   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
715   [Define if doubles are stored in x86 representation.])
716 else if test "x$fp_layout_type" = "xendianflip"; then
717   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
718   [Define if endianflip is needed to convert to x86 representation.])
719 else if test "x$fp_layout_type" = "xintswap"; then
720   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
721   [Define if intswap is needed to convert to x86 representation.])
722 else
723   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
724 fi; fi; fi
725
726 have_getfsstat="no"
727 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
728 have_getvfsstat="no"
729 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
730 have_listmntent="no"
731 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
732
733 have_getmntent="no"
734 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
735 if test "x$have_getmntent" = "xno"; then
736         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
737 fi
738 if test "x$have_getmntent" = "xno"; then
739         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
740 fi
741 if test "x$have_getmntent" = "xno"; then
742         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
743 fi
744
745 if test "x$have_getmntent" = "xc"; then
746         AC_CACHE_CHECK([whether getmntent takes one argument],
747                 [have_one_getmntent],
748                 AC_COMPILE_IFELSE(
749                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
750 #include <mntent.h>
751 #include "$srcdir/src/utils_mount.h"]],
752                                 [[
753                                  FILE *fh;
754                                  struct mntent *me;
755                                  fh = setmntent ("/etc/mtab", "r");
756                                  me = getmntent (fh);
757                                 ]]
758                         ),
759                         [have_one_getmntent="yes"],
760                         [have_one_getmntent="no"]
761                 )
762         )
763         AC_CACHE_CHECK([whether getmntent takes two arguments],
764                 [have_two_getmntent],
765                 AC_COMPILE_IFELSE(
766                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
767 #include <sys/mnttab.h>
768 #include "$srcdir/src/utils_mount.h"]],
769                                 [[
770                                  FILE *fh;
771                                  struct mnttab mt;
772                                  int status;
773                                  fh = fopen ("/etc/mnttab", "r");
774                                  status = getmntent (fh, &mt);
775                                 ]]
776                         ),
777                         [have_two_getmntent="yes"],
778                         [have_two_getmntent="no"]
779                 )
780         )
781 fi
782
783 # Check for different versions of `getmntent' here..
784
785 if test "x$have_getmntent" = "xc"; then
786         if test "x$have_one_getmntent" = "xyes"; then
787                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
788                           [Define if the function getmntent exists and takes one argument.])
789         fi
790         if test "x$have_two_getmntent" = "xyes"; then
791                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
792                           [Define if the function getmntent exists and takes two arguments.])
793         fi
794 fi
795 if test "x$have_getmntent" = "xsun"; then
796         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
797                   [Define if the function getmntent exists. It's the version from libsun.])
798 fi
799 if test "x$have_getmntent" = "xseq"; then
800         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
801                   [Define if the function getmntent exists. It's the version from libseq.])
802 fi
803 if test "x$have_getmntent" = "xgen"; then
804         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
805                   [Define if the function getmntent exists. It's the version from libgen.])
806 fi
807
808 # Check for structures
809 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
810         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
811         [],
812         [
813         #include <sys/types.h>
814         #include <sys/socket.h>
815         #include <net/if.h>
816         ])
817 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
818         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
819         [],
820         [
821         #include <sys/types.h>
822         #include <sys/socket.h>
823         #include <linux/if.h>
824         #include <linux/netdevice.h>
825         ])
826
827 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
828 [#if HAVE_STDINT_H
829 # include <stdint.h>
830 #endif
831 #if HAVE_SYS_TYPES_H
832 # include <sys/types.h>
833 #endif
834 #if HAVE_NETINET_IN_SYSTM_H
835 # include <netinet/in_systm.h>
836 #endif
837 #if HAVE_NETINET_IN_H
838 # include <netinet/in.h>
839 #endif
840 #if HAVE_NETINET_IP_H
841 # include <netinet/ip.h>
842 #endif
843 #if HAVE_NETINET_UDP_H
844 # include <netinet/udp.h>
845 #endif
846 ])
847 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
848 [#if HAVE_STDINT_H
849 # include <stdint.h>
850 #endif
851 #if HAVE_SYS_TYPES_H
852 # include <sys/types.h>
853 #endif
854 #if HAVE_NETINET_IN_SYSTM_H
855 # include <netinet/in_systm.h>
856 #endif
857 #if HAVE_NETINET_IN_H
858 # include <netinet/in.h>
859 #endif
860 #if HAVE_NETINET_IP_H
861 # include <netinet/ip.h>
862 #endif
863 #if HAVE_NETINET_UDP_H
864 # include <netinet/udp.h>
865 #endif
866 ])
867
868 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
869         [],
870         [],
871         [
872 #if HAVE_KSTAT_H
873 # include <kstat.h>
874 #endif
875         ])
876
877 #
878 # Checks for libraries begin here
879 #
880 with_libresolv="yes"
881 AC_CHECK_LIB(resolv, res_search,
882 [
883         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
884 ],
885 [with_libresolv="no"])
886 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
887
888 dnl Check for HAL (hardware abstraction library)
889 with_libhal="yes"
890 AC_CHECK_LIB(hal,libhal_device_property_exists,
891              [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
892              [with_libhal="no"])
893 if test "x$with_libhal" = "xyes"; then
894         if test "x$PKG_CONFIG" != "x"; then
895                 BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
896                 BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
897                 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
898                 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
899         fi
900 fi
901
902 m4_divert_once([HELP_WITH], [
903 collectd additional packages:])
904
905 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
906 librrd_cflags=""
907 librrd_ldflags=""
908 librrd_threadsafe="yes"
909 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
910 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
911         then
912                 librrd_cflags="-I$withval/include"
913                 librrd_ldflags="-L$withval/lib"
914                 with_rrdtool="yes"
915         else
916                 with_rrdtool="$withval"
917         fi
918 ], [with_rrdtool="yes"])
919 if test "x$with_rrdtool" = "xyes"
920 then
921         SAVE_CPPFLAGS="$CPPFLAGS"
922         SAVE_LDFLAGS="$LDFLAGS"
923
924         CPPFLAGS="$CPPFLAGS $librrd_cflags"
925         LDFLAGS="$LDFLAGS $librrd_ldflags"
926
927         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
928
929         CPPFLAGS="$SAVE_CPPFLAGS"
930         LDFLAGS="$SAVE_LDFLAGS"
931 fi
932 if test "x$with_rrdtool" = "xyes"
933 then
934         SAVE_CPPFLAGS="$CPPFLAGS"
935         SAVE_LDFLAGS="$LDFLAGS"
936
937         CPPFLAGS="$CPPFLAGS $librrd_cflags"
938         LDFLAGS="$LDFLAGS $librrd_ldflags"
939
940         AC_CHECK_LIB(rrd_th, rrd_update_r,
941         [with_rrdtool="yes"
942          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
943         ],
944         [librrd_threadsafe="no"
945          AC_CHECK_LIB(rrd, rrd_update,
946          [with_rrdtool="yes"
947           librrd_ldflags="$librrd_ldflags -lrrd -lm"
948          ],
949          [with_rrdtool="no (symbol 'rrd_update' not found)"],
950          [-lm])
951         ],
952         [-lm])
953
954         CPPFLAGS="$SAVE_CPPFLAGS"
955         LDFLAGS="$SAVE_LDFLAGS"
956 fi
957 if test "x$with_rrdtool" = "xyes"
958 then
959         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
960         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
961         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
962         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
963 fi
964 if test "x$librrd_threadsafe" = "xyes"
965 then
966         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
967 fi
968
969 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
970 [       if test "x$withval" != "xno" \
971                 && test "x$withval" != "xyes"
972         then
973                 LDFLAGS="$LDFLAGS -L$withval/lib"
974                 CPPFLAGS="$CPPFLAGS -I$withval/include"
975                 with_libpthread="yes"
976         else
977                 if test "x$withval" = "xno"
978                 then
979                         with_libpthread="no (disabled)"
980                 fi
981         fi
982 ], [with_libpthread="yes"])
983 if test "x$with_libpthread" = "xyes"
984 then
985         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
986 fi
987 if test "x$with_libpthread" = "xyes"
988 then
989         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
990 fi
991 if test "x$with_libpthread" = "xyes"
992 then
993         collect_pthread=1
994 else
995         collect_pthread=0
996 fi
997 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
998         [Wether or not to use pthread (POSIX threads) library])
999 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
1000
1001 if test "x$ac_system" = "xSolaris"
1002 then
1003         with_kstat="yes"
1004         with_devinfo="yes"
1005 else
1006         with_kstat="no (Solaris only)"
1007         with_devinfo="no (Solaris only)"
1008 fi
1009
1010 if test "x$with_kstat" = "xyes"
1011 then
1012         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
1013 fi
1014 if test "x$with_kstat" = "xyes"
1015 then
1016         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
1017         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
1018 fi
1019 if test "x$with_kstat" = "xyes"
1020 then
1021         AC_DEFINE(HAVE_LIBKSTAT, 1,
1022                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1023 fi
1024 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1025 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1026
1027 ### BEGIN of check for libcurl ###
1028 with_curl_config="curl-config"
1029 with_curl_cflags=""
1030 with_curl_libs=""
1031 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
1032 [
1033         if test "x$withval" = "xno"
1034         then
1035                 with_libcurl="no"
1036         else if test "x$withval" = "xyes"
1037         then
1038                 with_libcurl="yes"
1039         else
1040                 if test -f "$withval" && test -x "$withval"
1041                 then
1042                         with_curl_config="$withval"
1043                         with_libcurl="yes"
1044                 else if test -x "$withval/bin/curl-config"
1045                 then
1046                         with_curl_config="$withval/bin/curl-config"
1047                         with_libcurl="yes"
1048                 fi; fi
1049                 with_libcurl="yes"
1050         fi; fi
1051 ],
1052 [
1053         with_libcurl="yes"
1054 ])
1055 if test "x$with_libcurl" = "xyes"
1056 then
1057         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1058         curl_config_status=$?
1059
1060         if test $curl_config_status -ne 0
1061         then
1062                 with_libcurl="no ($with_curl_config failed)"
1063         else
1064                 SAVE_CPPFLAGS="$CPPFLAGS"
1065                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1066
1067                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1068
1069                 CPPFLAGS="$SAVE_CPPFLAGS"
1070         fi
1071 fi
1072 if test "x$with_libcurl" = "xyes"
1073 then
1074         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1075         curl_config_status=$?
1076
1077         if test $curl_config_status -ne 0
1078         then
1079                 with_libcurl="no ($with_curl_config failed)"
1080         else
1081                 AC_CHECK_LIB(curl, curl_easy_init,
1082                  [with_libcurl="yes"],
1083                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1084                  [$with_curl_libs])
1085         fi
1086 fi
1087 if test "x$with_libcurl" = "xyes"
1088 then
1089         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1090         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1091         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1092         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1093 fi
1094 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1095 ### END of check for libcurl ###
1096
1097 with_libiokit="no"
1098 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1099 [
1100         with_libiokit="yes"
1101 ], 
1102 [
1103         with_libiokit="no"
1104 ])
1105 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1106
1107 with_libstatgrab_cflags=""
1108 with_libstatgrab_ldflags=""
1109 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
1110 [
1111         if test "x$withval" != "xno" \
1112                 && test "x$withval" != "xyes"
1113         then
1114                 with_libstatgrab_cflags="-I$withval/include"
1115                 with_libstatgrab_ldflags="-L$withval/lib"
1116                 with_libstatgrab="yes"
1117         else
1118                 with_libstatgrab="$withval"
1119         fi
1120 ],
1121 [
1122         if test "x$ac_system" = "xunknown"
1123         then
1124                 with_libstatgrab="yes"
1125         else
1126                 with_libstatgrab="no"
1127         fi
1128 ])
1129 with_libstatgrab_pkg_config="yes"
1130 if test "x$with_libstatgrab" = "xyes" \
1131   && test "x$PKG_CONFIG" != "x"
1132 then
1133   AC_MSG_CHECKING([pkg-config for libstatgrab])
1134   temp_result="found"
1135   $PKG_CONFIG --exists libstatgrab 2>/dev/null
1136   if test "$?" != "0"
1137   then
1138     with_libstatgrab_pkg_config="no"
1139     temp_result="not found"
1140   fi
1141   AC_MSG_RESULT([$temp_result])
1142 else
1143   AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
1144   with_libstatgrab_pkg_config="no"
1145   with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
1146 fi
1147
1148 if test "x$with_libstatgrab" = "xyes" \
1149   && test "x$with_libstatgrab_pkg_config" = "xyes" \
1150   && test "x$with_libstatgrab_cflags" = "x"
1151 then
1152   AC_MSG_CHECKING([for libstatgrab CFLAGS])
1153   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
1154   if test "$?" = "0"
1155   then
1156     with_libstatgrab_cflags="$temp_result"
1157   else
1158     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
1159     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
1160   fi
1161   AC_MSG_RESULT([$temp_result])
1162 fi
1163
1164 if test "x$with_libstatgrab" = "xyes" \
1165   && test "x$with_libstatgrab_pkg_config" = "xyes" \
1166   && test "x$with_libstatgrab_ldflags" = "x"
1167 then
1168   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
1169   temp_result="`$PKG_CONFIG --libs libstatgrab`"
1170   if test "$?" = "0"
1171   then
1172     with_libstatgrab_ldflags="$temp_result"
1173   else
1174     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
1175     temp_result="$PKG_CONFIG --libs libstatgrab failed"
1176   fi
1177   AC_MSG_RESULT([$temp_result])
1178 fi
1179
1180 if test "x$with_libstatgrab" = "xyes"
1181 then
1182   SAVE_CPPFLAGS="$CPPFLAGS"
1183   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
1184
1185   AC_CHECK_HEADERS(statgrab.h,
1186                    [with_libstatgrab="yes"],
1187                    [with_libstatgrab="no (statgrab.h not found)"])
1188
1189   CPPFLAGS="$SAVE_CPPFLAGS"
1190 fi
1191
1192 if test "x$with_libstatgrab" = "xyes"
1193 then
1194   SAVE_CFLAGS="$CFLAGS"
1195   SAVE_LDFLAGS="$LDFLAGS"
1196
1197   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
1198   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
1199
1200   AC_CHECK_LIB(statgrab, sg_init,
1201                [with_libstatgrab="yes"],
1202                [with_libstatgrab="no (symbol sg_init not found)"])
1203
1204   CFLAGS="$SAVE_CFLAGS"
1205   LDFLAGS="$SAVE_LDFLAGS"
1206 fi
1207
1208 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
1209 if test "x$with_libstatgrab" = "xyes"
1210 then
1211   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
1212   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
1213   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
1214   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
1215   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
1216 fi
1217
1218 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
1219 if test "x$with_libkvm" = "xyes"
1220 then
1221         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
1222 fi
1223 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
1224
1225 with_sensors_cflags=""
1226 with_sensors_ldflags=""
1227 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
1228 [
1229         if test "x$withval" = "xno"
1230         then
1231                 with_lm_sensors="no"
1232         else
1233                 with_lm_sensors="yes"
1234                 if test "x$withval" != "xyes"
1235                 then
1236                         with_sensors_cflags="-I$withval/include"
1237                         with_sensors_ldflags="-L$withval/lib"
1238                         with_lm_sensors="yes"
1239                 fi
1240         fi
1241 ],
1242 [
1243         if test "x$ac_system" = "xLinux"
1244         then
1245                 with_lm_sensors="yes"
1246         else
1247                 with_lm_sensors="no (Linux only library)"
1248         fi
1249 ])
1250 if test "x$with_lm_sensors" = "xyes"
1251 then
1252         SAVE_CPPFLAGS="$CPPFLAGS"
1253         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1254
1255 #       AC_CHECK_HEADERS(sensors/sensors.h,
1256 #       [
1257 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
1258 #       ],
1259 #       [with_lm_sensors="no (sensors/sensors.h not found)"])
1260         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_lm_sensors="no (sensors/sensors.h not found)"])
1261
1262         CPPFLAGS="$SAVE_CPPFLAGS"
1263 fi
1264 if test "x$with_lm_sensors" = "xyes"
1265 then
1266         SAVE_CPPFLAGS="$CPPFLAGS"
1267         SAVE_LDFLAGS="$LDFLAGS"
1268         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1269         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
1270
1271         AC_CHECK_LIB(sensors, sensors_init,
1272         [
1273                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
1274         ],
1275         [with_lm_sensors="no (libsensors not found)"])
1276
1277         CPPFLAGS="$SAVE_CPPFLAGS"
1278         LDFLAGS="$SAVE_LDFLAGS"
1279 fi
1280 if test "x$with_lm_sensors" = "xyes"
1281 then
1282         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
1283         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
1284         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
1285         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
1286 fi
1287 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
1288
1289 with_mysql_config="mysql_config"
1290 with_mysql_cflags=""
1291 with_mysql_libs=""
1292 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1293 [
1294         if test "x$withval" = "xno"
1295         then
1296                 with_libmysql="no"
1297         else if test "x$withval" = "xyes"
1298         then
1299                 with_libmysql="yes"
1300         else
1301                 if test -f "$withval" && test -x "$withval";
1302                 then
1303                         with_mysql_config="$withval"
1304                 else if test -x "$withval/bin/mysql_config"
1305                 then
1306                         with_mysql_config="$withval/bin/mysql_config"
1307                 fi; fi
1308                 with_libmysql="yes"
1309         fi; fi
1310 ],
1311 [
1312         with_libmysql="yes"
1313 ])
1314 if test "x$with_libmysql" = "xyes"
1315 then
1316         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1317         mysql_config_status=$?
1318
1319         if test $mysql_config_status -ne 0
1320         then
1321                 with_libmysql="no"
1322         else
1323                 SAVE_CPPFLAGS="$CPPFLAGS"
1324                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1325
1326                 AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
1327
1328                 CPPFLAGS="$SAVE_CPPFLAGS"
1329         fi
1330 fi
1331 if test "x$with_libmysql" = "xyes"
1332 then
1333         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1334         mysql_config_status=$?
1335
1336         if test $mysql_config_status -ne 0
1337         then
1338                 with_libmysql="no"
1339         else
1340                 AC_CHECK_LIB(mysqlclient, mysql_init,
1341                  [with_libmysql="yes"],
1342                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1343                  [$with_mysql_libs])
1344         fi
1345 fi
1346 if test "x$with_libmysql" = "xyes"
1347 then
1348         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1349         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1350         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1351         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1352 fi
1353 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1354
1355 with_own_liboconfig="no"
1356 liboconfig_LDFLAGS="$LDFLAGS"
1357 liboconfig_CPPFLAGS="$CPPFLAGS"
1358 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1359 [
1360         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1361         then
1362                 if test -d "$withval/lib"
1363                 then
1364                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1365                 fi
1366                 if test -d "$withval/include"
1367                 then
1368                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1369                 fi
1370         fi
1371         if test "x$withval" = "xno"
1372         then
1373                 AC_MSG_ERROR("liboconfig is required")
1374         fi
1375 ],
1376 [
1377         with_liboconfig="yes"
1378 ])
1379
1380 save_LDFLAGS="$LDFLAGS"
1381 save_CPPFLAGS="$CPPFLAGS"
1382 LDFLAGS="$liboconfig_LDFLAGS"
1383 CPPFLAGS="$liboconfig_CPPFLAGS"
1384 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1385 [
1386         with_liboconfig="yes"
1387         with_own_liboconfig="no"
1388 ],
1389 [
1390         with_liboconfig="yes"
1391         with_own_liboconfig="yes"
1392         LDFLAGS="$save_LDFLAGS"
1393         CPPFLAGS="$save_CPPFLAGS"
1394 ])
1395
1396 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1397 if test "x$with_own_liboconfig" = "xyes"
1398 then
1399         with_liboconfig="yes (shipped version)"
1400 fi
1401
1402 #with_liboping="yes"
1403 with_own_liboping="no"
1404 liboping_LDFLAGS="$LDFLAGS"
1405 liboping_CPPFLAGS="$CPPFLAGS"
1406 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1407 [
1408         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1409         then
1410                 if test -d "$withval/lib"
1411                 then
1412                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1413                 fi
1414                 if test -d "$withval/include"
1415                 then
1416                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1417                 fi
1418         fi
1419         if test "x$withval" = "xno"
1420         then
1421                 with_liboping="no"
1422                 with_own_liboping="no"
1423         else if test "x$withval" = "xyes"
1424         then
1425                 with_liboping="yes"
1426         fi; fi
1427 ],
1428 [
1429         with_liboping="yes"
1430 ])
1431
1432 if test "x$with_liboping" = "xyes"
1433 then
1434         save_LDFLAGS="$LDFLAGS"
1435         save_CPPFLAGS="$CPPFLAGS"
1436         LDFLAGS="$liboping_LDFLAGS"
1437         CPPFLAGS="$liboping_CPPFLAGS"
1438         AC_CHECK_LIB(oping, ping_construct,
1439         [
1440                 with_liboping="yes"
1441                 with_own_liboping="no"
1442         ],
1443         [
1444                 with_liboping="yes"
1445                 with_own_liboping="yes"
1446                 LDFLAGS="$save_LDFLAGS"
1447                 CPPFLAGS="$save_CPPFLAGS"
1448         ])
1449 fi
1450 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1451 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1452
1453 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1454 [
1455         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1456         then
1457                 LDFLAGS="$LDFLAGS -L$withval/lib"
1458                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1459                 with_libpcap="yes"
1460         else
1461                 with_libpcap="$withval"
1462         fi
1463 ],
1464 [
1465         with_libpcap="yes"
1466 ])
1467 if test "x$with_libpcap" = "xyes"
1468 then
1469         AC_CHECK_LIB(pcap, pcap_open_live,
1470         [
1471                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1472         ], [with_libpcap="no (libpcap not found)"])
1473 fi
1474 if test "x$with_libpcap" = "xyes"
1475 then
1476         AC_CHECK_HEADERS(pcap.h,
1477         [
1478                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1479         ], [with_libpcap="no (pcap.h not found)"])
1480 fi
1481 if test "x$with_libpcap" = "xyes"
1482 then
1483         collect_libpcap=1
1484 else
1485         collect_libpcap=0
1486 fi
1487 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1488         [Wether or not to use the pcap library])
1489 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1490
1491 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
1492 [
1493         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1494         then
1495                 LDFLAGS="$LDFLAGS -L$withval/lib"
1496                 CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
1497                 with_libesmtp="yes"
1498         else
1499                 with_libesmtp="$withval"
1500         fi
1501 ],
1502 [
1503         with_libesmtp="yes"
1504 ])
1505 if test "x$with_libesmtp" = "xyes"
1506 then
1507         AC_CHECK_LIB(esmtp, smtp_create_session,
1508         [
1509                 AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
1510         ], [with_libesmtp="no (libesmtp not found)"])
1511 fi
1512 if test "x$with_libesmtp" = "xyes"
1513 then
1514         AC_CHECK_HEADERS(libesmtp.h,
1515         [
1516                 AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
1517         ], [with_libesmtp="no (libesmtp.h not found)"])
1518 fi
1519 if test "x$with_libesmtp" = "xyes"
1520 then
1521         collect_libesmtp=1
1522 else
1523         collect_libesmtp=0
1524 fi
1525 AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
1526         [Wether or not to use the esmtp library])
1527 AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
1528
1529 perl_interpreter="perl"
1530 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1531 [
1532         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1533         then
1534                 LDFLAGS="$LDFLAGS -L$withval/lib"
1535                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1536                 perl_interpreter="$withval/bin/perl"
1537                 with_libperl="yes"
1538         else
1539                 with_libperl="$withval"
1540         fi
1541 ],
1542 [
1543         with_libperl="yes"
1544 ])
1545
1546 AC_MSG_CHECKING([for perl])
1547 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
1548 if test -x "$perl_interpreter"
1549 then
1550         AC_MSG_RESULT([yes])
1551 else
1552         perl_interpreter=""
1553         AC_MSG_RESULT([no])
1554 fi
1555
1556 AC_SUBST(PERL, "$perl_interpreter")
1557
1558 if test "x$with_libperl" = "xyes" \
1559         && test -n "$perl_interpreter"
1560 then
1561   SAVE_CFLAGS=$CFLAGS
1562   SAVE_LDFLAGS=$LDFLAGS
1563   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1564   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1565   CFLAGS="$CFLAGS $PERL_CFLAGS"
1566   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1567
1568   AC_CACHE_CHECK([for libperl],
1569     [have_libperl],
1570     AC_LINK_IFELSE(
1571       AC_LANG_PROGRAM(
1572       [[
1573 #include <EXTERN.h>
1574 #include <perl.h>
1575 #include <XSUB.h>
1576       ]],
1577       [[
1578        PerlInterpreter *perl = NULL;
1579        Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
1580                          newSVpv ("Collectd::Plugin::FooBar", 24),
1581                          Nullsv);
1582       ]]),
1583       [have_libperl="yes"],
1584       [have_libperl="no"]
1585     )
1586   )
1587
1588   if test "x$have_libperl" = "xyes"
1589   then
1590           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1591           AC_SUBST(PERL_CFLAGS)
1592           AC_SUBST(PERL_LDFLAGS)
1593   else
1594           with_libperl="no"
1595   fi
1596
1597   CFLAGS=$SAVE_CFLAGS
1598   LDFLAGS=$SAVE_LDFLAGS
1599 else if test -z "$perl_interpreter"; then
1600   with_libperl="no (no perl interpreter found)"
1601   have_libperl="no"
1602 fi; fi
1603 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1604
1605 if test "x$with_libperl" = "xyes"
1606 then
1607         SAVE_CFLAGS=$CFLAGS
1608         SAVE_LDFLAGS=$LDFLAGS
1609         CFLAGS="$CFLAGS $PERL_CFLAGS"
1610         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1611
1612         AC_CACHE_CHECK([if perl supports ithreads],
1613                 [have_perl_ithreads],
1614                 AC_LINK_IFELSE(
1615                         AC_LANG_PROGRAM(
1616                         [[
1617 #include <EXTERN.h>
1618 #include <perl.h>
1619 #include <XSUB.h>
1620
1621 #if !defined(USE_ITHREADS)
1622 # error "Perl does not support ithreads!"
1623 #endif /* !defined(USE_ITHREADS) */
1624                         ]],
1625                         [[ ]]),
1626                         [have_perl_ithreads="yes"],
1627                         [have_perl_ithreads="no"]
1628                 )
1629         )
1630
1631         if test "x$have_perl_ithreads" = "xyes"
1632         then
1633                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
1634         fi
1635
1636         CFLAGS=$SAVE_CFLAGS
1637         LDFLAGS=$SAVE_LDFLAGS
1638 fi
1639
1640 if test "x$ac_system" = "xLinux"
1641 then
1642         AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
1643         if test -z "$KERNEL_DIR"
1644         then
1645                 KERNEL_DIR="/lib/modules/`uname -r`/source"
1646         fi
1647 fi
1648
1649 with_own_libiptc="no"
1650 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1651 [
1652         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1653         then
1654                 LDFLAGS="$LDFLAGS -L$withval/lib"
1655                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1656                 with_libiptc="yes"
1657         else
1658                 with_libiptc="$withval"
1659         fi
1660 ],
1661 [
1662         if test "x$ac_system" = "xLinux"
1663         then
1664                 with_libiptc="yes"
1665         else
1666                 with_libiptc="no (Linux only)"
1667         fi
1668 ])
1669 if test "x$with_libiptc" = "xyes"
1670 then
1671         AC_CHECK_LIB(iptc, iptc_init,
1672         [
1673                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1674         ],
1675         [
1676                 with_libiptc="yes"
1677                 with_own_libiptc="yes"
1678         ])
1679 fi
1680 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes"
1681 then
1682         AC_CHECK_HEADERS(libiptc/libiptc.h,
1683         [
1684                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1685         ],
1686         [
1687                 with_libiptc="yes"
1688                 with_own_libiptc="yes"
1689         ])
1690 fi
1691 if test "x$with_libiptc" = "xyes"
1692 then
1693         SAVE_CFLAGS=$CFLAGS
1694         CFLAGS="$CFLAGS -I$KERNEL_DIR/include"
1695
1696         AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
1697         [
1698                 with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)"
1699                 with_own_libiptc="no"
1700         ],
1701         [
1702 #include "$srcdir/src/libiptc/ipt_kernel_headers.h"
1703         ])
1704
1705         CFLAGS=$SAVE_CFLAGS
1706 fi
1707 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1708 AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
1709 if test "x$with_own_libiptc" = "xyes"
1710 then
1711         AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
1712 fi
1713
1714 with_snmp_config="net-snmp-config"
1715 with_snmp_cflags=""
1716 with_snmp_libs=""
1717 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1718 [
1719         if test "x$withval" = "xno"
1720         then
1721                 with_libnetsnmp="no"
1722         else if test "x$withval" = "xyes"
1723         then
1724                 with_libnetsnmp="yes"
1725         else
1726                 if test -x "$withval"
1727                 then
1728                         with_snmp_config="$withval"
1729                         with_libnetsnmp="yes"
1730                 else
1731                         with_snmp_config="$withval/bin/net-snmp-config"
1732                         with_libnetsnmp="yes"
1733                 fi
1734         fi; fi
1735 ],
1736 [with_libnetsnmp="yes"])
1737 if test "x$with_libnetsnmp" = "xyes"
1738 then
1739         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1740         snmp_config_status=$?
1741
1742         if test $snmp_config_status -ne 0
1743         then
1744                 with_libnetsnmp="no ($with_snmp_config failed)"
1745         else
1746                 SAVE_CPPFLAGS="$CPPFLAGS"
1747                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1748                 
1749                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1750
1751                 CPPFLAGS="$SAVE_CPPFLAGS"
1752         fi
1753 fi
1754 if test "x$with_libnetsnmp" = "xyes"
1755 then
1756         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1757         snmp_config_status=$?
1758
1759         if test $snmp_config_status -ne 0
1760         then
1761                 with_libnetsnmp="no ($with_snmp_config failed)"
1762         else
1763                 AC_CHECK_LIB(netsnmp, init_snmp,
1764                 [with_libnetsnmp="yes"],
1765                 [with_libnetsnmp="no (libnetsnmp not found)"],
1766                 [$with_snmp_libs])
1767         fi
1768 fi
1769 if test "x$with_libnetsnmp" = "xyes"
1770 then
1771         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1772         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1773         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1774         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1775 fi
1776 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1777
1778 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
1779                 [with_libnotify="yes"],
1780                 [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
1781
1782 with_libupsclient="no (pkg-config isn't available)"
1783 with_libupsclient_cflags=""
1784 with_libupsclient_libs=""
1785 if test "x$PKG_CONFIG" != "x"
1786 then
1787         pkg-config --exists 'libupsclient' 2>/dev/null
1788         if test "$?" = "0"
1789         then
1790                 with_libupsclient="yes"
1791         else
1792                 with_libupsclient="no (pkg-config doesn't know library)"
1793         fi
1794 fi
1795 if test "x$with_libupsclient" = "xyes"
1796 then
1797         with_libupsclient_cflags="`pkg-config --cflags 'libupsclient'`"
1798         if test $? -ne 0
1799         then
1800                 with_libupsclient="no"
1801         fi
1802         with_libupsclient_libs="`pkg-config --libs 'libupsclient'`"
1803         if test $? -ne 0
1804         then
1805                 with_libupsclient="no"
1806         fi
1807 fi
1808 if test "x$with_libupsclient" = "xyes"
1809 then
1810         SAVE_CPPFLAGS="$CPPFLAGS"
1811         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
1812
1813         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
1814
1815         CPPFLAGS="$SAVE_CPPFLAGS"
1816 fi
1817 if test "x$with_libupsclient" = "xyes"
1818 then
1819         SAVE_CPPFLAGS="$CPPFLAGS"
1820         SAVE_LDFLAGS="$LDFLAGS"
1821
1822         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
1823         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
1824
1825         AC_CHECK_LIB(upsclient, upscli_connect,
1826                      [with_libupsclient="yes"],
1827                      [with_libupsclient="no (symbol upscli_connect not found)"])
1828
1829         CPPFLAGS="$SAVE_CPPFLAGS"
1830         LDFLAGS="$SAVE_LDFLAGS"
1831 fi
1832 if test "x$with_libupsclient" = "xyes"
1833 then
1834         SAVE_CPPFLAGS="$CPPFLAGS"
1835         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
1836
1837         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
1838 [#include <stdlib.h>
1839 #include <stdio.h>
1840 #include <upsclient.h>])
1841
1842         CPPFLAGS="$SAVE_CPPFLAGS"
1843 fi
1844 if test "x$with_libupsclient" = "xyes"
1845 then
1846         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
1847         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
1848         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
1849         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
1850 fi
1851
1852 ### BEGIN of check for libxmms ###
1853 with_xmms_config="xmms-config"
1854 with_xmms_cflags=""
1855 with_xmms_libs=""
1856 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
1857 [
1858         if test "x$withval" != "xno" \
1859                 && test "x$withval" != "xyes"
1860         then
1861                 if test -f "$withval" && test -x "$withval";
1862                 then
1863                         with_xmms_config="$withval"
1864                 else if test -x "$withval/bin/xmms-config"
1865                 then
1866                         with_xmms_config="$withval/bin/xmms-config"
1867                 fi; fi
1868                 with_libxmms="yes"
1869         else if test "x$withval" = "xno"
1870         then
1871                 with_libxmms="no"
1872         else
1873                 with_libxmms="yes"
1874         fi; fi
1875 ],
1876 [
1877         with_libxmms="yes"
1878 ])
1879 if test "x$with_libxmms" = "xyes"
1880 then
1881         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
1882         xmms_config_status=$?
1883
1884         if test $xmms_config_status -ne 0
1885         then
1886                 with_libxmms="no"
1887         fi
1888 fi
1889 if test "x$with_libxmms" = "xyes"
1890 then
1891         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
1892         xmms_config_status=$?
1893
1894         if test $xmms_config_status -ne 0
1895         then
1896                 with_libxmms="no"
1897         fi
1898 fi
1899 if test "x$with_libxmms" = "xyes"
1900 then
1901         AC_CHECK_LIB(xmms, xmms_remote_get_info,
1902         [
1903                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
1904                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
1905                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
1906                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
1907         ],
1908         [
1909                 with_libxmms="no"
1910         ],
1911         [$with_xmms_libs])
1912 fi
1913 with_libxmms_numeric=0
1914 if test "x$with_libxmms" = "xyes"
1915 then
1916         with_libxmms_numeric=1
1917 fi
1918 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
1919 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
1920 ### END of check for libxmms ###
1921
1922 with_libnetlink_cflags=""
1923 with_libnetlink_libs="-lnetlink"
1924 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1925 [
1926  echo "libnetlink: withval = $withval"
1927  if test "x$withval" = "xyes"
1928  then
1929          with_libnetlink="yes"
1930  else if test "x$withval" = "xno"
1931  then
1932          with_libnetlink="no"
1933  else
1934          if test -d "$withval/include"
1935          then
1936                  with_libnetlink_cflags="-I$withval/include"
1937                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1938                  with_libnetlink="yes"
1939          else
1940                  AC_MSG_ERROR("no such directory: $withval/include")
1941          fi
1942  fi; fi
1943 ],
1944 [
1945  if test "x$ac_system" = "xLinux"
1946  then
1947          with_libnetlink="yes"
1948  else
1949          with_libnetlink="no (Linux only library)"
1950  fi
1951 ])
1952 if test "x$with_libnetlink" = "xyes"
1953 then
1954         SAVE_CFLAGS=$CFLAGS
1955         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1956
1957         with_libnetlink="no (libnetlink.h not found)"
1958
1959         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1960         [
1961          with_libnetlink="yes"
1962          break
1963         ], [],
1964 [#include <stdio.h>
1965 #include <sys/types.h>
1966 #include <asm/types.h>
1967 #include <sys/socket.h>
1968 #include <linux/netlink.h>
1969 #include <linux/rtnetlink.h>])
1970         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1971 [#include <stdio.h>
1972 #include <sys/types.h>
1973 #include <asm/types.h>
1974 #include <sys/socket.h>])
1975
1976         AC_COMPILE_IFELSE(
1977 [#include <stdio.h>
1978 #include <sys/types.h>
1979 #include <asm/types.h>
1980 #include <sys/socket.h>
1981 #include <linux/netlink.h>
1982 #include <linux/rtnetlink.h>
1983
1984 int main (void)
1985 {
1986         int retval = TCA_STATS2;
1987         return (retval);
1988 }],
1989         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1990         []);
1991
1992         AC_COMPILE_IFELSE(
1993 [#include <stdio.h>
1994 #include <sys/types.h>
1995 #include <asm/types.h>
1996 #include <sys/socket.h>
1997 #include <linux/netlink.h>
1998 #include <linux/rtnetlink.h>
1999
2000 int main (void)
2001 {
2002         int retval = TCA_STATS;
2003         return (retval);
2004 }],
2005         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
2006         []);
2007
2008         CFLAGS="$SAVE_CFLAGS"
2009 fi
2010 if test "x$with_libnetlink" = "xyes"
2011 then
2012         AC_CHECK_LIB(netlink, rtnl_open,
2013                      [with_libnetlink="yes"],
2014                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
2015                      [$with_libnetlink_libs])
2016 fi
2017 if test "x$with_libnetlink" = "xyes"
2018 then
2019         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
2020         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
2021         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
2022         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
2023 fi
2024 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
2025
2026 with_libopenipmipthread="yes"
2027 with_libopenipmipthread_cflags=""
2028 with_libopenipmipthread_libs=""
2029
2030 AC_MSG_CHECKING([for pkg-config])
2031 temp_result="no"
2032 if test "x$PKG_CONFIG" = "x"
2033 then
2034         with_libopenipmipthread="no"
2035         temp_result="no"
2036 else
2037         temp_result="$PKG_CONFIG"
2038 fi
2039 AC_MSG_RESULT([$temp_result])
2040
2041 if test "x$with_libopenipmipthread" = "xyes"
2042 then
2043         AC_MSG_CHECKING([for libOpenIPMIpthread])
2044         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
2045         if test "$?" != "0"
2046         then
2047                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
2048         fi
2049         AC_MSG_RESULT([$with_libopenipmipthread])
2050 fi
2051
2052 if test "x$with_libopenipmipthread" = "xyes"
2053 then
2054         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
2055         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
2056         if test "$?" = "0"
2057         then
2058                 with_libopenipmipthread_cflags="$temp_result"
2059         else
2060                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
2061                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
2062         fi
2063         AC_MSG_RESULT([$temp_result])
2064 fi
2065
2066 if test "x$with_libopenipmipthread" = "xyes"
2067 then
2068         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
2069         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
2070         if test "$?" = "0"
2071         then
2072                 with_libopenipmipthread_ldflags="$temp_result"
2073         else
2074                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
2075                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
2076         fi
2077         AC_MSG_RESULT([$temp_result])
2078 fi
2079
2080 if test "x$with_libopenipmipthread" = "xyes"
2081 then
2082         SAVE_CPPFLAGS="$CPPFLAGS"
2083         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
2084
2085         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
2086                          [with_libopenipmipthread="yes"],
2087                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
2088 [#include <OpenIPMI/ipmiif.h>
2089 #include <OpenIPMI/ipmi_err.h>
2090 #include <OpenIPMI/ipmi_posix.h>
2091 #include <OpenIPMI/ipmi_conn.h>
2092 ])
2093
2094         CPPFLAGS="$SAVE_CPPFLAGS"
2095 fi
2096
2097 if test "x$with_libopenipmipthread" = "xyes"
2098 then
2099         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
2100         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
2101         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
2102         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
2103 fi
2104
2105 dnl Check for libpq.
2106 with_pg_config="pg_config"
2107 with_libpq_includedir=""
2108 with_libpq_libdir=""
2109 with_libpq_cppflags=""
2110 with_libpq_ldflags=""
2111 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
2112         [Path to libpq.])],
2113 [
2114         if test "x$withval" = "xno"
2115         then
2116                 with_libpq="no"
2117         else if test "x$withval" = "xyes"
2118         then
2119                 with_libpq="yes"
2120         else
2121                 if test -f "$withval" && test -x "$withval";
2122                 then
2123                         with_pg_config="$withval"
2124                 else if test -x "$withval/bin/pg_config"
2125                 then
2126                         with_pg_config="$withval/bin/pg_config"
2127                 fi; fi
2128                 with_libpq="yes"
2129         fi; fi
2130 ],
2131 [
2132         with_libpq="yes"
2133 ])
2134 if test "x$with_libpq" = "xyes"
2135 then
2136         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
2137         pg_config_status=$?
2138
2139         if test $pg_config_status -eq 0
2140         then
2141                 if test -n "$with_libpq_includedir"; then
2142                         for dir in $with_libpq_includedir; do
2143                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
2144                         done
2145                 fi
2146         else
2147                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2148         fi
2149
2150         SAVE_CPPFLAGS="$CPPFLAGS"
2151         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
2152
2153         AC_CHECK_HEADERS(libpq-fe.h, [],
2154                 [with_libpq="no (libpq-fe.h not found)"], [])
2155
2156         CPPFLAGS="$SAVE_CPPFLAGS"
2157 fi
2158 if test "x$with_libpq" = "xyes"
2159 then
2160         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
2161         pg_config_status=$?
2162
2163         if test $pg_config_status -eq 0
2164         then
2165                 if test -n "$with_libpq_libdir"; then
2166                         for dir in $with_libpq_libdir; do
2167                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
2168                         done
2169                 fi
2170         else
2171                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2172         fi
2173
2174         SAVE_LDFLAGS="$LDFLAGS"
2175         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
2176
2177         AC_CHECK_LIB(pq, PQconnectdb,
2178                 [with_libpq="yes"],
2179                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
2180
2181         LDFLAGS="$SAVE_LDFLAGS"
2182 fi
2183 if test "x$with_libpq" = "xyes"
2184 then
2185         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
2186         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
2187         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
2188         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
2189 fi
2190 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
2191
2192 dnl Check for libvirt and libxml2 libraries.
2193 with_libxml2="no (pkg-config isn't available)"
2194 with_libxml2_cflags=""
2195 with_libxml2_ldflags=""
2196 with_libvirt="no (pkg-config isn't available)"
2197 with_libvirt_cflags=""
2198 with_libvirt_ldflags=""
2199 if test "x$PKG_CONFIG" != "x"
2200 then
2201         pkg-config --exists 'libxml-2.0' 2>/dev/null
2202         if test "$?" = "0"
2203         then
2204                 with_libxml2="yes"
2205         else
2206                 with_libxml2="no (pkg-config doesn't know library)"
2207         fi
2208
2209         pkg-config --exists libvirt 2>/dev/null
2210         if test "$?" = "0"
2211         then
2212                 with_libvirt="yes"
2213         else
2214                 with_libvirt="no (pkg-config doesn't know library)"
2215         fi
2216 fi
2217 if test "x$with_libxml2" = "xyes"
2218 then
2219         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
2220         if test $? -ne 0
2221         then
2222                 with_libxml2="no"
2223         fi
2224         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
2225         if test $? -ne 0
2226         then
2227                 with_libxml2="no"
2228         fi
2229 fi
2230 if test "x$with_libxml2" = "xyes"
2231 then
2232         SAVE_CPPFLAGS="$CPPFLAGS"
2233         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
2234
2235         AC_CHECK_HEADERS(libxml/parser.h, [],
2236                       [with_libxml2="no (libxml/parser.h not found)"])
2237
2238         CPPFLAGS="$SAVE_CPPFLAGS"
2239 fi
2240 if test "x$with_libxml2" = "xyes"
2241 then
2242         SAVE_CFLAGS="$CFLAGS"
2243         SAVE_LDFLAGS="$LDFLAGS"
2244
2245         CFLAGS="$CFLAGS $with_libxml2_cflags"
2246         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
2247
2248         AC_CHECK_LIB(xml2, xmlXPathEval,
2249                      [with_libxml2="yes"],
2250                      [with_libxml2="no (symbol xmlXPathEval not found)"])
2251
2252         CFLAGS="$SAVE_CFLAGS"
2253         LDFLAGS="$SAVE_LDFLAGS"
2254 fi
2255 dnl Add the right compiler flags and libraries.
2256 if test "x$with_libxml2" = "xyes"; then
2257         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
2258         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
2259         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
2260         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
2261 fi
2262 if test "x$with_libvirt" = "xyes"
2263 then
2264         with_libvirt_cflags="`pkg-config --cflags libvirt`"
2265         if test $? -ne 0
2266         then
2267                 with_libvirt="no"
2268         fi
2269         with_libvirt_ldflags="`pkg-config --libs libvirt`"
2270         if test $? -ne 0
2271         then
2272                 with_libvirt="no"
2273         fi
2274 fi
2275 if test "x$with_libvirt" = "xyes"
2276 then
2277         SAVE_CPPFLAGS="$CPPFLAGS"
2278         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
2279
2280         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
2281                       [with_libvirt="no (libvirt/libvirt.h not found)"])
2282
2283         CPPFLAGS="$SAVE_CPPFLAGS"
2284 fi
2285 if test "x$with_libvirt" = "xyes"
2286 then
2287         SAVE_CFLAGS="$CFLAGS"
2288         SAVE_LDFLAGS="$LDFLAGS"
2289
2290         CFLAGS="$CFLAGS $with_libvirt_cflags"
2291         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
2292
2293         AC_CHECK_LIB(virt, virDomainBlockStats,
2294                      [with_libvirt="yes"],
2295                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
2296
2297         CFLAGS="$SAVE_CFLAGS"
2298         LDFLAGS="$SAVE_LDFLAGS"
2299 fi
2300 dnl Add the right compiler flags and libraries.
2301 if test "x$with_libvirt" = "xyes"; then
2302         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
2303         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
2304         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
2305         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
2306 fi
2307
2308 dnl End of check for libvirt and libxml2 libraries.
2309
2310 # Check for enabled/disabled features
2311 #
2312
2313 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
2314 # ------------------------------------------------------------
2315 dnl
2316 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
2317 dnl
2318 AC_DEFUN(
2319         [AC_COLLECTD],
2320         [
2321         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
2322         m4_if(
2323                 [$2],
2324                 [enable],
2325                 [dnl
2326                 m4_define([EnDis],[disabled])dnl
2327                 m4_define([YesNo],[no])dnl
2328                 ],dnl
2329                 [m4_if(
2330                         [$2],
2331                         [disable],
2332                         [dnl
2333                         m4_define([EnDis],[enabled])dnl
2334                         m4_define([YesNo],[yes])dnl
2335                         ],
2336                         [dnl
2337                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
2338                         ]dnl
2339                 )]dnl
2340         )dnl
2341         m4_if([$3], [feature], [],
2342                 [m4_if(
2343                         [$3], [module], [],
2344                         [dnl
2345                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
2346                         ]dnl
2347                 )]dnl
2348         )dnl
2349         AC_ARG_ENABLE(
2350                 [$1],
2351                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
2352                 [],
2353                 enable_$1='[YesNo]'dnl
2354         )# AC_ARG_ENABLE
2355 if test "x$enable_$1" = "xno"
2356 then
2357         collectd_$1=0
2358 else
2359         if test "x$enable_$1" = "xyes"
2360         then
2361                 collectd_$1=1
2362         else
2363                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
2364                 collectd_$1=1
2365                 enable_$1='yes'
2366         fi
2367 fi
2368         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
2369         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
2370         ]dnl
2371 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
2372
2373 # AC_PLUGIN(name, default, info)
2374 # ------------------------------------------------------------
2375 dnl
2376 AC_DEFUN(
2377   [AC_PLUGIN],
2378   [
2379     enable_plugin="no"
2380     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
2381     [
2382      if test "x$enableval" = "xyes"
2383      then
2384              enable_plugin="yes"
2385      else
2386              enable_plugin="no"
2387      fi
2388     ],
2389     [
2390      if test "x$2" = "xyes"
2391      then
2392              enable_plugin="yes"
2393      else
2394              enable_plugin="no"
2395      fi
2396     ])
2397     if test "x$enable_plugin" = "xyes"
2398     then
2399             AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
2400     fi
2401     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
2402     enable_$1="$enable_plugin"
2403   ]
2404 )# AC_PLUGIN(name, default, info)
2405
2406 m4_divert_once([HELP_ENABLE], [
2407 collectd features:])
2408 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
2409 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
2410 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
2411 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
2412
2413 plugin_ascent="no"
2414 plugin_battery="no"
2415 plugin_cpu="no"
2416 plugin_cpufreq="no"
2417 plugin_df="no"
2418 plugin_disk="no"
2419 plugin_entropy="no"
2420 plugin_interface="no"
2421 plugin_ipmi="no"
2422 plugin_ipvs="no"
2423 plugin_irq="no"
2424 plugin_libvirt="no"
2425 plugin_load="no"
2426 plugin_memory="no"
2427 plugin_multimeter="no"
2428 plugin_nfs="no"
2429 plugin_perl="no"
2430 plugin_processes="no"
2431 plugin_serial="no"
2432 plugin_swap="no"
2433 plugin_tape="no"
2434 plugin_tcpconns="no"
2435 plugin_thermal="no"
2436 plugin_users="no"
2437 plugin_vmem="no"
2438 plugin_vserver="no"
2439 plugin_wireless="no"
2440
2441 # Linux
2442 if test "x$ac_system" = "xLinux"
2443 then
2444         plugin_battery="yes"
2445         plugin_cpu="yes"
2446         plugin_cpufreq="yes"
2447         plugin_disk="yes"
2448         plugin_entropy="yes"
2449         plugin_interface="yes"
2450         plugin_irq="yes"
2451         plugin_load="yes"
2452         plugin_memory="yes"
2453         plugin_nfs="yes"
2454         plugin_processes="yes"
2455         plugin_serial="yes"
2456         plugin_swap="yes"
2457         plugin_tcpconns="yes"
2458         plugin_thermal="yes"
2459         plugin_vmem="yes"
2460         plugin_vserver="yes"
2461         plugin_wireless="yes"
2462
2463         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
2464         then
2465                 plugin_ipvs="yes"
2466         fi
2467 fi
2468
2469 # Mac OS X devices
2470 if test "x$with_libiokit" = "xyes"
2471 then
2472         plugin_battery="yes"
2473         plugin_disk="yes"
2474 fi
2475
2476 # Solaris
2477 if test "x$with_devinfo$with_kstat" = "xyesyes"
2478 then
2479         plugin_cpu="yes"
2480         plugin_disk="yes"
2481         plugin_interface="yes"
2482         plugin_memory="yes"
2483         plugin_swap="yes"
2484         plugin_tape="yes"
2485 fi
2486
2487 # libstatgrab
2488 if test "x$with_libstatgrab" = "xyes"
2489 then
2490         plugin_cpu="yes"
2491         plugin_disk="yes"
2492         plugin_interface="yes"
2493         plugin_load="yes"
2494         plugin_memory="yes"
2495         plugin_swap="yes"
2496         plugin_users="yes"
2497 fi
2498
2499 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
2500 then
2501         plugin_ascent="yes"
2502 fi
2503
2504 if test "x$with_libopenipmipthread" = "xyes"
2505 then
2506         plugin_ipmi="yes"
2507 fi
2508
2509 if test "x$have_processor_info" = "xyes"
2510 then
2511         plugin_cpu="yes"
2512 fi
2513 if test "x$have_sysctlbyname" = "xyes"
2514 then
2515         plugin_cpu="yes"
2516         plugin_memory="yes"
2517         plugin_tcpconns="yes"
2518 fi
2519
2520 if test "x$have_statfs" = "xyes"
2521 then
2522         plugin_df="yes"
2523 fi
2524 if test "x$have_statvfs" = "xyes"
2525 then
2526         plugin_df="yes"
2527 fi
2528
2529 if test "x$have_getifaddrs" = "xyes"
2530 then
2531         plugin_interface="yes"
2532 fi
2533
2534 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
2535 then
2536         plugin_libvirt="yes"
2537 fi
2538
2539 if test "x$have_getloadavg" = "xyes"
2540 then
2541         plugin_load="yes"
2542 fi
2543
2544 if test "x$have_libperl$have_perl_ithreads" = "xyesyes"
2545 then
2546         plugin_perl="yes"
2547 fi
2548
2549 # Mac OS X memory interface
2550 if test "x$have_host_statistics" = "xyes"
2551 then
2552         plugin_memory="yes"
2553 fi
2554
2555 if test "x$have_termios_h" = "xyes"
2556 then
2557         plugin_multimeter="yes"
2558 fi
2559
2560 if test "x$have_thread_info" = "xyes"
2561 then
2562         plugin_processes="yes"
2563 fi
2564
2565 if test "x$with_libkvm" = "xyes"
2566 then
2567         plugin_processes="yes"
2568         plugin_swap="yes"
2569 fi
2570
2571 if test "x$have_getutent" = "xyes"
2572 then
2573         plugin_users="yes"
2574 fi
2575 if test "x$have_getutxent" = "xyes"
2576 then
2577         plugin_users="yes"
2578 fi
2579
2580 # FIXME: sysctl for swap plugin
2581
2582 m4_divert_once([HELP_ENABLE], [
2583 collectd plugins:])
2584
2585 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
2586 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
2587 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
2588 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
2589 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
2590 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
2591 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
2592 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
2593 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
2594 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
2595 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
2596 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
2597 AC_PLUGIN([email],       [yes],                [EMail statistics])
2598 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
2599 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
2600 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
2601 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
2602 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
2603 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
2604 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
2605 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
2606 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
2607 AC_PLUGIN([load],        [$plugin_load],       [System load])
2608 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
2609 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
2610 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
2611 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
2612 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
2613 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
2614 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
2615 AC_PLUGIN([network],     [yes],                [Network communication plugin])
2616 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
2617 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
2618 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
2619 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
2620 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
2621 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
2622 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
2623 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
2624 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
2625 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
2626 AC_PLUGIN([qmail],       [yes],                [QMail queue statistics])
2627 AC_PLUGIN([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
2628 AC_PLUGIN([sensors],     [$with_lm_sensors],   [lm_sensors statistics])
2629 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
2630 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
2631 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
2632 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
2633 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
2634 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
2635 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
2636 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
2637 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
2638 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
2639 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
2640 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
2641 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
2642 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
2643 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
2644 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
2645
2646 dnl ip_vs.h
2647 if test "x$ac_system" = "xLinux" \
2648         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
2649 then
2650         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
2651 fi
2652
2653 dnl Perl bindings
2654 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
2655 [
2656         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2657         then
2658                 PERL_BINDINGS_OPTIONS="$withval"
2659                 with_perl_bindings="yes"
2660         else
2661                 PERL_BINDINGS_OPTIONS=""
2662                 with_perl_bindings="$withval"
2663         fi
2664 ],
2665 [
2666         PERL_BINDINGS_OPTIONS=""
2667         if test -n "$perl_interpreter"
2668         then
2669                 with_perl_bindings="yes"
2670         else
2671                 with_perl_bindings="no (no perl interpreter found)"
2672         fi
2673 ])
2674 if test "x$with_perl_bindings" = "xyes"
2675 then
2676         PERL_BINDINGS="perl"
2677 else
2678         PERL_BINDINGS=""
2679 fi
2680 AC_SUBST(PERL_BINDINGS)
2681 AC_SUBST(PERL_BINDINGS_OPTIONS)
2682
2683 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
2684
2685 if test "x$with_rrdtool" = "xyes" \
2686         && test "x$librrd_threadsafe" != "xyes"
2687 then
2688         with_rrdtool="yes (warning: librrd is not thread-safe)"
2689 fi
2690
2691 if test "x$with_liboping" = "xyes" \
2692         && test "x$with_own_liboping" = "xyes"
2693 then
2694         with_liboping="yes (shipped version)"
2695 fi
2696
2697 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
2698 then
2699         with_libiptc="yes (shipped version)"
2700 fi
2701
2702 if test "x$with_libperl" = "xyes"
2703 then
2704         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
2705 else
2706         enable_perl="no (needs libperl)"
2707 fi
2708
2709 if test "x$with_perl_bindings" = "xyes" \
2710         && test "x$PERL_BINDINGS_OPTIONS" != "x"
2711 then
2712         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
2713 fi
2714
2715 cat <<EOF;
2716
2717 Configuration:
2718   Libraries:
2719     libcurl . . . . . . . $with_libcurl
2720     libesmtp  . . . . . . $with_libesmtp
2721     libiokit  . . . . . . $with_libiokit
2722     libiptc . . . . . . . $with_libiptc
2723     libkstat  . . . . . . $with_kstat
2724     libkvm  . . . . . . . $with_libkvm
2725     libmysql  . . . . . . $with_libmysql
2726     libnetlink  . . . . . $with_libnetlink
2727     libnetsnmp  . . . . . $with_libnetsnmp
2728     libnotify . . . . . . $with_libnotify
2729     liboconfig  . . . . . $with_liboconfig
2730     libopenipmi . . . . . $with_libopenipmipthread
2731     liboping  . . . . . . $with_liboping
2732     libpcap . . . . . . . $with_libpcap
2733     libperl . . . . . . . $with_libperl
2734     libpthread  . . . . . $with_libpthread
2735     libpq . . . . . . . . $with_libpq
2736     librrd  . . . . . . . $with_rrdtool
2737     libsensors  . . . . . $with_lm_sensors
2738     libstatgrab . . . . . $with_libstatgrab
2739     libupsclient  . . . . $with_libupsclient
2740     libvirt . . . . . . . $with_libvirt
2741     libxml2 . . . . . . . $with_libxml2
2742     libxmms . . . . . . . $with_libxmms
2743
2744   Features:
2745     daemon mode . . . . . $enable_daemon
2746     debug . . . . . . . . $enable_debug
2747
2748   Bindings:
2749     perl  . . . . . . . . $with_perl_bindings
2750
2751   Modules:
2752     apache  . . . . . . . $enable_apache
2753     apcups  . . . . . . . $enable_apcups
2754     apple_sensors . . . . $enable_apple_sensors
2755     ascent  . . . . . . . $enable_ascent
2756     battery . . . . . . . $enable_battery
2757     cpu . . . . . . . . . $enable_cpu
2758     cpufreq . . . . . . . $enable_cpufreq
2759     csv . . . . . . . . . $enable_csv
2760     df  . . . . . . . . . $enable_df
2761     disk  . . . . . . . . $enable_disk
2762     dns . . . . . . . . . $enable_dns
2763     email . . . . . . . . $enable_email
2764     entropy . . . . . . . $enable_entropy
2765     exec  . . . . . . . . $enable_exec
2766     hddtemp . . . . . . . $enable_hddtemp
2767     interface . . . . . . $enable_interface
2768     iptables  . . . . . . $enable_iptables
2769     ipmi  . . . . . . . . $enable_ipmi
2770     ipvs  . . . . . . . . $enable_ipvs
2771     irq . . . . . . . . . $enable_irq
2772     libvirt . . . . . . . $enable_libvirt
2773     load  . . . . . . . . $enable_load
2774     logfile . . . . . . . $enable_logfile
2775     mbmon . . . . . . . . $enable_mbmon
2776     memcached . . . . . . $enable_memcached
2777     memory  . . . . . . . $enable_memory
2778     multimeter  . . . . . $enable_multimeter
2779     mysql . . . . . . . . $enable_mysql
2780     netlink . . . . . . . $enable_netlink
2781     network . . . . . . . $enable_network
2782     nfs . . . . . . . . . $enable_nfs
2783     nginx . . . . . . . . $enable_nginx
2784     notify_desktop  . . . $enable_notify_desktop
2785     notify_email  . . . . $enable_notify_email
2786     ntpd  . . . . . . . . $enable_ntpd
2787     nut . . . . . . . . . $enable_nut
2788     perl  . . . . . . . . $enable_perl
2789     ping  . . . . . . . . $enable_ping
2790     postgresql  . . . . . $enable_postgresql
2791     powerdns  . . . . . . $enable_powerdns
2792     processes . . . . . . $enable_processes
2793     qmail . . . . . . . . $enable_qmail
2794     rrdtool . . . . . . . $enable_rrdtool
2795     sensors . . . . . . . $enable_sensors
2796     serial  . . . . . . . $enable_serial
2797     snmp  . . . . . . . . $enable_snmp
2798     swap  . . . . . . . . $enable_swap
2799     syslog  . . . . . . . $enable_syslog
2800     tail  . . . . . . . . $enable_tail
2801     tape  . . . . . . . . $enable_tape
2802     tcpconns  . . . . . . $enable_tcpconns
2803     teamspeak2  . . . . . $enable_teamspeak2
2804     thermal . . . . . . . $enable_thermal
2805     unixsock  . . . . . . $enable_unixsock
2806     users . . . . . . . . $enable_users
2807     uuid  . . . . . . . . $enable_uuid
2808     vmem  . . . . . . . . $enable_vmem
2809     vserver . . . . . . . $enable_vserver
2810     wireless  . . . . . . $enable_wireless
2811     xmms  . . . . . . . . $enable_xmms
2812
2813 EOF