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