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