contrib/exec-nagios.px: Added a Perl script which handles Nagios plugins.
[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         else
702                 with_rrdtool="$withval"
703         fi
704 ], [with_rrdtool="yes"])
705 if test "x$with_rrdtool" = "xyes"
706 then
707         SAVE_CPPFLAGS="$CPPFLAGS"
708         SAVE_LDFLAGS="$LDFLAGS"
709
710         CPPFLAGS="$CPPFLAGS $librrd_cflags"
711         LDFLAGS="$LDFLAGS $librrd_ldflags"
712
713         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
714
715         CPPFLAGS="$SAVE_CPPFLAGS"
716         LDFLAGS="$SAVE_LDFLAGS"
717 fi
718 if test "x$with_rrdtool" = "xyes"
719 then
720         SAVE_CPPFLAGS="$CPPFLAGS"
721         SAVE_LDFLAGS="$LDFLAGS"
722
723         CPPFLAGS="$CPPFLAGS $librrd_cflags"
724         LDFLAGS="$LDFLAGS $librrd_ldflags"
725
726         AC_CHECK_LIB(rrd_th, rrd_update_r,
727         [with_rrdtool="yes"
728          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
729         ],
730         [librrd_threadsafe="no"
731          AC_CHECK_LIB(rrd, rrd_update,
732          [with_rrdtool="yes"
733           librrd_ldflags="$librrd_ldflags -lrrd -lm"
734          ],
735          [with_rrdtool="no (symbol 'rrd_update' not found)"],
736          [-lm])
737         ]
738         [-lm])
739
740         CPPFLAGS="$SAVE_CPPFLAGS"
741         LDFLAGS="$SAVE_LDFLAGS"
742 fi
743 if test "x$with_rrdtool" = "xyes"
744 then
745         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
746         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
747         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
748         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
749 fi
750 if test "x$librrd_threadsafe" = "xyes"
751 then
752         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
753 fi
754
755 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
756 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
757         then
758                 LDFLAGS="$LDFLAGS -L$withval/lib"
759                 CPPFLAGS="$CPPFLAGS -I$withval/include"
760                 with_libpthread="yes"
761         else
762                 if test "x$withval" = "xno"
763                 then
764                         with_libpthread="no (disabled)"
765                 fi
766         fi
767 ], [with_libpthread="yes"])
768 if test "x$with_libpthread" = "xyes"
769 then
770         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
771 fi
772 if test "x$with_libpthread" = "xyes"
773 then
774         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
775 fi
776 if test "x$with_libpthread" = "xyes"
777 then
778         collect_pthread=1
779 else
780         collect_pthread=0
781 fi
782 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
783         [Wether or not to use pthread (POSIX threads) library])
784 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
785
786 if test "x$ac_system" = "xSolaris"
787 then
788         with_kstat="yes"
789         with_devinfo="yes"
790 else
791         with_kstat="no (Solaris only)"
792         with_devinfo="no (Solaris only)"
793 fi
794
795 if test "x$with_kstat" = "xyes"
796 then
797         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
798 fi
799 if test "x$with_kstat" = "xyes"
800 then
801         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
802         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
803 fi
804 if test "x$with_kstat" = "xyes"
805 then
806         AC_DEFINE(HAVE_LIBKSTAT, 1,
807                   [Define to 1 if you have the 'kstat' library (-lkstat)])
808 fi
809 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
810 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
811
812 ### BEGIN of check for libcurl ###
813 with_curl_config="curl-config"
814 with_curl_cflags=""
815 with_curl_libs=""
816 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
817 [
818         if test "x$withval" = "xno"
819         then
820                 with_libcurl="no"
821         else if test "x$withval" = "xyes"
822         then
823                 with_libcurl="yes"
824         else
825                 if test -f "$withval" && test -x "$withval"
826                 then
827                         with_curl_config="$withval"
828                         with_libcurl="yes"
829                 else if test -x "$withval/bin/curl-config"
830                 then
831                         with_curl_config="$withval/bin/curl-config"
832                         with_libcurl="yes"
833                 fi; fi
834                 with_libcurl="yes"
835         fi; fi
836 ],
837 [
838         with_libcurl="yes"
839 ])
840 if test "x$with_libcurl" = "xyes"
841 then
842         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
843         curl_config_status=$?
844
845         if test $curl_config_status -ne 0
846         then
847                 with_libcurl="no ($with_curl_config failed)"
848         else
849                 SAVE_CFLAGS=$CFLAGS
850                 CFLAGS="$CFLAGS $with_curl_cflags"
851
852                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
853
854                 CFLAGS="$SAVE_CFLAGS"
855         fi
856 fi
857 if test "x$with_libcurl" = "xyes"
858 then
859         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
860         curl_config_status=$?
861
862         if test $curl_config_status -ne 0
863         then
864                 with_libcurl="no ($with_curl_config failed)"
865         else
866                 AC_CHECK_LIB(curl, curl_easy_init,
867                  [with_libcurl="yes"],
868                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
869                  [$with_curl_libs])
870         fi
871 fi
872 if test "x$with_libcurl" = "xyes"
873 then
874         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
875         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
876         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
877         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
878 fi
879 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
880 ### END of check for libcurl ###
881
882 with_libiokit="no"
883 collectd_libiokit=0
884 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
885 [
886         with_libiokit="yes"
887         collectd_libiokit=1
888 ],
889 [
890         with_libiokit="no"
891         collectd_libiokit=0
892 ])
893 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
894 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
895
896 with_libstatgrab="yes"
897 with_libdevstat="no"
898 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
899 [
900         if test "x$withval" != "xno" -a "x$withval" != "xyes"
901         then
902                 LDFLAGS="$LDFLAGS -L$withval/lib"
903                 CPPFLAGS="$CPPFLAGS -I$withval/include"
904                 with_libstatgrab="yes"
905         else
906                 with_libstatgrab="$withval"
907         fi
908 ],
909 [
910         if test "x$ac_system" == "xunknown"
911         then
912                 with_libstatgrab="yes"
913         else
914                 with_libstatgrab="no"
915         fi
916 ])
917 if test "x$with_libstatgrab" = "xyes"
918 then
919         AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"])
920 fi
921 if test "x$with_libstatgrab" = "xyes"
922 then
923         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
924 fi
925 if test "x$with_libstatgrab" = "xyes"
926 then
927         AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"])
928 fi
929 if test "x$with_libstatgrab" = "xyes"
930 then
931         collect_libstatgrab=1
932 else
933         collect_libstatgrab=0
934 fi
935 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
936         [Wether or not to use statgrab library])
937 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
938 AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT,  test "x$with_libdevstat"  = "xyes")
939
940 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
941 if test "x$with_libkvm" = "xyes"
942 then
943         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
944 fi
945 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
946
947 with_sensors_cflags=""
948 with_sensors_ldflags=""
949 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
950 [
951         if test "x$withval" = "xno"
952         then
953                 with_lm_sensors="no"
954         else
955                 with_lm_sensors="yes"
956                 if test "x$withval" != "xyes"
957                 then
958                         with_sensors_cflags="-I$withval/include"
959                         with_sensors_ldflags="-L$withval/lib"
960                         with_lm_sensors="yes"
961                 fi
962         fi
963 ],
964 [
965         if test "x$ac_system" = "xLinux"
966         then
967                 with_lm_sensors="yes"
968         else
969                 with_lm_sensors="no (Linux only library)"
970         fi
971 ])
972 if test "x$with_lm_sensors" = "xyes"
973 then
974         SAVE_CPPFLAGS="$CPPFLAGS"
975         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
976
977 #       AC_CHECK_HEADERS(sensors/sensors.h,
978 #       [
979 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
980 #       ],
981 #       [with_lm_sensors="no (sensors/sensors.h not found)"])
982         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_lm_sensors="no (sensors/sensors.h not found)"])
983
984         CPPFLAGS="$SAVE_CPPFLAGS"
985 fi
986 if test "x$with_lm_sensors" = "xyes"
987 then
988         SAVE_CPPFLAGS="$CPPFLAGS"
989         SAVE_LDFLAGS="$LDFLAGS"
990         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
991         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
992
993         AC_CHECK_LIB(sensors, sensors_init,
994         [
995                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
996         ],
997         [with_lm_sensors="no (libsensors not found)"])
998
999         CPPFLAGS="$SAVE_CPPFLAGS"
1000         LDFLAGS="$SAVE_LDFLAGS"
1001 fi
1002 if test "x$with_lm_sensors" = "xyes"
1003 then
1004         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
1005         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
1006         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
1007         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
1008 fi
1009 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
1010
1011 with_mysql_config="mysql_config"
1012 with_mysql_cflags=""
1013 with_mysql_libs=""
1014 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1015 [
1016         if test "x$withval" = "xno"
1017         then
1018                 with_libmysql="no"
1019         else if test "x$withval" = "xyes"
1020         then
1021                 with_libmysql="yes"
1022         else
1023                 if test -f "$withval" && test -x "$withval";
1024                 then
1025                         with_mysql_config="$withval"
1026                 else if test -x "$withval/bin/mysql_config"
1027                 then
1028                         with_mysql_config="$withval/bin/mysql_config"
1029                 fi; fi
1030                 with_libmysql="yes"
1031         fi; fi
1032 ],
1033 [
1034         with_libmysql="yes"
1035 ])
1036 if test "x$with_libmysql" = "xyes"
1037 then
1038         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1039         mysql_config_status=$?
1040
1041         if test $mysql_config_status -ne 0
1042         then
1043                 with_libmysql="no"
1044         else
1045                 SAVE_CFLAGS=$CFLAGS
1046                 CFLAGS="$CFLAGS $with_mysql_cflags"
1047
1048                 AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
1049
1050                 CFLAGS="$SAVE_CFLAGS"
1051         fi
1052 fi
1053 if test "x$with_libmysql" = "xyes"
1054 then
1055         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1056         mysql_config_status=$?
1057
1058         if test $mysql_config_status -ne 0
1059         then
1060                 with_libmysql="no"
1061         else
1062                 AC_CHECK_LIB(mysqlclient, mysql_init,
1063                  [with_libmysql="yes"],
1064                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1065                  [$with_mysql_libs])
1066         fi
1067 fi
1068 if test "x$with_libmysql" = "xyes"
1069 then
1070         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1071         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1072         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1073         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1074 fi
1075 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1076
1077 with_own_liboconfig="no"
1078 liboconfig_LDFLAGS="$LDFLAGS"
1079 liboconfig_CPPFLAGS="$CPPFLAGS"
1080 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1081 [
1082         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1083         then
1084                 if test -d "$withval/lib"
1085                 then
1086                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1087                 fi
1088                 if test -d "$withval/include"
1089                 then
1090                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1091                 fi
1092         fi
1093         if test "x$withval" = "xno"
1094         then
1095                 AC_MSG_ERROR("liboconfig is required")
1096         fi
1097 ],
1098 [
1099         with_liboconfig="yes"
1100 ])
1101
1102 save_LDFLAGS="$LDFLAGS"
1103 save_CPPFLAGS="$CPPFLAGS"
1104 LDFLAGS="$liboconfig_LDFLAGS"
1105 CPPFLAGS="$liboconfig_CPPFLAGS"
1106 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1107 [
1108         with_liboconfig="yes"
1109         with_own_liboconfig="no"
1110 ],
1111 [
1112         with_liboconfig="yes"
1113         with_own_liboconfig="yes"
1114         LDFLAGS="$save_LDFLAGS"
1115         CPPFLAGS="$save_CPPFLAGS"
1116 ])
1117
1118 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1119 if test "x$with_own_liboconfig" = "xyes"
1120 then
1121         with_liboconfig="yes (shipped version)"
1122 fi
1123
1124 #with_liboping="yes"
1125 with_own_liboping="no"
1126 liboping_LDFLAGS="$LDFLAGS"
1127 liboping_CPPFLAGS="$CPPFLAGS"
1128 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1129 [
1130         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1131         then
1132                 if test -d "$withval/lib"
1133                 then
1134                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1135                 fi
1136                 if test -d "$withval/include"
1137                 then
1138                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1139                 fi
1140         fi
1141         if test "x$withval" = "xno"
1142         then
1143                 with_liboping="no"
1144                 with_own_liboping="no"
1145         else if test "x$withval" = "xyes"
1146         then
1147                 with_liboping="yes"
1148         fi; fi
1149 ],
1150 [
1151         with_liboping="yes"
1152 ])
1153
1154 if test "x$with_liboping" = "xyes"
1155 then
1156         save_LDFLAGS="$LDFLAGS"
1157         save_CPPFLAGS="$CPPFLAGS"
1158         LDFLAGS="$liboping_LDFLAGS"
1159         CPPFLAGS="$liboping_CPPFLAGS"
1160         AC_CHECK_LIB(oping, ping_construct,
1161         [
1162                 with_liboping="yes"
1163                 with_own_liboping="no"
1164         ],
1165         [
1166                 with_liboping="yes"
1167                 with_own_liboping="yes"
1168                 LDFLAGS="$save_LDFLAGS"
1169                 CPPFLAGS="$save_CPPFLAGS"
1170         ])
1171 fi
1172 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1173 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1174
1175 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1176 [
1177         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1178         then
1179                 LDFLAGS="$LDFLAGS -L$withval/lib"
1180                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1181                 with_libpcap="yes"
1182         else
1183                 with_libpcap="$withval"
1184         fi
1185 ],
1186 [
1187         with_libpcap="yes"
1188 ])
1189 if test "x$with_libpcap" = "xyes"
1190 then
1191         AC_CHECK_LIB(pcap, pcap_open_live,
1192         [
1193                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1194         ], [with_libpcap="no (libpcap not found)"])
1195 fi
1196 if test "x$with_libpcap" = "xyes"
1197 then
1198         AC_CHECK_HEADERS(pcap.h,
1199         [
1200                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1201         ], [with_libpcap="no (pcap.h not found)"])
1202 fi
1203 if test "x$with_libpcap" = "xyes"
1204 then
1205         collect_libpcap=1
1206 else
1207         collect_libpcap=0
1208 fi
1209 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1210         [Wether or not to use the pcap library])
1211 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1212
1213 perl_interpreter="perl"
1214 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1215 [
1216         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1217         then
1218                 LDFLAGS="$LDFLAGS -L$withval/lib"
1219                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1220                 perl_interpreter="$withval/bin/perl"
1221                 with_libperl="yes"
1222         else
1223                 with_libperl="$withval"
1224         fi
1225 ],
1226 [
1227         with_libperl="yes"
1228 ])
1229
1230 AC_SUBST(PERL, "$perl_interpreter")
1231
1232 if test "x$with_libperl" = "xyes"
1233 then
1234   SAVE_CFLAGS=$CFLAGS
1235   SAVE_LDFLAGS=$LDFLAGS
1236   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1237   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1238   CFLAGS="$CFLAGS $PERL_CFLAGS"
1239   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1240
1241   AC_CACHE_CHECK([for libperl],
1242     [have_libperl],
1243     AC_LINK_IFELSE(
1244       AC_LANG_PROGRAM(
1245       [[
1246 #include <EXTERN.h>
1247 #include <perl.h>
1248 #include <XSUB.h>
1249       ]],
1250       [[
1251        PerlInterpreter *perl = NULL;
1252        Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
1253                          newSVpv ("Collectd::Plugin::FooBar", 24),
1254                          Nullsv);
1255       ]]),
1256       [have_libperl="yes"],
1257       [have_libperl="no"]
1258     )
1259   )
1260
1261   if test "x$have_libperl" = "xyes"
1262   then
1263           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1264           AC_SUBST(PERL_CFLAGS)
1265           AC_SUBST(PERL_LDFLAGS)
1266   else
1267           with_libperl="no"
1268   fi
1269
1270   CFLAGS=$SAVE_CFLAGS
1271   LDFLAGS=$SAVE_LDFLAGS
1272 fi
1273 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1274
1275 if test "x$with_libperl" = "xyes"
1276 then
1277         SAVE_CFLAGS=$CFLAGS
1278         SAVE_LDFLAGS=$LDFLAGS
1279         CFLAGS="$CFLAGS $PERL_CFLAGS"
1280         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1281
1282         AC_CACHE_CHECK([if perl supports ithreads],
1283                 [have_perl_ithreads],
1284                 AC_LINK_IFELSE(
1285                         AC_LANG_PROGRAM(
1286                         [[
1287 #include <EXTERN.h>
1288 #include <perl.h>
1289 #include <XSUB.h>
1290
1291 #if !defined(USE_ITHREADS)
1292 # error "Perl does not support ithreads!"
1293 #endif /* !defined(USE_ITHREADS) */
1294                         ]],
1295                         [[ ]]),
1296                         [have_perl_ithreads="yes"],
1297                         [have_perl_ithreads="no"]
1298                 )
1299         )
1300
1301         if test "x$have_perl_ithreads" = "xyes"
1302         then
1303                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
1304         fi
1305
1306         CFLAGS=$SAVE_CFLAGS
1307         LDFLAGS=$SAVE_LDFLAGS
1308 fi
1309
1310 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1311 [
1312         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1313         then
1314                 LDFLAGS="$LDFLAGS -L$withval/lib"
1315                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1316                 with_libiptc="yes"
1317         else
1318                 with_libiptc="$withval"
1319         fi
1320 ],
1321 [
1322         if test "x$ac_system" = "xLinux"
1323         then
1324                 with_libiptc="yes"
1325         else
1326                 with_libiptc="no (Linux only)"
1327         fi
1328 ])
1329 if test "x$with_libiptc" = "xyes"
1330 then
1331         AC_CHECK_LIB(iptc, iptc_init,
1332         [
1333                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1334         ], [with_libiptc="no (libiptc not found)"])
1335 fi
1336 if test "x$with_libiptc" = "xyes"
1337 then
1338         AC_CHECK_HEADERS(libiptc/libiptc.h,
1339         [
1340                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1341         ], [with_libiptc="no (libiptc/libiptc.h not found)"])
1342 fi
1343 if test "x$with_libiptc" = "xyes"
1344 then
1345         collect_libiptc=1
1346 else
1347         collect_libiptc=0
1348 fi
1349 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1350
1351 with_snmp_config="net-snmp-config"
1352 with_snmp_cflags=""
1353 with_snmp_libs=""
1354 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1355 [
1356         if test "x$withval" = "xno"
1357         then
1358                 with_libnetsnmp="no"
1359         else if test "x$withval" = "xyes"
1360         then
1361                 with_libnetsnmp="yes"
1362         else
1363                 if test -x "$withval"
1364                 then
1365                         with_snmp_config="$withval"
1366                         with_libnetsnmp="yes"
1367                 else
1368                         with_snmp_config="$withval/bin/net-snmp-config"
1369                         with_libnetsnmp="yes"
1370                 fi
1371         fi; fi
1372 ],
1373 [with_libnetsnmp="yes"])
1374 if test "x$with_libnetsnmp" = "xyes"
1375 then
1376         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1377         snmp_config_status=$?
1378
1379         if test $snmp_config_status -ne 0
1380         then
1381                 with_libnetsnmp="no ($with_snmp_config failed)"
1382         else
1383                 SAVE_CFLAGS=$CFLAGS
1384                 CFLAGS="$CFLAGS $with_snmp_cflags"
1385                 
1386                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1387
1388                 CFLAGS="$SAVE_CFLAGS"
1389         fi
1390 fi
1391 if test "x$with_libnetsnmp" = "xyes"
1392 then
1393         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1394         snmp_config_status=$?
1395
1396         if test $snmp_config_status -ne 0
1397         then
1398                 with_libnetsnmp="no ($with_snmp_config failed)"
1399         else
1400                 AC_CHECK_LIB(netsnmp, init_snmp,
1401                 [with_libnetsnmp="yes"],
1402                 [with_libnetsnmp="no (libnetsnmp not found)"],
1403                 [$with_snmp_libs])
1404         fi
1405 fi
1406 if test "x$with_libnetsnmp" = "xyes"
1407 then
1408         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1409         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1410         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1411         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1412 fi
1413 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1414
1415 with_upsclient_config="libupsclient-config"
1416 with_upsclient_cflags=""
1417 with_upsclient_libs=""
1418 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
1419 [
1420         if test "x$withval" = "xno"
1421         then
1422                 with_libupsclient="no"
1423         else
1424                 if test "x$withval" != "xyes"
1425                 then
1426                         if test -f "$withval" && test -x "$withval";
1427                         then
1428                                 with_upsclient_config="$withval"
1429                         else
1430                                 with_upsclient_config="$withval/bin/libupsclient-config"
1431                         fi
1432                 fi
1433                 with_libupsclient="yes"
1434         fi
1435 ],
1436 [
1437         with_libupsclient="yes"
1438 ])
1439 if test "x$with_libupsclient" = "xyes"
1440 then
1441         with_upsclient_cflags=`$with_upsclient_config --cflags 2>/dev/null`
1442         upsclient_config_status=$?
1443
1444         if test $upsclient_config_status -ne 0
1445         then
1446                 with_libupsclient="no ($with_upsclient_config failed)"
1447         fi
1448 fi
1449 if test "x$with_libupsclient" = "xyes"
1450 then
1451         SAVE_CFLAGS="$CFLAGS"
1452         CFLAGS="$CFLAGS $with_upsclient_cflags"
1453
1454         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
1455
1456         CFLAGS="$SAVE_CFLAGS"
1457 fi
1458 if test "x$with_libupsclient" = "xyes"
1459 then
1460         with_upsclient_libs=`$with_upsclient_config --libs 2>/dev/null`
1461         upsclient_config_status=$?
1462
1463         if test $upsclient_config_status -ne 0
1464         then
1465                 with_libupsclient="no ($with_upsclient_config failed)"
1466         fi
1467 fi
1468 if test "x$with_libupsclient" = "xyes"
1469 then
1470         AC_CHECK_LIB(upsclient, upscli_connect,
1471         [
1472                 BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_upsclient_cflags"
1473                 BUILD_WITH_LIBUPSCLIENT_LIBS="$with_upsclient_libs"
1474                 AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
1475                 AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
1476         ],
1477         [
1478                 with_libupsclient="no (symbol 'upscli_connect' not found)"
1479         ], [$with_upsclient_libs])
1480 fi
1481 if test "x$with_libupsclient" = "xyes"
1482 then
1483         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
1484 [#include <stdlib.h>
1485 #include <stdio.h>
1486 #include <upsclient.h>])
1487 fi
1488 AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
1489
1490 ### BEGIN of check for libxmms ###
1491 with_xmms_config="xmms-config"
1492 with_xmms_cflags=""
1493 with_xmms_libs=""
1494 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
1495 [
1496         if test "x$withval" != "xno" -a "x$withval" != "xyes"
1497         then
1498                 if test -f "$withval" && test -x "$withval";
1499                 then
1500                         with_xmms_config="$withval"
1501                 else if test -x "$withval/bin/xmms-config"
1502                 then
1503                         with_xmms_config="$withval/bin/xmms-config"
1504                 fi; fi
1505                 with_libxmms="yes"
1506         else if test "x$withval" = "xno"
1507         then
1508                 with_libxmms="no"
1509         else
1510                 with_libxmms="yes"
1511         fi; fi
1512 ],
1513 [
1514         with_libxmms="yes"
1515 ])
1516 if test "x$with_libxmms" = "xyes"
1517 then
1518         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
1519         xmms_config_status=$?
1520
1521         if test $xmms_config_status -ne 0
1522         then
1523                 with_libxmms="no"
1524         fi
1525 fi
1526 if test "x$with_libxmms" = "xyes"
1527 then
1528         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
1529         xmms_config_status=$?
1530
1531         if test $xmms_config_status -ne 0
1532         then
1533                 with_libxmms="no"
1534         fi
1535 fi
1536 if test "x$with_libxmms" = "xyes"
1537 then
1538         AC_CHECK_LIB(xmms, xmms_remote_get_info,
1539         [
1540                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
1541                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
1542                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
1543                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
1544         ],
1545         [
1546                 with_libxmms="no"
1547         ],
1548         [$with_xmms_libs])
1549 fi
1550 with_libxmms_numeric=0
1551 if test "x$with_libxmms" = "xyes"
1552 then
1553         with_libxmms_numeric=1
1554 fi
1555 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
1556 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
1557 ### END of check for libxmms ###
1558
1559 with_libnetlink_cflags=""
1560 with_libnetlink_libs="-lnetlink"
1561 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1562 [
1563  echo "libnetlink: withval = $withval"
1564  if test "x$withval" = "xyes"
1565  then
1566          with_libnetlink="yes"
1567  else if test "x$withval" = "xno"
1568  then
1569          with_libnetlink="no"
1570  else
1571          if test -d "$withval/include"
1572          then
1573                  with_libnetlink_cflags="-I$withval/include"
1574                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1575                  with_libnetlink="yes"
1576          else
1577                  AC_MSG_ERROR("no such directory: $withval/include")
1578          fi
1579  fi; fi
1580 ],
1581 [
1582  if test "x$ac_system" = "xLinux"
1583  then
1584          with_libnetlink="yes"
1585  else
1586          with_libnetlink="no (Linux only library)"
1587  fi
1588 ])
1589 if test "x$with_libnetlink" = "xyes"
1590 then
1591         SAVE_CFLAGS=$CFLAGS
1592         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1593
1594         with_libnetlink="no (libnetlink.h not found)"
1595
1596         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1597         [
1598          with_libnetlink="yes"
1599          break
1600         ], [],
1601 [#include <stdio.h>
1602 #include <sys/types.h>
1603 #include <asm/types.h>
1604 #include <sys/socket.h>
1605 #include <linux/netlink.h>
1606 #include <linux/rtnetlink.h>])
1607         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1608 [#include <stdio.h>
1609 #include <sys/types.h>
1610 #include <asm/types.h>
1611 #include <sys/socket.h>])
1612
1613         AC_COMPILE_IFELSE(
1614 [#include <stdio.h>
1615 #include <sys/types.h>
1616 #include <asm/types.h>
1617 #include <sys/socket.h>
1618 #include <linux/netlink.h>
1619 #include <linux/rtnetlink.h>
1620
1621 int main (void)
1622 {
1623         int retval = TCA_STATS2;
1624         return (retval);
1625 }],
1626         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1627         []);
1628
1629         AC_COMPILE_IFELSE(
1630 [#include <stdio.h>
1631 #include <sys/types.h>
1632 #include <asm/types.h>
1633 #include <sys/socket.h>
1634 #include <linux/netlink.h>
1635 #include <linux/rtnetlink.h>
1636
1637 int main (void)
1638 {
1639         int retval = TCA_STATS;
1640         return (retval);
1641 }],
1642         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1643         []);
1644
1645         CFLAGS="$SAVE_CFLAGS"
1646 fi
1647 if test "x$with_libnetlink" = "xyes"
1648 then
1649         AC_CHECK_LIB(netlink, rtnl_open,
1650                      [with_libnetlink="yes"],
1651                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1652                      [$with_libnetlink_libs])
1653 fi
1654 if test "x$with_libnetlink" = "xyes"
1655 then
1656         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1657         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1658         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1659         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1660 fi
1661 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1662
1663 dnl Check for libvirt and libxml2 libraries.
1664 with_libxml2="no (pkg-config isn't available)"
1665 with_libxml2_cflags=""
1666 with_libxml2_ldflags=""
1667 with_libvirt="no (pkg-config isn't available)"
1668 with_libvirt_cflags=""
1669 with_libvirt_ldflags=""
1670 PKG_PROG_PKG_CONFIG
1671 if test "x$PKG_CONFIG" != "x"
1672 then
1673         pkg-config --exists 'libxml-2.0' 2>/dev/null
1674         if test "$?" = "0"
1675         then
1676                 with_libxml2="yes"
1677         else
1678                 with_libxml2="no (pkg-config doesn't know library)"
1679         fi
1680
1681         pkg-config --exists libvirt 2>/dev/null
1682         if test "$?" = "0"
1683         then
1684                 with_libvirt="yes"
1685         else
1686                 with_libvirt="no (pkg-config doesn't know library)"
1687         fi
1688 fi
1689 if test "x$with_libxml2" = "xyes"
1690 then
1691         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
1692         if test $? -ne 0
1693         then
1694                 with_libxml2="no"
1695         fi
1696         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
1697         if test $? -ne 0
1698         then
1699                 with_libxml2="no"
1700         fi
1701 fi
1702 if test "x$with_libxml2" = "xyes"
1703 then
1704         SAVE_CPPFLAGS="$CPPFLAGS"
1705         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
1706
1707         AC_CHECK_HEADERS(libxml/parser.h, [],
1708                       [with_libxml2="no (libxml/parser.h not found)"])
1709
1710         CPPFLAGS="$SAVE_CPPFLAGS"
1711 fi
1712 if test "x$with_libxml2" = "xyes"
1713 then
1714         SAVE_CFLAGS="$CFLAGS"
1715         SAVE_LD_FLAGS="$LDFLAGS"
1716
1717         CFLAGS="$CFLAGS $with_libxml2_cflags"
1718         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
1719
1720         AC_CHECK_LIB(xml2, xmlXPathEval,
1721                      [with_libxml2="yes"],
1722                      [with_libxml2="no (symbol xmlXPathEval not found)"])
1723
1724         CFLAGS="$SAVE_CFLAGS"
1725         LDFLAGS="$SAVE_LDFLAGS"
1726 fi
1727 dnl Add the right compiler flags and libraries.
1728 if test "x$with_libxml2" = "xyes"; then
1729         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
1730         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
1731         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
1732         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
1733 fi
1734 if test "x$with_libvirt" = "xyes"
1735 then
1736         with_libvirt_cflags="`pkg-config --cflags libvirt`"
1737         if test $? -ne 0
1738         then
1739                 with_libvirt="no"
1740         fi
1741         with_libvirt_ldflags="`pkg-config --libs libvirt`"
1742         if test $? -ne 0
1743         then
1744                 with_libvirt="no"
1745         fi
1746 fi
1747 if test "x$with_libvirt" = "xyes"
1748 then
1749         SAVE_CPPFLAGS="$CPPFLAGS"
1750         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
1751
1752         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
1753                       [with_libvirt="no (libvirt/libvirt.h not found)"])
1754
1755         CPPFLAGS="$SAVE_CPPFLAGS"
1756 fi
1757 if test "x$with_libvirt" = "xyes"
1758 then
1759         SAVE_CFLAGS="$CFLAGS"
1760         SAVE_LD_FLAGS="$LDFLAGS"
1761
1762         CFLAGS="$CFLAGS $with_libvirt_cflags"
1763         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
1764
1765         AC_CHECK_LIB(virt, virDomainBlockStats,
1766                      [with_libvirt="yes"],
1767                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
1768
1769         CFLAGS="$SAVE_CFLAGS"
1770         LDFLAGS="$SAVE_LDFLAGS"
1771 fi
1772 dnl Add the right compiler flags and libraries.
1773 if test "x$with_libvirt" = "xyes"; then
1774         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
1775         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
1776         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
1777         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
1778 fi
1779
1780 dnl End of check for libvirt and libxml2 libraries.
1781
1782 # Check for enabled/disabled features
1783 #
1784
1785 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
1786 # ------------------------------------------------------------
1787 dnl
1788 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
1789 dnl
1790 AC_DEFUN(
1791         [AC_COLLECTD],
1792         [
1793         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
1794         m4_if(
1795                 [$2],
1796                 [enable],
1797                 [dnl
1798                 m4_define([EnDis],[disabled])dnl
1799                 m4_define([YesNo],[no])dnl
1800                 ],dnl
1801                 [m4_if(
1802                         [$2],
1803                         [disable],
1804                         [dnl
1805                         m4_define([EnDis],[enabled])dnl
1806                         m4_define([YesNo],[yes])dnl
1807                         ],
1808                         [dnl
1809                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
1810                         ]dnl
1811                 )]dnl
1812         )dnl
1813         m4_if([$3], [feature], [],
1814                 [m4_if(
1815                         [$3], [module], [],
1816                         [dnl
1817                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
1818                         ]dnl
1819                 )]dnl
1820         )dnl
1821         AC_ARG_ENABLE(
1822                 [$1],
1823                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
1824                 [],
1825                 enable_$1='[YesNo]'dnl
1826         )# AC_ARG_ENABLE
1827 if test "x$enable_$1" = "xno"
1828 then
1829         collectd_$1=0
1830 else
1831         if test "x$enable_$1" = "xyes"
1832         then
1833                 collectd_$1=1
1834         else
1835                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
1836                 collectd_$1=1
1837                 enable_$1='yes'
1838         fi
1839 fi
1840         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
1841         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
1842         ]dnl
1843 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
1844
1845 # AC_PLUGIN(name, default, info)
1846 # ------------------------------------------------------------
1847 dnl
1848 AC_DEFUN(
1849   [AC_PLUGIN],
1850   [
1851     enable_plugin="no"
1852     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
1853     [
1854      if test "x$enableval" = "xyes"
1855      then
1856              enable_plugin="yes"
1857      else
1858              enable_plugin="no"
1859      fi
1860     ],
1861     [
1862      if test "x$2" = "xyes"
1863      then
1864              enable_plugin="yes"
1865      else
1866              enable_plugin="no"
1867      fi
1868     ])
1869     if test "x$enable_plugin" = "xyes"
1870     then
1871             AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
1872     fi
1873     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
1874     enable_$1="$enable_plugin"
1875   ]
1876 )# AC_PLUGIN(name, default, info)
1877
1878 m4_divert_once([HELP_ENABLE], [
1879 collectd features:])
1880 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
1881 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
1882 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
1883 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
1884
1885 plugin_battery="no"
1886 plugin_cpu="no"
1887 plugin_cpufreq="no"
1888 plugin_df="no"
1889 plugin_disk="no"
1890 plugin_entropy="no"
1891 plugin_interface="no"
1892 plugin_ipvs="no"
1893 plugin_irq="no"
1894 plugin_libvirt="no"
1895 plugin_load="no"
1896 plugin_memory="no"
1897 plugin_multimeter="no"
1898 plugin_nfs="no"
1899 plugin_perl="no"
1900 plugin_processes="no"
1901 plugin_serial="no"
1902 plugin_swap="no"
1903 plugin_tape="no"
1904 plugin_tcpconns="no"
1905 plugin_users="no"
1906 plugin_vserver="no"
1907 plugin_wireless="no"
1908
1909 # Linux
1910 if test "x$ac_system" = "xLinux"
1911 then
1912         plugin_battery="yes"
1913         plugin_cpu="yes"
1914         plugin_cpufreq="yes"
1915         plugin_disk="yes"
1916         plugin_entropy="yes"
1917         plugin_interface="yes"
1918         plugin_irq="yes"
1919         plugin_load="yes"
1920         plugin_memory="yes"
1921         plugin_nfs="yes"
1922         plugin_processes="yes"
1923         plugin_serial="yes"
1924         plugin_swap="yes"
1925         plugin_tcpconns="yes"
1926         plugin_vserver="yes"
1927         plugin_wireless="yes"
1928
1929         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
1930         then
1931                 plugin_ipvs="yes"
1932         fi
1933 fi
1934
1935 # Mac OS X devices
1936 if test "x$with_libiokit" = "xyes"
1937 then
1938         plugin_battery="yes"
1939         plugin_disk="yes"
1940 fi
1941
1942 # Solaris
1943 if test "x$with_devinfo$with_kstat" = "xyesyes"
1944 then
1945         plugin_cpu="yes"
1946         plugin_disk="yes"
1947         plugin_interface="yes"
1948         plugin_memory="yes"
1949         plugin_swap="yes"
1950         plugin_tape="yes"
1951 fi
1952
1953 # libstatgrab
1954 if test "x$with_libstatgrab" = "xyes"
1955 then
1956         plugin_interface="yes"
1957         plugin_load="yes"
1958         plugin_memory="yes"
1959         plugin_swap="yes"
1960 fi
1961
1962 if test "x$have_processor_info" = "xyes"
1963 then
1964         plugin_cpu="yes"
1965 fi
1966 if test "x$have_sysctlbyname" = "xyes"
1967 then
1968         plugin_cpu="yes"
1969         plugin_memory="yes"
1970         plugin_tcpconns="yes"
1971 fi
1972
1973 if test "x$have_statfs" = "xyes"
1974 then
1975         plugin_df="yes"
1976 fi
1977 if test "x$have_statvfs" = "xyes"
1978 then
1979         plugin_df="yes"
1980 fi
1981
1982 if test "x$have_getifaddrs" = "xyes"
1983 then
1984         plugin_interface="yes"
1985 fi
1986
1987 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
1988 then
1989         plugin_libvirt="yes"
1990 fi
1991
1992 if test "x$have_getloadavg" = "xyes"
1993 then
1994         plugin_load="yes"
1995 fi
1996
1997 if test "x$have_libperl$have_perl_ithreads" = "xyesyes"
1998 then
1999         plugin_perl="yes"
2000 fi
2001
2002 # Mac OS X memory interface
2003 if test "x$have_host_statistics" = "xyes"
2004 then
2005         plugin_memory="yes"
2006 fi
2007
2008 if test "x$have_termios_h" = "xyes"
2009 then
2010         plugin_multimeter="yes"
2011 fi
2012
2013 if test "x$have_thread_info" = "xyes"
2014 then
2015         plugin_processes="yes"
2016 fi
2017
2018 if test "x$with_libkvm" = "xyes"
2019 then
2020         plugin_swap="yes"
2021 fi
2022
2023 if test "x$have_getutent" = "xyes"
2024 then
2025         plugin_users="yes"
2026 fi
2027 if test "x$have_getutxent" = "xyes"
2028 then
2029         plugin_users="yes"
2030 fi
2031
2032 # FIXME: sysctl for swap plugin
2033
2034 m4_divert_once([HELP_ENABLE], [
2035 collectd plugins:])
2036
2037 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
2038 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
2039 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
2040 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
2041 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
2042 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
2043 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
2044 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
2045 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
2046 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
2047 AC_PLUGIN([email],       [yes],                [EMail statistics])
2048 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
2049 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
2050 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
2051 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
2052 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
2053 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
2054 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
2055 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
2056 AC_PLUGIN([load],        [$plugin_load],       [System load])
2057 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
2058 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
2059 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
2060 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
2061 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
2062 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
2063 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
2064 AC_PLUGIN([network],     [yes],                [Network communication plugin])
2065 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
2066 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
2067 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
2068 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
2069 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
2070 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
2071 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
2072 AC_PLUGIN([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
2073 AC_PLUGIN([sensors],     [$with_lm_sensors],   [lm_sensors statistics])
2074 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
2075 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
2076 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
2077 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
2078 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
2079 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
2080 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
2081 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
2082 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
2083 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
2084 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
2085 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
2086
2087 dnl ip_vs.h
2088 if test "x$ac_system" = "xLinux" -a "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
2089 then
2090         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
2091 fi
2092
2093 dnl Perl bindings
2094 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
2095 [
2096         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2097         then
2098                 PERL_BINDINGS_OPTIONS="$withval"
2099                 with_perl_bindings="yes"
2100         else
2101                 PERL_BINDINGS_OPTIONS=""
2102                 with_perl_bindings="$withval"
2103         fi
2104 ],
2105 [
2106         PERL_BINDINGS_OPTIONS=""
2107         with_perl_bindings="yes"
2108 ])
2109 if test "x$with_perl_bindings" = "xyes"
2110 then
2111         PERL_BINDINGS="perl"
2112 else
2113         PERL_BINDINGS=""
2114 fi
2115 AC_SUBST(PERL_BINDINGS)
2116 AC_SUBST(PERL_BINDINGS_OPTIONS)
2117
2118 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
2119
2120 if test "x$with_rrdtool" = "xyes" -a "x$librrd_threadsafe" != "xyes"
2121 then
2122         with_rrdtool="yes (warning: librrd is not thread-safe)"
2123 fi
2124
2125 if test "x$with_liboping" = "xyes" -a "x$with_own_liboping" = "xyes"
2126 then
2127         with_liboping="yes (shipped version)"
2128 fi
2129
2130 if test "x$with_libperl" = "xyes"
2131 then
2132         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
2133 else
2134         enable_perl="no (needs libperl)"
2135 fi
2136
2137 if test "x$with_perl_bindings" = "xyes" -a "x$PERL_BINDINGS_OPTIONS" != "x"
2138 then
2139         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
2140 fi
2141
2142 cat <<EOF;
2143
2144 Configuration:
2145   Libraries:
2146     libcurl . . . . . . $with_libcurl
2147     libiokit  . . . . . $with_libiokit
2148     libiptc . . . . . . $with_libiptc
2149     libkstat  . . . . . $with_kstat
2150     libkvm  . . . . . . $with_libkvm
2151     libmysql  . . . . . $with_libmysql
2152     libnetlink  . . . . $with_libnetlink
2153     libnetsnmp  . . . . $with_libnetsnmp
2154     liboconfig  . . . . $with_liboconfig
2155     liboping  . . . . . $with_liboping
2156     libpcap . . . . . . $with_libpcap
2157     libperl . . . . . . $with_libperl
2158     libpthread  . . . . $with_libpthread
2159     librrd  . . . . . . $with_rrdtool
2160     libsensors  . . . . $with_lm_sensors
2161     libstatgrab . . . . $with_libstatgrab
2162     libupsclient  . . . $with_libupsclient
2163     libvirt . . . . . . $with_libvirt
2164     libxml2 . . . . . . $with_libxml2
2165     libxmms . . . . . . $with_libxmms
2166
2167   Features:
2168     daemon mode . . . . $enable_daemon
2169     debug . . . . . . . $enable_debug
2170
2171   Bindings:
2172     perl  . . . . . . . $with_perl_bindings
2173
2174   Modules:
2175     apache  . . . . . . $enable_apache
2176     apcups  . . . . . . $enable_apcups
2177     apple_sensors . . . $enable_apple_sensors
2178     battery . . . . . . $enable_battery
2179     cpu . . . . . . . . $enable_cpu
2180     cpufreq . . . . . . $enable_cpufreq
2181     csv . . . . . . . . $enable_csv
2182     df  . . . . . . . . $enable_df
2183     disk  . . . . . . . $enable_disk
2184     dns . . . . . . . . $enable_dns
2185     email . . . . . . . $enable_email
2186     entropy . . . . . . $enable_entropy
2187     exec  . . . . . . . $enable_exec
2188     hddtemp . . . . . . $enable_hddtemp
2189     interface . . . . . $enable_interface
2190     iptables  . . . . . $enable_iptables
2191     ipvs  . . . . . . . $enable_ipvs
2192     irq . . . . . . . . $enable_irq
2193     libvirt . . . . . . $enable_libvirt
2194     load  . . . . . . . $enable_load
2195     logfile . . . . . . $enable_logfile
2196     mbmon . . . . . . . $enable_mbmon
2197     memcached . . . . . $enable_memcached
2198     memory  . . . . . . $enable_memory
2199     multimeter  . . . . $enable_multimeter
2200     mysql . . . . . . . $enable_mysql
2201     netlink . . . . . . $enable_netlink
2202     network . . . . . . $enable_network
2203     nfs . . . . . . . . $enable_nfs
2204     nginx . . . . . . . $enable_nginx
2205     ntpd  . . . . . . . $enable_ntpd
2206     nut . . . . . . . . $enable_nut
2207     perl  . . . . . . . $enable_perl
2208     ping  . . . . . . . $enable_ping
2209     processes . . . . . $enable_processes
2210     rrdtool . . . . . . $enable_rrdtool
2211     sensors . . . . . . $enable_sensors
2212     serial  . . . . . . $enable_serial
2213     snmp  . . . . . . . $enable_snmp
2214     swap  . . . . . . . $enable_swap
2215     syslog  . . . . . . $enable_syslog
2216     tape  . . . . . . . $enable_tape
2217     tcpconns  . . . . . $enable_tcpconns
2218     unixsock  . . . . . $enable_unixsock
2219     users . . . . . . . $enable_users
2220     uuid  . . . . . . . $enable_uuid
2221     vserver . . . . . . $enable_vserver
2222     wireless  . . . . . $enable_wireless
2223     xmms  . . . . . . . $enable_xmms
2224
2225 EOF