Merge branch 'collectd-4.3' into 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(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h sys/isa_defs.h)
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         PKG_PROG_PKG_CONFIG
895         if test "x$PKG_CONFIG" != "x"; then
896                 BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
897                 BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
898                 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
899                 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
900         fi
901 fi
902
903 m4_divert_once([HELP_WITH], [
904 collectd additional packages:])
905
906 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
907 librrd_cflags=""
908 librrd_ldflags=""
909 librrd_threadsafe="yes"
910 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
911 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
912         then
913                 librrd_cflags="-I$withval/include"
914                 librrd_ldflags="-L$withval/lib"
915                 with_rrdtool="yes"
916         else
917                 with_rrdtool="$withval"
918         fi
919 ], [with_rrdtool="yes"])
920 if test "x$with_rrdtool" = "xyes"
921 then
922         SAVE_CPPFLAGS="$CPPFLAGS"
923         SAVE_LDFLAGS="$LDFLAGS"
924
925         CPPFLAGS="$CPPFLAGS $librrd_cflags"
926         LDFLAGS="$LDFLAGS $librrd_ldflags"
927
928         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
929
930         CPPFLAGS="$SAVE_CPPFLAGS"
931         LDFLAGS="$SAVE_LDFLAGS"
932 fi
933 if test "x$with_rrdtool" = "xyes"
934 then
935         SAVE_CPPFLAGS="$CPPFLAGS"
936         SAVE_LDFLAGS="$LDFLAGS"
937
938         CPPFLAGS="$CPPFLAGS $librrd_cflags"
939         LDFLAGS="$LDFLAGS $librrd_ldflags"
940
941         AC_CHECK_LIB(rrd_th, rrd_update_r,
942         [with_rrdtool="yes"
943          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
944         ],
945         [librrd_threadsafe="no"
946          AC_CHECK_LIB(rrd, rrd_update,
947          [with_rrdtool="yes"
948           librrd_ldflags="$librrd_ldflags -lrrd -lm"
949          ],
950          [with_rrdtool="no (symbol 'rrd_update' not found)"],
951          [-lm])
952         ],
953         [-lm])
954
955         CPPFLAGS="$SAVE_CPPFLAGS"
956         LDFLAGS="$SAVE_LDFLAGS"
957 fi
958 if test "x$with_rrdtool" = "xyes"
959 then
960         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
961         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
962         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
963         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
964 fi
965 if test "x$librrd_threadsafe" = "xyes"
966 then
967         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
968 fi
969
970 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
971 [       if test "x$withval" != "xno" \
972                 && test "x$withval" != "xyes"
973         then
974                 LDFLAGS="$LDFLAGS -L$withval/lib"
975                 CPPFLAGS="$CPPFLAGS -I$withval/include"
976                 with_libpthread="yes"
977         else
978                 if test "x$withval" = "xno"
979                 then
980                         with_libpthread="no (disabled)"
981                 fi
982         fi
983 ], [with_libpthread="yes"])
984 if test "x$with_libpthread" = "xyes"
985 then
986         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
987 fi
988 if test "x$with_libpthread" = "xyes"
989 then
990         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
991 fi
992 if test "x$with_libpthread" = "xyes"
993 then
994         collect_pthread=1
995 else
996         collect_pthread=0
997 fi
998 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
999         [Wether or not to use pthread (POSIX threads) library])
1000 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
1001
1002 if test "x$ac_system" = "xSolaris"
1003 then
1004         with_kstat="yes"
1005         with_devinfo="yes"
1006 else
1007         with_kstat="no (Solaris only)"
1008         with_devinfo="no (Solaris only)"
1009 fi
1010
1011 if test "x$with_kstat" = "xyes"
1012 then
1013         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
1014 fi
1015 if test "x$with_kstat" = "xyes"
1016 then
1017         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
1018         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
1019 fi
1020 if test "x$with_kstat" = "xyes"
1021 then
1022         AC_DEFINE(HAVE_LIBKSTAT, 1,
1023                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1024 fi
1025 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1026 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1027
1028 ### BEGIN of check for libcurl ###
1029 with_curl_config="curl-config"
1030 with_curl_cflags=""
1031 with_curl_libs=""
1032 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
1033 [
1034         if test "x$withval" = "xno"
1035         then
1036                 with_libcurl="no"
1037         else if test "x$withval" = "xyes"
1038         then
1039                 with_libcurl="yes"
1040         else
1041                 if test -f "$withval" && test -x "$withval"
1042                 then
1043                         with_curl_config="$withval"
1044                         with_libcurl="yes"
1045                 else if test -x "$withval/bin/curl-config"
1046                 then
1047                         with_curl_config="$withval/bin/curl-config"
1048                         with_libcurl="yes"
1049                 fi; fi
1050                 with_libcurl="yes"
1051         fi; fi
1052 ],
1053 [
1054         with_libcurl="yes"
1055 ])
1056 if test "x$with_libcurl" = "xyes"
1057 then
1058         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1059         curl_config_status=$?
1060
1061         if test $curl_config_status -ne 0
1062         then
1063                 with_libcurl="no ($with_curl_config failed)"
1064         else
1065                 SAVE_CPPFLAGS="$CPPFLAGS"
1066                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1067
1068                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1069
1070                 CPPFLAGS="$SAVE_CPPFLAGS"
1071         fi
1072 fi
1073 if test "x$with_libcurl" = "xyes"
1074 then
1075         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1076         curl_config_status=$?
1077
1078         if test $curl_config_status -ne 0
1079         then
1080                 with_libcurl="no ($with_curl_config failed)"
1081         else
1082                 AC_CHECK_LIB(curl, curl_easy_init,
1083                  [with_libcurl="yes"],
1084                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1085                  [$with_curl_libs])
1086         fi
1087 fi
1088 if test "x$with_libcurl" = "xyes"
1089 then
1090         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1091         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1092         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1093         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1094 fi
1095 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1096 ### END of check for libcurl ###
1097
1098 with_libiokit="no"
1099 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1100 [
1101         with_libiokit="yes"
1102 ], 
1103 [
1104         with_libiokit="no"
1105 ])
1106 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1107
1108 with_libstatgrab_cflags=""
1109 with_libstatgrab_ldflags=""
1110 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
1111 [
1112         if test "x$withval" != "xno" \
1113                 && test "x$withval" != "xyes"
1114         then
1115                 with_libstatgrab_cflags="-I$withval/include"
1116                 with_libstatgrab_ldflags="-L$withval/lib"
1117                 with_libstatgrab="yes"
1118         else
1119                 with_libstatgrab="$withval"
1120         fi
1121 ],
1122 [
1123         if test "x$ac_system" = "xunknown"
1124         then
1125                 with_libstatgrab="yes"
1126         else
1127                 with_libstatgrab="no"
1128         fi
1129 ])
1130 with_libstatgrab_pkg_config="yes"
1131 if test "x$with_libstatgrab" = "xyes" \
1132   && test "x$PKG_CONFIG" != "x"
1133 then
1134   AC_MSG_CHECKING([pkg-config for libstatgrab])
1135   temp_result="found"
1136   $PKG_CONFIG --exists libstatgrab 2>/dev/null
1137   if test "$?" != "0"
1138   then
1139     with_libstatgrab_pkg_config="no"
1140     temp_result="not found"
1141   fi
1142   AC_MSG_RESULT([$temp_result])
1143 else
1144   AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
1145   with_libstatgrab_pkg_config="no"
1146   with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
1147 fi
1148
1149 if test "x$with_libstatgrab" = "xyes" \
1150   && test "x$with_libstatgrab_pkg_config" = "xyes" \
1151   && test "x$with_libstatgrab_cflags" = "x"
1152 then
1153   AC_MSG_CHECKING([for libstatgrab CFLAGS])
1154   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
1155   if test "$?" = "0"
1156   then
1157     with_libstatgrab_cflags="$temp_result"
1158   else
1159     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
1160     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
1161   fi
1162   AC_MSG_RESULT([$temp_result])
1163 fi
1164
1165 if test "x$with_libstatgrab" = "xyes" \
1166   && test "x$with_libstatgrab_pkg_config" = "xyes" \
1167   && test "x$with_libstatgrab_ldflags" = "x"
1168 then
1169   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
1170   temp_result="`$PKG_CONFIG --libs libstatgrab`"
1171   if test "$?" = "0"
1172   then
1173     with_libstatgrab_ldflags="$temp_result"
1174   else
1175     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
1176     temp_result="$PKG_CONFIG --libs libstatgrab failed"
1177   fi
1178   AC_MSG_RESULT([$temp_result])
1179 fi
1180
1181 if test "x$with_libstatgrab" = "xyes"
1182 then
1183   SAVE_CPPFLAGS="$CPPFLAGS"
1184   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
1185
1186   AC_CHECK_HEADERS(statgrab.h,
1187                    [with_libstatgrab="yes"],
1188                    [with_libstatgrab="no (statgrab.h not found)"])
1189
1190   CPPFLAGS="$SAVE_CPPFLAGS"
1191 fi
1192
1193 if test "x$with_libstatgrab" = "xyes"
1194 then
1195   SAVE_CFLAGS="$CFLAGS"
1196   SAVE_LDFLAGS="$LDFLAGS"
1197
1198   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
1199   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
1200
1201   AC_CHECK_LIB(statgrab, sg_init,
1202                [with_libstatgrab="yes"],
1203                [with_libstatgrab="no (symbol sg_init not found)"])
1204
1205   CFLAGS="$SAVE_CFLAGS"
1206   LDFLAGS="$SAVE_LDFLAGS"
1207 fi
1208
1209 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
1210 if test "x$with_libstatgrab" = "xyes"
1211 then
1212   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
1213   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
1214   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
1215   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
1216   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
1217 fi
1218
1219 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
1220 if test "x$with_libkvm" = "xyes"
1221 then
1222         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
1223 fi
1224 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
1225
1226 with_sensors_cflags=""
1227 with_sensors_ldflags=""
1228 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
1229 [
1230         if test "x$withval" = "xno"
1231         then
1232                 with_lm_sensors="no"
1233         else
1234                 with_lm_sensors="yes"
1235                 if test "x$withval" != "xyes"
1236                 then
1237                         with_sensors_cflags="-I$withval/include"
1238                         with_sensors_ldflags="-L$withval/lib"
1239                         with_lm_sensors="yes"
1240                 fi
1241         fi
1242 ],
1243 [
1244         if test "x$ac_system" = "xLinux"
1245         then
1246                 with_lm_sensors="yes"
1247         else
1248                 with_lm_sensors="no (Linux only library)"
1249         fi
1250 ])
1251 if test "x$with_lm_sensors" = "xyes"
1252 then
1253         SAVE_CPPFLAGS="$CPPFLAGS"
1254         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1255
1256 #       AC_CHECK_HEADERS(sensors/sensors.h,
1257 #       [
1258 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
1259 #       ],
1260 #       [with_lm_sensors="no (sensors/sensors.h not found)"])
1261         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_lm_sensors="no (sensors/sensors.h not found)"])
1262
1263         CPPFLAGS="$SAVE_CPPFLAGS"
1264 fi
1265 if test "x$with_lm_sensors" = "xyes"
1266 then
1267         SAVE_CPPFLAGS="$CPPFLAGS"
1268         SAVE_LDFLAGS="$LDFLAGS"
1269         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1270         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
1271
1272         AC_CHECK_LIB(sensors, sensors_init,
1273         [
1274                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
1275         ],
1276         [with_lm_sensors="no (libsensors not found)"])
1277
1278         CPPFLAGS="$SAVE_CPPFLAGS"
1279         LDFLAGS="$SAVE_LDFLAGS"
1280 fi
1281 if test "x$with_lm_sensors" = "xyes"
1282 then
1283         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
1284         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
1285         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
1286         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
1287 fi
1288 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
1289
1290 with_mysql_config="mysql_config"
1291 with_mysql_cflags=""
1292 with_mysql_libs=""
1293 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1294 [
1295         if test "x$withval" = "xno"
1296         then
1297                 with_libmysql="no"
1298         else if test "x$withval" = "xyes"
1299         then
1300                 with_libmysql="yes"
1301         else
1302                 if test -f "$withval" && test -x "$withval";
1303                 then
1304                         with_mysql_config="$withval"
1305                 else if test -x "$withval/bin/mysql_config"
1306                 then
1307                         with_mysql_config="$withval/bin/mysql_config"
1308                 fi; fi
1309                 with_libmysql="yes"
1310         fi; fi
1311 ],
1312 [
1313         with_libmysql="yes"
1314 ])
1315 if test "x$with_libmysql" = "xyes"
1316 then
1317         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1318         mysql_config_status=$?
1319
1320         if test $mysql_config_status -ne 0
1321         then
1322                 with_libmysql="no"
1323         else
1324                 SAVE_CPPFLAGS="$CPPFLAGS"
1325                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1326
1327                 AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
1328
1329                 CPPFLAGS="$SAVE_CPPFLAGS"
1330         fi
1331 fi
1332 if test "x$with_libmysql" = "xyes"
1333 then
1334         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1335         mysql_config_status=$?
1336
1337         if test $mysql_config_status -ne 0
1338         then
1339                 with_libmysql="no"
1340         else
1341                 AC_CHECK_LIB(mysqlclient, mysql_init,
1342                  [with_libmysql="yes"],
1343                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1344                  [$with_mysql_libs])
1345         fi
1346 fi
1347 if test "x$with_libmysql" = "xyes"
1348 then
1349         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1350         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1351         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1352         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1353 fi
1354 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1355
1356 with_own_liboconfig="no"
1357 liboconfig_LDFLAGS="$LDFLAGS"
1358 liboconfig_CPPFLAGS="$CPPFLAGS"
1359 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1360 [
1361         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1362         then
1363                 if test -d "$withval/lib"
1364                 then
1365                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1366                 fi
1367                 if test -d "$withval/include"
1368                 then
1369                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1370                 fi
1371         fi
1372         if test "x$withval" = "xno"
1373         then
1374                 AC_MSG_ERROR("liboconfig is required")
1375         fi
1376 ],
1377 [
1378         with_liboconfig="yes"
1379 ])
1380
1381 save_LDFLAGS="$LDFLAGS"
1382 save_CPPFLAGS="$CPPFLAGS"
1383 LDFLAGS="$liboconfig_LDFLAGS"
1384 CPPFLAGS="$liboconfig_CPPFLAGS"
1385 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1386 [
1387         with_liboconfig="yes"
1388         with_own_liboconfig="no"
1389 ],
1390 [
1391         with_liboconfig="yes"
1392         with_own_liboconfig="yes"
1393         LDFLAGS="$save_LDFLAGS"
1394         CPPFLAGS="$save_CPPFLAGS"
1395 ])
1396
1397 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1398 if test "x$with_own_liboconfig" = "xyes"
1399 then
1400         with_liboconfig="yes (shipped version)"
1401 fi
1402
1403 #with_liboping="yes"
1404 with_own_liboping="no"
1405 liboping_LDFLAGS="$LDFLAGS"
1406 liboping_CPPFLAGS="$CPPFLAGS"
1407 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1408 [
1409         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1410         then
1411                 if test -d "$withval/lib"
1412                 then
1413                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1414                 fi
1415                 if test -d "$withval/include"
1416                 then
1417                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1418                 fi
1419         fi
1420         if test "x$withval" = "xno"
1421         then
1422                 with_liboping="no"
1423                 with_own_liboping="no"
1424         else if test "x$withval" = "xyes"
1425         then
1426                 with_liboping="yes"
1427         fi; fi
1428 ],
1429 [
1430         with_liboping="yes"
1431 ])
1432
1433 if test "x$with_liboping" = "xyes"
1434 then
1435         save_LDFLAGS="$LDFLAGS"
1436         save_CPPFLAGS="$CPPFLAGS"
1437         LDFLAGS="$liboping_LDFLAGS"
1438         CPPFLAGS="$liboping_CPPFLAGS"
1439         AC_CHECK_LIB(oping, ping_construct,
1440         [
1441                 with_liboping="yes"
1442                 with_own_liboping="no"
1443         ],
1444         [
1445                 with_liboping="yes"
1446                 with_own_liboping="yes"
1447                 LDFLAGS="$save_LDFLAGS"
1448                 CPPFLAGS="$save_CPPFLAGS"
1449         ])
1450 fi
1451 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1452 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1453
1454 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1455 [
1456         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1457         then
1458                 LDFLAGS="$LDFLAGS -L$withval/lib"
1459                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1460                 with_libpcap="yes"
1461         else
1462                 with_libpcap="$withval"
1463         fi
1464 ],
1465 [
1466         with_libpcap="yes"
1467 ])
1468 if test "x$with_libpcap" = "xyes"
1469 then
1470         AC_CHECK_LIB(pcap, pcap_open_live,
1471         [
1472                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1473         ], [with_libpcap="no (libpcap not found)"])
1474 fi
1475 if test "x$with_libpcap" = "xyes"
1476 then
1477         AC_CHECK_HEADERS(pcap.h,
1478         [
1479                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1480         ], [with_libpcap="no (pcap.h not found)"])
1481 fi
1482 if test "x$with_libpcap" = "xyes"
1483 then
1484         collect_libpcap=1
1485 else
1486         collect_libpcap=0
1487 fi
1488 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1489         [Wether or not to use the pcap library])
1490 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1491
1492 perl_interpreter="perl"
1493 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1494 [
1495         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1496         then
1497                 LDFLAGS="$LDFLAGS -L$withval/lib"
1498                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1499                 perl_interpreter="$withval/bin/perl"
1500                 with_libperl="yes"
1501         else
1502                 with_libperl="$withval"
1503         fi
1504 ],
1505 [
1506         with_libperl="yes"
1507 ])
1508
1509 AC_MSG_CHECKING([for perl])
1510 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
1511 if test -x "$perl_interpreter"
1512 then
1513         AC_MSG_RESULT([yes])
1514 else
1515         perl_interpreter=""
1516         AC_MSG_RESULT([no])
1517 fi
1518
1519 AC_SUBST(PERL, "$perl_interpreter")
1520
1521 if test "x$with_libperl" = "xyes" \
1522         && test -n "$perl_interpreter"
1523 then
1524   SAVE_CFLAGS=$CFLAGS
1525   SAVE_LDFLAGS=$LDFLAGS
1526   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1527   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1528   CFLAGS="$CFLAGS $PERL_CFLAGS"
1529   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1530
1531   AC_CACHE_CHECK([for libperl],
1532     [have_libperl],
1533     AC_LINK_IFELSE(
1534       AC_LANG_PROGRAM(
1535       [[
1536 #include <EXTERN.h>
1537 #include <perl.h>
1538 #include <XSUB.h>
1539       ]],
1540       [[
1541        PerlInterpreter *perl = NULL;
1542        Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
1543                          newSVpv ("Collectd::Plugin::FooBar", 24),
1544                          Nullsv);
1545       ]]),
1546       [have_libperl="yes"],
1547       [have_libperl="no"]
1548     )
1549   )
1550
1551   if test "x$have_libperl" = "xyes"
1552   then
1553           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1554           AC_SUBST(PERL_CFLAGS)
1555           AC_SUBST(PERL_LDFLAGS)
1556   else
1557           with_libperl="no"
1558   fi
1559
1560   CFLAGS=$SAVE_CFLAGS
1561   LDFLAGS=$SAVE_LDFLAGS
1562 else if test -z "$perl_interpreter"; then
1563   with_libperl="no (no perl interpreter found)"
1564   have_libperl="no"
1565 fi; fi
1566 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1567
1568 if test "x$with_libperl" = "xyes"
1569 then
1570         SAVE_CFLAGS=$CFLAGS
1571         SAVE_LDFLAGS=$LDFLAGS
1572         CFLAGS="$CFLAGS $PERL_CFLAGS"
1573         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1574
1575         AC_CACHE_CHECK([if perl supports ithreads],
1576                 [have_perl_ithreads],
1577                 AC_LINK_IFELSE(
1578                         AC_LANG_PROGRAM(
1579                         [[
1580 #include <EXTERN.h>
1581 #include <perl.h>
1582 #include <XSUB.h>
1583
1584 #if !defined(USE_ITHREADS)
1585 # error "Perl does not support ithreads!"
1586 #endif /* !defined(USE_ITHREADS) */
1587                         ]],
1588                         [[ ]]),
1589                         [have_perl_ithreads="yes"],
1590                         [have_perl_ithreads="no"]
1591                 )
1592         )
1593
1594         if test "x$have_perl_ithreads" = "xyes"
1595         then
1596                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
1597         fi
1598
1599         CFLAGS=$SAVE_CFLAGS
1600         LDFLAGS=$SAVE_LDFLAGS
1601 fi
1602
1603 if test "x$ac_system" = "xLinux"
1604 then
1605         AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
1606         if test -z "$KERNEL_DIR"
1607         then
1608                 KERNEL_DIR="/lib/modules/`uname -r`/source"
1609         fi
1610 fi
1611
1612 with_own_libiptc="no"
1613 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1614 [
1615         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1616         then
1617                 LDFLAGS="$LDFLAGS -L$withval/lib"
1618                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1619                 with_libiptc="yes"
1620         else
1621                 with_libiptc="$withval"
1622         fi
1623 ],
1624 [
1625         if test "x$ac_system" = "xLinux"
1626         then
1627                 with_libiptc="yes"
1628         else
1629                 with_libiptc="no (Linux only)"
1630         fi
1631 ])
1632 if test "x$with_libiptc" = "xyes"
1633 then
1634         AC_CHECK_LIB(iptc, iptc_init,
1635         [
1636                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1637         ],
1638         [
1639                 with_libiptc="yes"
1640                 with_own_libiptc="yes"
1641         ])
1642 fi
1643 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes"
1644 then
1645         AC_CHECK_HEADERS(libiptc/libiptc.h,
1646         [
1647                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1648         ],
1649         [
1650                 with_libiptc="yes"
1651                 with_own_libiptc="yes"
1652         ])
1653 fi
1654 if test "x$with_libiptc" = "xyes"
1655 then
1656         SAVE_CFLAGS=$CFLAGS
1657         CFLAGS="$CFLAGS -I$KERNEL_DIR/include"
1658
1659         AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
1660         [
1661                 with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)"
1662                 with_own_libiptc="no"
1663         ],
1664         [
1665 #include "$srcdir/src/libiptc/ipt_kernel_headers.h"
1666         ])
1667
1668         CFLAGS=$SAVE_CFLAGS
1669 fi
1670 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1671 AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
1672 if test "x$with_own_libiptc" = "xyes"
1673 then
1674         AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
1675 fi
1676
1677 with_snmp_config="net-snmp-config"
1678 with_snmp_cflags=""
1679 with_snmp_libs=""
1680 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1681 [
1682         if test "x$withval" = "xno"
1683         then
1684                 with_libnetsnmp="no"
1685         else if test "x$withval" = "xyes"
1686         then
1687                 with_libnetsnmp="yes"
1688         else
1689                 if test -x "$withval"
1690                 then
1691                         with_snmp_config="$withval"
1692                         with_libnetsnmp="yes"
1693                 else
1694                         with_snmp_config="$withval/bin/net-snmp-config"
1695                         with_libnetsnmp="yes"
1696                 fi
1697         fi; fi
1698 ],
1699 [with_libnetsnmp="yes"])
1700 if test "x$with_libnetsnmp" = "xyes"
1701 then
1702         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1703         snmp_config_status=$?
1704
1705         if test $snmp_config_status -ne 0
1706         then
1707                 with_libnetsnmp="no ($with_snmp_config failed)"
1708         else
1709                 SAVE_CPPFLAGS="$CPPFLAGS"
1710                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1711                 
1712                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1713
1714                 CPPFLAGS="$SAVE_CPPFLAGS"
1715         fi
1716 fi
1717 if test "x$with_libnetsnmp" = "xyes"
1718 then
1719         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1720         snmp_config_status=$?
1721
1722         if test $snmp_config_status -ne 0
1723         then
1724                 with_libnetsnmp="no ($with_snmp_config failed)"
1725         else
1726                 AC_CHECK_LIB(netsnmp, init_snmp,
1727                 [with_libnetsnmp="yes"],
1728                 [with_libnetsnmp="no (libnetsnmp not found)"],
1729                 [$with_snmp_libs])
1730         fi
1731 fi
1732 if test "x$with_libnetsnmp" = "xyes"
1733 then
1734         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1735         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1736         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1737         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1738 fi
1739 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1740
1741 with_upsclient_config="libupsclient-config"
1742 with_upsclient_cflags=""
1743 with_upsclient_libs=""
1744 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
1745 [
1746         if test "x$withval" = "xno"
1747         then
1748                 with_libupsclient="no"
1749         else
1750                 if test "x$withval" != "xyes"
1751                 then
1752                         if test -f "$withval" && test -x "$withval";
1753                         then
1754                                 with_upsclient_config="$withval"
1755                         else
1756                                 with_upsclient_config="$withval/bin/libupsclient-config"
1757                         fi
1758                 fi
1759                 with_libupsclient="yes"
1760         fi
1761 ],
1762 [
1763         with_libupsclient="yes"
1764 ])
1765 if test "x$with_libupsclient" = "xyes"
1766 then
1767         with_upsclient_cflags=`$with_upsclient_config --cflags 2>/dev/null`
1768         upsclient_config_status=$?
1769
1770         if test $upsclient_config_status -ne 0
1771         then
1772                 with_libupsclient="no ($with_upsclient_config failed)"
1773         fi
1774 fi
1775 if test "x$with_libupsclient" = "xyes"
1776 then
1777         SAVE_CPPFLAGS="$CPPFLAGS"
1778         CPPFLAGS="$CPPFLAGS $with_upsclient_cflags"
1779
1780         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
1781
1782         CPPFLAGS="$SAVE_CPPFLAGS"
1783 fi
1784 if test "x$with_libupsclient" = "xyes"
1785 then
1786         with_upsclient_libs=`$with_upsclient_config --libs 2>/dev/null`
1787         upsclient_config_status=$?
1788
1789         if test $upsclient_config_status -ne 0
1790         then
1791                 with_libupsclient="no ($with_upsclient_config failed)"
1792         fi
1793 fi
1794 if test "x$with_libupsclient" = "xyes"
1795 then
1796         AC_CHECK_LIB(upsclient, upscli_connect,
1797         [
1798                 BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_upsclient_cflags"
1799                 BUILD_WITH_LIBUPSCLIENT_LIBS="$with_upsclient_libs"
1800                 AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
1801                 AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
1802         ],
1803         [
1804                 with_libupsclient="no (symbol 'upscli_connect' not found)"
1805         ], [$with_upsclient_libs])
1806 fi
1807 if test "x$with_libupsclient" = "xyes"
1808 then
1809         SAVE_CPPFLAGS="$CPPFLAGS"
1810         CPPFLAGS="$CPPFLAGS $with_upsclient_cflags"
1811
1812         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
1813 [#include <stdlib.h>
1814 #include <stdio.h>
1815 #include <upsclient.h>])
1816
1817         CPPFLAGS="$SAVE_CPPFLAGS"
1818 fi
1819 AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
1820
1821 ### BEGIN of check for libxmms ###
1822 with_xmms_config="xmms-config"
1823 with_xmms_cflags=""
1824 with_xmms_libs=""
1825 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
1826 [
1827         if test "x$withval" != "xno" \
1828                 && test "x$withval" != "xyes"
1829         then
1830                 if test -f "$withval" && test -x "$withval";
1831                 then
1832                         with_xmms_config="$withval"
1833                 else if test -x "$withval/bin/xmms-config"
1834                 then
1835                         with_xmms_config="$withval/bin/xmms-config"
1836                 fi; fi
1837                 with_libxmms="yes"
1838         else if test "x$withval" = "xno"
1839         then
1840                 with_libxmms="no"
1841         else
1842                 with_libxmms="yes"
1843         fi; fi
1844 ],
1845 [
1846         with_libxmms="yes"
1847 ])
1848 if test "x$with_libxmms" = "xyes"
1849 then
1850         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
1851         xmms_config_status=$?
1852
1853         if test $xmms_config_status -ne 0
1854         then
1855                 with_libxmms="no"
1856         fi
1857 fi
1858 if test "x$with_libxmms" = "xyes"
1859 then
1860         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
1861         xmms_config_status=$?
1862
1863         if test $xmms_config_status -ne 0
1864         then
1865                 with_libxmms="no"
1866         fi
1867 fi
1868 if test "x$with_libxmms" = "xyes"
1869 then
1870         AC_CHECK_LIB(xmms, xmms_remote_get_info,
1871         [
1872                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
1873                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
1874                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
1875                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
1876         ],
1877         [
1878                 with_libxmms="no"
1879         ],
1880         [$with_xmms_libs])
1881 fi
1882 with_libxmms_numeric=0
1883 if test "x$with_libxmms" = "xyes"
1884 then
1885         with_libxmms_numeric=1
1886 fi
1887 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
1888 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
1889 ### END of check for libxmms ###
1890
1891 with_libnetlink_cflags=""
1892 with_libnetlink_libs="-lnetlink"
1893 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1894 [
1895  echo "libnetlink: withval = $withval"
1896  if test "x$withval" = "xyes"
1897  then
1898          with_libnetlink="yes"
1899  else if test "x$withval" = "xno"
1900  then
1901          with_libnetlink="no"
1902  else
1903          if test -d "$withval/include"
1904          then
1905                  with_libnetlink_cflags="-I$withval/include"
1906                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1907                  with_libnetlink="yes"
1908          else
1909                  AC_MSG_ERROR("no such directory: $withval/include")
1910          fi
1911  fi; fi
1912 ],
1913 [
1914  if test "x$ac_system" = "xLinux"
1915  then
1916          with_libnetlink="yes"
1917  else
1918          with_libnetlink="no (Linux only library)"
1919  fi
1920 ])
1921 if test "x$with_libnetlink" = "xyes"
1922 then
1923         SAVE_CFLAGS=$CFLAGS
1924         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1925
1926         with_libnetlink="no (libnetlink.h not found)"
1927
1928         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1929         [
1930          with_libnetlink="yes"
1931          break
1932         ], [],
1933 [#include <stdio.h>
1934 #include <sys/types.h>
1935 #include <asm/types.h>
1936 #include <sys/socket.h>
1937 #include <linux/netlink.h>
1938 #include <linux/rtnetlink.h>])
1939         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1940 [#include <stdio.h>
1941 #include <sys/types.h>
1942 #include <asm/types.h>
1943 #include <sys/socket.h>])
1944
1945         AC_COMPILE_IFELSE(
1946 [#include <stdio.h>
1947 #include <sys/types.h>
1948 #include <asm/types.h>
1949 #include <sys/socket.h>
1950 #include <linux/netlink.h>
1951 #include <linux/rtnetlink.h>
1952
1953 int main (void)
1954 {
1955         int retval = TCA_STATS2;
1956         return (retval);
1957 }],
1958         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1959         []);
1960
1961         AC_COMPILE_IFELSE(
1962 [#include <stdio.h>
1963 #include <sys/types.h>
1964 #include <asm/types.h>
1965 #include <sys/socket.h>
1966 #include <linux/netlink.h>
1967 #include <linux/rtnetlink.h>
1968
1969 int main (void)
1970 {
1971         int retval = TCA_STATS;
1972         return (retval);
1973 }],
1974         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1975         []);
1976
1977         CFLAGS="$SAVE_CFLAGS"
1978 fi
1979 if test "x$with_libnetlink" = "xyes"
1980 then
1981         AC_CHECK_LIB(netlink, rtnl_open,
1982                      [with_libnetlink="yes"],
1983                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1984                      [$with_libnetlink_libs])
1985 fi
1986 if test "x$with_libnetlink" = "xyes"
1987 then
1988         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1989         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1990         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1991         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1992 fi
1993 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1994
1995 with_libopenipmipthread="yes"
1996 with_libopenipmipthread_cflags=""
1997 with_libopenipmipthread_libs=""
1998
1999 AC_MSG_CHECKING([for pkg-config])
2000 temp_result="no"
2001 if test "x$PKG_CONFIG" = "x"
2002 then
2003         with_libopenipmipthread="no"
2004         temp_result="no"
2005 else
2006         temp_result="$PKG_CONFIG"
2007 fi
2008 AC_MSG_RESULT([$temp_result])
2009
2010 if test "x$with_libopenipmipthread" = "xyes"
2011 then
2012         AC_MSG_CHECKING([for libOpenIPMIpthread])
2013         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
2014         if test "$?" != "0"
2015         then
2016                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
2017         fi
2018         AC_MSG_RESULT([$with_libopenipmipthread])
2019 fi
2020
2021 if test "x$with_libopenipmipthread" = "xyes"
2022 then
2023         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
2024         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
2025         if test "$?" = "0"
2026         then
2027                 with_libopenipmipthread_cflags="$temp_result"
2028         else
2029                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
2030                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
2031         fi
2032         AC_MSG_RESULT([$temp_result])
2033 fi
2034
2035 if test "x$with_libopenipmipthread" = "xyes"
2036 then
2037         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
2038         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
2039         if test "$?" = "0"
2040         then
2041                 with_libopenipmipthread_ldflags="$temp_result"
2042         else
2043                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
2044                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
2045         fi
2046         AC_MSG_RESULT([$temp_result])
2047 fi
2048
2049 if test "x$with_libopenipmipthread" = "xyes"
2050 then
2051         SAVE_CPPFLAGS="$CPPFLAGS"
2052         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
2053
2054         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
2055                          [with_libopenipmipthread="yes"],
2056                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
2057 [#include <OpenIPMI/ipmiif.h>
2058 #include <OpenIPMI/ipmi_err.h>
2059 #include <OpenIPMI/ipmi_posix.h>
2060 #include <OpenIPMI/ipmi_conn.h>
2061 ])
2062
2063         CPPFLAGS="$SAVE_CPPFLAGS"
2064 fi
2065
2066 if test "x$with_libopenipmipthread" = "xyes"
2067 then
2068         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
2069         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
2070         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
2071         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
2072 fi
2073
2074 dnl Check for libvirt and libxml2 libraries.
2075 with_libxml2="no (pkg-config isn't available)"
2076 with_libxml2_cflags=""
2077 with_libxml2_ldflags=""
2078 with_libvirt="no (pkg-config isn't available)"
2079 with_libvirt_cflags=""
2080 with_libvirt_ldflags=""
2081 if test "x$PKG_CONFIG" != "x"
2082 then
2083         pkg-config --exists 'libxml-2.0' 2>/dev/null
2084         if test "$?" = "0"
2085         then
2086                 with_libxml2="yes"
2087         else
2088                 with_libxml2="no (pkg-config doesn't know library)"
2089         fi
2090
2091         pkg-config --exists libvirt 2>/dev/null
2092         if test "$?" = "0"
2093         then
2094                 with_libvirt="yes"
2095         else
2096                 with_libvirt="no (pkg-config doesn't know library)"
2097         fi
2098 fi
2099 if test "x$with_libxml2" = "xyes"
2100 then
2101         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
2102         if test $? -ne 0
2103         then
2104                 with_libxml2="no"
2105         fi
2106         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
2107         if test $? -ne 0
2108         then
2109                 with_libxml2="no"
2110         fi
2111 fi
2112 if test "x$with_libxml2" = "xyes"
2113 then
2114         SAVE_CPPFLAGS="$CPPFLAGS"
2115         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
2116
2117         AC_CHECK_HEADERS(libxml/parser.h, [],
2118                       [with_libxml2="no (libxml/parser.h not found)"])
2119
2120         CPPFLAGS="$SAVE_CPPFLAGS"
2121 fi
2122 if test "x$with_libxml2" = "xyes"
2123 then
2124         SAVE_CFLAGS="$CFLAGS"
2125         SAVE_LDFLAGS="$LDFLAGS"
2126
2127         CFLAGS="$CFLAGS $with_libxml2_cflags"
2128         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
2129
2130         AC_CHECK_LIB(xml2, xmlXPathEval,
2131                      [with_libxml2="yes"],
2132                      [with_libxml2="no (symbol xmlXPathEval not found)"])
2133
2134         CFLAGS="$SAVE_CFLAGS"
2135         LDFLAGS="$SAVE_LDFLAGS"
2136 fi
2137 dnl Add the right compiler flags and libraries.
2138 if test "x$with_libxml2" = "xyes"; then
2139         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
2140         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
2141         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
2142         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
2143 fi
2144 if test "x$with_libvirt" = "xyes"
2145 then
2146         with_libvirt_cflags="`pkg-config --cflags libvirt`"
2147         if test $? -ne 0
2148         then
2149                 with_libvirt="no"
2150         fi
2151         with_libvirt_ldflags="`pkg-config --libs libvirt`"
2152         if test $? -ne 0
2153         then
2154                 with_libvirt="no"
2155         fi
2156 fi
2157 if test "x$with_libvirt" = "xyes"
2158 then
2159         SAVE_CPPFLAGS="$CPPFLAGS"
2160         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
2161
2162         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
2163                       [with_libvirt="no (libvirt/libvirt.h not found)"])
2164
2165         CPPFLAGS="$SAVE_CPPFLAGS"
2166 fi
2167 if test "x$with_libvirt" = "xyes"
2168 then
2169         SAVE_CFLAGS="$CFLAGS"
2170         SAVE_LDFLAGS="$LDFLAGS"
2171
2172         CFLAGS="$CFLAGS $with_libvirt_cflags"
2173         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
2174
2175         AC_CHECK_LIB(virt, virDomainBlockStats,
2176                      [with_libvirt="yes"],
2177                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
2178
2179         CFLAGS="$SAVE_CFLAGS"
2180         LDFLAGS="$SAVE_LDFLAGS"
2181 fi
2182 dnl Add the right compiler flags and libraries.
2183 if test "x$with_libvirt" = "xyes"; then
2184         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
2185         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
2186         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
2187         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
2188 fi
2189
2190 dnl End of check for libvirt and libxml2 libraries.
2191
2192 # Check for enabled/disabled features
2193 #
2194
2195 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
2196 # ------------------------------------------------------------
2197 dnl
2198 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
2199 dnl
2200 AC_DEFUN(
2201         [AC_COLLECTD],
2202         [
2203         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
2204         m4_if(
2205                 [$2],
2206                 [enable],
2207                 [dnl
2208                 m4_define([EnDis],[disabled])dnl
2209                 m4_define([YesNo],[no])dnl
2210                 ],dnl
2211                 [m4_if(
2212                         [$2],
2213                         [disable],
2214                         [dnl
2215                         m4_define([EnDis],[enabled])dnl
2216                         m4_define([YesNo],[yes])dnl
2217                         ],
2218                         [dnl
2219                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
2220                         ]dnl
2221                 )]dnl
2222         )dnl
2223         m4_if([$3], [feature], [],
2224                 [m4_if(
2225                         [$3], [module], [],
2226                         [dnl
2227                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
2228                         ]dnl
2229                 )]dnl
2230         )dnl
2231         AC_ARG_ENABLE(
2232                 [$1],
2233                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
2234                 [],
2235                 enable_$1='[YesNo]'dnl
2236         )# AC_ARG_ENABLE
2237 if test "x$enable_$1" = "xno"
2238 then
2239         collectd_$1=0
2240 else
2241         if test "x$enable_$1" = "xyes"
2242         then
2243                 collectd_$1=1
2244         else
2245                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
2246                 collectd_$1=1
2247                 enable_$1='yes'
2248         fi
2249 fi
2250         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
2251         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
2252         ]dnl
2253 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
2254
2255 # AC_PLUGIN(name, default, info)
2256 # ------------------------------------------------------------
2257 dnl
2258 AC_DEFUN(
2259   [AC_PLUGIN],
2260   [
2261     enable_plugin="no"
2262     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
2263     [
2264      if test "x$enableval" = "xyes"
2265      then
2266              enable_plugin="yes"
2267      else
2268              enable_plugin="no"
2269      fi
2270     ],
2271     [
2272      if test "x$2" = "xyes"
2273      then
2274              enable_plugin="yes"
2275      else
2276              enable_plugin="no"
2277      fi
2278     ])
2279     if test "x$enable_plugin" = "xyes"
2280     then
2281             AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
2282     fi
2283     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
2284     enable_$1="$enable_plugin"
2285   ]
2286 )# AC_PLUGIN(name, default, info)
2287
2288 m4_divert_once([HELP_ENABLE], [
2289 collectd features:])
2290 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
2291 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
2292 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
2293 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
2294
2295 plugin_ascent="no"
2296 plugin_battery="no"
2297 plugin_cpu="no"
2298 plugin_cpufreq="no"
2299 plugin_df="no"
2300 plugin_disk="no"
2301 plugin_entropy="no"
2302 plugin_interface="no"
2303 plugin_ipmi="no"
2304 plugin_ipvs="no"
2305 plugin_irq="no"
2306 plugin_libvirt="no"
2307 plugin_load="no"
2308 plugin_memory="no"
2309 plugin_multimeter="no"
2310 plugin_nfs="no"
2311 plugin_perl="no"
2312 plugin_processes="no"
2313 plugin_serial="no"
2314 plugin_swap="no"
2315 plugin_tape="no"
2316 plugin_tcpconns="no"
2317 plugin_users="no"
2318 plugin_vmem="no"
2319 plugin_vserver="no"
2320 plugin_wireless="no"
2321
2322 # Linux
2323 if test "x$ac_system" = "xLinux"
2324 then
2325         plugin_battery="yes"
2326         plugin_cpu="yes"
2327         plugin_cpufreq="yes"
2328         plugin_disk="yes"
2329         plugin_entropy="yes"
2330         plugin_interface="yes"
2331         plugin_irq="yes"
2332         plugin_load="yes"
2333         plugin_memory="yes"
2334         plugin_nfs="yes"
2335         plugin_processes="yes"
2336         plugin_serial="yes"
2337         plugin_swap="yes"
2338         plugin_tcpconns="yes"
2339         plugin_vmem="yes"
2340         plugin_vserver="yes"
2341         plugin_wireless="yes"
2342
2343         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
2344         then
2345                 plugin_ipvs="yes"
2346         fi
2347 fi
2348
2349 # Mac OS X devices
2350 if test "x$with_libiokit" = "xyes"
2351 then
2352         plugin_battery="yes"
2353         plugin_disk="yes"
2354 fi
2355
2356 # Solaris
2357 if test "x$with_devinfo$with_kstat" = "xyesyes"
2358 then
2359         plugin_cpu="yes"
2360         plugin_disk="yes"
2361         plugin_interface="yes"
2362         plugin_memory="yes"
2363         plugin_swap="yes"
2364         plugin_tape="yes"
2365 fi
2366
2367 # libstatgrab
2368 if test "x$with_libstatgrab" = "xyes"
2369 then
2370         plugin_cpu="yes"
2371         plugin_disk="yes"
2372         plugin_interface="yes"
2373         plugin_load="yes"
2374         plugin_memory="yes"
2375         plugin_swap="yes"
2376         plugin_users="yes"
2377 fi
2378
2379 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
2380 then
2381         plugin_ascent="yes"
2382 fi
2383
2384 if test "x$with_libopenipmipthread" = "xyes"
2385 then
2386         plugin_ipmi="yes"
2387 fi
2388
2389 if test "x$have_processor_info" = "xyes"
2390 then
2391         plugin_cpu="yes"
2392 fi
2393 if test "x$have_sysctlbyname" = "xyes"
2394 then
2395         plugin_cpu="yes"
2396         plugin_memory="yes"
2397         plugin_tcpconns="yes"
2398 fi
2399
2400 if test "x$have_statfs" = "xyes"
2401 then
2402         plugin_df="yes"
2403 fi
2404 if test "x$have_statvfs" = "xyes"
2405 then
2406         plugin_df="yes"
2407 fi
2408
2409 if test "x$have_getifaddrs" = "xyes"
2410 then
2411         plugin_interface="yes"
2412 fi
2413
2414 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
2415 then
2416         plugin_libvirt="yes"
2417 fi
2418
2419 if test "x$have_getloadavg" = "xyes"
2420 then
2421         plugin_load="yes"
2422 fi
2423
2424 if test "x$have_libperl$have_perl_ithreads" = "xyesyes"
2425 then
2426         plugin_perl="yes"
2427 fi
2428
2429 # Mac OS X memory interface
2430 if test "x$have_host_statistics" = "xyes"
2431 then
2432         plugin_memory="yes"
2433 fi
2434
2435 if test "x$have_termios_h" = "xyes"
2436 then
2437         plugin_multimeter="yes"
2438 fi
2439
2440 if test "x$have_thread_info" = "xyes"
2441 then
2442         plugin_processes="yes"
2443 fi
2444
2445 if test "x$with_libkvm" = "xyes"
2446 then
2447         plugin_swap="yes"
2448 fi
2449
2450 if test "x$have_getutent" = "xyes"
2451 then
2452         plugin_users="yes"
2453 fi
2454 if test "x$have_getutxent" = "xyes"
2455 then
2456         plugin_users="yes"
2457 fi
2458
2459 # FIXME: sysctl for swap plugin
2460
2461 m4_divert_once([HELP_ENABLE], [
2462 collectd plugins:])
2463
2464 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
2465 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
2466 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
2467 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
2468 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
2469 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
2470 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
2471 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
2472 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
2473 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
2474 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
2475 AC_PLUGIN([email],       [yes],                [EMail statistics])
2476 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
2477 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
2478 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
2479 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
2480 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
2481 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
2482 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
2483 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
2484 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
2485 AC_PLUGIN([load],        [$plugin_load],       [System load])
2486 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
2487 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
2488 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
2489 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
2490 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
2491 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
2492 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
2493 AC_PLUGIN([network],     [yes],                [Network communication plugin])
2494 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
2495 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
2496 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
2497 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
2498 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
2499 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
2500 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
2501 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
2502 AC_PLUGIN([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
2503 AC_PLUGIN([sensors],     [$with_lm_sensors],   [lm_sensors statistics])
2504 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
2505 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
2506 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
2507 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
2508 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
2509 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
2510 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
2511 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
2512 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
2513 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
2514 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
2515 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
2516 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
2517 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
2518 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
2519
2520 dnl ip_vs.h
2521 if test "x$ac_system" = "xLinux" \
2522         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
2523 then
2524         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
2525 fi
2526
2527 dnl Perl bindings
2528 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
2529 [
2530         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2531         then
2532                 PERL_BINDINGS_OPTIONS="$withval"
2533                 with_perl_bindings="yes"
2534         else
2535                 PERL_BINDINGS_OPTIONS=""
2536                 with_perl_bindings="$withval"
2537         fi
2538 ],
2539 [
2540         PERL_BINDINGS_OPTIONS=""
2541         if test -n "$perl_interpreter"
2542         then
2543                 with_perl_bindings="yes"
2544         else
2545                 with_perl_bindings="no (no perl interpreter found)"
2546         fi
2547 ])
2548 if test "x$with_perl_bindings" = "xyes"
2549 then
2550         PERL_BINDINGS="perl"
2551 else
2552         PERL_BINDINGS=""
2553 fi
2554 AC_SUBST(PERL_BINDINGS)
2555 AC_SUBST(PERL_BINDINGS_OPTIONS)
2556
2557 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
2558
2559 if test "x$with_rrdtool" = "xyes" \
2560         && test "x$librrd_threadsafe" != "xyes"
2561 then
2562         with_rrdtool="yes (warning: librrd is not thread-safe)"
2563 fi
2564
2565 if test "x$with_liboping" = "xyes" \
2566         && test "x$with_own_liboping" = "xyes"
2567 then
2568         with_liboping="yes (shipped version)"
2569 fi
2570
2571 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
2572 then
2573         with_libiptc="yes (shipped version)"
2574 fi
2575
2576 if test "x$with_libperl" = "xyes"
2577 then
2578         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
2579 else
2580         enable_perl="no (needs libperl)"
2581 fi
2582
2583 if test "x$with_perl_bindings" = "xyes" \
2584         && test "x$PERL_BINDINGS_OPTIONS" != "x"
2585 then
2586         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
2587 fi
2588
2589 cat <<EOF;
2590
2591 Configuration:
2592   Libraries:
2593     libcurl . . . . . . $with_libcurl
2594     libiokit  . . . . . $with_libiokit
2595     libiptc . . . . . . $with_libiptc
2596     libkstat  . . . . . $with_kstat
2597     libkvm  . . . . . . $with_libkvm
2598     libmysql  . . . . . $with_libmysql
2599     libnetlink  . . . . $with_libnetlink
2600     libnetsnmp  . . . . $with_libnetsnmp
2601     liboconfig  . . . . $with_liboconfig
2602     libopenipmi . . . . $with_libopenipmipthread
2603     liboping  . . . . . $with_liboping
2604     libpcap . . . . . . $with_libpcap
2605     libperl . . . . . . $with_libperl
2606     libpthread  . . . . $with_libpthread
2607     librrd  . . . . . . $with_rrdtool
2608     libsensors  . . . . $with_lm_sensors
2609     libstatgrab . . . . $with_libstatgrab
2610     libupsclient  . . . $with_libupsclient
2611     libvirt . . . . . . $with_libvirt
2612     libxml2 . . . . . . $with_libxml2
2613     libxmms . . . . . . $with_libxmms
2614
2615   Features:
2616     daemon mode . . . . $enable_daemon
2617     debug . . . . . . . $enable_debug
2618
2619   Bindings:
2620     perl  . . . . . . . $with_perl_bindings
2621
2622   Modules:
2623     apache  . . . . . . $enable_apache
2624     apcups  . . . . . . $enable_apcups
2625     apple_sensors . . . $enable_apple_sensors
2626     ascent  . . . . . . $enable_ascent
2627     battery . . . . . . $enable_battery
2628     cpu . . . . . . . . $enable_cpu
2629     cpufreq . . . . . . $enable_cpufreq
2630     csv . . . . . . . . $enable_csv
2631     df  . . . . . . . . $enable_df
2632     disk  . . . . . . . $enable_disk
2633     dns . . . . . . . . $enable_dns
2634     email . . . . . . . $enable_email
2635     entropy . . . . . . $enable_entropy
2636     exec  . . . . . . . $enable_exec
2637     hddtemp . . . . . . $enable_hddtemp
2638     interface . . . . . $enable_interface
2639     iptables  . . . . . $enable_iptables
2640     ipmi  . . . . . . . $enable_ipmi
2641     ipvs  . . . . . . . $enable_ipvs
2642     irq . . . . . . . . $enable_irq
2643     libvirt . . . . . . $enable_libvirt
2644     load  . . . . . . . $enable_load
2645     logfile . . . . . . $enable_logfile
2646     mbmon . . . . . . . $enable_mbmon
2647     memcached . . . . . $enable_memcached
2648     memory  . . . . . . $enable_memory
2649     multimeter  . . . . $enable_multimeter
2650     mysql . . . . . . . $enable_mysql
2651     netlink . . . . . . $enable_netlink
2652     network . . . . . . $enable_network
2653     nfs . . . . . . . . $enable_nfs
2654     nginx . . . . . . . $enable_nginx
2655     ntpd  . . . . . . . $enable_ntpd
2656     nut . . . . . . . . $enable_nut
2657     perl  . . . . . . . $enable_perl
2658     ping  . . . . . . . $enable_ping
2659     powerdns  . . . . . $enable_powerdns
2660     processes . . . . . $enable_processes
2661     rrdtool . . . . . . $enable_rrdtool
2662     sensors . . . . . . $enable_sensors
2663     serial  . . . . . . $enable_serial
2664     snmp  . . . . . . . $enable_snmp
2665     swap  . . . . . . . $enable_swap
2666     syslog  . . . . . . $enable_syslog
2667     tail  . . . . . . . $enable_tail
2668     tape  . . . . . . . $enable_tape
2669     tcpconns  . . . . . $enable_tcpconns
2670     teamspeak2  . . . . $enable_teamspeak2
2671     unixsock  . . . . . $enable_unixsock
2672     users . . . . . . . $enable_users
2673     uuid  . . . . . . . $enable_uuid
2674     vmem  . . . . . . . $enable_vmem
2675     vserver . . . . . . $enable_vserver
2676     wireless  . . . . . $enable_wireless
2677     xmms  . . . . . . . $enable_xmms
2678
2679 EOF