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