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