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