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