contrib/php-collection: Save/load graph list and fix HTTPS handling.
[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_config=""
1775 with_libupsclient_cflags=""
1776 with_libupsclient_libs=""
1777 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1778 [
1779         if test "x$withval" = "xno"
1780         then
1781                 with_libupsclient="no"
1782         else if test "x$withval" = "xyes"
1783         then
1784                 with_libupsclient="use_pkgconfig"
1785         else
1786                 if test -x "$withval"
1787                 then
1788                         with_libupsclient_config="$withval"
1789                         with_libupsclient="use_libupsclient_config"
1790                 else if test -x "$withval/bin/libupsclient-config"
1791                 then
1792                         with_libupsclient_config="$withval/bin/net-snmp-config"
1793                         with_libupsclient="use_libupsclient_config"
1794                 else
1795                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
1796                         with_libupsclient_cflags="-I$withval/include"
1797                         with_libupsclient_libs="-L$withval/lib -lupsclient"
1798                         with_libupsclient="yes"
1799                 fi; fi
1800         fi; fi
1801 ],
1802 [with_libupsclient="use_pkgconfig"])
1803
1804 # configure using libupsclient-config
1805 if test "x$with_libupsclient" = "xuse_libupsclient_config"
1806 then
1807         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
1808         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
1809         if test $? -ne 0
1810         then
1811                 with_libupsclient="no ($with_libupsclient_config failed)"
1812         fi
1813         with_libupsclient_libs="`$with_libupsclient_config --libs`"
1814         if test $? -ne 0
1815         then
1816                 with_libupsclient="no ($with_libupsclient_config failed)"
1817         fi
1818 fi
1819 if test "x$with_libupsclient" = "xuse_libupsclient_config"
1820 then
1821         with_libupsclient="yes"
1822 fi
1823
1824 # configure using pkg-config
1825 if test "x$with_libupsclient" = "xuse_pkgconfig"
1826 then
1827         if test "x$PKG_CONFIG" = "x"
1828         then
1829                 with_libupsclient="no (Don't have pkg-config)"
1830         fi
1831 fi
1832 if test "x$with_libupsclient" = "xuse_pkgconfig"
1833 then
1834         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
1835         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
1836         if test $? -ne 0
1837         then
1838                 with_libupsclient="no (pkg-config doesn't know library)"
1839         fi
1840 fi
1841 if test "x$with_libupsclient" = "xuse_pkgconfig"
1842 then
1843         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
1844         if test $? -ne 0
1845         then
1846                 with_libupsclient="no ($PKG_CONFIG failed)"
1847         fi
1848         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
1849         if test $? -ne 0
1850         then
1851                 with_libupsclient="no ($PKG_CONFIG failed)"
1852         fi
1853 fi
1854 if test "x$with_libupsclient" = "xuse_pkgconfig"
1855 then
1856         with_libupsclient="yes"
1857 fi
1858
1859 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
1860 # the actual checks.
1861 if test "x$with_libupsclient" = "xyes"
1862 then
1863         SAVE_CPPFLAGS="$CPPFLAGS"
1864         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
1865
1866         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
1867
1868         CPPFLAGS="$SAVE_CPPFLAGS"
1869 fi
1870 if test "x$with_libupsclient" = "xyes"
1871 then
1872         SAVE_CPPFLAGS="$CPPFLAGS"
1873         SAVE_LDFLAGS="$LDFLAGS"
1874
1875         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
1876         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
1877
1878         AC_CHECK_LIB(upsclient, upscli_connect,
1879                      [with_libupsclient="yes"],
1880                      [with_libupsclient="no (symbol upscli_connect not found)"])
1881
1882         CPPFLAGS="$SAVE_CPPFLAGS"
1883         LDFLAGS="$SAVE_LDFLAGS"
1884 fi
1885 if test "x$with_libupsclient" = "xyes"
1886 then
1887         SAVE_CPPFLAGS="$CPPFLAGS"
1888         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
1889
1890         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
1891 [#include <stdlib.h>
1892 #include <stdio.h>
1893 #include <upsclient.h>])
1894
1895         CPPFLAGS="$SAVE_CPPFLAGS"
1896 fi
1897 if test "x$with_libupsclient" = "xyes"
1898 then
1899         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
1900         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
1901         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
1902         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
1903 fi
1904
1905 ### BEGIN of check for libxmms ###
1906 with_xmms_config="xmms-config"
1907 with_xmms_cflags=""
1908 with_xmms_libs=""
1909 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
1910 [
1911         if test "x$withval" != "xno" \
1912                 && test "x$withval" != "xyes"
1913         then
1914                 if test -f "$withval" && test -x "$withval";
1915                 then
1916                         with_xmms_config="$withval"
1917                 else if test -x "$withval/bin/xmms-config"
1918                 then
1919                         with_xmms_config="$withval/bin/xmms-config"
1920                 fi; fi
1921                 with_libxmms="yes"
1922         else if test "x$withval" = "xno"
1923         then
1924                 with_libxmms="no"
1925         else
1926                 with_libxmms="yes"
1927         fi; fi
1928 ],
1929 [
1930         with_libxmms="yes"
1931 ])
1932 if test "x$with_libxmms" = "xyes"
1933 then
1934         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
1935         xmms_config_status=$?
1936
1937         if test $xmms_config_status -ne 0
1938         then
1939                 with_libxmms="no"
1940         fi
1941 fi
1942 if test "x$with_libxmms" = "xyes"
1943 then
1944         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
1945         xmms_config_status=$?
1946
1947         if test $xmms_config_status -ne 0
1948         then
1949                 with_libxmms="no"
1950         fi
1951 fi
1952 if test "x$with_libxmms" = "xyes"
1953 then
1954         AC_CHECK_LIB(xmms, xmms_remote_get_info,
1955         [
1956                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
1957                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
1958                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
1959                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
1960         ],
1961         [
1962                 with_libxmms="no"
1963         ],
1964         [$with_xmms_libs])
1965 fi
1966 with_libxmms_numeric=0
1967 if test "x$with_libxmms" = "xyes"
1968 then
1969         with_libxmms_numeric=1
1970 fi
1971 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
1972 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
1973 ### END of check for libxmms ###
1974
1975 with_libnetlink_cflags=""
1976 with_libnetlink_libs="-lnetlink"
1977 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1978 [
1979  echo "libnetlink: withval = $withval"
1980  if test "x$withval" = "xyes"
1981  then
1982          with_libnetlink="yes"
1983  else if test "x$withval" = "xno"
1984  then
1985          with_libnetlink="no"
1986  else
1987          if test -d "$withval/include"
1988          then
1989                  with_libnetlink_cflags="-I$withval/include"
1990                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1991                  with_libnetlink="yes"
1992          else
1993                  AC_MSG_ERROR("no such directory: $withval/include")
1994          fi
1995  fi; fi
1996 ],
1997 [
1998  if test "x$ac_system" = "xLinux"
1999  then
2000          with_libnetlink="yes"
2001  else
2002          with_libnetlink="no (Linux only library)"
2003  fi
2004 ])
2005 if test "x$with_libnetlink" = "xyes"
2006 then
2007         SAVE_CFLAGS=$CFLAGS
2008         CFLAGS="$CFLAGS $with_libnetlink_cflags"
2009
2010         with_libnetlink="no (libnetlink.h not found)"
2011
2012         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
2013         [
2014          with_libnetlink="yes"
2015          break
2016         ], [],
2017 [#include <stdio.h>
2018 #include <sys/types.h>
2019 #include <asm/types.h>
2020 #include <sys/socket.h>
2021 #include <linux/netlink.h>
2022 #include <linux/rtnetlink.h>])
2023         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
2024 [#include <stdio.h>
2025 #include <sys/types.h>
2026 #include <asm/types.h>
2027 #include <sys/socket.h>])
2028
2029         AC_COMPILE_IFELSE(
2030 [#include <stdio.h>
2031 #include <sys/types.h>
2032 #include <asm/types.h>
2033 #include <sys/socket.h>
2034 #include <linux/netlink.h>
2035 #include <linux/rtnetlink.h>
2036
2037 int main (void)
2038 {
2039         int retval = TCA_STATS2;
2040         return (retval);
2041 }],
2042         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
2043         []);
2044
2045         AC_COMPILE_IFELSE(
2046 [#include <stdio.h>
2047 #include <sys/types.h>
2048 #include <asm/types.h>
2049 #include <sys/socket.h>
2050 #include <linux/netlink.h>
2051 #include <linux/rtnetlink.h>
2052
2053 int main (void)
2054 {
2055         int retval = TCA_STATS;
2056         return (retval);
2057 }],
2058         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
2059         []);
2060
2061         CFLAGS="$SAVE_CFLAGS"
2062 fi
2063 if test "x$with_libnetlink" = "xyes"
2064 then
2065         AC_CHECK_LIB(netlink, rtnl_open,
2066                      [with_libnetlink="yes"],
2067                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
2068                      [$with_libnetlink_libs])
2069 fi
2070 if test "x$with_libnetlink" = "xyes"
2071 then
2072         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
2073         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
2074         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
2075         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
2076 fi
2077 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
2078
2079 with_libopenipmipthread="yes"
2080 with_libopenipmipthread_cflags=""
2081 with_libopenipmipthread_libs=""
2082
2083 AC_MSG_CHECKING([for pkg-config])
2084 temp_result="no"
2085 if test "x$PKG_CONFIG" = "x"
2086 then
2087         with_libopenipmipthread="no"
2088         temp_result="no"
2089 else
2090         temp_result="$PKG_CONFIG"
2091 fi
2092 AC_MSG_RESULT([$temp_result])
2093
2094 if test "x$with_libopenipmipthread" = "xyes"
2095 then
2096         AC_MSG_CHECKING([for libOpenIPMIpthread])
2097         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
2098         if test "$?" != "0"
2099         then
2100                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
2101         fi
2102         AC_MSG_RESULT([$with_libopenipmipthread])
2103 fi
2104
2105 if test "x$with_libopenipmipthread" = "xyes"
2106 then
2107         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
2108         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
2109         if test "$?" = "0"
2110         then
2111                 with_libopenipmipthread_cflags="$temp_result"
2112         else
2113                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
2114                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
2115         fi
2116         AC_MSG_RESULT([$temp_result])
2117 fi
2118
2119 if test "x$with_libopenipmipthread" = "xyes"
2120 then
2121         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
2122         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
2123         if test "$?" = "0"
2124         then
2125                 with_libopenipmipthread_ldflags="$temp_result"
2126         else
2127                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
2128                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
2129         fi
2130         AC_MSG_RESULT([$temp_result])
2131 fi
2132
2133 if test "x$with_libopenipmipthread" = "xyes"
2134 then
2135         SAVE_CPPFLAGS="$CPPFLAGS"
2136         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
2137
2138         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
2139                          [with_libopenipmipthread="yes"],
2140                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
2141 [#include <OpenIPMI/ipmiif.h>
2142 #include <OpenIPMI/ipmi_err.h>
2143 #include <OpenIPMI/ipmi_posix.h>
2144 #include <OpenIPMI/ipmi_conn.h>
2145 ])
2146
2147         CPPFLAGS="$SAVE_CPPFLAGS"
2148 fi
2149
2150 if test "x$with_libopenipmipthread" = "xyes"
2151 then
2152         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
2153         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
2154         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
2155         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
2156 fi
2157
2158 dnl Check for libvirt and libxml2 libraries.
2159 with_libxml2="no (pkg-config isn't available)"
2160 with_libxml2_cflags=""
2161 with_libxml2_ldflags=""
2162 with_libvirt="no (pkg-config isn't available)"
2163 with_libvirt_cflags=""
2164 with_libvirt_ldflags=""
2165 if test "x$PKG_CONFIG" != "x"
2166 then
2167         pkg-config --exists 'libxml-2.0' 2>/dev/null
2168         if test "$?" = "0"
2169         then
2170                 with_libxml2="yes"
2171         else
2172                 with_libxml2="no (pkg-config doesn't know library)"
2173         fi
2174
2175         pkg-config --exists libvirt 2>/dev/null
2176         if test "$?" = "0"
2177         then
2178                 with_libvirt="yes"
2179         else
2180                 with_libvirt="no (pkg-config doesn't know library)"
2181         fi
2182 fi
2183 if test "x$with_libxml2" = "xyes"
2184 then
2185         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
2186         if test $? -ne 0
2187         then
2188                 with_libxml2="no"
2189         fi
2190         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
2191         if test $? -ne 0
2192         then
2193                 with_libxml2="no"
2194         fi
2195 fi
2196 if test "x$with_libxml2" = "xyes"
2197 then
2198         SAVE_CPPFLAGS="$CPPFLAGS"
2199         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
2200
2201         AC_CHECK_HEADERS(libxml/parser.h, [],
2202                       [with_libxml2="no (libxml/parser.h not found)"])
2203
2204         CPPFLAGS="$SAVE_CPPFLAGS"
2205 fi
2206 if test "x$with_libxml2" = "xyes"
2207 then
2208         SAVE_CFLAGS="$CFLAGS"
2209         SAVE_LDFLAGS="$LDFLAGS"
2210
2211         CFLAGS="$CFLAGS $with_libxml2_cflags"
2212         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
2213
2214         AC_CHECK_LIB(xml2, xmlXPathEval,
2215                      [with_libxml2="yes"],
2216                      [with_libxml2="no (symbol xmlXPathEval not found)"])
2217
2218         CFLAGS="$SAVE_CFLAGS"
2219         LDFLAGS="$SAVE_LDFLAGS"
2220 fi
2221 dnl Add the right compiler flags and libraries.
2222 if test "x$with_libxml2" = "xyes"; then
2223         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
2224         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
2225         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
2226         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
2227 fi
2228 if test "x$with_libvirt" = "xyes"
2229 then
2230         with_libvirt_cflags="`pkg-config --cflags libvirt`"
2231         if test $? -ne 0
2232         then
2233                 with_libvirt="no"
2234         fi
2235         with_libvirt_ldflags="`pkg-config --libs libvirt`"
2236         if test $? -ne 0
2237         then
2238                 with_libvirt="no"
2239         fi
2240 fi
2241 if test "x$with_libvirt" = "xyes"
2242 then
2243         SAVE_CPPFLAGS="$CPPFLAGS"
2244         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
2245
2246         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
2247                       [with_libvirt="no (libvirt/libvirt.h not found)"])
2248
2249         CPPFLAGS="$SAVE_CPPFLAGS"
2250 fi
2251 if test "x$with_libvirt" = "xyes"
2252 then
2253         SAVE_CFLAGS="$CFLAGS"
2254         SAVE_LDFLAGS="$LDFLAGS"
2255
2256         CFLAGS="$CFLAGS $with_libvirt_cflags"
2257         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
2258
2259         AC_CHECK_LIB(virt, virDomainBlockStats,
2260                      [with_libvirt="yes"],
2261                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
2262
2263         CFLAGS="$SAVE_CFLAGS"
2264         LDFLAGS="$SAVE_LDFLAGS"
2265 fi
2266 dnl Add the right compiler flags and libraries.
2267 if test "x$with_libvirt" = "xyes"; then
2268         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
2269         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
2270         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
2271         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
2272 fi
2273
2274 dnl End of check for libvirt and libxml2 libraries.
2275
2276 # Check for enabled/disabled features
2277 #
2278
2279 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
2280 # ------------------------------------------------------------
2281 dnl
2282 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
2283 dnl
2284 AC_DEFUN(
2285         [AC_COLLECTD],
2286         [
2287         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
2288         m4_if(
2289                 [$2],
2290                 [enable],
2291                 [dnl
2292                 m4_define([EnDis],[disabled])dnl
2293                 m4_define([YesNo],[no])dnl
2294                 ],dnl
2295                 [m4_if(
2296                         [$2],
2297                         [disable],
2298                         [dnl
2299                         m4_define([EnDis],[enabled])dnl
2300                         m4_define([YesNo],[yes])dnl
2301                         ],
2302                         [dnl
2303                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
2304                         ]dnl
2305                 )]dnl
2306         )dnl
2307         m4_if([$3], [feature], [],
2308                 [m4_if(
2309                         [$3], [module], [],
2310                         [dnl
2311                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
2312                         ]dnl
2313                 )]dnl
2314         )dnl
2315         AC_ARG_ENABLE(
2316                 [$1],
2317                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
2318                 [],
2319                 enable_$1='[YesNo]'dnl
2320         )# AC_ARG_ENABLE
2321 if test "x$enable_$1" = "xno"
2322 then
2323         collectd_$1=0
2324 else
2325         if test "x$enable_$1" = "xyes"
2326         then
2327                 collectd_$1=1
2328         else
2329                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
2330                 collectd_$1=1
2331                 enable_$1='yes'
2332         fi
2333 fi
2334         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
2335         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
2336         ]dnl
2337 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
2338
2339 # AC_PLUGIN(name, default, info)
2340 # ------------------------------------------------------------
2341 dnl
2342 AC_DEFUN(
2343   [AC_PLUGIN],
2344   [
2345     enable_plugin="no"
2346     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
2347     [
2348      if test "x$enableval" = "xyes"
2349      then
2350              enable_plugin="yes"
2351      else
2352              enable_plugin="no"
2353      fi
2354     ],
2355     [
2356      if test "x$2" = "xyes"
2357      then
2358              enable_plugin="yes"
2359      else
2360              enable_plugin="no"
2361      fi
2362     ])
2363     if test "x$enable_plugin" = "xyes"
2364     then
2365             if test "x$2" = "xyes"
2366             then
2367                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
2368             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
2369                     dependency_error="yes"
2370                     enable_plugin="no (dependency error)"
2371             fi
2372     fi
2373     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
2374     enable_$1="$enable_plugin"
2375   ]
2376 )# AC_PLUGIN(name, default, info)
2377
2378 m4_divert_once([HELP_ENABLE], [
2379 collectd features:])
2380 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
2381 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
2382 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
2383 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
2384
2385 dependency_error="no"
2386 plugin_ascent="no"
2387 plugin_battery="no"
2388 plugin_cpu="no"
2389 plugin_cpufreq="no"
2390 plugin_df="no"
2391 plugin_disk="no"
2392 plugin_entropy="no"
2393 plugin_interface="no"
2394 plugin_ipmi="no"
2395 plugin_ipvs="no"
2396 plugin_irq="no"
2397 plugin_libvirt="no"
2398 plugin_load="no"
2399 plugin_memory="no"
2400 plugin_multimeter="no"
2401 plugin_nfs="no"
2402 plugin_perl="no"
2403 plugin_processes="no"
2404 plugin_serial="no"
2405 plugin_swap="no"
2406 plugin_tape="no"
2407 plugin_tcpconns="no"
2408 plugin_users="no"
2409 plugin_vmem="no"
2410 plugin_vserver="no"
2411 plugin_wireless="no"
2412
2413 # Linux
2414 if test "x$ac_system" = "xLinux"
2415 then
2416         plugin_battery="yes"
2417         plugin_cpu="yes"
2418         plugin_cpufreq="yes"
2419         plugin_disk="yes"
2420         plugin_entropy="yes"
2421         plugin_interface="yes"
2422         plugin_irq="yes"
2423         plugin_load="yes"
2424         plugin_memory="yes"
2425         plugin_nfs="yes"
2426         plugin_processes="yes"
2427         plugin_serial="yes"
2428         plugin_swap="yes"
2429         plugin_tcpconns="yes"
2430         plugin_vmem="yes"
2431         plugin_vserver="yes"
2432         plugin_wireless="yes"
2433
2434         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
2435         then
2436                 plugin_ipvs="yes"
2437         fi
2438 fi
2439
2440 # Mac OS X devices
2441 if test "x$with_libiokit" = "xyes"
2442 then
2443         plugin_battery="yes"
2444         plugin_disk="yes"
2445 fi
2446
2447 # Solaris
2448 if test "x$with_devinfo$with_kstat" = "xyesyes"
2449 then
2450         plugin_cpu="yes"
2451         plugin_disk="yes"
2452         plugin_interface="yes"
2453         plugin_memory="yes"
2454         plugin_tape="yes"
2455 fi
2456
2457 if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris"
2458 then
2459         plugin_swap="yes"
2460 fi
2461
2462 # libstatgrab
2463 if test "x$with_libstatgrab" = "xyes"
2464 then
2465         plugin_cpu="yes"
2466         plugin_disk="yes"
2467         plugin_interface="yes"
2468         plugin_load="yes"
2469         plugin_memory="yes"
2470         plugin_swap="yes"
2471         plugin_users="yes"
2472 fi
2473
2474 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
2475 then
2476         plugin_ascent="yes"
2477 fi
2478
2479 if test "x$with_libopenipmipthread" = "xyes"
2480 then
2481         plugin_ipmi="yes"
2482 fi
2483
2484 if test "x$have_processor_info" = "xyes"
2485 then
2486         plugin_cpu="yes"
2487 fi
2488 if test "x$have_sysctlbyname" = "xyes"
2489 then
2490         plugin_cpu="yes"
2491         plugin_memory="yes"
2492         plugin_tcpconns="yes"
2493 fi
2494
2495 if test "x$have_statfs" = "xyes"
2496 then
2497         plugin_df="yes"
2498 fi
2499 if test "x$have_statvfs" = "xyes"
2500 then
2501         plugin_df="yes"
2502 fi
2503
2504 if test "x$have_getifaddrs" = "xyes"
2505 then
2506         plugin_interface="yes"
2507 fi
2508
2509 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
2510 then
2511         plugin_libvirt="yes"
2512 fi
2513
2514 if test "x$have_getloadavg" = "xyes"
2515 then
2516         plugin_load="yes"
2517 fi
2518
2519 if test "x$have_libperl$have_perl_ithreads" = "xyesyes"
2520 then
2521         plugin_perl="yes"
2522 fi
2523
2524 # Mac OS X memory interface
2525 if test "x$have_host_statistics" = "xyes"
2526 then
2527         plugin_memory="yes"
2528 fi
2529
2530 if test "x$have_termios_h" = "xyes"
2531 then
2532         plugin_multimeter="yes"
2533 fi
2534
2535 if test "x$have_thread_info" = "xyes"
2536 then
2537         plugin_processes="yes"
2538 fi
2539
2540 if test "x$with_kvm_getswapinfo" = "xyes"
2541 then
2542         plugin_swap="yes"
2543 fi
2544
2545 if test "x$have_getutent" = "xyes"
2546 then
2547         plugin_users="yes"
2548 fi
2549 if test "x$have_getutxent" = "xyes"
2550 then
2551         plugin_users="yes"
2552 fi
2553
2554 # FIXME: sysctl for swap plugin
2555
2556 m4_divert_once([HELP_ENABLE], [
2557 collectd plugins:])
2558
2559 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
2560 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
2561 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
2562 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
2563 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
2564 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
2565 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
2566 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
2567 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
2568 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
2569 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
2570 AC_PLUGIN([email],       [yes],                [EMail statistics])
2571 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
2572 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
2573 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
2574 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
2575 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
2576 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
2577 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
2578 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
2579 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
2580 AC_PLUGIN([load],        [$plugin_load],       [System load])
2581 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
2582 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
2583 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
2584 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
2585 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
2586 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
2587 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
2588 AC_PLUGIN([network],     [yes],                [Network communication plugin])
2589 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
2590 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
2591 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
2592 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
2593 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
2594 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
2595 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
2596 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
2597 AC_PLUGIN([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
2598 AC_PLUGIN([sensors],     [$with_lm_sensors],   [lm_sensors statistics])
2599 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
2600 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
2601 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
2602 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
2603 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
2604 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
2605 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
2606 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
2607 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
2608 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
2609 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
2610 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
2611 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
2612 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
2613 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
2614
2615 dnl ip_vs.h
2616 if test "x$ac_system" = "xLinux" \
2617         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
2618 then
2619         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
2620 fi
2621
2622 dnl Perl bindings
2623 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
2624 [
2625         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2626         then
2627                 PERL_BINDINGS_OPTIONS="$withval"
2628                 with_perl_bindings="yes"
2629         else
2630                 PERL_BINDINGS_OPTIONS=""
2631                 with_perl_bindings="$withval"
2632         fi
2633 ],
2634 [
2635         PERL_BINDINGS_OPTIONS=""
2636         if test -n "$perl_interpreter"
2637         then
2638                 with_perl_bindings="yes"
2639         else
2640                 with_perl_bindings="no (no perl interpreter found)"
2641         fi
2642 ])
2643 if test "x$with_perl_bindings" = "xyes"
2644 then
2645         PERL_BINDINGS="perl"
2646 else
2647         PERL_BINDINGS=""
2648 fi
2649 AC_SUBST(PERL_BINDINGS)
2650 AC_SUBST(PERL_BINDINGS_OPTIONS)
2651
2652 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
2653
2654 if test "x$with_rrdtool" = "xyes" \
2655         && test "x$librrd_threadsafe" != "xyes"
2656 then
2657         with_rrdtool="yes (warning: librrd is not thread-safe)"
2658 fi
2659
2660 if test "x$with_liboping" = "xyes" \
2661         && test "x$with_own_liboping" = "xyes"
2662 then
2663         with_liboping="yes (shipped version)"
2664 fi
2665
2666 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
2667 then
2668         with_libiptc="yes (shipped version)"
2669 fi
2670
2671 if test "x$with_libperl" = "xyes"
2672 then
2673         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
2674 else
2675         enable_perl="no (needs libperl)"
2676 fi
2677
2678 if test "x$with_perl_bindings" = "xyes" \
2679         && test "x$PERL_BINDINGS_OPTIONS" != "x"
2680 then
2681         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
2682 fi
2683
2684 cat <<EOF;
2685
2686 Configuration:
2687   Libraries:
2688     libcurl . . . . . . $with_libcurl
2689     libiokit  . . . . . $with_libiokit
2690     libiptc . . . . . . $with_libiptc
2691     libkstat  . . . . . $with_kstat
2692     libkvm  . . . . . . $with_libkvm
2693     libmysql  . . . . . $with_libmysql
2694     libnetlink  . . . . $with_libnetlink
2695     libnetsnmp  . . . . $with_libnetsnmp
2696     liboconfig  . . . . $with_liboconfig
2697     libopenipmi . . . . $with_libopenipmipthread
2698     liboping  . . . . . $with_liboping
2699     libpcap . . . . . . $with_libpcap
2700     libperl . . . . . . $with_libperl
2701     libpthread  . . . . $with_libpthread
2702     librrd  . . . . . . $with_rrdtool
2703     libsensors  . . . . $with_lm_sensors
2704     libstatgrab . . . . $with_libstatgrab
2705     libupsclient  . . . $with_libupsclient
2706     libvirt . . . . . . $with_libvirt
2707     libxml2 . . . . . . $with_libxml2
2708     libxmms . . . . . . $with_libxmms
2709
2710   Features:
2711     daemon mode . . . . $enable_daemon
2712     debug . . . . . . . $enable_debug
2713
2714   Bindings:
2715     perl  . . . . . . . $with_perl_bindings
2716
2717   Modules:
2718     apache  . . . . . . $enable_apache
2719     apcups  . . . . . . $enable_apcups
2720     apple_sensors . . . $enable_apple_sensors
2721     ascent  . . . . . . $enable_ascent
2722     battery . . . . . . $enable_battery
2723     cpu . . . . . . . . $enable_cpu
2724     cpufreq . . . . . . $enable_cpufreq
2725     csv . . . . . . . . $enable_csv
2726     df  . . . . . . . . $enable_df
2727     disk  . . . . . . . $enable_disk
2728     dns . . . . . . . . $enable_dns
2729     email . . . . . . . $enable_email
2730     entropy . . . . . . $enable_entropy
2731     exec  . . . . . . . $enable_exec
2732     hddtemp . . . . . . $enable_hddtemp
2733     interface . . . . . $enable_interface
2734     iptables  . . . . . $enable_iptables
2735     ipmi  . . . . . . . $enable_ipmi
2736     ipvs  . . . . . . . $enable_ipvs
2737     irq . . . . . . . . $enable_irq
2738     libvirt . . . . . . $enable_libvirt
2739     load  . . . . . . . $enable_load
2740     logfile . . . . . . $enable_logfile
2741     mbmon . . . . . . . $enable_mbmon
2742     memcached . . . . . $enable_memcached
2743     memory  . . . . . . $enable_memory
2744     multimeter  . . . . $enable_multimeter
2745     mysql . . . . . . . $enable_mysql
2746     netlink . . . . . . $enable_netlink
2747     network . . . . . . $enable_network
2748     nfs . . . . . . . . $enable_nfs
2749     nginx . . . . . . . $enable_nginx
2750     ntpd  . . . . . . . $enable_ntpd
2751     nut . . . . . . . . $enable_nut
2752     perl  . . . . . . . $enable_perl
2753     ping  . . . . . . . $enable_ping
2754     powerdns  . . . . . $enable_powerdns
2755     processes . . . . . $enable_processes
2756     rrdtool . . . . . . $enable_rrdtool
2757     sensors . . . . . . $enable_sensors
2758     serial  . . . . . . $enable_serial
2759     snmp  . . . . . . . $enable_snmp
2760     swap  . . . . . . . $enable_swap
2761     syslog  . . . . . . $enable_syslog
2762     tail  . . . . . . . $enable_tail
2763     tape  . . . . . . . $enable_tape
2764     tcpconns  . . . . . $enable_tcpconns
2765     teamspeak2  . . . . $enable_teamspeak2
2766     unixsock  . . . . . $enable_unixsock
2767     users . . . . . . . $enable_users
2768     uuid  . . . . . . . $enable_uuid
2769     vmem  . . . . . . . $enable_vmem
2770     vserver . . . . . . $enable_vserver
2771     wireless  . . . . . $enable_wireless
2772     xmms  . . . . . . . $enable_xmms
2773
2774 EOF
2775
2776 if test "x$dependency_error" = "xyes"; then
2777         AC_MSG_ERROR("Some plugins are missing dependencies - see above summary for details")
2778 fi