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