Merge branch 'collectd-4.0'
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, 4.0.5)
3 AC_CONFIG_SRCDIR(src/collectd.c)
4 AC_CONFIG_HEADERS(src/config.h)
5 AM_INIT_AUTOMAKE(dist-bzip2)
6 AC_LANG(C)
7
8 AC_PREFIX_DEFAULT("/opt/collectd")
9
10 AC_SYS_LARGEFILE
11
12 #
13 # Checks for programs.
14 #
15 AC_PROG_CC
16 AC_PROG_CPP
17 AC_PROG_INSTALL
18 AC_PROG_LN_S
19 AC_PROG_MAKE_SET
20 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
21
22 dnl configure libtool
23 AC_DISABLE_STATIC
24 AC_LIBLTDL_CONVENIENCE
25 AC_SUBST(LTDLINCL)
26 AC_SUBST(LIBLTDL)
27 AC_LIBTOOL_DLOPEN
28 AC_PROG_LIBTOOL
29 AC_PROG_LEX
30 AC_PROG_YACC
31 AC_CONFIG_SUBDIRS(libltdl)
32
33 #
34 # Checks for header files.
35 #
36 AC_HEADER_STDC
37 AC_HEADER_SYS_WAIT
38 AC_HEADER_DIRENT
39
40 AC_CHECK_HEADERS(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h)
41
42 # For ping library
43 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
44 [#if HAVE_STDINT_H
45 # include <stdint.h>
46 #endif
47 #if HAVE_SYS_TYPES_H
48 # include <sys/types.h>
49 #endif
50 ])
51 AC_CHECK_HEADERS(netinet/in.h, [], [],
52 [#if HAVE_STDINT_H
53 # include <stdint.h>
54 #endif
55 #if HAVE_SYS_TYPES_H
56 # include <sys/types.h>
57 #endif
58 #if HAVE_NETINET_IN_SYSTM_H
59 # include <netinet/in_systm.h>
60 #endif
61 ])
62 AC_CHECK_HEADERS(netinet/ip.h, [], [],
63 [#if HAVE_STDINT_H
64 # include <stdint.h>
65 #endif
66 #if HAVE_SYS_TYPES_H
67 # include <sys/types.h>
68 #endif
69 #if HAVE_NETINET_IN_SYSTM_H
70 # include <netinet/in_systm.h>
71 #endif
72 #if HAVE_NETINET_IN_H
73 # include <netinet/in.h>
74 #endif
75 ])
76 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
77 [#if HAVE_STDINT_H
78 # include <stdint.h>
79 #endif
80 #if HAVE_SYS_TYPES_H
81 # include <sys/types.h>
82 #endif
83 #if HAVE_NETINET_IN_SYSTM_H
84 # include <netinet/in_systm.h>
85 #endif
86 #if HAVE_NETINET_IN_H
87 # include <netinet/in.h>
88 #endif
89 #if HAVE_NETINET_IP_H
90 # include <netinet/ip.h>
91 #endif
92 ])
93 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
94 [#if HAVE_STDINT_H
95 # include <stdint.h>
96 #endif
97 #if HAVE_SYS_TYPES_H
98 # include <sys/types.h>
99 #endif
100 #if HAVE_NETINET_IN_SYSTM_H
101 # include <netinet/in_systm.h>
102 #endif
103 #if HAVE_NETINET_IN_H
104 # include <netinet/in.h>
105 #endif
106 #if HAVE_NETINET_IP_H
107 # include <netinet/ip.h>
108 #endif
109 ])
110 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
111 [#if HAVE_STDINT_H
112 # include <stdint.h>
113 #endif
114 #if HAVE_SYS_TYPES_H
115 # include <sys/types.h>
116 #endif
117 #if HAVE_NETINET_IN_SYSTM_H
118 # include <netinet/in_systm.h>
119 #endif
120 #if HAVE_NETINET_IN_H
121 # include <netinet/in.h>
122 #endif
123 ])
124 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
125 [#if HAVE_STDINT_H
126 # include <stdint.h>
127 #endif
128 #if HAVE_SYS_TYPES_H
129 # include <sys/types.h>
130 #endif
131 #if HAVE_NETINET_IN_SYSTM_H
132 # include <netinet/in_systm.h>
133 #endif
134 #if HAVE_NETINET_IN_H
135 # include <netinet/in.h>
136 #endif
137 #if HAVE_NETINET_IP6_H
138 # include <netinet/ip6.h>
139 #endif
140 ])
141 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
142 [#if HAVE_STDINT_H
143 # include <stdint.h>
144 #endif
145 #if HAVE_SYS_TYPES_H
146 # include <sys/types.h>
147 #endif
148 #if HAVE_NETINET_IN_SYSTM_H
149 # include <netinet/in_systm.h>
150 #endif
151 #if HAVE_NETINET_IN_H
152 # include <netinet/in.h>
153 #endif
154 #if HAVE_NETINET_IP_H
155 # include <netinet/ip.h>
156 #endif
157 ])
158 AC_CHECK_HEADERS(netinet/udp.h, [], [],
159 [#if HAVE_STDINT_H
160 # include <stdint.h>
161 #endif
162 #if HAVE_SYS_TYPES_H
163 # include <sys/types.h>
164 #endif
165 #if HAVE_NETINET_IN_SYSTM_H
166 # include <netinet/in_systm.h>
167 #endif
168 #if HAVE_NETINET_IN_H
169 # include <netinet/in.h>
170 #endif
171 #if HAVE_NETINET_IP_H
172 # include <netinet/ip.h>
173 #endif
174 ])
175
176 # For cpu modules
177 AC_CHECK_HEADERS(sys/dkstat.h 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)
178 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
179 [
180 #if HAVE_SYS_TYPES_H
181 #  include <sys/types.h>
182 #endif
183 #if HAVE_SYS_PARAM_H
184 # include <sys/param.h>
185 #endif
186 ])
187
188 # For hddtemp module
189 AC_CHECK_HEADERS(linux/major.h libgen.h)
190
191 # For the apple_sensors module
192 AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
193
194 # For the battery plugin
195 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
196 [
197 #if HAVE_IOKIT_IOKITLIB_H
198 #  include <IOKit/IOKitLib.h>
199 #endif
200 #if HAVE_IOKIT_IOTYPES_H
201 #  include <IOKit/IOTypes.h>
202 #endif
203 ])
204
205 # For the swap module
206 AC_CHECK_HEADERS(sys/swap.h, [], [],
207 [
208 #if HAVE_SYS_TYPES_H
209 #  include <sys/types.h>
210 #endif
211 #if HAVE_SYS_PARAM_H
212 # include <sys/param.h>
213 #endif
214 ])
215
216 # For load module
217 # For the processes plugin
218 # For users module
219 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
220
221 # For interface plugin
222 AC_CHECK_HEADERS(ifaddrs.h)
223 AC_CHECK_HEADERS(net/if.h, [], [],
224 [
225 #if HAVE_SYS_TYPES_H
226 #  include <sys/types.h>
227 #endif
228 #if HAVE_SYS_SOCKET_H
229 #  include <sys/socket.h>
230 #endif
231 ])
232 AC_CHECK_HEADERS(linux/if.h, [], [],
233 [
234 #if HAVE_SYS_TYPES_H
235 #  include <sys/types.h>
236 #endif
237 #if HAVE_SYS_SOCKET_H
238 #  include <sys/socket.h>
239 #endif
240 ])
241 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
242 [
243 #if HAVE_SYS_TYPES_H
244 #  include <sys/types.h>
245 #endif
246 #if HAVE_SYS_SOCKET_H
247 #  include <sys/socket.h>
248 #endif
249 #if HAVE_LINUX_IF_H
250 # include <linux/if.h>
251 #endif
252 ])
253
254 # For quota module
255 AC_CHECK_HEADERS(sys/ucred.h, [], [],
256 [
257 #if HAVE_SYS_TYPES_H
258 #  include <sys/types.h>
259 #endif
260 #if HAVE_SYS_PARAM_H
261 # include <sys/param.h>
262 #endif
263 ])
264
265 # For mount interface
266 AC_CHECK_HEADERS(sys/mount.h, [], [],
267 [
268 #if HAVE_SYS_TYPES_H
269 #  include <sys/types.h>
270 #endif
271 #if HAVE_SYS_PARAM_H
272 # include <sys/param.h>
273 #endif
274 ])
275
276 # For the email plugin
277 AC_CHECK_HEADERS(linux/un.h, [], [],
278 [
279 #if HAVE_SYS_SOCKET_H
280 #       include <sys/socket.h>
281 #endif
282 ])
283
284 AC_CHECK_HEADERS(curl/curl.h 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)
285
286 # For the dns plugin
287 AC_CHECK_HEADERS(arpa/nameser.h)
288 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
289 [
290 #if HAVE_ARPA_NAMESER_H
291 # include <arpa/nameser.h>
292 #endif
293 ])
294
295 AC_CHECK_HEADERS(net/if_arp.h, [], [],
296 [#if HAVE_SYS_SOCKET_H
297 # include <sys/socket.h>
298 #endif
299 ])
300 AC_CHECK_HEADERS(net/ppp_defs.h)
301 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
302 [#if HAVE_NET_PPP_DEFS_H
303 # include <net/ppp_defs.h>
304 #endif
305 ])
306 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
307 [#if HAVE_STDINT_H
308 # include <stdint.h>
309 #endif
310 #if HAVE_SYS_TYPES_H
311 # include <sys/types.h>
312 #endif
313 #if HAVE_SYS_SOCKET_H
314 # include <sys/socket.h>
315 #endif
316 #if HAVE_NET_IF_H
317 # include <net/if.h>
318 #endif
319 #if HAVE_NETINET_IN_H
320 # include <netinet/in.h>
321 #endif
322 ])
323
324 # For the multimeter plugin
325 AC_CHECK_HEADERS(termios.h sys/ioctl.h)
326
327 #
328 # Checking for libraries
329 #
330 AC_CHECK_LIB(m, ext)
331
332 #
333 # Checks for typedefs, structures, and compiler characteristics.
334 #
335 AC_C_CONST
336 AC_TYPE_PID_T
337 AC_TYPE_SIZE_T
338 AC_TYPE_UID_T
339 AC_HEADER_TIME
340
341 #
342 # Checks for library functions.
343 #
344 AC_PROG_GCC_TRADITIONAL
345 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog)
346
347 AC_CHECK_FUNCS(getpwnam_r)
348 AC_CHECK_FUNCS(getgrnam_r)
349
350 socket_needs_socket="no"
351 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
352 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
353
354 nanosleep_needs_rt="no"
355 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
356 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
357
358 AC_CHECK_FUNCS(regcomp regerror regexec regfree)
359
360 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
361 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
362 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
363 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
364 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
365 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
366 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
367 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
368 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
369 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
370
371 # For load module
372 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
373
374 # Check for NAN
375 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
376 [
377  if test "x$withval" = "xno"; then
378          nan_type="none"
379  else if test "x$withval" = "xyes"; then
380          nan_type="zero"
381  else
382          nan_type="$withval"
383  fi; fi
384 ],
385 [nan_type="none"])
386 if test "x$nan_type" = "xnone"; then
387   AC_CACHE_CHECK([whether NAN is defined by default],
388     [have_nan_default],
389     AC_COMPILE_IFELSE(
390       AC_LANG_PROGRAM(
391       [[
392 #include <stdlib.h>
393 #include <math.h>
394 static float foo = NAN;
395       ]],
396       [[
397        if (isnan (foo))
398         return 0;
399        else
400         return 1;
401       ]]),
402       [have_nan_default="yes"],
403       [have_nan_default="no"]
404     )
405   )
406   if test "x$have_nan_default" = "xyes"
407   then
408     nan_type="default"
409   fi
410 fi
411 if test "x$nan_type" = "xnone"; then
412   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
413     [have_nan_isoc],
414     AC_COMPILE_IFELSE(
415       AC_LANG_PROGRAM(
416       [[
417 #include <stdlib.h>
418 #define __USE_ISOC99 1
419 #include <math.h>
420 static float foo = NAN;
421       ]],
422       [[
423        if (isnan (foo))
424         return 0;
425        else
426         return 1;
427       ]]),
428       [have_nan_isoc="yes"],
429       [have_nan_isoc="no"]
430     )
431   )
432   if test "x$have_nan_isoc" = "xyes"
433   then
434     nan_type="isoc99"
435   fi
436 fi
437 if test "x$nan_type" = "xnone"; then
438   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
439     [have_nan_zero],
440     AC_RUN_IFELSE(
441       AC_LANG_PROGRAM(
442       [[
443 #include <stdlib.h>
444 #include <math.h>
445 #ifdef NAN
446 # undef NAN
447 #endif
448 #define NAN (0.0 / 0.0)
449 #ifndef isnan
450 # define isnan(f) ((f) != (f))
451 #endif
452 static float foo = NAN;
453       ]],
454       [[
455        if (isnan (foo))
456         return 0;
457        else
458         return 1;
459       ]]),
460       [have_nan_zero="yes"],
461       [have_nan_zero="no"]
462     )
463   )
464   if test "x$have_nan_zero" = "xyes"
465   then
466     nan_type="zero"
467   fi
468 fi
469
470 if test "x$nan_type" = "xdefault"; then
471   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
472     [Define if NAN is defined by default and can initialize static variables.])
473 else if test "x$nan_type" = "xisoc99"; then
474   AC_DEFINE(NAN_STATIC_ISOC, 1,
475     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
476 else if test "x$nan_type" = "xzero"; then
477   AC_DEFINE(NAN_ZERO_ZERO, 1,
478     [Define if NAN can be defined as (0.0 / 0.0)])
479 else
480   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
481 fi; fi; fi
482
483 # For mount interface
484 #AC_CHECK_FUNCS(getfsent getvfsent)
485
486 have_getfsstat="no"
487 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
488 have_getvfsstat="no"
489 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
490 have_listmntent="no"
491 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
492
493 have_getmntent="no"
494 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
495 if test "x$have_getmntent" = "xno"; then
496         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
497 fi
498 if test "x$have_getmntent" = "xno"; then
499         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
500 fi
501 if test "x$have_getmntent" = "xno"; then
502         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
503 fi
504
505 if test "x$have_getmntent" = "xc"; then
506         AC_CACHE_CHECK([whether getmntent takes one argument],
507                 [have_one_getmntent],
508                 AC_COMPILE_IFELSE(
509                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
510 #include <mntent.h>
511 #include "$srcdir/src/utils_mount.h"]],
512                                 [[
513                                  FILE *fh;
514                                  struct mntent *me;
515                                  fh = setmntent ("/etc/mtab", "r");
516                                  me = getmntent (fh);
517                                 ]]
518                         ),
519                         [have_one_getmntent="yes"],
520                         [have_one_getmntent="no"]
521                 )
522         )
523         AC_CACHE_CHECK([whether getmntent takes two arguments],
524                 [have_two_getmntent],
525                 AC_COMPILE_IFELSE(
526                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
527 #include <sys/mnttab.h>
528 #include "$srcdir/src/utils_mount.h"]],
529                                 [[
530                                  FILE *fh;
531                                  struct mnttab mt;
532                                  int status;
533                                  fh = fopen ("/etc/mnttab", "r");
534                                  status = getmntent (fh, &mt);
535                                 ]]
536                         ),
537                         [have_two_getmntent="yes"],
538                         [have_two_getmntent="no"]
539                 )
540         )
541 fi
542
543 # Check for different versions of `getmntent' here..
544
545 if test "x$have_getmntent" = "xc"; then
546         if test "x$have_one_getmntent" = "xyes"; then
547                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
548                           [Define if the function getmntent exists and takes one argument.])
549         fi
550         if test "x$have_two_getmntent" = "xyes"; then
551                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
552                           [Define if the function getmntent exists and takes two arguments.])
553         fi
554 fi
555 if test "x$have_getmntent" = "xsun"; then
556         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
557                   [Define if the function getmntent exists. It's the version from libsun.])
558 fi
559 if test "x$have_getmntent" = "xseq"; then
560         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
561                   [Define if the function getmntent exists. It's the version from libseq.])
562 fi
563 if test "x$have_getmntent" = "xgen"; then
564         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
565                   [Define if the function getmntent exists. It's the version from libgen.])
566 fi
567
568 # Check for structures
569 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
570         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
571         [],
572         [
573         #include <sys/types.h>
574         #include <sys/socket.h>
575         #include <net/if.h>
576         ])
577 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
578         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
579         [],
580         [
581         #include <sys/types.h>
582         #include <sys/socket.h>
583         #include <linux/if.h>
584         #include <linux/netdevice.h>
585         ])
586
587 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
588 [#if HAVE_STDINT_H
589 # include <stdint.h>
590 #endif
591 #if HAVE_SYS_TYPES_H
592 # include <sys/types.h>
593 #endif
594 #if HAVE_NETINET_IN_SYSTM_H
595 # include <netinet/in_systm.h>
596 #endif
597 #if HAVE_NETINET_IN_H
598 # include <netinet/in.h>
599 #endif
600 #if HAVE_NETINET_IP_H
601 # include <netinet/ip.h>
602 #endif
603 #if HAVE_NETINET_UDP_H
604 # include <netinet/udp.h>
605 #endif
606 ])
607 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
608 [#if HAVE_STDINT_H
609 # include <stdint.h>
610 #endif
611 #if HAVE_SYS_TYPES_H
612 # include <sys/types.h>
613 #endif
614 #if HAVE_NETINET_IN_SYSTM_H
615 # include <netinet/in_systm.h>
616 #endif
617 #if HAVE_NETINET_IN_H
618 # include <netinet/in.h>
619 #endif
620 #if HAVE_NETINET_IP_H
621 # include <netinet/ip.h>
622 #endif
623 #if HAVE_NETINET_UDP_H
624 # include <netinet/udp.h>
625 #endif
626 ])
627
628 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
629         [],
630         [],
631         [
632 #if HAVE_KSTAT_H
633 # include <kstat.h>
634 #endif
635         ])
636
637 AC_MSG_CHECKING([for kernel type ($host_os)])
638 case $host_os in
639         *linux*)
640         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
641         ac_system="Linux"
642         ;;
643         *solaris*)
644         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
645         ac_system="Solaris"
646         ;;
647         *)
648         ac_system="unknown"
649 esac
650 AC_MSG_RESULT([$ac_system])
651
652 with_libresolv="yes"
653 AC_CHECK_LIB(resolv, res_search,
654 [
655         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
656 ],
657 [with_libresolv="no"])
658 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
659
660
661 m4_divert_once([HELP_WITH], [
662 collectd additional packages:])
663
664 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
665 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
666 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
667         then
668                 LDFLAGS="$LDFLAGS -L$withval/lib"
669                 CPPFLAGS="$CPPFLAGS -I$withval/include"
670                 with_rrdtool="yes"
671         fi
672 ], [with_rrdtool="yes"])
673 if test "x$with_rrdtool" = "xyes"
674 then
675         AC_CHECK_LIB(rrd, rrd_update,
676         [
677                 AC_DEFINE(HAVE_LIBRRD, 1, [Define to 1 if you have the rrd library (-lrrd).])
678         ],
679         [with_rrdtool="no (librrd not found)"], [-lm])
680 fi
681 if test "x$with_rrdtool" = "xyes"
682 then
683         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
684 fi
685 if test "x$with_rrdtool" = "xyes"
686 then
687         collect_rrdtool=1
688 else
689         collect_rrdtool=0
690 fi
691 AC_DEFINE_UNQUOTED(COLLECT_RRDTOOL, [$collect_rrdtool],
692         [Wether or not to use rrdtool library])
693 AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
694
695 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
696 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
697         then
698                 LDFLAGS="$LDFLAGS -L$withval/lib"
699                 CPPFLAGS="$CPPFLAGS -I$withval/include"
700                 with_libpthread="yes"
701         else
702                 if test "x$withval" = "xno"
703                 then
704                         with_libpthread="no (disabled)"
705                 fi
706         fi
707 ], [with_libpthread="yes"])
708 if test "x$with_libpthread" = "xyes"
709 then
710         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
711 fi
712 if test "x$with_libpthread" = "xyes"
713 then
714         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
715 fi
716 if test "x$with_libpthread" = "xyes"
717 then
718         collect_pthread=1
719 else
720         collect_pthread=0
721 fi
722 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
723         [Wether or not to use pthread (POSIX threads) library])
724 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
725
726 if test "$ac_system" = "Solaris"
727 then
728         with_kstat="yes"
729         with_devinfo="yes"
730 else
731         with_kstat="no (Solaris only)"
732         with_devinfo="no (Solaris only)"
733 fi
734
735 if test "x$with_kstat" = "xyes"
736 then
737         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
738 fi
739 if test "x$with_kstat" = "xyes"
740 then
741         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
742         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
743 fi
744 if test "x$with_kstat" = "xyes"
745 then
746         AC_DEFINE(HAVE_LIBKSTAT, 1,
747                   [Define to 1 if you have the 'kstat' library (-lkstat)])
748 fi
749 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
750 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
751
752 ### BEGIN of check for libcurl ###
753 with_curl_config="curl-config"
754 with_curl_prefix=0
755 with_curl_libs=""
756 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
757 [
758         if test "x$withval" != "xno" -a "x$withval" != "xyes"
759         then
760                 if test -x "$withval/bin/curl-config"
761                 then
762                         with_curl_config="$withval/bin/curl-config"
763                         with_curl_prefix=1
764                 fi
765         fi
766         if test "x$withval" = "xno"
767         then
768                 with_libcurl="no"
769         else
770                 with_libcurl="yes"
771         fi
772 ],
773 [
774         with_libcurl="yes"
775 ])
776 if test "x$with_libcurl" = "xyes"
777 then
778         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
779         curl_config_status=$?
780
781         if test $curl_config_status -ne 0
782         then
783                 with_libcurl="no"
784         else
785                 AC_CHECK_LIB(curl, curl_easy_init,
786                 [
787                         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
788                         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
789                 ],
790                 [
791                         with_libcurl="no"
792                 ],
793                 [$with_curl_libs])
794         fi
795 fi
796 if test "x$with_libcurl" = "xyes" -a $with_curl_prefix -ne 0
797 then
798         with_curl_prefix=`$with_curl_config --libs 2>/dev/null`
799         curl_config_status=$?
800
801         if test $curl_config_status -ne 0
802         then
803                 with_libcurl="no"
804         else
805                 if test -d "$with_curl_prefix/include"
806                 then
807                         CPPFLAGS="$CPPFLAGS -I$with_curl_prefix/include"
808                 fi
809         fi
810 fi
811
812 with_libcurl_numeric=0
813 if test "x$with_libcurl" = "xyes"
814 then
815         with_libcurl_numeric=1
816 fi
817 AC_DEFINE_UNQUOTED(HAVE_LIBCURL, [$with_libcurl_numeric], [Define to 1 if you have the 'curl' library (-lcurl).])
818 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
819 ### END of check for libcurl ###
820
821 with_libiokit="no"
822 collectd_libiokit=0
823 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
824 [
825         with_libiokit="yes"
826         collectd_libiokit=1
827 ], 
828 [
829         with_libiokit="no"
830         collectd_libiokit=0
831 ])
832 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
833 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
834
835 with_libstatgrab="yes"
836 with_libdevstat="no"
837 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
838 [
839         if test "x$withval" != "xno" -a "x$withval" != "xyes"
840         then
841                 LDFLAGS="$LDFLAGS -L$withval/lib"
842                 CPPFLAGS="$CPPFLAGS -I$withval/include"
843                 with_libstatgrab="yes"
844         fi
845 ],
846 [
847         if test "x$ac_system" == "xunknown"
848         then
849                 with_libstatgrab="yes"
850         else
851                 with_libstatgrab="no"
852         fi
853 ])
854 if test "x$with_libstatgrab" = "xyes"
855 then
856         AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"])
857 fi
858 if test "x$with_libstatgrab" = "xyes"
859 then
860         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
861 fi
862 if test "x$with_libstatgrab" = "xyes"
863 then
864         AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"])
865 fi
866 if test "x$with_libstatgrab" = "xyes"
867 then
868         collect_libstatgrab=1
869 else
870         collect_libstatgrab=0
871 fi
872 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
873         [Wether or not to use statgrab library])
874 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
875 AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT,  test "x$with_libdevstat"  = "xyes")
876
877 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
878 if test "x$with_libkvm" = "xyes"
879 then
880         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
881 fi
882 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
883
884 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
885 [
886         if test "x$withval" != "xno" && test "x$withval" != "xyes"
887         then
888                 LDFLAGS="$LDFLAGS -L$withval/lib"
889                 CPPFLAGS="$CPPFLAGS -I$withval/include"
890                 with_lm_sensors="yes"
891         fi
892 ],
893 [
894         if test "x$ac_system" = "xLinux"
895         then
896                 with_lm_sensors="yes"
897         else
898                 with_lm_sensors="no"
899         fi
900 ])
901 if test "x$with_lm_sensors" = "xyes"
902 then
903         AC_CHECK_LIB(sensors, sensors_init,
904         [
905                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
906         ],
907         [with_lm_sensors="no (libsensors not found)"])
908 fi
909 if test "x$with_lm_sensors" = "xyes"
910 then
911         AC_CHECK_HEADERS(sensors/sensors.h,
912         [
913                 AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
914         ],
915         [with_lm_sensors="no (sensors/sensors.h not found)"])
916 fi
917 if test "x$with_lm_sensors" = "xyes"
918 then
919         collect_lm_sensors=1
920 else
921         collect_lm_sensors=0
922 fi
923 AC_DEFINE_UNQUOTED(COLLECT_LM_SENSORS, [$collect_lm_sensors],
924         [Wether or not to use sensors library])
925 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
926
927 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
928 [
929         if test "x$withval" != "xno" && test "x$withval" != "xyes"
930         then
931                 LDFLAGS="$LDFLAGS -L$withval/lib"
932                 CPPFLAGS="$CPPFLAGS -I$withval/include"
933                 with_libmysql="yes"
934         fi
935 ],
936 [
937         with_libmysql="yes"
938 ])
939 if test "x$with_libmysql" = "xyes"
940 then
941         AC_CHECK_LIB(mysqlclient, mysql_init,
942         [
943                 AC_DEFINE(HAVE_LIBMYSQLCLIENT, 1, [Define to 1 if you have the mysqlclient library (-lmysqlclient).])
944         ], [with_libmysql="no (libmysql not found)"])
945 fi
946 if test "x$with_libmysql" = "xyes"
947 then
948         AC_CHECK_HEADERS(mysql/mysql.h,
949         [
950                 AC_DEFINE(HAVE_MYSQL_MYSQL_H, 1, [Define to 1 if you have the <mysql/mysql.h> header file.])
951         ], [with_libmysql="no (mysql/mysql.h not found)"])
952 fi
953 if test "x$with_libmysql" = "xyes"
954 then
955         collect_libmysql=1
956 else
957         collect_libmysql=0
958 fi
959 AC_DEFINE_UNQUOTED(COLLECT_LIBMYSQL, [$collect_libmysql],
960         [Wether or not to use mysql library])
961 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
962
963 with_own_liboconfig="no"
964 liboconfig_LDFLAGS="$LDFLAGS"
965 liboconfig_CPPFLAGS="$CPPFLAGS"
966 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
967 [
968         if test "x$withval" != "xno" && test "x$withval" != "xyes"
969         then
970                 if test -d "$withval/lib"
971                 then
972                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
973                 fi
974                 if test -d "$withval/include"
975                 then
976                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
977                 fi
978         fi
979         if test "x$withval" = "xno"
980         then
981                 AC_MSG_ERROR("liboconfig is required")
982         fi
983 ],
984 [
985         with_liboconfig="yes"
986 ])
987
988 save_LDFLAGS="$LDFLAGS"
989 save_CPPFLAGS="$CPPFLAGS"
990 LDFLAGS="$liboconfig_LDFLAGS"
991 CPPFLAGS="$liboconfig_CPPFLAGS"
992 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
993 [
994         with_liboconfig="yes"
995         with_own_liboconfig="no"
996 ],
997 [
998         with_liboconfig="yes"
999         with_own_liboconfig="yes"
1000         LDFLAGS="$save_LDFLAGS"
1001         CPPFLAGS="$save_CPPFLAGS"
1002 ])
1003
1004 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1005 if test "x$with_own_liboconfig" = "xyes"
1006 then
1007         with_liboconfig="yes (shipped version)"
1008 fi
1009
1010 #with_liboping="yes"
1011 with_own_liboping="no"
1012 liboping_LDFLAGS="$LDFLAGS"
1013 liboping_CPPFLAGS="$CPPFLAGS"
1014 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1015 [
1016         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1017         then
1018                 if test -d "$withval/lib"
1019                 then
1020                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1021                 fi
1022                 if test -d "$withval/include"
1023                 then
1024                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1025                 fi
1026         fi
1027         if test "x$withval" = "xno"
1028         then
1029                 with_liboping="no"
1030                 with_own_liboping="no"
1031         fi
1032 ],
1033 [
1034         #753
1035         with_liboping="yes"
1036 ])
1037
1038 if test "x$with_liboping" = "xyes"
1039 then
1040         save_LDFLAGS="$LDFLAGS"
1041         save_CPPFLAGS="$CPPFLAGS"
1042         LDFLAGS="$liboping_LDFLAGS"
1043         CPPFLAGS="$liboping_CPPFLAGS"
1044         AC_CHECK_LIB(oping, ping_construct,
1045         [
1046                 with_liboping="yes"
1047                 with_own_liboping="no"
1048         ],
1049         [
1050                 with_liboping="yes"
1051                 with_own_liboping="yes"
1052                 LDFLAGS="$save_LDFLAGS"
1053                 CPPFLAGS="$save_CPPFLAGS"
1054         ])
1055 fi
1056 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1057 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1058
1059 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1060 [
1061         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1062         then
1063                 LDFLAGS="$LDFLAGS -L$withval/lib"
1064                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1065                 with_libpcap="yes"
1066         fi
1067 ],
1068 [
1069         with_libpcap="yes"
1070 ])
1071 if test "x$with_libpcap" = "xyes"
1072 then
1073         AC_CHECK_LIB(pcap, pcap_open_live,
1074         [
1075                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1076         ], [with_libpcap="no (libpcap not found)"])
1077 fi
1078 if test "x$with_libpcap" = "xyes"
1079 then
1080         AC_CHECK_HEADERS(pcap.h,
1081         [
1082                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1083         ], [with_libpcap="no (pcap.h not found)"])
1084 fi
1085 if test "x$with_libpcap" = "xyes"
1086 then
1087         collect_libpcap=1
1088 else
1089         collect_libpcap=0
1090 fi
1091 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1092         [Wether or not to use the pcap library])
1093 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1094
1095 perl_interpreter="perl"
1096 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1097 [
1098         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1099         then
1100                 LDFLAGS="$LDFLAGS -L$withval/lib"
1101                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1102                 perl_interpreter="$withval/bin/perl"
1103                 with_libperl="yes"
1104         fi
1105 ],
1106 [
1107         with_libperl="yes"
1108 ])
1109 if test "x$with_libperl" = "xyes"
1110 then
1111   SAVE_CFLAGS=$CFLAGS
1112   SAVE_LDFLAGS=$LDFLAGS
1113   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1114   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1115   CFLAGS="$CFLAGS $PERL_CFLAGS"
1116   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1117
1118   AC_CACHE_CHECK([for libperl],
1119     [have_libperl],
1120     AC_LINK_IFELSE(
1121       AC_LANG_PROGRAM(
1122       [[
1123 #include <EXTERN.h>
1124 #include <perl.h>
1125 #include <XSUB.h>
1126       ]],
1127       [[
1128        PerlInterpreter *perl = NULL;
1129        Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
1130                          newSVpv ("Collectd::Plugin::FooBar", 24),
1131                          Nullsv);
1132       ]]),
1133       [have_libperl="yes"],
1134       [have_libperl="no"]
1135     )
1136   )
1137
1138   if test "x$have_libperl" = "xyes"
1139   then
1140           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1141           AC_SUBST(PERL_CFLAGS)
1142           AC_SUBST(PERL_LDFLAGS)
1143   else
1144           with_libperl="no"
1145   fi
1146
1147   CFLAGS=$SAVE_CFLAGS
1148   LDFLAGS=$SAVE_LDFLAGS
1149 fi
1150 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1151
1152 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1153 [
1154         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1155         then
1156                 LDFLAGS="$LDFLAGS -L$withval/lib"
1157                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1158                 with_libiptc="yes"
1159         fi
1160 ],
1161 [
1162         if test "x$ac_system" = "xLinux"
1163         then
1164                 with_libiptc="yes"
1165         else
1166                 with_libiptc="no (Linux only)"
1167         fi
1168 ])
1169 if test "x$with_libiptc" = "xyes"
1170 then
1171         AC_CHECK_LIB(iptc, iptc_init,
1172         [
1173                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1174         ], [with_libiptc="no (libiptc not found)"])
1175 fi
1176 if test "x$with_libiptc" = "xyes"
1177 then
1178         AC_CHECK_HEADERS(libiptc/libiptc.h,
1179         [
1180                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1181         ], [with_libiptc="no (libiptc/libiptc.h not found)"])
1182 fi
1183 if test "x$with_libiptc" = "xyes"
1184 then
1185         collect_libiptc=1
1186 else
1187         collect_libiptc=0
1188 fi
1189 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1190
1191 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1192 [
1193         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1194         then
1195                 LDFLAGS="$LDFLAGS -L$withval/lib"
1196                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1197                 with_libnetsnmp="yes"
1198         fi
1199 ],
1200 [with_libnetsnmp="yes"])
1201 if test "x$with_libnetsnmp" = "xyes"
1202 then
1203         AC_CHECK_LIB(netsnmp, init_snmp,
1204         [
1205                 AC_DEFINE(HAVE_LIBSNMP, 1, [Define to 1 if you have the Net-SNMP library (-lnetsnmp).])
1206         ], [with_libnetsnmp="no (libnetsnmp not found)"])
1207 fi
1208 if test "x$with_libnetsnmp" = "xyes"
1209 then
1210         AC_CHECK_HEADERS(net-snmp/net-snmp-config.h,
1211         [
1212                 AC_DEFINE(HAVE_NET_SNMP_NET_SNMP_CONFIG_H, 1, [Define to 1 if you have the <net-snmp/net-snmp-config.h> header file.])
1213         ], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1214 fi
1215 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1216
1217 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
1218 [
1219         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1220         then
1221                 LDFLAGS="$LDFLAGS -L$withval/lib"
1222                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1223                 with_libupsclient="yes"
1224         fi
1225 ],
1226 [
1227         with_libupsclient="yes"
1228 ])
1229 if test "x$with_libupsclient" = "xyes"
1230 then
1231         AC_CHECK_LIB(upsclient, upscli_connect,
1232         [
1233                 AC_DEFINE(HAVE_LIBUPSCLIENT, 1, [Define to 1 if you have the upsclient library (-lupsclient).])
1234         ], [with_libupsclient="no (libupsclient not found)"])
1235 fi
1236 if test "x$with_libupsclient" = "xyes"
1237 then
1238         AC_CHECK_HEADERS(upsclient.h,
1239         [
1240                 AC_DEFINE(HAVE_UPSCLIENT_H, 1, [Define to 1 if you have the <upsclient.h> header file.])
1241         ], [with_libupsclient="no (upsclient.h not found)"])
1242 fi
1243 AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
1244
1245 ### BEGIN of check for libxmms ###
1246 with_xmms_config="xmms-config"
1247 with_xmms_prefix=0
1248 with_xmms_cflags=""
1249 with_xmms_libs=""
1250 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
1251 [
1252         if test "x$withval" != "xno" -a "x$withval" != "xyes"
1253         then
1254                 if test -x "$withval/bin/xmms-config"
1255                 then
1256                         with_xmms_config="$withval/bin/xmms-config"
1257                         with_xmms_prefix=1
1258                 fi
1259         fi
1260         if test "x$withval" = "xno"
1261         then
1262                 with_libxmms="no"
1263         else
1264                 with_libxmms="yes"
1265         fi
1266 ],
1267 [
1268         with_libxmms="yes"
1269 ])
1270 if test "x$with_libxmms" = "xyes"
1271 then
1272         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
1273         xmms_config_status=$?
1274
1275         if test $xmms_config_status -ne 0
1276         then
1277                 with_libxmms="no"
1278         fi
1279 fi
1280 if test "x$with_libxmms" = "xyes"
1281 then
1282         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
1283         xmms_config_status=$?
1284
1285         if test $xmms_config_status -ne 0
1286         then
1287                 with_libxmms="no"
1288         fi
1289 fi
1290 if test "x$with_libxmms" = "xyes"
1291 then
1292         AC_CHECK_LIB(xmms, xmms_remote_get_info,
1293         [
1294                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
1295                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
1296                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
1297                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
1298         ],
1299         [
1300                 with_libxmms="no"
1301         ],
1302         [$with_xmms_libs])
1303 fi
1304 with_libxmms_numeric=0
1305 if test "x$with_libxmms" = "xyes"
1306 then
1307         with_libxmms_numeric=1
1308 fi
1309 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
1310 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
1311 ### END of check for libxmms ###
1312
1313 # Check for enabled/disabled features
1314 #
1315
1316 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
1317 # ------------------------------------------------------------
1318 dnl
1319 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
1320 dnl
1321 AC_DEFUN(
1322         [AC_COLLECTD],
1323         [
1324         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
1325         m4_if(
1326                 [$2],
1327                 [enable],
1328                 [dnl
1329                 m4_define([EnDis],[disabled])dnl
1330                 m4_define([YesNo],[no])dnl
1331                 ],dnl
1332                 [m4_if(
1333                         [$2],
1334                         [disable],
1335                         [dnl
1336                         m4_define([EnDis],[enabled])dnl
1337                         m4_define([YesNo],[yes])dnl
1338                         ],
1339                         [dnl
1340                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
1341                         ]dnl
1342                 )]dnl
1343         )dnl
1344         m4_if([$3], [feature], [],
1345                 [m4_if(
1346                         [$3], [module], [],
1347                         [dnl
1348                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
1349                         ]dnl
1350                 )]dnl
1351         )dnl
1352         AC_ARG_ENABLE(
1353                 [$1],
1354                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
1355                 [],
1356                 enable_$1='[YesNo]'dnl
1357         )# AC_ARG_ENABLE
1358 if test "x$enable_$1" = "xno"
1359 then
1360         collectd_$1=0
1361 else
1362         if test "x$enable_$1" = "xyes"
1363         then
1364                 collectd_$1=1
1365         else
1366                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
1367                 collectd_$1=1
1368                 enable_$1='yes'
1369         fi
1370 fi
1371         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
1372         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
1373         ]dnl
1374 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
1375
1376 # AC_PLUGIN(name, default, info)
1377 # ------------------------------------------------------------
1378 dnl
1379 AC_DEFUN(
1380   [AC_PLUGIN],
1381   [
1382     enable_plugin="no"
1383     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
1384     [
1385      if test "x$enableval" = "xyes"
1386      then
1387              enable_plugin="yes"
1388      else
1389              enable_plugin="no"
1390      fi
1391     ],
1392     [
1393      if test "x$2" = "xyes"
1394      then
1395              enable_plugin="yes"
1396      else
1397              enable_plugin="no"
1398      fi
1399     ])
1400     if test "x$enable_plugin" = "xyes"
1401     then
1402             AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
1403     fi
1404     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
1405     enable_$1="$enable_plugin"
1406   ]
1407 )# AC_PLUGIN(name, default, info)
1408
1409 m4_divert_once([HELP_ENABLE], [
1410 collectd features:])
1411 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
1412 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
1413 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
1414 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
1415
1416 plugin_battery="no"
1417 plugin_cpu="no"
1418 plugin_cpufreq="no"
1419 plugin_df="no"
1420 plugin_disk="no"
1421 plugin_entropy="no"
1422 plugin_interface="no"
1423 plugin_irq="no"
1424 plugin_load="no"
1425 plugin_memory="no"
1426 plugin_nfs="no"
1427 plugin_processes="no"
1428 plugin_serial="no"
1429 plugin_swap="no"
1430 plugin_tape="no"
1431 plugin_users="no"
1432 plugin_vserver="no"
1433 plugin_wireless="no"
1434
1435 # Linux
1436 if test "x$ac_system" = "xLinux"
1437 then
1438         plugin_battery="yes"
1439         plugin_cpu="yes"
1440         plugin_cpufreq="yes"
1441         plugin_disk="yes"
1442         plugin_entropy="yes"
1443         plugin_interface="yes"
1444         plugin_irq="yes"
1445         plugin_load="yes"
1446         plugin_memory="yes"
1447         plugin_nfs="yes"
1448         plugin_processes="yes"
1449         plugin_serial="yes"
1450         plugin_swap="yes"
1451         plugin_vserver="yes"
1452         plugin_wireless="yes"
1453 fi
1454
1455 # Mac OS X devices
1456 if test "x$with_libiokit" = "xyes"
1457 then
1458         plugin_battery="yes"
1459         plugin_disk="yes"
1460 fi
1461
1462 # Solaris
1463 if test "x$with_devinfo$with_kstat" = "xyesyes"
1464 then
1465         plugin_cpu="yes"
1466         plugin_disk="yes"
1467         plugin_interface="yes"
1468         plugin_memory="yes"
1469         plugin_swap="yes"
1470         plugin_tape="yes"
1471 fi
1472
1473 # libstatgrab
1474 if test "x$with_libstatgrab" = "xyes"
1475 then
1476         plugin_interface="yes"
1477         plugin_load="yes"
1478         plugin_memory="yes"
1479         plugin_swap="yes"
1480 fi
1481
1482 if test "x$have_processor_info" = "xyes"
1483 then
1484         plugin_cpu="yes"
1485 fi
1486 if test "x$have_sysctlbyname" = "xyes"
1487 then
1488         plugin_cpu="yes"
1489         plugin_memory="yes"
1490 fi
1491
1492 if test "x$have_statfs" = "xyes"
1493 then
1494         plugin_df="yes"
1495 fi
1496 if test "x$have_statvfs" = "xyes"
1497 then
1498         plugin_df="yes"
1499 fi
1500
1501 if test "x$have_getifaddrs" = "xyes"
1502 then
1503         plugin_interface="yes"
1504 fi
1505
1506 if test "x$have_getloadavg" = "xyes"
1507 then
1508         plugin_load="yes"
1509 fi
1510
1511 # Mac OS X memory interface
1512 if test "x$have_host_statistics" = "xyes"
1513 then
1514         plugin_memory="yes"
1515 fi
1516
1517 if test "x$have_thread_info" = "xyes"
1518 then
1519         plugin_processes="yes"
1520 fi
1521
1522 if test "x$with_libkvm" = "xyes"
1523 then
1524         plugin_swap="yes"
1525 fi
1526
1527 if test "x$have_getutent" = "xyes"
1528 then
1529         plugin_users="yes"
1530 fi
1531 if test "x$have_getutxent" = "xyes"
1532 then
1533         plugin_users="yes"
1534 fi
1535
1536 # FIXME: sysctl for swap plugin
1537
1538 m4_divert_once([HELP_ENABLE], [
1539 collectd plugins:])
1540
1541 AC_PLUGIN([apache],      [$with_libcurl],     [Apache httpd statistics])
1542 AC_PLUGIN([apcups],      [yes],               [Statistics of UPSes by APC])
1543 AC_PLUGIN([apple_sensors], [$with_libiokit],  [Apple's hardware sensors])
1544 AC_PLUGIN([battery],     [$plugin_battery],   [Battery statistics])
1545 AC_PLUGIN([cpu],         [$plugin_cpu],       [CPU usage statistics])
1546 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],   [CPU frequency statistics])
1547 AC_PLUGIN([csv],         [yes],               [CSV output plugin])
1548 AC_PLUGIN([df],          [$plugin_df],        [Filesystem usage statistics])
1549 AC_PLUGIN([disk],        [$plugin_disk],      [Disk usage statistics])
1550 AC_PLUGIN([dns],         [$with_libpcap],     [DNS traffic analysis])
1551 AC_PLUGIN([email],       [yes],               [EMail statistics])
1552 AC_PLUGIN([entropy],     [$plugin_entropy],   [Entropy statistics])
1553 AC_PLUGIN([exec],        [yes],               [Execution of external programs])
1554 AC_PLUGIN([hddtemp],     [yes],               [Query hddtempd])
1555 AC_PLUGIN([interface],   [$plugin_interface], [Interface traffic statistics])
1556 AC_PLUGIN([iptables],    [$with_libiptc],     [IPTables rule counters])
1557 AC_PLUGIN([irq],         [$plugin_irq],       [IRQ statistics])
1558 AC_PLUGIN([load],        [$plugin_load],      [System load])
1559 AC_PLUGIN([logfile],     [yes],               [File logging plugin])
1560 AC_PLUGIN([mbmon],       [yes],               [Query mbmond])
1561 AC_PLUGIN([memory],      [$plugin_memory],    [Memory usage])
1562 AC_PLUGIN([multimeter],  [no],                [Read multimeter values])
1563 AC_PLUGIN([mysql],       [$with_libmysql],    [MySQL statistics])
1564 AC_PLUGIN([network],     [yes],               [Network communication plugin])
1565 AC_PLUGIN([nfs],         [$plugin_nfs],       [NFS statistics])
1566 AC_PLUGIN([ntpd],        [yes],               [NTPd statistics])
1567 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
1568 AC_PLUGIN([perl],        [$with_libperl],     [Embed a Perl interpreter])
1569 AC_PLUGIN([ping],        [$with_liboping],    [Network latency statistics])
1570 AC_PLUGIN([processes],   [$plugin_processes], [Process statistics])
1571 AC_PLUGIN([rrdtool],     [$with_rrdtool],     [RRDTool output plugin])
1572 AC_PLUGIN([sensors],     [$with_lm_sensors],  [lm_sensors statistics])
1573 AC_PLUGIN([serial],      [$plugin_serial],    [serial port traffic])
1574 AC_PLUGIN([snmp],        [$with_libnetsnmp],  [SNMP querying plugin])
1575 AC_PLUGIN([swap],        [$plugin_swap],      [Swap usage statistics])
1576 AC_PLUGIN([syslog],      [$have_syslog],      [Syslog logging plugin])
1577 AC_PLUGIN([tape],        [$plugin_tape],      [Tape drive statistics])
1578 AC_PLUGIN([unixsock],    [yes],               [Unixsock communication plugin])
1579 AC_PLUGIN([users],       [$plugin_users],     [User statistics])
1580 AC_PLUGIN([vserver],     [$plugin_vserver],   [Linux VServer statistics])
1581 AC_PLUGIN([wireless],    [$plugin_wireless],  [Wireless statistics])
1582 AC_PLUGIN([xmms],        [$with_libxmms],     [XMMS statistics])
1583
1584 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile)
1585
1586 if test "x$with_liboping" = "xyes" -a "x$with_own_liboping" = "xyes"
1587 then
1588         with_liboping="yes (shipped version)"
1589 fi
1590
1591 if test "x$with_libperl" = "xyes"
1592 then
1593         with_libperl="yes (version `perl -MConfig -e 'print $Config{version};'`)"
1594 else
1595         enable_perl="no (needs libperl)"
1596 fi
1597
1598 cat <<EOF;
1599
1600 Configuration:
1601   Libraries:
1602     libcurl . . . . . . $with_libcurl
1603     libiokit  . . . . . $with_libiokit
1604     libiptc . . . . . . $with_libiptc
1605     libkstat  . . . . . $with_kstat
1606     libkvm  . . . . . . $with_libkvm
1607     libmysql  . . . . . $with_libmysql
1608     libnetsnmp  . . . . $with_libnetsnmp
1609     liboconfig  . . . . $with_liboconfig
1610     liboping  . . . . . $with_liboping
1611     libpcap . . . . . . $with_libpcap
1612     libperl . . . . . . $with_libperl
1613     libpthread  . . . . $with_libpthread
1614     librrd  . . . . . . $with_rrdtool
1615     libsensors  . . . . $with_lm_sensors
1616     libstatgrab . . . . $with_libstatgrab
1617     libupsclient  . . . $with_libupsclient
1618     libxmms . . . . . . $with_libxmms
1619
1620   Features:
1621     daemon mode . . . . $enable_daemon
1622     debug . . . . . . . $enable_debug
1623
1624   Modules:
1625     apache  . . . . . . $enable_apache
1626     apcups  . . . . . . $enable_apcups
1627     apple_sensors . . . $enable_apple_sensors
1628     battery . . . . . . $enable_battery
1629     cpu . . . . . . . . $enable_cpu
1630     cpufreq . . . . . . $enable_cpufreq
1631     csv . . . . . . . . $enable_csv
1632     df  . . . . . . . . $enable_df
1633     disk  . . . . . . . $enable_disk
1634     dns . . . . . . . . $enable_dns
1635     email . . . . . . . $enable_email
1636     entropy . . . . . . $enable_entropy
1637     exec  . . . . . . . $enable_exec
1638     hddtemp . . . . . . $enable_hddtemp
1639     interface . . . . . $enable_interface
1640     iptables  . . . . . $enable_iptables
1641     irq . . . . . . . . $enable_irq
1642     load  . . . . . . . $enable_load
1643     logfile . . . . . . $enable_logfile
1644     mbmon . . . . . . . $enable_mbmon
1645     memory  . . . . . . $enable_memory
1646     multimeter  . . . . $enable_multimeter
1647     mysql . . . . . . . $enable_mysql
1648     network . . . . . . $enable_network
1649     nfs . . . . . . . . $enable_nfs
1650     ntpd  . . . . . . . $enable_ntpd
1651     nut . . . . . . . . $enable_nut
1652     perl  . . . . . . . $enable_perl
1653     ping  . . . . . . . $enable_ping
1654     processes . . . . . $enable_processes
1655     sensors . . . . . . $enable_sensors
1656     serial  . . . . . . $enable_serial
1657     snmp  . . . . . . . $enable_snmp
1658     swap  . . . . . . . $enable_swap
1659     syslog  . . . . . . $enable_syslog
1660     tape  . . . . . . . $enable_tape
1661     unixsock  . . . . . $enable_unixsock
1662     users . . . . . . . $enable_users
1663     vserver . . . . . . $enable_vserver
1664     wireless  . . . . . $enable_wireless
1665     xmms  . . . . . . . $enable_xmms
1666
1667 EOF