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