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