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