Changed the `traffic' plugin to generate `packets' and `errors' statistics, too.
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, 3.9.0)
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 #
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")
19
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)
29
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(netdb.h)
48 AC_CHECK_HEADERS(arpa/inet.h)
49 AC_CHECK_HEADERS(sys/resource.h)
50 AC_CHECK_HEADERS(sys/param.h)
51
52 # For ping library
53 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
54 [#if HAVE_STDINT_H
55 # include <stdint.h>
56 #endif
57 ])
58 AC_CHECK_HEADERS(netinet/in.h, [], [],
59 [#if HAVE_STDINT_H
60 # include <stdint.h>
61 #endif
62 #if HAVE_NETINET_IN_SYSTM_H
63 # include <netinet/in_systm.h>
64 #endif
65 ])
66 AC_CHECK_HEADERS(netinet/ip.h, [], [],
67 [#if HAVE_STDINT_H
68 # include <stdint.h>
69 #endif
70 #if HAVE_NETINET_IN_SYSTM_H
71 # include <netinet/in_systm.h>
72 #endif
73 #if HAVE_NETINET_IN_H
74 # include <netinet/in.h>
75 #endif
76 ])
77 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
78 [#if HAVE_STDINT_H
79 # include <stdint.h>
80 #endif
81 #if HAVE_NETINET_IN_SYSTM_H
82 # include <netinet/in_systm.h>
83 #endif
84 #if HAVE_NETINET_IN_H
85 # include <netinet/in.h>
86 #endif
87 #if HAVE_NETINET_IP_H
88 # include <netinet/ip.h>
89 #endif
90 ])
91 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
92 [#if HAVE_STDINT_H
93 # include <stdint.h>
94 #endif
95 #if HAVE_NETINET_IN_SYSTM_H
96 # include <netinet/in_systm.h>
97 #endif
98 #if HAVE_NETINET_IN_H
99 # include <netinet/in.h>
100 #endif
101 #if HAVE_NETINET_IP_H
102 # include <netinet/ip.h>
103 #endif
104 ])
105 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
106 [#if HAVE_STDINT_H
107 # include <stdint.h>
108 #endif
109 #if HAVE_SYS_TYPES_H
110 # include <sys/types.h>
111 #endif
112 #if HAVE_NETINET_IN_SYSTM_H
113 # include <netinet/in_systm.h>
114 #endif
115 #if HAVE_NETINET_IN_H
116 # include <netinet/in.h>
117 #endif
118 ])
119 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
120 [#if HAVE_STDINT_H
121 # include <stdint.h>
122 #endif
123 #if HAVE_SYS_TYPES_H
124 # include <sys/types.h>
125 #endif
126 #if HAVE_NETINET_IN_SYSTM_H
127 # include <netinet/in_systm.h>
128 #endif
129 #if HAVE_NETINET_IN_H
130 # include <netinet/in.h>
131 #endif
132 #if HAVE_NETINET_IP6_H
133 # include <netinet/ip6.h>
134 #endif
135 ])
136
137 # For cpu modules
138 AC_CHECK_HEADERS(sys/sysctl.h sys/dkstat.h)
139 AC_CHECK_HEADERS(mach/mach_init.h)
140 AC_CHECK_HEADERS(mach/host_priv.h)
141 AC_CHECK_HEADERS(mach/mach_error.h)
142 AC_CHECK_HEADERS(mach/mach_host.h)
143 AC_CHECK_HEADERS(mach/mach_port.h)
144 AC_CHECK_HEADERS(mach/mach_types.h)
145 AC_CHECK_HEADERS(mach/message.h)
146 AC_CHECK_HEADERS(mach/processor_set.h)
147 AC_CHECK_HEADERS(mach/processor.h)
148 AC_CHECK_HEADERS(mach/processor_info.h)
149 AC_CHECK_HEADERS(mach/task.h)
150 AC_CHECK_HEADERS(mach/thread_act.h)
151 AC_CHECK_HEADERS(mach/vm_region.h)
152 AC_CHECK_HEADERS(mach/vm_map.h)
153 AC_CHECK_HEADERS(mach/vm_prot.h)
154 AC_CHECK_HEADERS(mach/vm_statistics.h)
155 AC_CHECK_HEADERS(mach/kern_return.h)
156
157 # For hddtemp module
158 AC_CHECK_HEADERS(linux/major.h)
159
160 # For the apple_sensors module
161 AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h)
162 AC_CHECK_HEADERS(IOKit/IOKitLib.h)
163 AC_CHECK_HEADERS(IOKit/IOTypes.h)
164
165 # For the battery plugin
166 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
167 [
168 #if HAVE_IOKIT_IOKITLIB_H
169 #  include <IOKit/IOKitLib.h>
170 #endif
171 #if HAVE_IOKIT_IOTYPES_H
172 #  include <IOKit/IOTypes.h>
173 #endif
174 ])
175 AC_CHECK_HEADERS(IOKit/ps/IOPSKeys.h)
176
177 # For the `disk' plugin
178 AC_CHECK_HEADERS(IOKit/IOBSD.h)
179 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDriver.h)
180
181 # For load module
182 AC_CHECK_HEADERS(sys/loadavg.h)
183
184 # For the swap module
185 AC_CHECK_HEADERS(sys/swap.h)
186
187 # For users module
188 AC_CHECK_HEADERS(utmp.h)
189 AC_CHECK_HEADERS(utmpx.h)
190
191 # For traffic plugin
192 AC_CHECK_HEADERS(ifaddrs.h)
193 AC_CHECK_HEADERS(net/if.h, [], [],
194 [
195 #if HAVE_SYS_TYPES_H
196 #  include <sys/types.h>
197 #endif
198 #if HAVE_SYS_SOCKET_H
199 #  include <sys/socket.h>
200 #endif
201 ])
202 AC_CHECK_HEADERS(linux/if.h, [], [],
203 [
204 #if HAVE_SYS_TYPES_H
205 #  include <sys/types.h>
206 #endif
207 #if HAVE_SYS_SOCKET_H
208 #  include <sys/socket.h>
209 #endif
210 ])
211 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
212 [
213 #if HAVE_SYS_TYPES_H
214 #  include <sys/types.h>
215 #endif
216 #if HAVE_SYS_SOCKET_H
217 #  include <sys/socket.h>
218 #endif
219 #if HAVE_LINUX_IF_H
220 # include <linux/if.h>
221 #endif
222 ])
223
224 # For apache plugin
225 AC_CHECK_HEADERS(curl/curl.h)
226
227 # For quota module
228 AC_CHECK_HEADERS(grp.h pwd.h sys/ucred.h)
229 AC_CHECK_HEADERS(ctype.h)
230 AC_CHECK_HEADERS(limits.h)
231 AC_CHECK_HEADERS(sys/quota.h)
232 AC_CHECK_HEADERS(xfs/xqm.h)
233
234 # For mount interface
235 AC_CHECK_HEADERS(fs_info.h)
236 AC_CHECK_HEADERS(fshelp.h)
237 AC_CHECK_HEADERS(paths.h)
238 AC_CHECK_HEADERS(mntent.h)
239 AC_CHECK_HEADERS(mnttab.h)
240 AC_CHECK_HEADERS(sys/fstyp.h)
241 AC_CHECK_HEADERS(sys/fs_types.h)
242 AC_CHECK_HEADERS(sys/mntent.h)
243 AC_CHECK_HEADERS(sys/mnttab.h)
244 AC_CHECK_HEADERS(sys/mount.h)
245 AC_CHECK_HEADERS(sys/statfs.h)
246 AC_CHECK_HEADERS(sys/statvfs.h)
247 AC_CHECK_HEADERS(sys/vfs.h)
248 AC_CHECK_HEADERS(sys/vfstab.h)
249
250 # For debugging interface (variable number of arguments)
251 AC_CHECK_HEADERS(stdarg.h)
252
253 dnl Checking for libraries
254 AC_CHECK_LIB(m, ext)
255
256 #
257 # Checks for typedefs, structures, and compiler characteristics.
258 #
259 AC_C_CONST
260 AC_TYPE_PID_T
261 AC_TYPE_SIZE_T
262 AC_TYPE_UID_T
263 AC_HEADER_TIME
264
265 #
266 # Checks for library functions.
267 #
268 AC_PROG_GCC_TRADITIONAL
269 AC_CHECK_FUNCS(gettimeofday select strdup strtol)
270 AC_CHECK_FUNCS(getaddrinfo getnameinfo)
271 AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen)
272 AC_CHECK_FUNCS(strncasecmp strcasecmp)
273 AC_CHECK_FUNCS(openlog syslog closelog)
274
275 socket_needs_socket="no"
276 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
277 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
278
279 nanosleep_needs_rt="no"
280 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
281 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
282
283 # For cpu module
284 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
285
286 # For df module
287 AC_CHECK_FUNCS(statfs statvfs)
288
289 # For load module
290 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
291
292 # For the `processes' plugin
293 AC_CHECK_FUNCS(thread_info)
294
295 # For users module
296 AC_CHECK_FUNCS(getutent getutxent)
297
298 # For quota module
299 AC_CHECK_FUNCS(quotactl)
300 AC_CHECK_FUNCS(getgrgid getpwuid)
301
302 # For traffic module
303 AC_CHECK_FUNCS(getifaddrs)
304
305 # For mount interface
306 AC_CHECK_FUNCS(getfsent getvfsent listmntent)
307 AC_CHECK_FUNCS(getfsstat)
308
309 # Check for different versions of `getmntent' here..
310 AC_FUNC_GETMNTENT
311 if test "x$ac_cv_lib_sun_getmntent" = "xyes"
312 then
313         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
314                   [Define if the function getmntent exists. It's the version from libsun.])
315 fi
316 if test "x$ac_cv_lib_seq_getmntent" = "xyes"
317 then
318         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
319                   [Define if the function getmntent exists. It's the version from libseq.])
320 fi
321 if test "x$ac_cv_lib_gen_getmntent" = "xyes"
322 then
323         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
324                   [Define if the function getmntent exists. It's the version from libgen.])
325 fi
326
327 if test "x$ac_cv_func_getmntent" = "xyes"; then
328         saveCFLAGS="$CFLAGS"
329         CFLAGS="-Wall -Werror $CFLAGS"
330         AC_CACHE_CHECK([whether getmntent takes one argument],
331                 [fu_cv_getmntent1],
332                 AC_COMPILE_IFELSE(
333                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
334 #include "$srcdir/src/utils_mount.h"]],
335                                 [[(void)getmntent((FILE *)NULL);]]
336                         ),
337                         [fu_cv_getmntent1=yes],
338                         [fu_cv_getmntent1=no]
339                 )
340         )
341         if test "x$fu_cv_getmntent1" = "xno"; then
342                 AC_CACHE_CHECK([whether getmntent takes two arguments],
343                         [fu_cv_getmntent2],
344                         AC_COMPILE_IFELSE(
345                                 AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
346 #include "$srcdir/src/utils_mount.h"]],
347                                         [[(void)getmntent((FILE *)NULL,
348                                                 (struct mnttab *)NULL);]]
349                                 ),
350                                 [fu_cv_getmntent2=yes],
351                                 [fu_cv_getmntent2=no]
352                         )
353                 )
354         fi
355         CFLAGS="$saveCFLAGS"
356 fi
357 if test "x$fu_cv_getmntent1" = "xyes"; then
358         AC_DEFINE(HAVE_GETMNTENT1,
359                 1,
360                 [Define if there is a function named getmntent
361                         for reading the list of mounted filesystems, and
362                         that function takes a single argument. (4.3BSD,
363                         SunOS, HP-UX, Dynix, Irix, Linux)]
364                 )
365 fi
366 if test "x$fu_cv_getmntent2" = "xyes"; then
367         AC_DEFINE(HAVE_GETMNTENT2,
368                 1,
369                 [Define if there is a function named getmntent
370                         for reading the list of mounted filesystems, and
371                         that function takes two arguments. (SVR4)]
372                 )
373 fi
374
375 # Check for structures
376 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
377         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
378         [],
379         [
380         #include <sys/types.h>
381         #include <sys/socket.h>
382         #include <net/if.h>
383         ])
384 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
385         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
386         [],
387         [
388         #include <sys/types.h>
389         #include <sys/socket.h>
390         #include <linux/if.h>
391         #include <linux/netdevice.h>
392         ])
393
394 AC_MSG_CHECKING([for kernel type ($host_os)])
395 case $host_os in
396         *linux*)
397         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
398         ac_system="Linux"
399         ;;
400         *solaris*)
401         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
402         ac_system="Solaris"
403         ;;
404         *)
405         ac_system="unknown"
406 esac
407 AC_MSG_RESULT([$ac_system])
408
409 with_libresolv="yes"
410 AC_CHECK_LIB(resolv, res_search,
411 [
412         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
413 ],
414 [with_libresolv="no"])
415 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
416
417
418 m4_divert_once([HELP_WITH], [
419 collectd additional packages:])
420
421 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
422 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
423 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
424         then
425                 LDFLAGS="$LDFLAGS -L$withval/lib"
426                 CPPFLAGS="$CPPFLAGS -I$withval/include"
427                 with_rrdtool="yes"
428         fi
429 ], [with_rrdtool="yes"])
430 if test "x$with_rrdtool" = "xyes"
431 then
432         AC_CHECK_LIB(rrd, rrd_update,
433         [
434                 AC_DEFINE(HAVE_LIBRRD, 1, [Define to 1 if you have the rrd library (-lrrd).])
435         ],
436         [with_rrdtool="no (librrd not found)"], [-lm])
437 fi
438 if test "x$with_rrdtool" = "xyes"
439 then
440         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
441 fi
442 if test "x$with_rrdtool" = "xyes"
443 then
444         collect_rrdtool=1
445 else
446         collect_rrdtool=0
447 fi
448 AC_DEFINE_UNQUOTED(COLLECT_RRDTOOL, [$collect_rrdtool],
449         [Wether or not to use rrdtool library])
450 AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
451
452 #AC_ARG_WITH(pth, [AS_HELP_STRING([--with-pth=@<:@=PREFIX@:>@], [Path to pth (experimental).]),
453 #[      if test "x$withval" != "xno" && test "x$withval" != "xyes"
454 #       then
455 #               LDFLAGS="$LDFLAGS -L$withval/lib"
456 #               CPPFLAGS="$CPPFLAGS -I$withval/include"
457 #               with_pth="yes"
458 #       fi
459 #], [with_pth="no"])
460 #if test "x$with_pth" = "xyes"
461 #then
462 #       AC_CHECK_LIB(pth, pth_init,, [with_pth="no (libpth not found)"], [])
463 #fi
464 #if test "x$with_pth" = "xyes"
465 #then
466 #       AC_CHECK_HEADERS(pth.h,, [with_pth="no (pth.h not found)"])
467 #fi
468 #if test "x$with_pth" = "xyes"
469 #then
470 #       collect_pth=1
471 #else
472 #       collect_pth=0
473 #fi
474 #AC_DEFINE_UNQUOTED(COLLECT_PTH, [$collect_pth],
475 #       [Wether or not to use pth (portable threads) library])
476 #AM_CONDITIONAL(BUILD_WITH_PTH, test "x$with_pth" = "xyes")
477
478 if test "$ac_system" = "Solaris"
479 then
480         with_kstat="yes"
481         with_devinfo="yes"
482 else
483         with_kstat="no (Solaris only)"
484         with_devinfo="no (Solaris only)"
485 fi
486
487 if test "x$with_kstat" = "xyes"
488 then
489         AC_CHECK_LIB(kstat, kstat_open,, [with_kstat="no (libkstat not found)"])
490 fi
491 if test "x$with_kstat" = "xyes"
492 then
493         AC_CHECK_LIB(devinfo, di_init,, [with_devinfo="no (not found)"])
494         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
495 fi
496 if test "x$with_kstat" = "xyes"
497 then
498         collect_kstat=1
499 else
500         collect_kstat=0
501 fi
502 AC_DEFINE_UNQUOTED(COLLECT_KSTAT, [$collect_kstat],
503         [Wether or not to use kstat library (Solaris)])
504 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
505 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
506
507 ### BEGIN of check for libcurl ###
508 with_curl_config="curl-config"
509 with_curl_prefix=0
510 with_curl_libs=""
511 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
512 [
513         if test "x$withval" != "xno" -a "x$withval" != "xyes"
514         then
515                 if test -x "$withval/bin/curl-config"
516                 then
517                         with_curl_config="$withval/bin/curl-config"
518                         with_curl_prefix=1
519                 fi
520         fi
521         if test "x$withval" = "xno"
522         then
523                 with_libcurl="no"
524         else
525                 with_libcurl="yes"
526         fi
527 ],
528 [
529         with_libcurl="yes"
530 ])
531 if test "x$with_libcurl" = "xyes"
532 then
533         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
534         curl_config_status=$?
535
536         if test $curl_config_status -ne 0
537         then
538                 with_libcurl="no"
539         else
540                 AC_CHECK_LIB(curl, curl_easy_init,
541                 [
542                         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
543                         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
544                 ],
545                 [
546                         with_libcurl="no"
547                 ],
548                 [$with_curl_libs])
549         fi
550 fi
551 if test "x$with_libcurl" = "xyes" -a $with_curl_prefix -ne 0
552 then
553         with_curl_prefix=`$with_curl_config --libs 2>/dev/null`
554         curl_config_status=$?
555
556         if test $curl_config_status -ne 0
557         then
558                 with_libcurl="no"
559         else
560                 if test -d "$with_curl_prefix/include"
561                 then
562                         CPPFLAGS="$CPPFLAGS -I$with_curl_prefix/include"
563                 fi
564         fi
565 fi
566
567 with_libcurl_numeric=0
568 if test "x$with_libcurl" = "xyes"
569 then
570         with_libcurl_numeric=1
571 fi
572 AC_DEFINE_UNQUOTED(HAVE_LIBCURL, [$with_libcurl_numeric], [Define to 1 if you have the 'curl' library (-lcurl).])
573 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
574 ### END of check for libcurl ###
575
576 with_libiokit="no"
577 collectd_libiokit=0
578 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
579 [
580         with_libiokit="yes"
581         collectd_libiokit=1
582 ], 
583 [
584         with_libiokit="no"
585         collectd_libiokit=0
586 ])
587 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
588 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
589
590 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
591 [
592         if test "x$withval" != "xno" -a "x$withval" != "xyes"
593         then
594                 LDFLAGS="$LDFLAGS -L$withval/lib"
595                 CPPFLAGS="$CPPFLAGS -I$withval/include"
596                 with_libstatgrab="yes"
597         fi
598 ],
599 [
600         if test "x$ac_system" == "xunknown"
601         then
602                 with_libstatgrab="yes"
603         else
604                 with_libstatgrab="no"
605         fi
606 ])
607 if test "x$with_libstatgrab" = "xyes"
608 then
609         AC_CHECK_LIB(devstat, getdevs)
610         AC_CHECK_LIB(kvm, kvm_getargv)
611         AC_CHECK_LIB(statgrab, sg_init,, [with_libstatgrab="no (libstatgrab not found)"])
612 fi
613 if test "x$with_libstatgrab" = "xyes"
614 then
615         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
616 fi
617 if test "x$with_libstatgrab" = "xyes"
618 then
619         collect_libstatgrab=1
620 else
621         collect_libstatgrab=0
622 fi
623 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
624         [Wether or not to use statgrab library])
625 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
626
627 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
628 [
629         if test "x$withval" != "xno" && test "x$withval" != "xyes"
630         then
631                 LDFLAGS="$LDFLAGS -L$withval/lib"
632                 CPPFLAGS="$CPPFLAGS -I$withval/include"
633                 with_lm_sensors="yes"
634         fi
635 ],
636 [
637         if test "x$ac_system" = "xLinux"
638         then
639                 with_lm_sensors="yes"
640         else
641                 with_lm_sensors="no"
642         fi
643 ])
644 if test "x$with_lm_sensors" = "xyes"
645 then
646         AC_CHECK_LIB(sensors, sensors_init,
647         [
648                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
649         ],
650         [with_lm_sensors="no (libsensors not found)"])
651 fi
652 if test "x$with_lm_sensors" = "xyes"
653 then
654         AC_CHECK_HEADERS(sensors/sensors.h,
655         [
656                 AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
657         ],
658         [with_lm_sensors="no (sensors/sensors.h not found)"])
659 fi
660 if test "x$with_lm_sensors" = "xyes"
661 then
662         collect_lm_sensors=1
663 else
664         collect_lm_sensors=0
665 fi
666 AC_DEFINE_UNQUOTED(COLLECT_LM_SENSORS, [$collect_lm_sensors],
667         [Wether or not to use sensors library])
668 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
669
670 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
671 [
672         if test "x$withval" != "xno" && test "x$withval" != "xyes"
673         then
674                 LDFLAGS="$LDFLAGS -L$withval/lib"
675                 CPPFLAGS="$CPPFLAGS -I$withval/include"
676                 with_libmysql="yes"
677         fi
678 ],
679 [
680         with_libmysql="yes"
681 ])
682 if test "x$with_libmysql" = "xyes"
683 then
684         AC_CHECK_LIB(mysqlclient, mysql_init,
685         [
686                 AC_DEFINE(HAVE_LIBMYSQLCLIENT, 1, [Define to 1 if you have the mysqlclient library (-lmysqlclient).])
687         ], [with_libmysql="no (libmysql not found)"])
688 fi
689 if test "x$with_libmysql" = "xyes"
690 then
691         AC_CHECK_HEADERS(mysql/mysql.h,
692         [
693                 AC_DEFINE(HAVE_MYSQL_MYSQL_H, 1, [Define to 1 if you have the <mysql/mysql.h> header file.])
694         ], [with_libmysql="no (mysql/mysql.h not found)"])
695 fi
696 if test "x$with_libmysql" = "xyes"
697 then
698         collect_libmysql=1
699 else
700         collect_libmysql=0
701 fi
702 AC_DEFINE_UNQUOTED(COLLECT_LIBMYSQL, [$collect_libmysql],
703         [Wether or not to use mysql library])
704 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
705
706 # Define `step' and `hearbeat' values..
707 declare -i collectd_step=10
708 declare -i collectd_heartbeat=25
709 AC_ARG_WITH(step, [AS_HELP_STRING([--with-step=SECONDS], [Interval in which plugins are queried.])],
710 [
711         if test "x$withval" != "xno" -a "x$withval" != "xyes"
712         then
713                 declare -i tmp_collectd_step="$withval"
714                 if test $tmp_collectd_step -gt 0
715                 then
716                         collectd_step=$tmp_collectd_step
717                         let "collectd_heartbeat=$collectd_step*2"
718                 fi
719         fi
720 ], [])
721 AC_ARG_WITH(heartbeat, [AS_HELP_STRING([--with-heartbeat=SECONDS], [Heartbeat of the DS in generated RRD files.])],
722 [
723         if test "x$withval" != "xno" -a "x$withval" != "xyes"
724         then
725                 declare -i tmp_collectd_heartbeat="$withval"
726                 if test $tmp_collectd_heartbeat -gt 0
727                 then
728                         collectd_heartbeat=$tmp_collectd_heartbeat
729                 fi
730         fi
731 ], [])
732
733 if test $collectd_step -ne 10
734 then
735         AC_DEFINE_UNQUOTED(COLLECTD_STEP, "$collectd_step", [Interval in which plugins are queried.])
736 fi
737 if test $collectd_heartbeat -ne 25
738 then
739         AC_DEFINE_UNQUOTED(COLLECTD_HEARTBEAT, "$collectd_heartbeat", [Interval in which plugins are queried.])
740 fi
741
742 #
743 # Check for enabled/disabled features
744 #
745
746 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
747 # ------------------------------------------------------------
748 dnl
749 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
750 dnl
751 AC_DEFUN(
752         [AC_COLLECTD],
753         [
754         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
755         m4_if(
756                 [$2],
757                 [enable],
758                 [dnl
759                 m4_define([EnDis],[disabled])dnl
760                 m4_define([YesNo],[no])dnl
761                 ],dnl
762                 [m4_if(
763                         [$2],
764                         [disable],
765                         [dnl
766                         m4_define([EnDis],[enabled])dnl
767                         m4_define([YesNo],[yes])dnl
768                         ],
769                         [dnl
770                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
771                         ]dnl
772                 )]dnl
773         )dnl
774         m4_if([$3], [feature], [],
775                 [m4_if(
776                         [$3], [module], [],
777                         [dnl
778                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
779                         ]dnl
780                 )]dnl
781         )dnl
782         AC_ARG_ENABLE(
783                 [$1],
784                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
785                 [],
786                 enable_$1='[YesNo]'dnl
787         )# AC_ARG_ENABLE
788 if test "x$enable_$1" = "xno"
789 then
790         collectd_$1=0
791 else
792         if test "x$enable_$1" = "xyes"
793         then
794                 collectd_$1=1
795         else
796                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
797                 collectd_$1=1
798                 enable_$1='yes'
799         fi
800 fi
801         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
802         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
803         ]dnl
804 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
805
806 m4_divert_once([HELP_ENABLE], [
807 collectd features:])
808 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
809 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
810
811 m4_divert_once([HELP_ENABLE], [
812 collectd modules:])
813 AC_COLLECTD([apache],    [disable], [module], [Apache httpd statistics])
814 AC_COLLECTD([apple_sensors], [disable], [module], [Apple's hardware sensors])
815 AC_COLLECTD([battery],   [disable], [module], [battery statistics])
816 AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
817 AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
818 AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
819 AC_COLLECTD([df],        [disable], [module], [df statistics])
820 AC_COLLECTD([quota],     [enable],  [module], [quota statistics (experimental)])
821 AC_COLLECTD([hddtemp],   [disable], [module], [hdd temperature statistics])
822 AC_COLLECTD([load],      [disable], [module], [system load statistics])
823 AC_COLLECTD([memory],    [disable], [module], [memory statistics])
824 AC_COLLECTD([mysql],     [disable], [module], [mysql statistics])
825 AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
826 AC_COLLECTD([ping],      [disable], [module], [ping statistics])
827 AC_COLLECTD([processes], [disable], [module], [processes statistics])
828 AC_COLLECTD([sensors],   [disable], [module], [lm_sensors statistics])
829 AC_COLLECTD([serial],    [disable], [module], [serial statistics])
830 AC_COLLECTD([swap],      [disable], [module], [swap statistics])
831 AC_COLLECTD([tape],      [disable], [module], [tape statistics])
832 AC_COLLECTD([traffic],   [disable], [module], [system traffic statistics])
833 AC_COLLECTD([users],     [disable], [module], [user count statistics])
834 AC_COLLECTD([vserver],   [disable], [module], [vserver statistics])
835 AC_COLLECTD([wireless],  [disable], [module], [wireless link statistics])
836
837 #m4_divert_once([HELP_ENABLE], [
838 #collectd modules:])
839 #AC_ARG_ENABLE(cpu, AC_HELP_STRING([--disable-cpu], [Disable CPU usage statistics]),, [enable_cpu="yes"])
840 #if test "x$enable_cpu" != "xno"
841 #then
842 #       if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$have_sysctlbyname" = "xyes"
843 #       then
844 #               enable_cpu="yes"
845 #       else
846 #               enable_cpu="no"
847 #       fi
848 #fi
849 #if test "x$enable_cpu" = "xno"
850 #then
851 #       AC_DEFINE(COLLECT_CPU, 0, [Wether or not to collect CPU usage statistics])
852 #fi
853 #AM_CONDITIONAL(BUILD_MODULE_CPU, test "x$enable_cpu" = "xyes")
854
855 #AC_ARG_ENABLE(cpufreq, AC_HELP_STRING([--disable-cpufreq], [Disable system cpu frequency statistics]),, [enable_cpufreq="yes"])
856 #if test "x$enable_cpufreq" != "xno"
857 #then
858 #       if test "x$ac_system" = "xLinux"
859 #       then
860 #               enable_cpufreq="yes"
861 #       else
862 #               enable_cpufreq="no"
863 #       fi
864 #fi
865 #if test "x$enable_cpufreq" = "xno"
866 #then
867 #       AC_DEFINE(COLLECT_CPUFREQ, 0, [Wether or not to collect cpu frequency statistics])
868 #fi
869 #AM_CONDITIONAL(BUILD_MODULE_CPUFREQ, test "x$enable_cpufreq" = "xyes")
870
871 #AC_ARG_ENABLE(disk, AC_HELP_STRING([--disable-disk], [Disable disk/partition statistics]),, [enable_disk="yes"])
872 #if test "x$enable_disk" != "xno"
873 #then
874 #       if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes"
875 #       then
876 #               enable_disk="yes"
877 #       else
878 #               enable_disk="no"
879 #       fi
880 #fi
881 #if test "x$enable_disk" = "xno"
882 #then
883 #       AC_DEFINE(COLLECT_DISK, 0, [Wether or not to collect diskstats])
884 #fi
885 #AM_CONDITIONAL(BUILD_MODULE_DISK, test "x$enable_disk" = "xyes")
886
887 #AC_ARG_ENABLE(hddtemp, AC_HELP_STRING([--disable-hddtemp], [Disable hdd temperature statistics]),, [enable_hddtemp="yes"])
888 #if test "x$enable_hddtemp" = "xno"
889 #then
890 #       AC_DEFINE(COLLECT_HDDTEMP, 0, [Wether or not to collect hdd temperature statistics])
891 #fi
892 #AM_CONDITIONAL(BUILD_MODULE_HDDTEMP, test "x$enable_hddtemp" = "xyes")
893
894 #AC_ARG_ENABLE(load, AC_HELP_STRING([--disable-load], [Disable system load statistics]),, [enable_load="yes"])
895 #if test "x$enable_load" != "xno"
896 #then
897 #       if test "x$have_getloadavg" = "xyes" -o "x$ac_system" = "xLinux" -o "x$with_libstatgrab" = "xyes"
898 #       then
899 #               enable_load="yes"
900 #       else
901 #               enable_load="no"
902 #       fi
903 #fi
904 #if test "x$enable_load" = "xno"
905 #then
906 #       AC_DEFINE(COLLECT_LOAD, 0, [Wether or not to collect system load statistics])
907 #fi
908 #AM_CONDITIONAL(BUILD_MODULE_LOAD, test "x$enable_load" = "xyes")
909
910 #AC_ARG_ENABLE(memory, AC_HELP_STRING([--disable-memory], [Disable memory statistics]),, [enable_memory="yes"])
911 #if test "x$enable_memory" != "xno"
912 #then
913 #       if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
914 #       then
915 #               enable_memory="yes"
916 #       else
917 #               enable_memory="no"
918 #       fi
919 #fi
920 #if test "x$enable_memory" = "xno"
921 #then
922 #       AC_DEFINE(COLLECT_MEMORY, 0, [Wether or not to collect memory statistics])
923 #fi
924 #AM_CONDITIONAL(BUILD_MODULE_MEMORY, test "x$enable_memory" = "xyes")
925
926 #AC_ARG_ENABLE(nfs, AC_HELP_STRING([--disable-nfs], [Disable nfs statistics]),, [enable_nfs="yes"])
927 #if test "x$enable_nfs" != "xno"
928 #then
929 #       if test "x$ac_system" = "xLinux"
930 #       then
931 #               enable_nfs="yes"
932 #       else
933 #               enable_nfs="no"
934 #       fi
935 #fi
936 #if test "x$enable_nfs" = "xno"
937 #then
938 #       AC_DEFINE(COLLECT_NFS, 0, [Wether or not to collect nfs statistics])
939 #fi
940 #AM_CONDITIONAL(BUILD_MODULE_NFS, test "x$enable_nfs" = "xyes")
941
942 #AC_ARG_ENABLE(ping, AC_HELP_STRING([--disable-ping], [Disable ping statistics]),, [enable_ping="yes"])
943 #if test "x$enable_ping" != "xno"
944 #then
945 #       enable_ping="yes"
946 #fi
947 #if test "x$enable_ping" = "xno"
948 #then
949 #       AC_DEFINE(COLLECT_PING, 0, [Wether or not to collect ping statistics])
950 #fi
951 #AM_CONDITIONAL(BUILD_MODULE_PING, test "x$enable_ping" = "xyes")
952
953 #AC_ARG_ENABLE(processes, AC_HELP_STRING([--disable-processes], [Disable processes statistics]),, [enable_processes="yes"])
954 #if test "x$enable_processes" != "xno"
955 #then
956 #       if test "x$ac_system" = "xLinux" 
957 #       then
958 #               enable_processes="yes"
959 #       else
960 #               enable_processes="no"
961 #       fi
962 #fi
963 #if test "x$enable_processes" = "xno"
964 #then
965 #       AC_DEFINE(COLLECT_PROCESSES, 0, [Wether or not to collect processes statistics])
966 #fi
967 #AM_CONDITIONAL(BUILD_MODULE_PROCESSES, test "x$enable_processes" = "xyes")
968
969 ##AC_COLLECTD([quota],     [enable],  [module], [quota statistics (experimental)])
970
971 #AC_ARG_ENABLE(sensors, AC_HELP_STRING([--disable-sensors], [Disable lm_sensors statistics]),, [enable_sensors=$with_lm_sensors])
972 #if test "x$enable_sensors" != "xno"
973 #then
974 #       if test "x$with_lm_sensors" = "xyes"
975 #       then
976 #               enable_sensors="yes"
977 #       else
978 #               enable_sensors="no"
979 #       fi
980 #fi
981 #if test "x$enable_sensors" = "xno"
982 #then
983 #       AC_DEFINE(COLLECT_SENSORS, 0, [Wether or not to collect lm_sensors statistics])
984 #fi
985 #AM_CONDITIONAL(BUILD_MODULE_SENSORS, test "x$enable_sensors" = "xyes")
986
987 #AC_ARG_ENABLE(serial, AC_HELP_STRING([--disable-serial], [Disable serial statistics]),, [enable_serial="yes"])
988 #if test "x$enable_serial" != "xno"
989 #then
990 #       if test "x$ac_system" = "xLinux"
991 #       then
992 #               enable_serial="yes"
993 #       else
994 #               enable_serial="no"
995 #       fi
996 #fi
997 #if test "x$enable_serial" = "xno"
998 #then
999 #       AC_DEFINE(COLLECT_SERIAL, 0, [Wether or not to collect serial statistics])
1000 #fi
1001 #AM_CONDITIONAL(BUILD_MODULE_SERIAL, test "x$enable_serial" = "xyes")
1002
1003 #AC_ARG_ENABLE(swap, AC_HELP_STRING([--disable-swap], [Disable swap statistics]),, [enable_swap="yes"])
1004 #if test "x$enable_swap" != "xno"
1005 #then
1006 #       if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
1007 #       then
1008 #               enable_swap="yes"
1009 #       else
1010 #               enable_swap="no"
1011 #       fi
1012 #fi
1013 #if test "x$enable_swap" = "xno"
1014 #then
1015 #       AC_DEFINE(COLLECT_SWAP, 0, [Wether or not to collect swap statistics])
1016 #fi
1017 #AM_CONDITIONAL(BUILD_MODULE_SWAP, test "x$enable_swap" = "xyes")
1018
1019 #AC_ARG_ENABLE(tape, AC_HELP_STRING([--disable-tape], [Disable tape statistics]),, [enable_tape="yes"])
1020 #if test "x$enable_tape" != "xno"
1021 #then
1022 #       if test "x$with_kstat" = "xyes"
1023 #       then
1024 #               enable_tape="yes"
1025 #       else
1026 #               enable_tape="no"
1027 #       fi
1028 #fi
1029 #if test "x$enable_tape" = "xno"
1030 #then
1031 #       AC_DEFINE(COLLECT_TAPE, 0, [Wether or not to collect tape statistics])
1032 #fi
1033 #AM_CONDITIONAL(BUILD_MODULE_TAPE, test "x$enable_tape" = "xyes")
1034
1035 #AC_ARG_ENABLE(traffic, AC_HELP_STRING([--disable-traffic], [Disable system traffic statistics]),, [enable_traffic="yes"])
1036 #if test "x$enable_traffic" != "xno"
1037 #then
1038 #       if test "x$ac_system" = "xLinux" -o "x$with_kstat" = "xyes" -o "x$with_libstatgrab" = "xyes"
1039 #       then
1040 #               enable_traffic="yes"
1041 #       else
1042 #               enable_traffic="no"
1043 #       fi
1044 #fi
1045 #if test "x$enable_traffic" = "xno"
1046 #then
1047 #       AC_DEFINE(COLLECT_TRAFFIC, 0, [Wether or not to collect network traffic statistics])
1048 #fi
1049 #AM_CONDITIONAL(BUILD_MODULE_TRAFFIC, test "x$enable_traffic" = "xyes")
1050
1051 #AC_COLLECTD([users],     [disable], [module], [user count statistics])
1052
1053 AC_OUTPUT(Makefile src/libconfig/Makefile src/liboping/Makefile src/Makefile)
1054
1055 cat <<EOF;
1056
1057 Configuration:
1058   Libraries:
1059     libcurl . . . . . . $with_libcurl
1060     libiokit  . . . . . $with_libiokit
1061     librrd  . . . . . . $with_rrdtool
1062     lm_sensors  . . . . $with_lm_sensors
1063     libstatgrab . . . . $with_libstatgrab
1064     libkstat  . . . . . $with_kstat
1065     libmysql  . . . . . $with_libmysql
1066
1067   Features:
1068     debug . . . . . . . $enable_debug
1069     daemon mode . . . . $enable_daemon
1070     step  . . . . . . . $collectd_step seconds
1071     heartbeat . . . . . $collectd_heartbeat seconds
1072
1073   Modules:
1074     apache  . . . . . . $enable_apache
1075     apple_sensors . . . $enable_apple_sensors
1076     battery . . . . . . $enable_battery
1077     cpu . . . . . . . . $enable_cpu
1078     cpufreq . . . . . . $enable_cpufreq
1079     df  . . . . . . . . $enable_df
1080     disk  . . . . . . . $enable_disk
1081     hddtemp . . . . . . $enable_hddtemp
1082     load  . . . . . . . $enable_load
1083     memory  . . . . . . $enable_memory
1084     mysql . . . . . . . $enable_mysql
1085     nfs . . . . . . . . $enable_nfs
1086     ping  . . . . . . . $enable_ping
1087     processes . . . . . $enable_processes
1088     sensors . . . . . . $enable_sensors
1089     serial  . . . . . . $enable_serial
1090     swap  . . . . . . . $enable_swap
1091     tape  . . . . . . . $enable_tape
1092     traffic . . . . . . $enable_traffic
1093     users . . . . . . . $enable_users
1094     vserver . . . . . . $enable_vserver
1095     wireless  . . . . . $enable_wireless
1096
1097 EOF