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