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