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