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