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