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