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