Code

Added a call to `poll(2)' to the ntpd plugin. Also added some needed time calculation...
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, 3.9.2)
3 AC_CONFIG_SRCDIR(src/collectd.c)
4 AC_CONFIG_HEADERS(src/config.h)
5 AM_INIT_AUTOMAKE(dist-bzip2)
6 AC_LANG(C)
8 AC_PREFIX_DEFAULT("/opt/collectd")
10 #
11 # Checks for programs.
12 #
13 AC_PROG_CC
14 AC_PROG_CPP
15 AC_PROG_INSTALL
16 AC_PROG_LN_S
17 AC_PROG_MAKE_SET
18 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
20 dnl configure libtool
21 AC_DISABLE_STATIC
22 AC_LIBLTDL_CONVENIENCE
23 AC_SUBST(LTDLINCL)
24 AC_SUBST(LIBLTDL)
25 AC_LIBTOOL_DLOPEN
26 AC_PROG_LIBTOOL
27 #AC_PROG_RANLIB
28 AC_CONFIG_SUBDIRS(libltdl src/libconfig)
30 #
31 # Checks for header files.
32 #
33 AC_HEADER_STDC
34 AC_HEADER_SYS_WAIT
35 AC_HEADER_DIRENT
36 AC_CHECK_HEADERS(stdint.h)
37 AC_CHECK_HEADERS(stdio.h)
38 AC_CHECK_HEADERS(errno.h)
39 AC_CHECK_HEADERS(math.h)
40 AC_CHECK_HEADERS(syslog.h)
41 AC_CHECK_HEADERS(fcntl.h)
42 AC_CHECK_HEADERS(signal.h)
43 AC_CHECK_HEADERS(assert.h)
44 AC_CHECK_HEADERS(sys/types.h)
45 AC_CHECK_HEADERS(sys/socket.h)
46 AC_CHECK_HEADERS(sys/select.h)
47 AC_CHECK_HEADERS(sys/poll.h)
48 AC_CHECK_HEADERS(netdb.h)
49 AC_CHECK_HEADERS(arpa/inet.h)
50 AC_CHECK_HEADERS(sys/resource.h)
51 AC_CHECK_HEADERS(sys/param.h)
53 # For ping library
54 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
55 [#if HAVE_STDINT_H
56 # include <stdint.h>
57 #endif
58 ])
59 AC_CHECK_HEADERS(netinet/in.h, [], [],
60 [#if HAVE_STDINT_H
61 # include <stdint.h>
62 #endif
63 #if HAVE_NETINET_IN_SYSTM_H
64 # include <netinet/in_systm.h>
65 #endif
66 ])
67 AC_CHECK_HEADERS(netinet/ip.h, [], [],
68 [#if HAVE_STDINT_H
69 # include <stdint.h>
70 #endif
71 #if HAVE_NETINET_IN_SYSTM_H
72 # include <netinet/in_systm.h>
73 #endif
74 #if HAVE_NETINET_IN_H
75 # include <netinet/in.h>
76 #endif
77 ])
78 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
79 [#if HAVE_STDINT_H
80 # include <stdint.h>
81 #endif
82 #if HAVE_NETINET_IN_SYSTM_H
83 # include <netinet/in_systm.h>
84 #endif
85 #if HAVE_NETINET_IN_H
86 # include <netinet/in.h>
87 #endif
88 #if HAVE_NETINET_IP_H
89 # include <netinet/ip.h>
90 #endif
91 ])
92 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
93 [#if HAVE_STDINT_H
94 # include <stdint.h>
95 #endif
96 #if HAVE_NETINET_IN_SYSTM_H
97 # include <netinet/in_systm.h>
98 #endif
99 #if HAVE_NETINET_IN_H
100 # include <netinet/in.h>
101 #endif
102 #if HAVE_NETINET_IP_H
103 # include <netinet/ip.h>
104 #endif
105 ])
106 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
107 [#if HAVE_STDINT_H
108 # include <stdint.h>
109 #endif
110 #if HAVE_SYS_TYPES_H
111 # include <sys/types.h>
112 #endif
113 #if HAVE_NETINET_IN_SYSTM_H
114 # include <netinet/in_systm.h>
115 #endif
116 #if HAVE_NETINET_IN_H
117 # include <netinet/in.h>
118 #endif
119 ])
120 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
121 [#if HAVE_STDINT_H
122 # include <stdint.h>
123 #endif
124 #if HAVE_SYS_TYPES_H
125 # include <sys/types.h>
126 #endif
127 #if HAVE_NETINET_IN_SYSTM_H
128 # include <netinet/in_systm.h>
129 #endif
130 #if HAVE_NETINET_IN_H
131 # include <netinet/in.h>
132 #endif
133 #if HAVE_NETINET_IP6_H
134 # include <netinet/ip6.h>
135 #endif
136 ])
138 # For cpu modules
139 AC_CHECK_HEADERS(sys/sysctl.h sys/dkstat.h)
140 AC_CHECK_HEADERS(mach/mach_init.h)
141 AC_CHECK_HEADERS(mach/host_priv.h)
142 AC_CHECK_HEADERS(mach/mach_error.h)
143 AC_CHECK_HEADERS(mach/mach_host.h)
144 AC_CHECK_HEADERS(mach/mach_port.h)
145 AC_CHECK_HEADERS(mach/mach_types.h)
146 AC_CHECK_HEADERS(mach/message.h)
147 AC_CHECK_HEADERS(mach/processor_set.h)
148 AC_CHECK_HEADERS(mach/processor.h)
149 AC_CHECK_HEADERS(mach/processor_info.h)
150 AC_CHECK_HEADERS(mach/task.h)
151 AC_CHECK_HEADERS(mach/thread_act.h)
152 AC_CHECK_HEADERS(mach/vm_region.h)
153 AC_CHECK_HEADERS(mach/vm_map.h)
154 AC_CHECK_HEADERS(mach/vm_prot.h)
155 AC_CHECK_HEADERS(mach/vm_statistics.h)
156 AC_CHECK_HEADERS(mach/kern_return.h)
158 # For hddtemp module
159 AC_CHECK_HEADERS(linux/major.h)
161 # For the apple_sensors module
162 AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h)
163 AC_CHECK_HEADERS(IOKit/IOKitLib.h)
164 AC_CHECK_HEADERS(IOKit/IOTypes.h)
166 # For the battery plugin
167 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
169 #if HAVE_IOKIT_IOKITLIB_H
170 #  include <IOKit/IOKitLib.h>
171 #endif
172 #if HAVE_IOKIT_IOTYPES_H
173 #  include <IOKit/IOTypes.h>
174 #endif
175 ])
176 AC_CHECK_HEADERS(IOKit/ps/IOPSKeys.h)
178 # For the `disk' plugin
179 AC_CHECK_HEADERS(IOKit/IOBSD.h)
180 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDriver.h)
182 # For load module
183 AC_CHECK_HEADERS(sys/loadavg.h)
185 # For the swap module
186 AC_CHECK_HEADERS(sys/swap.h)
188 # For users module
189 AC_CHECK_HEADERS(utmp.h)
190 AC_CHECK_HEADERS(utmpx.h)
192 # For traffic plugin
193 AC_CHECK_HEADERS(ifaddrs.h)
194 AC_CHECK_HEADERS(net/if.h, [], [],
196 #if HAVE_SYS_TYPES_H
197 #  include <sys/types.h>
198 #endif
199 #if HAVE_SYS_SOCKET_H
200 #  include <sys/socket.h>
201 #endif
202 ])
203 AC_CHECK_HEADERS(linux/if.h, [], [],
205 #if HAVE_SYS_TYPES_H
206 #  include <sys/types.h>
207 #endif
208 #if HAVE_SYS_SOCKET_H
209 #  include <sys/socket.h>
210 #endif
211 ])
212 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
214 #if HAVE_SYS_TYPES_H
215 #  include <sys/types.h>
216 #endif
217 #if HAVE_SYS_SOCKET_H
218 #  include <sys/socket.h>
219 #endif
220 #if HAVE_LINUX_IF_H
221 # include <linux/if.h>
222 #endif
223 ])
225 # For apache plugin
226 AC_CHECK_HEADERS(curl/curl.h)
228 # For quota module
229 AC_CHECK_HEADERS(grp.h pwd.h sys/ucred.h)
230 AC_CHECK_HEADERS(ctype.h)
231 AC_CHECK_HEADERS(limits.h)
232 AC_CHECK_HEADERS(sys/quota.h)
233 AC_CHECK_HEADERS(xfs/xqm.h)
235 # For mount interface
236 AC_CHECK_HEADERS(fs_info.h)
237 AC_CHECK_HEADERS(fshelp.h)
238 AC_CHECK_HEADERS(paths.h)
239 AC_CHECK_HEADERS(mntent.h)
240 AC_CHECK_HEADERS(mnttab.h)
241 AC_CHECK_HEADERS(sys/fstyp.h)
242 AC_CHECK_HEADERS(sys/fs_types.h)
243 AC_CHECK_HEADERS(sys/mntent.h)
244 AC_CHECK_HEADERS(sys/mnttab.h)
245 AC_CHECK_HEADERS(sys/mount.h)
246 AC_CHECK_HEADERS(sys/statfs.h)
247 AC_CHECK_HEADERS(sys/statvfs.h)
248 AC_CHECK_HEADERS(sys/vfs.h)
249 AC_CHECK_HEADERS(sys/vfstab.h)
251 # For debugging interface (variable number of arguments)
252 AC_CHECK_HEADERS(stdarg.h)
254 dnl Checking for libraries
255 AC_CHECK_LIB(m, ext)
258 # Checks for typedefs, structures, and compiler characteristics.
260 AC_C_CONST
261 AC_TYPE_PID_T
262 AC_TYPE_SIZE_T
263 AC_TYPE_UID_T
264 AC_HEADER_TIME
267 # Checks for library functions.
269 AC_PROG_GCC_TRADITIONAL
270 AC_CHECK_FUNCS(gettimeofday select strdup strtol)
271 AC_CHECK_FUNCS(getaddrinfo getnameinfo)
272 AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen)
273 AC_CHECK_FUNCS(strncasecmp strcasecmp)
274 AC_CHECK_FUNCS(openlog syslog closelog)
276 socket_needs_socket="no"
277 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
278 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
280 nanosleep_needs_rt="no"
281 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
282 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
284 # For cpu module
285 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
287 # For df module
288 AC_CHECK_FUNCS(statfs statvfs)
290 # For load module
291 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
293 # For the `processes' plugin
294 AC_CHECK_FUNCS(thread_info)
296 # For users module
297 AC_CHECK_FUNCS(getutent getutxent)
299 # For quota module
300 AC_CHECK_FUNCS(quotactl)
301 AC_CHECK_FUNCS(getgrgid getpwuid)
303 # For traffic module
304 AC_CHECK_FUNCS(getifaddrs)
306 # For mount interface
307 AC_CHECK_FUNCS(getfsent getvfsent listmntent)
308 AC_CHECK_FUNCS(getfsstat)
310 # Check for different versions of `getmntent' here..
311 AC_FUNC_GETMNTENT
312 if test "x$ac_cv_lib_sun_getmntent" = "xyes"
313 then
314         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
315                   [Define if the function getmntent exists. It's the version from libsun.])
316 fi
317 if test "x$ac_cv_lib_seq_getmntent" = "xyes"
318 then
319         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
320                   [Define if the function getmntent exists. It's the version from libseq.])
321 fi
322 if test "x$ac_cv_lib_gen_getmntent" = "xyes"
323 then
324         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
325                   [Define if the function getmntent exists. It's the version from libgen.])
326 fi
328 if test "x$ac_cv_func_getmntent" = "xyes"; then
329         saveCFLAGS="$CFLAGS"
330         CFLAGS="-Wall -Werror $CFLAGS"
331         AC_CACHE_CHECK([whether getmntent takes one argument],
332                 [fu_cv_getmntent1],
333                 AC_COMPILE_IFELSE(
334                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
335 #include "$srcdir/src/utils_mount.h"]],
336                                 [[(void)getmntent((FILE *)NULL);]]
337                         ),
338                         [fu_cv_getmntent1=yes],
339                         [fu_cv_getmntent1=no]
340                 )
341         )
342         if test "x$fu_cv_getmntent1" = "xno"; then
343                 AC_CACHE_CHECK([whether getmntent takes two arguments],
344                         [fu_cv_getmntent2],
345                         AC_COMPILE_IFELSE(
346                                 AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
347 #include "$srcdir/src/utils_mount.h"]],
348                                         [[(void)getmntent((FILE *)NULL,
349                                                 (struct mnttab *)NULL);]]
350                                 ),
351                                 [fu_cv_getmntent2=yes],
352                                 [fu_cv_getmntent2=no]
353                         )
354                 )
355         fi
356         CFLAGS="$saveCFLAGS"
357 fi
358 if test "x$fu_cv_getmntent1" = "xyes"; then
359         AC_DEFINE(HAVE_GETMNTENT1,
360                 1,
361                 [Define if there is a function named getmntent
362                         for reading the list of mounted filesystems, and
363                         that function takes a single argument. (4.3BSD,
364                         SunOS, HP-UX, Dynix, Irix, Linux)]
365                 )
366 fi
367 if test "x$fu_cv_getmntent2" = "xyes"; then
368         AC_DEFINE(HAVE_GETMNTENT2,
369                 1,
370                 [Define if there is a function named getmntent
371                         for reading the list of mounted filesystems, and
372                         that function takes two arguments. (SVR4)]
373                 )
374 fi
376 # Check for structures
377 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
378         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
379         [],
380         [
381         #include <sys/types.h>
382         #include <sys/socket.h>
383         #include <net/if.h>
384         ])
385 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
386         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
387         [],
388         [
389         #include <sys/types.h>
390         #include <sys/socket.h>
391         #include <linux/if.h>
392         #include <linux/netdevice.h>
393         ])
395 AC_MSG_CHECKING([for kernel type ($host_os)])
396 case $host_os in
397         *linux*)
398         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
399         ac_system="Linux"
400         ;;
401         *solaris*)
402         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
403         ac_system="Solaris"
404         ;;
405         *)
406         ac_system="unknown"
407 esac
408 AC_MSG_RESULT([$ac_system])
410 with_libresolv="yes"
411 AC_CHECK_LIB(resolv, res_search,
413         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
414 ],
415 [with_libresolv="no"])
416 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
419 m4_divert_once([HELP_WITH], [
420 collectd additional packages:])
422 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
423 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
424 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
425         then
426                 LDFLAGS="$LDFLAGS -L$withval/lib"
427                 CPPFLAGS="$CPPFLAGS -I$withval/include"
428                 with_rrdtool="yes"
429         fi
430 ], [with_rrdtool="yes"])
431 if test "x$with_rrdtool" = "xyes"
432 then
433         AC_CHECK_LIB(rrd, rrd_update,
434         [
435                 AC_DEFINE(HAVE_LIBRRD, 1, [Define to 1 if you have the rrd library (-lrrd).])
436         ],
437         [with_rrdtool="no (librrd not found)"], [-lm])
438 fi
439 if test "x$with_rrdtool" = "xyes"
440 then
441         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
442 fi
443 if test "x$with_rrdtool" = "xyes"
444 then
445         collect_rrdtool=1
446 else
447         collect_rrdtool=0
448 fi
449 AC_DEFINE_UNQUOTED(COLLECT_RRDTOOL, [$collect_rrdtool],
450         [Wether or not to use rrdtool library])
451 AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
453 #AC_ARG_WITH(pth, [AS_HELP_STRING([--with-pth=@<:@=PREFIX@:>@], [Path to pth (experimental).]),
454 #[      if test "x$withval" != "xno" && test "x$withval" != "xyes"
455 #       then
456 #               LDFLAGS="$LDFLAGS -L$withval/lib"
457 #               CPPFLAGS="$CPPFLAGS -I$withval/include"
458 #               with_pth="yes"
459 #       fi
460 #], [with_pth="no"])
461 #if test "x$with_pth" = "xyes"
462 #then
463 #       AC_CHECK_LIB(pth, pth_init,, [with_pth="no (libpth not found)"], [])
464 #fi
465 #if test "x$with_pth" = "xyes"
466 #then
467 #       AC_CHECK_HEADERS(pth.h,, [with_pth="no (pth.h not found)"])
468 #fi
469 #if test "x$with_pth" = "xyes"
470 #then
471 #       collect_pth=1
472 #else
473 #       collect_pth=0
474 #fi
475 #AC_DEFINE_UNQUOTED(COLLECT_PTH, [$collect_pth],
476 #       [Wether or not to use pth (portable threads) library])
477 #AM_CONDITIONAL(BUILD_WITH_PTH, test "x$with_pth" = "xyes")
479 if test "$ac_system" = "Solaris"
480 then
481         with_kstat="yes"
482         with_devinfo="yes"
483 else
484         with_kstat="no (Solaris only)"
485         with_devinfo="no (Solaris only)"
486 fi
488 if test "x$with_kstat" = "xyes"
489 then
490         AC_CHECK_LIB(kstat, kstat_open,, [with_kstat="no (libkstat not found)"])
491 fi
492 if test "x$with_kstat" = "xyes"
493 then
494         AC_CHECK_LIB(devinfo, di_init,, [with_devinfo="no (not found)"])
495         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
496 fi
497 if test "x$with_kstat" = "xyes"
498 then
499         collect_kstat=1
500 else
501         collect_kstat=0
502 fi
503 AC_DEFINE_UNQUOTED(COLLECT_KSTAT, [$collect_kstat],
504         [Wether or not to use kstat library (Solaris)])
505 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
506 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
508 ### BEGIN of check for libcurl ###
509 with_curl_config="curl-config"
510 with_curl_prefix=0
511 with_curl_libs=""
512 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
514         if test "x$withval" != "xno" -a "x$withval" != "xyes"
515         then
516                 if test -x "$withval/bin/curl-config"
517                 then
518                         with_curl_config="$withval/bin/curl-config"
519                         with_curl_prefix=1
520                 fi
521         fi
522         if test "x$withval" = "xno"
523         then
524                 with_libcurl="no"
525         else
526                 with_libcurl="yes"
527         fi
528 ],
530         with_libcurl="yes"
531 ])
532 if test "x$with_libcurl" = "xyes"
533 then
534         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
535         curl_config_status=$?
537         if test $curl_config_status -ne 0
538         then
539                 with_libcurl="no"
540         else
541                 AC_CHECK_LIB(curl, curl_easy_init,
542                 [
543                         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
544                         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
545                 ],
546                 [
547                         with_libcurl="no"
548                 ],
549                 [$with_curl_libs])
550         fi
551 fi
552 if test "x$with_libcurl" = "xyes" -a $with_curl_prefix -ne 0
553 then
554         with_curl_prefix=`$with_curl_config --libs 2>/dev/null`
555         curl_config_status=$?
557         if test $curl_config_status -ne 0
558         then
559                 with_libcurl="no"
560         else
561                 if test -d "$with_curl_prefix/include"
562                 then
563                         CPPFLAGS="$CPPFLAGS -I$with_curl_prefix/include"
564                 fi
565         fi
566 fi
568 with_libcurl_numeric=0
569 if test "x$with_libcurl" = "xyes"
570 then
571         with_libcurl_numeric=1
572 fi
573 AC_DEFINE_UNQUOTED(HAVE_LIBCURL, [$with_libcurl_numeric], [Define to 1 if you have the 'curl' library (-lcurl).])
574 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
575 ### END of check for libcurl ###
577 with_libiokit="no"
578 collectd_libiokit=0
579 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
581         with_libiokit="yes"
582         collectd_libiokit=1
583 ], 
585         with_libiokit="no"
586         collectd_libiokit=0
587 ])
588 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
589 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
591 with_libstatgrab="yes"
592 with_libdevstat="no"
593 with_libkvm="no"
594 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
596         if test "x$withval" != "xno" -a "x$withval" != "xyes"
597         then
598                 LDFLAGS="$LDFLAGS -L$withval/lib"
599                 CPPFLAGS="$CPPFLAGS -I$withval/include"
600                 with_libstatgrab="yes"
601         fi
602 ],
604         if test "x$ac_system" == "xunknown"
605         then
606                 with_libstatgrab="yes"
607         else
608                 with_libstatgrab="no"
609         fi
610 ])
611 if test "x$with_libstatgrab" = "xyes"
612 then
613         AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"])
614 fi
615 if test "x$with_libstatgrab" = "xyes"
616 then
617         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
618 fi
619 if test "x$with_libstatgrab" = "xyes"
620 then
621         AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"])
622         AC_CHECK_LIB(kvm, kvm_getargv, [with_libkvm="yes"],     [with_libkvm="no"])
623 fi
624 if test "x$with_libstatgrab" = "xyes"
625 then
626         collect_libstatgrab=1
627 else
628         collect_libstatgrab=0
629 fi
630 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
631         [Wether or not to use statgrab library])
632 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
633 AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT,  test "x$with_libdevstat"  = "xyes")
634 AM_CONDITIONAL(BUILD_WITH_LIBKVM,      test "x$with_libkvm"      = "xyes")
636 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
638         if test "x$withval" != "xno" && test "x$withval" != "xyes"
639         then
640                 LDFLAGS="$LDFLAGS -L$withval/lib"
641                 CPPFLAGS="$CPPFLAGS -I$withval/include"
642                 with_lm_sensors="yes"
643         fi
644 ],
646         if test "x$ac_system" = "xLinux"
647         then
648                 with_lm_sensors="yes"
649         else
650                 with_lm_sensors="no"
651         fi
652 ])
653 if test "x$with_lm_sensors" = "xyes"
654 then
655         AC_CHECK_LIB(sensors, sensors_init,
656         [
657                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
658         ],
659         [with_lm_sensors="no (libsensors not found)"])
660 fi
661 if test "x$with_lm_sensors" = "xyes"
662 then
663         AC_CHECK_HEADERS(sensors/sensors.h,
664         [
665                 AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
666         ],
667         [with_lm_sensors="no (sensors/sensors.h not found)"])
668 fi
669 if test "x$with_lm_sensors" = "xyes"
670 then
671         collect_lm_sensors=1
672 else
673         collect_lm_sensors=0
674 fi
675 AC_DEFINE_UNQUOTED(COLLECT_LM_SENSORS, [$collect_lm_sensors],
676         [Wether or not to use sensors library])
677 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
679 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
681         if test "x$withval" != "xno" && test "x$withval" != "xyes"
682         then
683                 LDFLAGS="$LDFLAGS -L$withval/lib"
684                 CPPFLAGS="$CPPFLAGS -I$withval/include"
685                 with_libmysql="yes"
686         fi
687 ],
689         with_libmysql="yes"
690 ])
691 if test "x$with_libmysql" = "xyes"
692 then
693         AC_CHECK_LIB(mysqlclient, mysql_init,
694         [
695                 AC_DEFINE(HAVE_LIBMYSQLCLIENT, 1, [Define to 1 if you have the mysqlclient library (-lmysqlclient).])
696         ], [with_libmysql="no (libmysql not found)"])
697 fi
698 if test "x$with_libmysql" = "xyes"
699 then
700         AC_CHECK_HEADERS(mysql/mysql.h,
701         [
702                 AC_DEFINE(HAVE_MYSQL_MYSQL_H, 1, [Define to 1 if you have the <mysql/mysql.h> header file.])
703         ], [with_libmysql="no (mysql/mysql.h not found)"])
704 fi
705 if test "x$with_libmysql" = "xyes"
706 then
707         collect_libmysql=1
708 else
709         collect_libmysql=0
710 fi
711 AC_DEFINE_UNQUOTED(COLLECT_LIBMYSQL, [$collect_libmysql],
712         [Wether or not to use mysql library])
713 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
715 # Define `step' and `hearbeat' values..
716 declare -i collectd_step=10
717 declare -i collectd_heartbeat=25
718 AC_ARG_WITH(step, [AS_HELP_STRING([--with-step=SECONDS], [Interval in which plugins are queried.])],
720         if test "x$withval" != "xno" -a "x$withval" != "xyes"
721         then
722                 declare -i tmp_collectd_step="$withval"
723                 if test $tmp_collectd_step -gt 0
724                 then
725                         collectd_step=$tmp_collectd_step
726                         let "collectd_heartbeat=$collectd_step*2"
727                 fi
728         fi
729 ], [])
730 AC_ARG_WITH(heartbeat, [AS_HELP_STRING([--with-heartbeat=SECONDS], [Heartbeat of the DS in generated RRD files.])],
732         if test "x$withval" != "xno" -a "x$withval" != "xyes"
733         then
734                 declare -i tmp_collectd_heartbeat="$withval"
735                 if test $tmp_collectd_heartbeat -gt 0
736                 then
737                         collectd_heartbeat=$tmp_collectd_heartbeat
738                 fi
739         fi
740 ], [])
742 if test $collectd_step -ne 10
743 then
744         AC_DEFINE_UNQUOTED(COLLECTD_STEP, "$collectd_step", [Interval in which plugins are queried.])
745 fi
746 if test $collectd_heartbeat -ne 25
747 then
748         AC_DEFINE_UNQUOTED(COLLECTD_HEARTBEAT, "$collectd_heartbeat", [Interval in which plugins are queried.])
749 fi
752 # Check for enabled/disabled features
755 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
756 # ------------------------------------------------------------
757 dnl
758 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
759 dnl
760 AC_DEFUN(
761         [AC_COLLECTD],
762         [
763         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
764         m4_if(
765                 [$2],
766                 [enable],
767                 [dnl
768                 m4_define([EnDis],[disabled])dnl
769                 m4_define([YesNo],[no])dnl
770                 ],dnl
771                 [m4_if(
772                         [$2],
773                         [disable],
774                         [dnl
775                         m4_define([EnDis],[enabled])dnl
776                         m4_define([YesNo],[yes])dnl
777                         ],
778                         [dnl
779                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
780                         ]dnl
781                 )]dnl
782         )dnl
783         m4_if([$3], [feature], [],
784                 [m4_if(
785                         [$3], [module], [],
786                         [dnl
787                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
788                         ]dnl
789                 )]dnl
790         )dnl
791         AC_ARG_ENABLE(
792                 [$1],
793                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
794                 [],
795                 enable_$1='[YesNo]'dnl
796         )# AC_ARG_ENABLE
797 if test "x$enable_$1" = "xno"
798 then
799         collectd_$1=0
800 else
801         if test "x$enable_$1" = "xyes"
802         then
803                 collectd_$1=1
804         else
805                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
806                 collectd_$1=1
807                 enable_$1='yes'
808         fi
809 fi
810         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
811         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
812         ]dnl
813 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
815 m4_divert_once([HELP_ENABLE], [
816 collectd features:])
817 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
818 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
819 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
821 m4_divert_once([HELP_ENABLE], [
822 collectd modules:])
823 AC_COLLECTD([apache],    [disable], [module], [Apache httpd statistics])
824 AC_COLLECTD([apcups],    [disable], [module], [Statistics of UPSes by APC])
825 AC_COLLECTD([apple_sensors], [disable], [module], [Apple's hardware sensors])
826 AC_COLLECTD([battery],   [disable], [module], [battery statistics])
827 AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
828 AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
829 AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
830 AC_COLLECTD([df],        [disable], [module], [df statistics])
831 AC_COLLECTD([quota],     [enable],  [module], [quota statistics (experimental)])
832 AC_COLLECTD([hddtemp],   [disable], [module], [hdd temperature statistics])
833 AC_COLLECTD([load],      [disable], [module], [system load statistics])
834 AC_COLLECTD([memory],    [disable], [module], [memory statistics])
835 AC_COLLECTD([mysql],     [disable], [module], [mysql statistics])
836 AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
837 AC_COLLECTD([ntpd],      [disable], [module], [nfs statistics])
838 AC_COLLECTD([ping],      [disable], [module], [ping statistics])
839 AC_COLLECTD([processes], [disable], [module], [processes statistics])
840 AC_COLLECTD([sensors],   [disable], [module], [lm_sensors statistics])
841 AC_COLLECTD([serial],    [disable], [module], [serial statistics])
842 AC_COLLECTD([swap],      [disable], [module], [swap statistics])
843 AC_COLLECTD([tape],      [disable], [module], [tape statistics])
844 AC_COLLECTD([traffic],   [disable], [module], [system traffic statistics])
845 AC_COLLECTD([users],     [disable], [module], [user count statistics])
846 AC_COLLECTD([vserver],   [disable], [module], [vserver statistics])
847 AC_COLLECTD([wireless],  [disable], [module], [wireless link statistics])
849 AC_OUTPUT(Makefile src/libconfig/Makefile src/liboping/Makefile src/Makefile)
851 cat <<EOF;
853 Configuration:
854   Libraries:
855     libcurl . . . . . . $with_libcurl
856     libiokit  . . . . . $with_libiokit
857     librrd  . . . . . . $with_rrdtool
858     lm_sensors  . . . . $with_lm_sensors
859     libstatgrab . . . . $with_libstatgrab
860     libkstat  . . . . . $with_kstat
861     libmysql  . . . . . $with_libmysql
863   Features:
864     debug . . . . . . . $enable_debug
865     daemon mode . . . . $enable_daemon
866     step  . . . . . . . $collectd_step seconds
867     heartbeat . . . . . $collectd_heartbeat seconds
869   Modules:
870     apache  . . . . . . $enable_apache
871     apcups  . . . . . . $enable_apcups
872     apple_sensors . . . $enable_apple_sensors
873     battery . . . . . . $enable_battery
874     cpu . . . . . . . . $enable_cpu
875     cpufreq . . . . . . $enable_cpufreq
876     df  . . . . . . . . $enable_df
877     disk  . . . . . . . $enable_disk
878     hddtemp . . . . . . $enable_hddtemp
879     load  . . . . . . . $enable_load
880     memory  . . . . . . $enable_memory
881     mysql . . . . . . . $enable_mysql
882     nfs . . . . . . . . $enable_nfs
883     ntpd  . . . . . . . $enable_ntpd
884     ping  . . . . . . . $enable_ping
885     processes . . . . . $enable_processes
886     sensors . . . . . . $enable_sensors
887     serial  . . . . . . $enable_serial
888     swap  . . . . . . . $enable_swap
889     tape  . . . . . . . $enable_tape
890     traffic . . . . . . $enable_traffic
891     users . . . . . . . $enable_users
892     vserver . . . . . . $enable_vserver
893     wireless  . . . . . $enable_wireless
895 EOF