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