configure.in: Added checks to find out how doubles are stored.
[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_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
21
22 dnl configure libtool
23 AC_DISABLE_STATIC
24 AC_LIBLTDL_CONVENIENCE
25 AC_SUBST(LTDLINCL)
26 AC_SUBST(LIBLTDL)
27 AC_LIBTOOL_DLOPEN
28 AC_PROG_LIBTOOL
29 AC_PROG_LEX
30 AC_PROG_YACC
31 AC_CONFIG_SUBDIRS(libltdl)
32
33 AC_MSG_CHECKING([for kernel type ($host_os)])
34 case $host_os in
35         *linux*)
36         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
37         ac_system="Linux"
38         ;;
39         *solaris*)
40         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
41         ac_system="Solaris"
42         ;;
43         *darwin*)
44         ac_system="Darwin"
45         ;;
46         *)
47         ac_system="unknown"
48 esac
49 AC_MSG_RESULT([$ac_system])
50
51 #
52 # Checks for header files.
53 #
54 AC_HEADER_STDC
55 AC_HEADER_SYS_WAIT
56 AC_HEADER_DIRENT
57
58 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)
59
60 # For ping library
61 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
62 [#if HAVE_STDINT_H
63 # include <stdint.h>
64 #endif
65 #if HAVE_SYS_TYPES_H
66 # include <sys/types.h>
67 #endif
68 ])
69 AC_CHECK_HEADERS(netinet/in.h, [], [],
70 [#if HAVE_STDINT_H
71 # include <stdint.h>
72 #endif
73 #if HAVE_SYS_TYPES_H
74 # include <sys/types.h>
75 #endif
76 #if HAVE_NETINET_IN_SYSTM_H
77 # include <netinet/in_systm.h>
78 #endif
79 ])
80 AC_CHECK_HEADERS(netinet/ip.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 #if HAVE_NETINET_IN_SYSTM_H
88 # include <netinet/in_systm.h>
89 #endif
90 #if HAVE_NETINET_IN_H
91 # include <netinet/in.h>
92 #endif
93 ])
94 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
95 [#if HAVE_STDINT_H
96 # include <stdint.h>
97 #endif
98 #if HAVE_SYS_TYPES_H
99 # include <sys/types.h>
100 #endif
101 #if HAVE_NETINET_IN_SYSTM_H
102 # include <netinet/in_systm.h>
103 #endif
104 #if HAVE_NETINET_IN_H
105 # include <netinet/in.h>
106 #endif
107 #if HAVE_NETINET_IP_H
108 # include <netinet/ip.h>
109 #endif
110 ])
111 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
112 [#if HAVE_STDINT_H
113 # include <stdint.h>
114 #endif
115 #if HAVE_SYS_TYPES_H
116 # include <sys/types.h>
117 #endif
118 #if HAVE_NETINET_IN_SYSTM_H
119 # include <netinet/in_systm.h>
120 #endif
121 #if HAVE_NETINET_IN_H
122 # include <netinet/in.h>
123 #endif
124 #if HAVE_NETINET_IP_H
125 # include <netinet/ip.h>
126 #endif
127 ])
128 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
129 [#if HAVE_STDINT_H
130 # include <stdint.h>
131 #endif
132 #if HAVE_SYS_TYPES_H
133 # include <sys/types.h>
134 #endif
135 #if HAVE_NETINET_IN_SYSTM_H
136 # include <netinet/in_systm.h>
137 #endif
138 #if HAVE_NETINET_IN_H
139 # include <netinet/in.h>
140 #endif
141 ])
142 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
143 [#if HAVE_STDINT_H
144 # include <stdint.h>
145 #endif
146 #if HAVE_SYS_TYPES_H
147 # include <sys/types.h>
148 #endif
149 #if HAVE_NETINET_IN_SYSTM_H
150 # include <netinet/in_systm.h>
151 #endif
152 #if HAVE_NETINET_IN_H
153 # include <netinet/in.h>
154 #endif
155 #if HAVE_NETINET_IP6_H
156 # include <netinet/ip6.h>
157 #endif
158 ])
159 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
160 [#if HAVE_STDINT_H
161 # include <stdint.h>
162 #endif
163 #if HAVE_SYS_TYPES_H
164 # include <sys/types.h>
165 #endif
166 #if HAVE_NETINET_IN_SYSTM_H
167 # include <netinet/in_systm.h>
168 #endif
169 #if HAVE_NETINET_IN_H
170 # include <netinet/in.h>
171 #endif
172 #if HAVE_NETINET_IP_H
173 # include <netinet/ip.h>
174 #endif
175 ])
176 AC_CHECK_HEADERS(netinet/udp.h, [], [],
177 [#if HAVE_STDINT_H
178 # include <stdint.h>
179 #endif
180 #if HAVE_SYS_TYPES_H
181 # include <sys/types.h>
182 #endif
183 #if HAVE_NETINET_IN_SYSTM_H
184 # include <netinet/in_systm.h>
185 #endif
186 #if HAVE_NETINET_IN_H
187 # include <netinet/in.h>
188 #endif
189 #if HAVE_NETINET_IP_H
190 # include <netinet/ip.h>
191 #endif
192 ])
193
194 # For cpu modules
195 AC_CHECK_HEADERS(sys/dkstat.h)
196 if test "x$ac_system" = "xDarwin"
197 then
198         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)
199         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
200 fi
201 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
202 [
203 #if HAVE_SYS_TYPES_H
204 #  include <sys/types.h>
205 #endif
206 #if HAVE_SYS_PARAM_H
207 # include <sys/param.h>
208 #endif
209 ])
210
211 # For hddtemp module
212 AC_CHECK_HEADERS(linux/major.h libgen.h)
213
214 # For the battery plugin
215 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
216 [
217 #if HAVE_IOKIT_IOKITLIB_H
218 #  include <IOKit/IOKitLib.h>
219 #endif
220 #if HAVE_IOKIT_IOTYPES_H
221 #  include <IOKit/IOTypes.h>
222 #endif
223 ])
224
225 # For the swap module
226 AC_CHECK_HEADERS(sys/swap.h, [], [],
227 [
228 #if HAVE_SYS_TYPES_H
229 #  include <sys/types.h>
230 #endif
231 #if HAVE_SYS_PARAM_H
232 # include <sys/param.h>
233 #endif
234 ])
235
236 # For load module
237 # For the processes plugin
238 # For users module
239 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
240
241 # For interface plugin
242 AC_CHECK_HEADERS(ifaddrs.h)
243 AC_CHECK_HEADERS(net/if.h, [], [],
244 [
245 #if HAVE_SYS_TYPES_H
246 #  include <sys/types.h>
247 #endif
248 #if HAVE_SYS_SOCKET_H
249 #  include <sys/socket.h>
250 #endif
251 ])
252 AC_CHECK_HEADERS(linux/if.h, [], [],
253 [
254 #if HAVE_SYS_TYPES_H
255 #  include <sys/types.h>
256 #endif
257 #if HAVE_SYS_SOCKET_H
258 #  include <sys/socket.h>
259 #endif
260 ])
261 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
262 [
263 #if HAVE_SYS_TYPES_H
264 #  include <sys/types.h>
265 #endif
266 #if HAVE_SYS_SOCKET_H
267 #  include <sys/socket.h>
268 #endif
269 #if HAVE_LINUX_IF_H
270 # include <linux/if.h>
271 #endif
272 ])
273
274 # For ipvs module
275 have_net_ip_vs_h="no"
276 have_ip_vs_h="no"
277 if test "x$ac_system" = "xLinux"
278 then
279         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
280         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
281 fi
282
283 # For quota module
284 AC_CHECK_HEADERS(sys/ucred.h, [], [],
285 [
286 #if HAVE_SYS_TYPES_H
287 #  include <sys/types.h>
288 #endif
289 #if HAVE_SYS_PARAM_H
290 # include <sys/param.h>
291 #endif
292 ])
293
294 # For mount interface
295 AC_CHECK_HEADERS(sys/mount.h, [], [],
296 [
297 #if HAVE_SYS_TYPES_H
298 #  include <sys/types.h>
299 #endif
300 #if HAVE_SYS_PARAM_H
301 # include <sys/param.h>
302 #endif
303 ])
304
305 # For the email plugin
306 AC_CHECK_HEADERS(linux/un.h, [], [],
307 [
308 #if HAVE_SYS_SOCKET_H
309 #       include <sys/socket.h>
310 #endif
311 ])
312
313 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)
314
315 # For the dns plugin
316 AC_CHECK_HEADERS(arpa/nameser.h)
317 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
318 [
319 #if HAVE_ARPA_NAMESER_H
320 # include <arpa/nameser.h>
321 #endif
322 ])
323
324 AC_CHECK_HEADERS(net/if_arp.h, [], [],
325 [#if HAVE_SYS_SOCKET_H
326 # include <sys/socket.h>
327 #endif
328 ])
329 AC_CHECK_HEADERS(net/ppp_defs.h)
330 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
331 [#if HAVE_NET_PPP_DEFS_H
332 # include <net/ppp_defs.h>
333 #endif
334 ])
335 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
336 [#if HAVE_STDINT_H
337 # include <stdint.h>
338 #endif
339 #if HAVE_SYS_TYPES_H
340 # include <sys/types.h>
341 #endif
342 #if HAVE_SYS_SOCKET_H
343 # include <sys/socket.h>
344 #endif
345 #if HAVE_NET_IF_H
346 # include <net/if.h>
347 #endif
348 #if HAVE_NETINET_IN_H
349 # include <netinet/in.h>
350 #endif
351 ])
352
353 # For the multimeter plugin
354 have_termios_h="no"
355 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
356
357 #
358 # Checks for typedefs, structures, and compiler characteristics.
359 #
360 AC_C_CONST
361 AC_TYPE_PID_T
362 AC_TYPE_SIZE_T
363 AC_TYPE_UID_T
364 AC_HEADER_TIME
365
366 #
367 # Checks for library functions.
368 #
369 AC_PROG_GCC_TRADITIONAL
370 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog)
371
372 AC_FUNC_STRERROR_R
373
374 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
375
376 socket_needs_socket="no"
377 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
378 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
379
380 nanosleep_needs_rt="no"
381 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
382 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
383
384 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
385 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
386 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
387 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
388 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
389 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
390 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
391 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
392 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
393 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
394
395 # For load module
396 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
397
398 # Check for NAN
399 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
400 [
401  if test "x$withval" = "xno"; then
402          nan_type="none"
403  else if test "x$withval" = "xyes"; then
404          nan_type="zero"
405  else
406          nan_type="$withval"
407  fi; fi
408 ],
409 [nan_type="none"])
410 if test "x$nan_type" = "xnone"; then
411   AC_CACHE_CHECK([whether NAN is defined by default],
412     [have_nan_default],
413     AC_COMPILE_IFELSE(
414       AC_LANG_PROGRAM(
415       [[
416 #include <stdlib.h>
417 #include <math.h>
418 static float foo = NAN;
419       ]],
420       [[
421        if (isnan (foo))
422         return 0;
423        else
424         return 1;
425       ]]),
426       [have_nan_default="yes"],
427       [have_nan_default="no"]
428     )
429   )
430   if test "x$have_nan_default" = "xyes"
431   then
432     nan_type="default"
433   fi
434 fi
435 if test "x$nan_type" = "xnone"; then
436   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
437     [have_nan_isoc],
438     AC_COMPILE_IFELSE(
439       AC_LANG_PROGRAM(
440       [[
441 #include <stdlib.h>
442 #define __USE_ISOC99 1
443 #include <math.h>
444 static float foo = NAN;
445       ]],
446       [[
447        if (isnan (foo))
448         return 0;
449        else
450         return 1;
451       ]]),
452       [have_nan_isoc="yes"],
453       [have_nan_isoc="no"]
454     )
455   )
456   if test "x$have_nan_isoc" = "xyes"
457   then
458     nan_type="isoc99"
459   fi
460 fi
461 if test "x$nan_type" = "xnone"; then
462   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
463     [have_nan_zero],
464     AC_RUN_IFELSE(
465       AC_LANG_PROGRAM(
466       [[
467 #include <stdlib.h>
468 #include <math.h>
469 #ifdef NAN
470 # undef NAN
471 #endif
472 #define NAN (0.0 / 0.0)
473 #ifndef isnan
474 # define isnan(f) ((f) != (f))
475 #endif
476 static float foo = NAN;
477       ]],
478       [[
479        if (isnan (foo))
480         return 0;
481        else
482         return 1;
483       ]]),
484       [have_nan_zero="yes"],
485       [have_nan_zero="no"]
486     )
487   )
488   if test "x$have_nan_zero" = "xyes"
489   then
490     nan_type="zero"
491   fi
492 fi
493
494 if test "x$nan_type" = "xdefault"; then
495   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
496     [Define if NAN is defined by default and can initialize static variables.])
497 else if test "x$nan_type" = "xisoc99"; then
498   AC_DEFINE(NAN_STATIC_ISOC, 1,
499     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
500 else if test "x$nan_type" = "xzero"; then
501   AC_DEFINE(NAN_ZERO_ZERO, 1,
502     [Define if NAN can be defined as (0.0 / 0.0)])
503 else
504   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
505 fi; fi; fi
506
507 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
508 [
509  if test "x$withval" = "xnothing"; then
510         fp_layout_type="nothing"
511  else if test "x$withval" = "xendianflip"; then
512         fp_layout_type="endianflip"
513  else if test "x$withval" = "xintswap"; then
514         fp_layout_type="intswap"
515  else
516         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
517 fi; fi; fi
518 ],
519 [fp_layout_type="unknown"])
520
521 if test "x$fp_layout_type" = "xunknown"; then
522   AC_CACHE_CHECK([if doubles are stored in x86 representation],
523     [fp_layout_need_nothing],
524     AC_RUN_IFELSE(
525       AC_LANG_PROGRAM(
526       [[[[
527 #include <stdlib.h>
528 #include <stdio.h>
529 #include <stdint.h>
530 #include <string.h>
531       ]]]],
532       [[[[
533         uint64_t i0;
534         uint64_t i1;
535         uint8_t c[8];
536         double d;
537
538         d = 8.642135e130; 
539         memcpy ((void *) &i0, (void *) &d, 8);
540
541         i1 = i0;
542         memcpy ((void *) c, (void *) &i1, 8);
543
544         if ((c[0] == 0x2f) && (c[1] == 0x25)
545                         && (c[2] == 0xc0) && (c[3] == 0xc7)
546                         && (c[4] == 0x43) && (c[5] == 0x2b)
547                         && (c[6] == 0x1f) && (c[7] == 0x5b))
548                 return (0);
549         else
550                 return (1);
551       ]]]]),
552       [fp_layout_need_nothing="yes"],
553       [fp_layout_need_nothing="no"]
554     )
555   )
556   if test "x$fp_layout_need_nothing" = "xyes"; then
557     fp_layout_type="nothing"
558   fi
559 fi
560 if test "x$fp_layout_type" = "xunknown"; then
561   AC_CACHE_CHECK([if endianflip converts to x86 representation],
562     [fp_layout_need_endianflip],
563     AC_RUN_IFELSE(
564       AC_LANG_PROGRAM(
565       [[[[
566 #include <stdlib.h>
567 #include <stdio.h>
568 #include <stdint.h>
569 #include <string.h>
570 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
571                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
572                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
573                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
574                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
575                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
576                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
577                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
578       ]]]],
579       [[[[
580         uint64_t i0;
581         uint64_t i1;
582         uint8_t c[8];
583         double d;
584
585         d = 8.642135e130; 
586         memcpy ((void *) &i0, (void *) &d, 8);
587
588         i1 = endianflip (i0);
589         memcpy ((void *) c, (void *) &i1, 8);
590
591         if ((c[0] == 0x2f) && (c[1] == 0x25)
592                         && (c[2] == 0xc0) && (c[3] == 0xc7)
593                         && (c[4] == 0x43) && (c[5] == 0x2b)
594                         && (c[6] == 0x1f) && (c[7] == 0x5b))
595                 return (0);
596         else
597                 return (1);
598       ]]]]),
599       [fp_layout_need_endianflip="yes"],
600       [fp_layout_need_endianflip="no"]
601     )
602   )
603   if test "x$fp_layout_need_endianflip" = "xyes"; then
604     fp_layout_type="endianflip"
605   fi
606 fi
607 if test "x$fp_layout_type" = "xunknown"; then
608   AC_CACHE_CHECK([if intswap converts to x86 representation],
609     [fp_layout_need_intswap],
610     AC_RUN_IFELSE(
611       AC_LANG_PROGRAM(
612       [[[[
613 #include <stdlib.h>
614 #include <stdio.h>
615 #include <stdint.h>
616 #include <string.h>
617 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
618                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
619       ]]]],
620       [[[[
621         uint64_t i0;
622         uint64_t i1;
623         uint8_t c[8];
624         double d;
625
626         d = 8.642135e130; 
627         memcpy ((void *) &i0, (void *) &d, 8);
628
629         i1 = intswap (i0);
630         memcpy ((void *) c, (void *) &i1, 8);
631
632         if ((c[0] == 0x2f) && (c[1] == 0x25)
633                         && (c[2] == 0xc0) && (c[3] == 0xc7)
634                         && (c[4] == 0x43) && (c[5] == 0x2b)
635                         && (c[6] == 0x1f) && (c[7] == 0x5b))
636                 return (0);
637         else
638                 return (1);
639       ]]]]),
640       [fp_layout_need_intswap="yes"],
641       [fp_layout_need_intswap="no"]
642     )
643   )
644   if test "x$fp_layout_need_intswap" = "xyes"; then
645     fp_layout_type="intswap"
646   fi
647 fi
648
649 if test "x$fp_layout_type" = "xnothing"; then
650   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
651   [Define if doubles are stored in x86 representation.])
652 else if test "x$fp_layout_type" = "xendianflip"; then
653   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
654   [Define if endianflip is needed to convert to x86 representation.])
655 else if test "x$fp_layout_type" = "xintswap"; then
656   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
657   [Define if intswap is needed to convert to x86 representation.])
658 else
659   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
660 fi; fi; fi
661
662 have_getfsstat="no"
663 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
664 have_getvfsstat="no"
665 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
666 have_listmntent="no"
667 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
668
669 have_getmntent="no"
670 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
671 if test "x$have_getmntent" = "xno"; then
672         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
673 fi
674 if test "x$have_getmntent" = "xno"; then
675         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
676 fi
677 if test "x$have_getmntent" = "xno"; then
678         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
679 fi
680
681 if test "x$have_getmntent" = "xc"; then
682         AC_CACHE_CHECK([whether getmntent takes one argument],
683                 [have_one_getmntent],
684                 AC_COMPILE_IFELSE(
685                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
686 #include <mntent.h>
687 #include "$srcdir/src/utils_mount.h"]],
688                                 [[
689                                  FILE *fh;
690                                  struct mntent *me;
691                                  fh = setmntent ("/etc/mtab", "r");
692                                  me = getmntent (fh);
693                                 ]]
694                         ),
695                         [have_one_getmntent="yes"],
696                         [have_one_getmntent="no"]
697                 )
698         )
699         AC_CACHE_CHECK([whether getmntent takes two arguments],
700                 [have_two_getmntent],
701                 AC_COMPILE_IFELSE(
702                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
703 #include <sys/mnttab.h>
704 #include "$srcdir/src/utils_mount.h"]],
705                                 [[
706                                  FILE *fh;
707                                  struct mnttab mt;
708                                  int status;
709                                  fh = fopen ("/etc/mnttab", "r");
710                                  status = getmntent (fh, &mt);
711                                 ]]
712                         ),
713                         [have_two_getmntent="yes"],
714                         [have_two_getmntent="no"]
715                 )
716         )
717 fi
718
719 # Check for different versions of `getmntent' here..
720
721 if test "x$have_getmntent" = "xc"; then
722         if test "x$have_one_getmntent" = "xyes"; then
723                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
724                           [Define if the function getmntent exists and takes one argument.])
725         fi
726         if test "x$have_two_getmntent" = "xyes"; then
727                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
728                           [Define if the function getmntent exists and takes two arguments.])
729         fi
730 fi
731 if test "x$have_getmntent" = "xsun"; then
732         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
733                   [Define if the function getmntent exists. It's the version from libsun.])
734 fi
735 if test "x$have_getmntent" = "xseq"; then
736         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
737                   [Define if the function getmntent exists. It's the version from libseq.])
738 fi
739 if test "x$have_getmntent" = "xgen"; then
740         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
741                   [Define if the function getmntent exists. It's the version from libgen.])
742 fi
743
744 # Check for structures
745 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
746         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
747         [],
748         [
749         #include <sys/types.h>
750         #include <sys/socket.h>
751         #include <net/if.h>
752         ])
753 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
754         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
755         [],
756         [
757         #include <sys/types.h>
758         #include <sys/socket.h>
759         #include <linux/if.h>
760         #include <linux/netdevice.h>
761         ])
762
763 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
764 [#if HAVE_STDINT_H
765 # include <stdint.h>
766 #endif
767 #if HAVE_SYS_TYPES_H
768 # include <sys/types.h>
769 #endif
770 #if HAVE_NETINET_IN_SYSTM_H
771 # include <netinet/in_systm.h>
772 #endif
773 #if HAVE_NETINET_IN_H
774 # include <netinet/in.h>
775 #endif
776 #if HAVE_NETINET_IP_H
777 # include <netinet/ip.h>
778 #endif
779 #if HAVE_NETINET_UDP_H
780 # include <netinet/udp.h>
781 #endif
782 ])
783 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
784 [#if HAVE_STDINT_H
785 # include <stdint.h>
786 #endif
787 #if HAVE_SYS_TYPES_H
788 # include <sys/types.h>
789 #endif
790 #if HAVE_NETINET_IN_SYSTM_H
791 # include <netinet/in_systm.h>
792 #endif
793 #if HAVE_NETINET_IN_H
794 # include <netinet/in.h>
795 #endif
796 #if HAVE_NETINET_IP_H
797 # include <netinet/ip.h>
798 #endif
799 #if HAVE_NETINET_UDP_H
800 # include <netinet/udp.h>
801 #endif
802 ])
803
804 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
805         [],
806         [],
807         [
808 #if HAVE_KSTAT_H
809 # include <kstat.h>
810 #endif
811         ])
812
813 with_libresolv="yes"
814 AC_CHECK_LIB(resolv, res_search,
815 [
816         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
817 ],
818 [with_libresolv="no"])
819 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
820
821
822 m4_divert_once([HELP_WITH], [
823 collectd additional packages:])
824
825 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
826 librrd_cflags=""
827 librrd_ldflags=""
828 librrd_threadsafe="yes"
829 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
830 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
831         then
832                 librrd_cflags="-I$withval/include"
833                 librrd_ldflags="-L$withval/lib"
834                 with_rrdtool="yes"
835         fi
836 ], [with_rrdtool="yes"])
837 if test "x$with_rrdtool" = "xyes"
838 then
839         SAVE_CPPFLAGS="$CPPFLAGS"
840         SAVE_LDFLAGS="$LDFLAGS"
841
842         CPPFLAGS="$CPPFLAGS $librrd_cflags"
843         LDFLAGS="$LDFLAGS $librrd_ldflags"
844
845         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
846
847         CPPFLAGS="$SAVE_CPPFLAGS"
848         LDFLAGS="$SAVE_LDFLAGS"
849 fi
850 if test "x$with_rrdtool" = "xyes"
851 then
852         SAVE_CPPFLAGS="$CPPFLAGS"
853         SAVE_LDFLAGS="$LDFLAGS"
854
855         CPPFLAGS="$CPPFLAGS $librrd_cflags"
856         LDFLAGS="$LDFLAGS $librrd_ldflags"
857
858         AC_CHECK_LIB(rrd_th, rrd_update_r,
859         [with_rrdtool="yes"
860          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
861         ],
862         [librrd_threadsafe="no"
863          AC_CHECK_LIB(rrd, rrd_update,
864          [with_rrdtool="yes"
865           librrd_ldflags="$librrd_ldflags -lrrd -lm"
866          ],
867          [with_rrdtool="no (symbol 'rrd_update' not found)"],
868          [-lm])
869         ]
870         [-lm])
871
872         CPPFLAGS="$SAVE_CPPFLAGS"
873         LDFLAGS="$SAVE_LDFLAGS"
874 fi
875 if test "x$with_rrdtool" = "xyes"
876 then
877         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
878         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
879         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
880         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
881 fi
882 if test "x$librrd_threadsafe" = "xyes"
883 then
884         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
885 fi
886
887 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
888 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
889         then
890                 LDFLAGS="$LDFLAGS -L$withval/lib"
891                 CPPFLAGS="$CPPFLAGS -I$withval/include"
892                 with_libpthread="yes"
893         else
894                 if test "x$withval" = "xno"
895                 then
896                         with_libpthread="no (disabled)"
897                 fi
898         fi
899 ], [with_libpthread="yes"])
900 if test "x$with_libpthread" = "xyes"
901 then
902         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
903 fi
904 if test "x$with_libpthread" = "xyes"
905 then
906         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
907 fi
908 if test "x$with_libpthread" = "xyes"
909 then
910         collect_pthread=1
911 else
912         collect_pthread=0
913 fi
914 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
915         [Wether or not to use pthread (POSIX threads) library])
916 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
917
918 if test "x$ac_system" = "xSolaris"
919 then
920         with_kstat="yes"
921         with_devinfo="yes"
922 else
923         with_kstat="no (Solaris only)"
924         with_devinfo="no (Solaris only)"
925 fi
926
927 if test "x$with_kstat" = "xyes"
928 then
929         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
930 fi
931 if test "x$with_kstat" = "xyes"
932 then
933         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
934         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
935 fi
936 if test "x$with_kstat" = "xyes"
937 then
938         AC_DEFINE(HAVE_LIBKSTAT, 1,
939                   [Define to 1 if you have the 'kstat' library (-lkstat)])
940 fi
941 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
942 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
943
944 ### BEGIN of check for libcurl ###
945 with_curl_config="curl-config"
946 with_curl_cflags=""
947 with_curl_libs=""
948 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
949 [
950         if test "x$withval" = "xno"
951         then
952                 with_libcurl="no"
953         else if test "x$withval" = "xyes"
954         then
955                 with_libcurl="yes"
956         else
957                 if test -f "$withval" && test -x "$withval"
958                 then
959                         with_curl_config="$withval"
960                         with_libcurl="yes"
961                 else if test -x "$withval/bin/curl-config"
962                 then
963                         with_curl_config="$withval/bin/curl-config"
964                         with_libcurl="yes"
965                 fi; fi
966                 with_libcurl="yes"
967         fi; fi
968 ],
969 [
970         with_libcurl="yes"
971 ])
972 if test "x$with_libcurl" = "xyes"
973 then
974         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
975         curl_config_status=$?
976
977         if test $curl_config_status -ne 0
978         then
979                 with_libcurl="no ($with_curl_config failed)"
980         else
981                 SAVE_CFLAGS=$CFLAGS
982                 CFLAGS="$CFLAGS $with_curl_cflags"
983
984                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
985
986                 CFLAGS="$SAVE_CFLAGS"
987         fi
988 fi
989 if test "x$with_libcurl" = "xyes"
990 then
991         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
992         curl_config_status=$?
993
994         if test $curl_config_status -ne 0
995         then
996                 with_libcurl="no ($with_curl_config failed)"
997         else
998                 AC_CHECK_LIB(curl, curl_easy_init,
999                  [with_libcurl="yes"],
1000                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1001                  [$with_curl_libs])
1002         fi
1003 fi
1004 if test "x$with_libcurl" = "xyes"
1005 then
1006         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1007         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1008         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1009         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1010 fi
1011 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1012 ### END of check for libcurl ###
1013
1014 with_libiokit="no"
1015 collectd_libiokit=0
1016 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1017 [
1018         with_libiokit="yes"
1019         collectd_libiokit=1
1020 ], 
1021 [
1022         with_libiokit="no"
1023         collectd_libiokit=0
1024 ])
1025 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
1026 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1027
1028 with_libstatgrab="yes"
1029 with_libdevstat="no"
1030 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
1031 [
1032         if test "x$withval" != "xno" -a "x$withval" != "xyes"
1033         then
1034                 LDFLAGS="$LDFLAGS -L$withval/lib"
1035                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1036                 with_libstatgrab="yes"
1037         fi
1038 ],
1039 [
1040         if test "x$ac_system" == "xunknown"
1041         then
1042                 with_libstatgrab="yes"
1043         else
1044                 with_libstatgrab="no"
1045         fi
1046 ])
1047 if test "x$with_libstatgrab" = "xyes"
1048 then
1049         AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"])
1050 fi
1051 if test "x$with_libstatgrab" = "xyes"
1052 then
1053         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
1054 fi
1055 if test "x$with_libstatgrab" = "xyes"
1056 then
1057         AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"])
1058 fi
1059 if test "x$with_libstatgrab" = "xyes"
1060 then
1061         collect_libstatgrab=1
1062 else
1063         collect_libstatgrab=0
1064 fi
1065 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
1066         [Wether or not to use statgrab library])
1067 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
1068 AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT,  test "x$with_libdevstat"  = "xyes")
1069
1070 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
1071 if test "x$with_libkvm" = "xyes"
1072 then
1073         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
1074 fi
1075 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
1076
1077 with_sensors_cflags=""
1078 with_sensors_ldflags=""
1079 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
1080 [
1081         if test "x$withval" = "xno"
1082         then
1083                 with_lm_sensors="no"
1084         else
1085                 with_lm_sensors="yes"
1086                 if test "x$withval" != "xyes"
1087                 then
1088                         with_sensors_cflags="-I$withval/include"
1089                         with_sensors_ldflags="-L$withval/lib"
1090                         with_lm_sensors="yes"
1091                 fi
1092         fi
1093 ],
1094 [
1095         if test "x$ac_system" = "xLinux"
1096         then
1097                 with_lm_sensors="yes"
1098         else
1099                 with_lm_sensors="no (Linux only library)"
1100         fi
1101 ])
1102 if test "x$with_lm_sensors" = "xyes"
1103 then
1104         SAVE_CPPFLAGS="$CPPFLAGS"
1105         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1106
1107 #       AC_CHECK_HEADERS(sensors/sensors.h,
1108 #       [
1109 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
1110 #       ],
1111 #       [with_lm_sensors="no (sensors/sensors.h not found)"])
1112         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_lm_sensors="no (sensors/sensors.h not found)"])
1113
1114         CPPFLAGS="$SAVE_CPPFLAGS"
1115 fi
1116 if test "x$with_lm_sensors" = "xyes"
1117 then
1118         SAVE_CPPFLAGS="$CPPFLAGS"
1119         SAVE_LDFLAGS="$LDFLAGS"
1120         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1121         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
1122
1123         AC_CHECK_LIB(sensors, sensors_init,
1124         [
1125                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
1126         ],
1127         [with_lm_sensors="no (libsensors not found)"])
1128
1129         CPPFLAGS="$SAVE_CPPFLAGS"
1130         LDFLAGS="$SAVE_LDFLAGS"
1131 fi
1132 if test "x$with_lm_sensors" = "xyes"
1133 then
1134         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
1135         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
1136         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
1137         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
1138 fi
1139 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
1140
1141 with_mysql_config="mysql_config"
1142 with_mysql_cflags=""
1143 with_mysql_libs=""
1144 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1145 [
1146         if test "x$withval" = "xno"
1147         then
1148                 with_libmysql="no"
1149         else if test "x$withval" = "xyes"
1150         then
1151                 with_libmysql="yes"
1152         else
1153                 if test -f "$withval" && test -x "$withval";
1154                 then
1155                         with_mysql_config="$withval"
1156                 else if test -x "$withval/bin/mysql_config"
1157                 then
1158                         with_mysql_config="$withval/bin/mysql_config"
1159                 fi; fi
1160                 with_libmysql="yes"
1161         fi; fi
1162 ],
1163 [
1164         with_libmysql="yes"
1165 ])
1166 if test "x$with_libmysql" = "xyes"
1167 then
1168         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1169         mysql_config_status=$?
1170
1171         if test $mysql_config_status -ne 0
1172         then
1173                 with_libmysql="no"
1174         else
1175                 SAVE_CFLAGS=$CFLAGS
1176                 CFLAGS="$CFLAGS $with_mysql_cflags"
1177
1178                 AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
1179
1180                 CFLAGS="$SAVE_CFLAGS"
1181         fi
1182 fi
1183 if test "x$with_libmysql" = "xyes"
1184 then
1185         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1186         mysql_config_status=$?
1187
1188         if test $mysql_config_status -ne 0
1189         then
1190                 with_libmysql="no"
1191         else
1192                 AC_CHECK_LIB(mysqlclient, mysql_init,
1193                  [with_libmysql="yes"],
1194                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1195                  [$with_mysql_libs])
1196         fi
1197 fi
1198 if test "x$with_libmysql" = "xyes"
1199 then
1200         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1201         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1202         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1203         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1204 fi
1205 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1206
1207 with_own_liboconfig="no"
1208 liboconfig_LDFLAGS="$LDFLAGS"
1209 liboconfig_CPPFLAGS="$CPPFLAGS"
1210 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1211 [
1212         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1213         then
1214                 if test -d "$withval/lib"
1215                 then
1216                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1217                 fi
1218                 if test -d "$withval/include"
1219                 then
1220                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1221                 fi
1222         fi
1223         if test "x$withval" = "xno"
1224         then
1225                 AC_MSG_ERROR("liboconfig is required")
1226         fi
1227 ],
1228 [
1229         with_liboconfig="yes"
1230 ])
1231
1232 save_LDFLAGS="$LDFLAGS"
1233 save_CPPFLAGS="$CPPFLAGS"
1234 LDFLAGS="$liboconfig_LDFLAGS"
1235 CPPFLAGS="$liboconfig_CPPFLAGS"
1236 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1237 [
1238         with_liboconfig="yes"
1239         with_own_liboconfig="no"
1240 ],
1241 [
1242         with_liboconfig="yes"
1243         with_own_liboconfig="yes"
1244         LDFLAGS="$save_LDFLAGS"
1245         CPPFLAGS="$save_CPPFLAGS"
1246 ])
1247
1248 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1249 if test "x$with_own_liboconfig" = "xyes"
1250 then
1251         with_liboconfig="yes (shipped version)"
1252 fi
1253
1254 #with_liboping="yes"
1255 with_own_liboping="no"
1256 liboping_LDFLAGS="$LDFLAGS"
1257 liboping_CPPFLAGS="$CPPFLAGS"
1258 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1259 [
1260         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1261         then
1262                 if test -d "$withval/lib"
1263                 then
1264                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1265                 fi
1266                 if test -d "$withval/include"
1267                 then
1268                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1269                 fi
1270         fi
1271         if test "x$withval" = "xno"
1272         then
1273                 with_liboping="no"
1274                 with_own_liboping="no"
1275         fi
1276 ],
1277 [
1278         #753
1279         with_liboping="yes"
1280 ])
1281
1282 if test "x$with_liboping" = "xyes"
1283 then
1284         save_LDFLAGS="$LDFLAGS"
1285         save_CPPFLAGS="$CPPFLAGS"
1286         LDFLAGS="$liboping_LDFLAGS"
1287         CPPFLAGS="$liboping_CPPFLAGS"
1288         AC_CHECK_LIB(oping, ping_construct,
1289         [
1290                 with_liboping="yes"
1291                 with_own_liboping="no"
1292         ],
1293         [
1294                 with_liboping="yes"
1295                 with_own_liboping="yes"
1296                 LDFLAGS="$save_LDFLAGS"
1297                 CPPFLAGS="$save_CPPFLAGS"
1298         ])
1299 fi
1300 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1301 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1302
1303 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1304 [
1305         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1306         then
1307                 LDFLAGS="$LDFLAGS -L$withval/lib"
1308                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1309                 with_libpcap="yes"
1310         fi
1311 ],
1312 [
1313         with_libpcap="yes"
1314 ])
1315 if test "x$with_libpcap" = "xyes"
1316 then
1317         AC_CHECK_LIB(pcap, pcap_open_live,
1318         [
1319                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1320         ], [with_libpcap="no (libpcap not found)"])
1321 fi
1322 if test "x$with_libpcap" = "xyes"
1323 then
1324         AC_CHECK_HEADERS(pcap.h,
1325         [
1326                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1327         ], [with_libpcap="no (pcap.h not found)"])
1328 fi
1329 if test "x$with_libpcap" = "xyes"
1330 then
1331         collect_libpcap=1
1332 else
1333         collect_libpcap=0
1334 fi
1335 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1336         [Wether or not to use the pcap library])
1337 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1338
1339 perl_interpreter="perl"
1340 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1341 [
1342         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1343         then
1344                 LDFLAGS="$LDFLAGS -L$withval/lib"
1345                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1346                 perl_interpreter="$withval/bin/perl"
1347                 with_libperl="yes"
1348         fi
1349 ],
1350 [
1351         with_libperl="yes"
1352 ])
1353
1354 AC_SUBST(PERL, "$perl_interpreter")
1355
1356 if test "x$with_libperl" = "xyes"
1357 then
1358   SAVE_CFLAGS=$CFLAGS
1359   SAVE_LDFLAGS=$LDFLAGS
1360   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1361   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1362   CFLAGS="$CFLAGS $PERL_CFLAGS"
1363   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1364
1365   AC_CACHE_CHECK([for libperl],
1366     [have_libperl],
1367     AC_LINK_IFELSE(
1368       AC_LANG_PROGRAM(
1369       [[
1370 #include <EXTERN.h>
1371 #include <perl.h>
1372 #include <XSUB.h>
1373       ]],
1374       [[
1375        PerlInterpreter *perl = NULL;
1376        Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
1377                          newSVpv ("Collectd::Plugin::FooBar", 24),
1378                          Nullsv);
1379       ]]),
1380       [have_libperl="yes"],
1381       [have_libperl="no"]
1382     )
1383   )
1384
1385   if test "x$have_libperl" = "xyes"
1386   then
1387           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1388           AC_SUBST(PERL_CFLAGS)
1389           AC_SUBST(PERL_LDFLAGS)
1390   else
1391           with_libperl="no"
1392   fi
1393
1394   CFLAGS=$SAVE_CFLAGS
1395   LDFLAGS=$SAVE_LDFLAGS
1396 fi
1397 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1398
1399 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1400 [
1401         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1402         then
1403                 LDFLAGS="$LDFLAGS -L$withval/lib"
1404                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1405                 with_libiptc="yes"
1406         fi
1407 ],
1408 [
1409         if test "x$ac_system" = "xLinux"
1410         then
1411                 with_libiptc="yes"
1412         else
1413                 with_libiptc="no (Linux only)"
1414         fi
1415 ])
1416 if test "x$with_libiptc" = "xyes"
1417 then
1418         AC_CHECK_LIB(iptc, iptc_init,
1419         [
1420                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1421         ], [with_libiptc="no (libiptc not found)"])
1422 fi
1423 if test "x$with_libiptc" = "xyes"
1424 then
1425         AC_CHECK_HEADERS(libiptc/libiptc.h,
1426         [
1427                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1428         ], [with_libiptc="no (libiptc/libiptc.h not found)"])
1429 fi
1430 if test "x$with_libiptc" = "xyes"
1431 then
1432         collect_libiptc=1
1433 else
1434         collect_libiptc=0
1435 fi
1436 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1437
1438 with_snmp_config="net-snmp-config"
1439 with_snmp_cflags=""
1440 with_snmp_libs=""
1441 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1442 [
1443         if test "x$withval" = "xno"
1444         then
1445                 with_libnetsnmp="no"
1446         else if test "x$withval" = "xyes"
1447         then
1448                 with_libnetsnmp="yes"
1449         else
1450                 if test -x "$withval"
1451                 then
1452                         with_snmp_config="$withval"
1453                         with_libnetsnmp="yes"
1454                 else
1455                         with_snmp_config="$withval/bin/net-snmp-config"
1456                         with_libnetsnmp="yes"
1457                 fi
1458         fi; fi
1459 ],
1460 [with_libnetsnmp="yes"])
1461 if test "x$with_libnetsnmp" = "xyes"
1462 then
1463         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1464         snmp_config_status=$?
1465
1466         if test $snmp_config_status -ne 0
1467         then
1468                 with_libnetsnmp="no ($with_snmp_config failed)"
1469         else
1470                 SAVE_CFLAGS=$CFLAGS
1471                 CFLAGS="$CFLAGS $with_snmp_cflags"
1472                 
1473                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1474
1475                 CFLAGS="$SAVE_CFLAGS"
1476         fi
1477 fi
1478 if test "x$with_libnetsnmp" = "xyes"
1479 then
1480         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1481         snmp_config_status=$?
1482
1483         if test $snmp_config_status -ne 0
1484         then
1485                 with_libnetsnmp="no ($with_snmp_config failed)"
1486         else
1487                 AC_CHECK_LIB(netsnmp, init_snmp,
1488                 [with_libnetsnmp="yes"],
1489                 [with_libnetsnmp="no (libnetsnmp not found)"],
1490                 [$with_snmp_libs])
1491         fi
1492 fi
1493 if test "x$with_libnetsnmp" = "xyes"
1494 then
1495         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1496         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1497         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1498         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1499 fi
1500 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1501
1502 with_upsclient_config="libupsclient-config"
1503 with_upsclient_cflags=""
1504 with_upsclient_libs=""
1505 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
1506 [
1507         if test "x$withval" = "xno"
1508         then
1509                 with_libupsclient="no"
1510         else
1511                 if test "x$withval" != "xyes"
1512                 then
1513                         if test -f "$withval" && test -x "$withval";
1514                         then
1515                                 with_upsclient_config="$withval"
1516                         else
1517                                 with_upsclient_config="$withval/bin/libupsclient-config"
1518                         fi
1519                 fi
1520                 with_libupsclient="yes"
1521         fi
1522 ],
1523 [
1524         with_libupsclient="yes"
1525 ])
1526 if test "x$with_libupsclient" = "xyes"
1527 then
1528         with_upsclient_cflags=`$with_upsclient_config --cflags 2>/dev/null`
1529         upsclient_config_status=$?
1530
1531         if test $upsclient_config_status -ne 0
1532         then
1533                 with_libupsclient="no ($with_upsclient_config failed)"
1534         fi
1535 fi
1536 if test "x$with_libupsclient" = "xyes"
1537 then
1538         SAVE_CFLAGS="$CFLAGS"
1539         CFLAGS="$CFLAGS $with_upsclient_cflags"
1540
1541         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
1542
1543         CFLAGS="$SAVE_CFLAGS"
1544 fi
1545 if test "x$with_libupsclient" = "xyes"
1546 then
1547         with_upsclient_libs=`$with_upsclient_config --libs 2>/dev/null`
1548         upsclient_config_status=$?
1549
1550         if test $upsclient_config_status -ne 0
1551         then
1552                 with_libupsclient="no ($with_upsclient_config failed)"
1553         fi
1554 fi
1555 if test "x$with_libupsclient" = "xyes"
1556 then
1557         AC_CHECK_LIB(upsclient, upscli_connect,
1558         [
1559                 BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_upsclient_cflags"
1560                 BUILD_WITH_LIBUPSCLIENT_LIBS="$with_upsclient_libs"
1561                 AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
1562                 AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
1563         ],
1564         [
1565                 with_libupsclient="no (symbol 'upscli_connect' not found)"
1566         ], [$with_upsclient_libs])
1567 fi
1568 if test "x$with_libupsclient" = "xyes"
1569 then
1570         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [], 
1571 [#include <stdlib.h>
1572 #include <stdio.h>
1573 #include <upsclient.h>])
1574 fi
1575 AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
1576
1577 ### BEGIN of check for libxmms ###
1578 with_xmms_config="xmms-config"
1579 with_xmms_cflags=""
1580 with_xmms_libs=""
1581 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
1582 [
1583         if test "x$withval" != "xno" -a "x$withval" != "xyes"
1584         then
1585                 if test -f "$withval" && test -x "$withval";
1586                 then
1587                         with_xmms_config="$withval"
1588                 else if test -x "$withval/bin/xmms-config"
1589                 then
1590                         with_xmms_config="$withval/bin/xmms-config"
1591                 fi; fi
1592                 with_libxmms="yes"
1593         else if test "x$withval" = "xno"
1594         then
1595                 with_libxmms="no"
1596         else
1597                 with_libxmms="yes"
1598         fi; fi
1599 ],
1600 [
1601         with_libxmms="yes"
1602 ])
1603 if test "x$with_libxmms" = "xyes"
1604 then
1605         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
1606         xmms_config_status=$?
1607
1608         if test $xmms_config_status -ne 0
1609         then
1610                 with_libxmms="no"
1611         fi
1612 fi
1613 if test "x$with_libxmms" = "xyes"
1614 then
1615         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
1616         xmms_config_status=$?
1617
1618         if test $xmms_config_status -ne 0
1619         then
1620                 with_libxmms="no"
1621         fi
1622 fi
1623 if test "x$with_libxmms" = "xyes"
1624 then
1625         AC_CHECK_LIB(xmms, xmms_remote_get_info,
1626         [
1627                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
1628                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
1629                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
1630                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
1631         ],
1632         [
1633                 with_libxmms="no"
1634         ],
1635         [$with_xmms_libs])
1636 fi
1637 with_libxmms_numeric=0
1638 if test "x$with_libxmms" = "xyes"
1639 then
1640         with_libxmms_numeric=1
1641 fi
1642 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
1643 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
1644 ### END of check for libxmms ###
1645
1646 with_libnetlink_cflags=""
1647 with_libnetlink_libs="-lnetlink"
1648 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1649 [
1650  echo "libnetlink: withval = $withval"
1651  if test "x$withval" = "xyes"
1652  then
1653          with_libnetlink="yes"
1654  else if test "x$withval" = "xno"
1655  then
1656          with_libnetlink="no"
1657  else
1658          if test -d "$withval/include"
1659          then
1660                  with_libnetlink_cflags="-I$withval/include"
1661                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1662                  with_libnetlink="yes"
1663          else
1664                  AC_MSG_ERROR("no such directory: $withval/include")
1665          fi
1666  fi; fi
1667 ],
1668 [
1669  if test "x$ac_system" = "xLinux"
1670  then
1671          with_libnetlink="yes"
1672  else
1673          with_libnetlink="no (Linux only library)"
1674  fi
1675 ])
1676 if test "x$with_libnetlink" = "xyes"
1677 then
1678         SAVE_CFLAGS=$CFLAGS
1679         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1680
1681         with_libnetlink="no (libnetlink.h not found)"
1682
1683         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1684         [
1685          with_libnetlink="yes"
1686          break
1687         ], [],
1688 [#include <stdio.h>
1689 #include <sys/types.h>
1690 #include <asm/types.h>
1691 #include <sys/socket.h>
1692 #include <linux/netlink.h>
1693 #include <linux/rtnetlink.h>])
1694         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1695 [#include <stdio.h>
1696 #include <sys/types.h>
1697 #include <asm/types.h>
1698 #include <sys/socket.h>])
1699
1700         AC_COMPILE_IFELSE(
1701 [#include <stdio.h>
1702 #include <sys/types.h>
1703 #include <asm/types.h>
1704 #include <sys/socket.h>
1705 #include <linux/netlink.h>
1706 #include <linux/rtnetlink.h>
1707
1708 int main (void)
1709 {
1710         int retval = TCA_STATS2;
1711         return (retval);
1712 }],
1713         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1714         []);
1715
1716         AC_COMPILE_IFELSE(
1717 [#include <stdio.h>
1718 #include <sys/types.h>
1719 #include <asm/types.h>
1720 #include <sys/socket.h>
1721 #include <linux/netlink.h>
1722 #include <linux/rtnetlink.h>
1723
1724 int main (void)
1725 {
1726         int retval = TCA_STATS;
1727         return (retval);
1728 }],
1729         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1730         []);
1731
1732         CFLAGS="$SAVE_CFLAGS"
1733 fi
1734 if test "x$with_libnetlink" = "xyes"
1735 then
1736         AC_CHECK_LIB(netlink, rtnl_open,
1737                      [with_libnetlink="yes"],
1738                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1739                      [$with_libnetlink_libs])
1740 fi
1741 if test "x$with_libnetlink" = "xyes"
1742 then
1743         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1744         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1745         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1746         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1747 fi
1748 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1749
1750 # Check for enabled/disabled features
1751 #
1752
1753 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
1754 # ------------------------------------------------------------
1755 dnl
1756 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
1757 dnl
1758 AC_DEFUN(
1759         [AC_COLLECTD],
1760         [
1761         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
1762         m4_if(
1763                 [$2],
1764                 [enable],
1765                 [dnl
1766                 m4_define([EnDis],[disabled])dnl
1767                 m4_define([YesNo],[no])dnl
1768                 ],dnl
1769                 [m4_if(
1770                         [$2],
1771                         [disable],
1772                         [dnl
1773                         m4_define([EnDis],[enabled])dnl
1774                         m4_define([YesNo],[yes])dnl
1775                         ],
1776                         [dnl
1777                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
1778                         ]dnl
1779                 )]dnl
1780         )dnl
1781         m4_if([$3], [feature], [],
1782                 [m4_if(
1783                         [$3], [module], [],
1784                         [dnl
1785                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
1786                         ]dnl
1787                 )]dnl
1788         )dnl
1789         AC_ARG_ENABLE(
1790                 [$1],
1791                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
1792                 [],
1793                 enable_$1='[YesNo]'dnl
1794         )# AC_ARG_ENABLE
1795 if test "x$enable_$1" = "xno"
1796 then
1797         collectd_$1=0
1798 else
1799         if test "x$enable_$1" = "xyes"
1800         then
1801                 collectd_$1=1
1802         else
1803                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
1804                 collectd_$1=1
1805                 enable_$1='yes'
1806         fi
1807 fi
1808         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
1809         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
1810         ]dnl
1811 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
1812
1813 # AC_PLUGIN(name, default, info)
1814 # ------------------------------------------------------------
1815 dnl
1816 AC_DEFUN(
1817   [AC_PLUGIN],
1818   [
1819     enable_plugin="no"
1820     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
1821     [
1822      if test "x$enableval" = "xyes"
1823      then
1824              enable_plugin="yes"
1825      else
1826              enable_plugin="no"
1827      fi
1828     ],
1829     [
1830      if test "x$2" = "xyes"
1831      then
1832              enable_plugin="yes"
1833      else
1834              enable_plugin="no"
1835      fi
1836     ])
1837     if test "x$enable_plugin" = "xyes"
1838     then
1839             AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
1840     fi
1841     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
1842     enable_$1="$enable_plugin"
1843   ]
1844 )# AC_PLUGIN(name, default, info)
1845
1846 m4_divert_once([HELP_ENABLE], [
1847 collectd features:])
1848 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
1849 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
1850 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
1851 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
1852
1853 plugin_battery="no"
1854 plugin_cpu="no"
1855 plugin_cpufreq="no"
1856 plugin_df="no"
1857 plugin_disk="no"
1858 plugin_entropy="no"
1859 plugin_interface="no"
1860 plugin_ipvs="no"
1861 plugin_irq="no"
1862 plugin_load="no"
1863 plugin_memory="no"
1864 plugin_multimeter="no"
1865 plugin_nfs="no"
1866 plugin_processes="no"
1867 plugin_serial="no"
1868 plugin_swap="no"
1869 plugin_tape="no"
1870 plugin_tcpconns="no"
1871 plugin_users="no"
1872 plugin_vserver="no"
1873 plugin_wireless="no"
1874
1875 # Linux
1876 if test "x$ac_system" = "xLinux"
1877 then
1878         plugin_battery="yes"
1879         plugin_cpu="yes"
1880         plugin_cpufreq="yes"
1881         plugin_disk="yes"
1882         plugin_entropy="yes"
1883         plugin_interface="yes"
1884         plugin_irq="yes"
1885         plugin_load="yes"
1886         plugin_memory="yes"
1887         plugin_nfs="yes"
1888         plugin_processes="yes"
1889         plugin_serial="yes"
1890         plugin_swap="yes"
1891         plugin_tcpconns="yes"
1892         plugin_vserver="yes"
1893         plugin_wireless="yes"
1894
1895         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
1896         then
1897                 plugin_ipvs="yes"
1898         fi
1899 fi
1900
1901 # Mac OS X devices
1902 if test "x$with_libiokit" = "xyes"
1903 then
1904         plugin_battery="yes"
1905         plugin_disk="yes"
1906 fi
1907
1908 # Solaris
1909 if test "x$with_devinfo$with_kstat" = "xyesyes"
1910 then
1911         plugin_cpu="yes"
1912         plugin_disk="yes"
1913         plugin_interface="yes"
1914         plugin_memory="yes"
1915         plugin_swap="yes"
1916         plugin_tape="yes"
1917 fi
1918
1919 # libstatgrab
1920 if test "x$with_libstatgrab" = "xyes"
1921 then
1922         plugin_interface="yes"
1923         plugin_load="yes"
1924         plugin_memory="yes"
1925         plugin_swap="yes"
1926 fi
1927
1928 if test "x$have_processor_info" = "xyes"
1929 then
1930         plugin_cpu="yes"
1931 fi
1932 if test "x$have_sysctlbyname" = "xyes"
1933 then
1934         plugin_cpu="yes"
1935         plugin_memory="yes"
1936         plugin_tcpconns="yes"
1937 fi
1938
1939 if test "x$have_statfs" = "xyes"
1940 then
1941         plugin_df="yes"
1942 fi
1943 if test "x$have_statvfs" = "xyes"
1944 then
1945         plugin_df="yes"
1946 fi
1947
1948 if test "x$have_getifaddrs" = "xyes"
1949 then
1950         plugin_interface="yes"
1951 fi
1952
1953 if test "x$have_getloadavg" = "xyes"
1954 then
1955         plugin_load="yes"
1956 fi
1957
1958 # Mac OS X memory interface
1959 if test "x$have_host_statistics" = "xyes"
1960 then
1961         plugin_memory="yes"
1962 fi
1963
1964 if test "x$have_termios_h" = "xyes"
1965 then
1966         plugin_multimeter="yes"
1967 fi
1968
1969 if test "x$have_thread_info" = "xyes"
1970 then
1971         plugin_processes="yes"
1972 fi
1973
1974 if test "x$with_libkvm" = "xyes"
1975 then
1976         plugin_swap="yes"
1977 fi
1978
1979 if test "x$have_getutent" = "xyes"
1980 then
1981         plugin_users="yes"
1982 fi
1983 if test "x$have_getutxent" = "xyes"
1984 then
1985         plugin_users="yes"
1986 fi
1987
1988 # FIXME: sysctl for swap plugin
1989
1990 m4_divert_once([HELP_ENABLE], [
1991 collectd plugins:])
1992
1993 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
1994 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
1995 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
1996 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
1997 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
1998 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
1999 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
2000 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
2001 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
2002 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
2003 AC_PLUGIN([email],       [yes],                [EMail statistics])
2004 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
2005 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
2006 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
2007 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
2008 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
2009 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
2010 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
2011 AC_PLUGIN([load],        [$plugin_load],       [System load])
2012 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
2013 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
2014 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
2015 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
2016 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
2017 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
2018 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
2019 AC_PLUGIN([network],     [yes],                [Network communication plugin])
2020 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
2021 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
2022 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
2023 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
2024 AC_PLUGIN([perl],        [$with_libperl],      [Embed a Perl interpreter])
2025 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
2026 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
2027 AC_PLUGIN([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
2028 AC_PLUGIN([sensors],     [$with_lm_sensors],   [lm_sensors statistics])
2029 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
2030 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
2031 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
2032 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
2033 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
2034 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
2035 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
2036 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
2037 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
2038 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
2039 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
2040
2041 dnl ip_vs.h
2042 if test "x$ac_system" = "xLinux" -a "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
2043 then
2044         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
2045 fi
2046
2047 dnl Perl bindings
2048 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
2049 [
2050         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2051         then
2052                 PERL_BINDINGS_OPTIONS="$withval"
2053                 with_perl_bindings="yes"
2054         else
2055                 PERL_BINDINGS_OPTIONS=""
2056                 with_perl_bindings="$withval"
2057         fi
2058 ],
2059 [
2060         PERL_BINDINGS_OPTIONS=""
2061         with_perl_bindings="yes"
2062 ])
2063 if test "x$with_perl_bindings" = "xyes"
2064 then
2065         PERL_BINDINGS="perl"
2066 else
2067         PERL_BINDINGS=""
2068 fi
2069 AC_SUBST(PERL_BINDINGS)
2070 AC_SUBST(PERL_BINDINGS_OPTIONS)
2071
2072 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
2073
2074 if test "x$with_liboping" = "xyes" -a "x$with_own_liboping" = "xyes"
2075 then
2076         with_liboping="yes (shipped version)"
2077 fi
2078
2079 if test "x$with_libperl" = "xyes"
2080 then
2081         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
2082 else
2083         enable_perl="no (needs libperl)"
2084 fi
2085
2086 if test "x$with_perl_bindings" = "xyes" -a "x$PERL_BINDINGS_OPTIONS" != "x"
2087 then
2088         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
2089 fi
2090
2091 cat <<EOF;
2092
2093 Configuration:
2094   Libraries:
2095     libcurl . . . . . . $with_libcurl
2096     libiokit  . . . . . $with_libiokit
2097     libiptc . . . . . . $with_libiptc
2098     libkstat  . . . . . $with_kstat
2099     libkvm  . . . . . . $with_libkvm
2100     libmysql  . . . . . $with_libmysql
2101     libnetlink  . . . . $with_libnetlink
2102     libnetsnmp  . . . . $with_libnetsnmp
2103     liboconfig  . . . . $with_liboconfig
2104     liboping  . . . . . $with_liboping
2105     libpcap . . . . . . $with_libpcap
2106     libperl . . . . . . $with_libperl
2107     libpthread  . . . . $with_libpthread
2108     librrd  . . . . . . $with_rrdtool
2109     libsensors  . . . . $with_lm_sensors
2110     libstatgrab . . . . $with_libstatgrab
2111     libupsclient  . . . $with_libupsclient
2112     libxmms . . . . . . $with_libxmms
2113
2114   Features:
2115     daemon mode . . . . $enable_daemon
2116     debug . . . . . . . $enable_debug
2117
2118   Bindings:
2119     perl  . . . . . . . $with_perl_bindings
2120
2121   Modules:
2122     apache  . . . . . . $enable_apache
2123     apcups  . . . . . . $enable_apcups
2124     apple_sensors . . . $enable_apple_sensors
2125     battery . . . . . . $enable_battery
2126     cpu . . . . . . . . $enable_cpu
2127     cpufreq . . . . . . $enable_cpufreq
2128     csv . . . . . . . . $enable_csv
2129     df  . . . . . . . . $enable_df
2130     disk  . . . . . . . $enable_disk
2131     dns . . . . . . . . $enable_dns
2132     email . . . . . . . $enable_email
2133     entropy . . . . . . $enable_entropy
2134     exec  . . . . . . . $enable_exec
2135     hddtemp . . . . . . $enable_hddtemp
2136     interface . . . . . $enable_interface
2137     iptables  . . . . . $enable_iptables
2138     ipvs  . . . . . . . $enable_ipvs
2139     irq . . . . . . . . $enable_irq
2140     load  . . . . . . . $enable_load
2141     logfile . . . . . . $enable_logfile
2142     mbmon . . . . . . . $enable_mbmon
2143     memcached . . . . . $enable_memcached
2144     memory  . . . . . . $enable_memory
2145     multimeter  . . . . $enable_multimeter
2146     mysql . . . . . . . $enable_mysql
2147     netlink . . . . . . $enable_netlink
2148     network . . . . . . $enable_network
2149     nfs . . . . . . . . $enable_nfs
2150     nginx . . . . . . . $enable_nginx
2151     ntpd  . . . . . . . $enable_ntpd
2152     nut . . . . . . . . $enable_nut
2153     perl  . . . . . . . $enable_perl
2154     ping  . . . . . . . $enable_ping
2155     processes . . . . . $enable_processes
2156     rrdtool . . . . . . $enable_rrdtool
2157     sensors . . . . . . $enable_sensors
2158     serial  . . . . . . $enable_serial
2159     snmp  . . . . . . . $enable_snmp
2160     swap  . . . . . . . $enable_swap
2161     syslog  . . . . . . $enable_syslog
2162     tape  . . . . . . . $enable_tape
2163     tcpconns  . . . . . $enable_tcpconns
2164     unixsock  . . . . . $enable_unixsock
2165     users . . . . . . . $enable_users
2166     vserver . . . . . . $enable_vserver
2167     wireless  . . . . . $enable_wireless
2168     xmms  . . . . . . . $enable_xmms
2169
2170 EOF