iptables plugin: Adds a plugin to collect iptables'-counters.
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, 3.11.2)
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)
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 AC_CHECK_HEADERS(netinet/udp.h, [], [],
153 [#if HAVE_STDINT_H
154 # include <stdint.h>
155 #endif
156 #if HAVE_SYS_TYPES_H
157 # include <sys/types.h>
158 #endif
159 #if HAVE_NETINET_IN_SYSTM_H
160 # include <netinet/in_systm.h>
161 #endif
162 #if HAVE_NETINET_IN_H
163 # include <netinet/in.h>
164 #endif
165 #if HAVE_NETINET_IP_H
166 # include <netinet/ip.h>
167 #endif
168 ])
169
170 # For cpu modules
171 AC_CHECK_HEADERS(sys/sysctl.h sys/dkstat.h)
172 AC_CHECK_HEADERS(mach/mach_init.h)
173 AC_CHECK_HEADERS(mach/host_priv.h)
174 AC_CHECK_HEADERS(mach/mach_error.h)
175 AC_CHECK_HEADERS(mach/mach_host.h)
176 AC_CHECK_HEADERS(mach/mach_port.h)
177 AC_CHECK_HEADERS(mach/mach_types.h)
178 AC_CHECK_HEADERS(mach/message.h)
179 AC_CHECK_HEADERS(mach/processor_set.h)
180 AC_CHECK_HEADERS(mach/processor.h)
181 AC_CHECK_HEADERS(mach/processor_info.h)
182 AC_CHECK_HEADERS(mach/task.h)
183 AC_CHECK_HEADERS(mach/thread_act.h)
184 AC_CHECK_HEADERS(mach/vm_region.h)
185 AC_CHECK_HEADERS(mach/vm_map.h)
186 AC_CHECK_HEADERS(mach/vm_prot.h)
187 AC_CHECK_HEADERS(mach/vm_statistics.h)
188 AC_CHECK_HEADERS(mach/kern_return.h)
189
190 # For hddtemp module
191 AC_CHECK_HEADERS(linux/major.h)
192
193 # For the apple_sensors module
194 AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h)
195 AC_CHECK_HEADERS(IOKit/IOKitLib.h)
196 AC_CHECK_HEADERS(IOKit/IOTypes.h)
197
198 # For the battery plugin
199 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
200 [
201 #if HAVE_IOKIT_IOKITLIB_H
202 #  include <IOKit/IOKitLib.h>
203 #endif
204 #if HAVE_IOKIT_IOTYPES_H
205 #  include <IOKit/IOTypes.h>
206 #endif
207 ])
208 AC_CHECK_HEADERS(IOKit/ps/IOPSKeys.h)
209
210 # For the `disk' plugin
211 AC_CHECK_HEADERS(IOKit/IOBSD.h)
212 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDriver.h)
213
214 # For load module
215 AC_CHECK_HEADERS(sys/loadavg.h)
216
217 # For the processes plugin
218 AC_CHECK_HEADERS(linux/config.h)
219
220 # For the swap module
221 AC_CHECK_HEADERS(sys/swap.h)
222
223 # For users module
224 AC_CHECK_HEADERS(utmp.h)
225 AC_CHECK_HEADERS(utmpx.h)
226
227 # For traffic plugin
228 AC_CHECK_HEADERS(ifaddrs.h)
229 AC_CHECK_HEADERS(net/if.h, [], [],
230 [
231 #if HAVE_SYS_TYPES_H
232 #  include <sys/types.h>
233 #endif
234 #if HAVE_SYS_SOCKET_H
235 #  include <sys/socket.h>
236 #endif
237 ])
238 AC_CHECK_HEADERS(linux/if.h, [], [],
239 [
240 #if HAVE_SYS_TYPES_H
241 #  include <sys/types.h>
242 #endif
243 #if HAVE_SYS_SOCKET_H
244 #  include <sys/socket.h>
245 #endif
246 ])
247 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
248 [
249 #if HAVE_SYS_TYPES_H
250 #  include <sys/types.h>
251 #endif
252 #if HAVE_SYS_SOCKET_H
253 #  include <sys/socket.h>
254 #endif
255 #if HAVE_LINUX_IF_H
256 # include <linux/if.h>
257 #endif
258 ])
259
260 # For apache plugin
261 AC_CHECK_HEADERS(curl/curl.h)
262
263 # For quota module
264 AC_CHECK_HEADERS(grp.h pwd.h sys/ucred.h)
265 AC_CHECK_HEADERS(ctype.h)
266 AC_CHECK_HEADERS(limits.h)
267 AC_CHECK_HEADERS(sys/quota.h)
268 AC_CHECK_HEADERS(xfs/xqm.h)
269
270 # For mount interface
271 AC_CHECK_HEADERS(fs_info.h)
272 AC_CHECK_HEADERS(fshelp.h)
273 AC_CHECK_HEADERS(paths.h)
274 AC_CHECK_HEADERS(mntent.h)
275 AC_CHECK_HEADERS(mnttab.h)
276 AC_CHECK_HEADERS(sys/fstyp.h)
277 AC_CHECK_HEADERS(sys/fs_types.h)
278 AC_CHECK_HEADERS(sys/mntent.h)
279 AC_CHECK_HEADERS(sys/mnttab.h)
280 AC_CHECK_HEADERS(sys/mount.h)
281 AC_CHECK_HEADERS(sys/statfs.h)
282 AC_CHECK_HEADERS(sys/statvfs.h)
283 AC_CHECK_HEADERS(sys/vfs.h)
284 AC_CHECK_HEADERS(sys/vfstab.h)
285
286 # For the swap plugin, FreeBSD
287 AC_CHECK_HEADERS(kvm.h)
288
289 # For the email plugin
290 AC_CHECK_HEADERS(linux/un.h, [], [],
291 [
292 #if HAVE_SYS_SOCKET_H
293 #       include <sys/socket.h>
294 #endif
295 ])
296 AC_CHECK_HEADERS(sys/un.h)
297 AC_CHECK_HEADERS(grp.h)
298
299 # For debugging interface (variable number of arguments)
300 AC_CHECK_HEADERS(stdarg.h)
301
302 # Regular expressions for the ignorelist.
303 AC_CHECK_HEADERS(regex.h)
304
305 # For the dns plugin
306 AC_CHECK_HEADERS(arpa/nameser.h arpa/nameser_compat.h)
307
308 AC_CHECK_HEADERS(net/if_arp.h)
309 AC_CHECK_HEADERS(net/if_ppp.h)
310 AC_CHECK_HEADERS(netinet/if_ether.h)
311
312 dnl Checking for libraries
313 AC_CHECK_LIB(m, ext)
314
315 #
316 # Checks for typedefs, structures, and compiler characteristics.
317 #
318 AC_C_CONST
319 AC_TYPE_PID_T
320 AC_TYPE_SIZE_T
321 AC_TYPE_UID_T
322 AC_HEADER_TIME
323
324 #
325 # Checks for library functions.
326 #
327 AC_PROG_GCC_TRADITIONAL
328 AC_CHECK_FUNCS(gettimeofday select strdup strtol)
329 AC_CHECK_FUNCS(getaddrinfo getnameinfo)
330 AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen)
331 AC_CHECK_FUNCS(strncasecmp strcasecmp)
332 AC_CHECK_FUNCS(openlog syslog closelog)
333
334 socket_needs_socket="no"
335 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
336 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
337
338 nanosleep_needs_rt="no"
339 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
340 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
341
342 # Regular expressions for the ignorelist.
343 AC_CHECK_FUNCS(regcomp regerror regexec regfree)
344
345 # For cpu module
346 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
347
348 # For df module
349 AC_CHECK_FUNCS(statfs statvfs)
350
351 # For load module
352 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
353
354 # For the `processes' plugin
355 AC_CHECK_FUNCS(thread_info)
356
357 # For users module
358 AC_CHECK_FUNCS(getutent getutxent)
359
360 # For quota module
361 AC_CHECK_FUNCS(quotactl)
362 AC_CHECK_FUNCS(getgrgid getpwuid)
363
364 # For traffic module
365 AC_CHECK_FUNCS(getifaddrs)
366
367 # For mount interface
368 #AC_CHECK_FUNCS(getfsent getvfsent)
369
370 have_getfsstat="no"
371 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
372 have_getvfsstat="no"
373 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
374 have_listmntent="no"
375 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
376
377 have_getmntent="no"
378 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
379 if test "x$have_getmntent" = "xno"; then
380         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
381 fi
382 if test "x$have_getmntent" = "xno"; then
383         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
384 fi
385 if test "x$have_getmntent" = "xno"; then
386         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
387 fi
388
389 if test "x$have_getmntent" = "xc"; then
390         AC_CACHE_CHECK([whether getmntent takes one argument],
391                 [have_one_getmntent],
392                 AC_COMPILE_IFELSE(
393                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
394 #include <mntent.h>
395 #include "$srcdir/src/utils_mount.h"]],
396                                 [[
397                                  FILE *fh;
398                                  struct mntent *me;
399                                  fh = setmntent ("/etc/mtab", "r");
400                                  me = getmntent (fh);
401                                 ]]
402                         ),
403                         [have_one_getmntent="yes"],
404                         [have_one_getmntent="no"]
405                 )
406         )
407         AC_CACHE_CHECK([whether getmntent takes two arguments],
408                 [have_two_getmntent],
409                 AC_COMPILE_IFELSE(
410                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
411 #include <sys/mnttab.h>
412 #include "$srcdir/src/utils_mount.h"]],
413                                 [[
414                                  FILE *fh;
415                                  struct mnttab mt;
416                                  int status;
417                                  fh = fopen ("/etc/mnttab", "r");
418                                  status = getmntent (fh, &mt);
419                                 ]]
420                         ),
421                         [have_two_getmntent="yes"],
422                         [have_two_getmntent="no"]
423                 )
424         )
425 fi
426
427 # Check for different versions of `getmntent' here..
428
429 if test "x$have_getmntent" = "xc"; then
430         if test "x$have_one_getmntent" = "xyes"; then
431                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
432                           [Define if the function getmntent exists and takes one argument.])
433         fi
434         if test "x$have_two_getmntent" = "xyes"; then
435                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
436                           [Define if the function getmntent exists and takes two arguments.])
437         fi
438 fi
439 if test "x$have_getmntent" = "xsun"; then
440         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
441                   [Define if the function getmntent exists. It's the version from libsun.])
442 fi
443 if test "x$have_getmntent" = "xseq"; then
444         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
445                   [Define if the function getmntent exists. It's the version from libseq.])
446 fi
447 if test "x$have_getmntent" = "xgen"; then
448         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
449                   [Define if the function getmntent exists. It's the version from libgen.])
450 fi
451
452 # Check for structures
453 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
454         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
455         [],
456         [
457         #include <sys/types.h>
458         #include <sys/socket.h>
459         #include <net/if.h>
460         ])
461 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
462         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
463         [],
464         [
465         #include <sys/types.h>
466         #include <sys/socket.h>
467         #include <linux/if.h>
468         #include <linux/netdevice.h>
469         ])
470
471 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
472 [#if HAVE_STDINT_H
473 # include <stdint.h>
474 #endif
475 #if HAVE_SYS_TYPES_H
476 # include <sys/types.h>
477 #endif
478 #if HAVE_NETINET_IN_SYSTM_H
479 # include <netinet/in_systm.h>
480 #endif
481 #if HAVE_NETINET_IN_H
482 # include <netinet/in.h>
483 #endif
484 #if HAVE_NETINET_IP_H
485 # include <netinet/ip.h>
486 #endif
487 #if HAVE_NETINET_UDP_H
488 # include <netinet/udp.h>
489 #endif
490 ])
491 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
492 [#if HAVE_STDINT_H
493 # include <stdint.h>
494 #endif
495 #if HAVE_SYS_TYPES_H
496 # include <sys/types.h>
497 #endif
498 #if HAVE_NETINET_IN_SYSTM_H
499 # include <netinet/in_systm.h>
500 #endif
501 #if HAVE_NETINET_IN_H
502 # include <netinet/in.h>
503 #endif
504 #if HAVE_NETINET_IP_H
505 # include <netinet/ip.h>
506 #endif
507 #if HAVE_NETINET_UDP_H
508 # include <netinet/udp.h>
509 #endif
510 ])
511
512 AC_MSG_CHECKING([for kernel type ($host_os)])
513 case $host_os in
514         *linux*)
515         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
516         ac_system="Linux"
517         ;;
518         *solaris*)
519         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
520         ac_system="Solaris"
521         ;;
522         *)
523         ac_system="unknown"
524 esac
525 AC_MSG_RESULT([$ac_system])
526
527 with_libresolv="yes"
528 AC_CHECK_LIB(resolv, res_search,
529 [
530         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
531 ],
532 [with_libresolv="no"])
533 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
534
535
536 m4_divert_once([HELP_WITH], [
537 collectd additional packages:])
538
539 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
540 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
541 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
542         then
543                 LDFLAGS="$LDFLAGS -L$withval/lib"
544                 CPPFLAGS="$CPPFLAGS -I$withval/include"
545                 with_rrdtool="yes"
546         fi
547 ], [with_rrdtool="yes"])
548 if test "x$with_rrdtool" = "xyes"
549 then
550         AC_CHECK_LIB(rrd, rrd_update,
551         [
552                 AC_DEFINE(HAVE_LIBRRD, 1, [Define to 1 if you have the rrd library (-lrrd).])
553         ],
554         [with_rrdtool="no (librrd not found)"], [-lm])
555 fi
556 if test "x$with_rrdtool" = "xyes"
557 then
558         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
559 fi
560 if test "x$with_rrdtool" = "xyes"
561 then
562         collect_rrdtool=1
563 else
564         collect_rrdtool=0
565 fi
566 AC_DEFINE_UNQUOTED(COLLECT_RRDTOOL, [$collect_rrdtool],
567         [Wether or not to use rrdtool library])
568 AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
569
570 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
571 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
572         then
573                 LDFLAGS="$LDFLAGS -L$withval/lib"
574                 CPPFLAGS="$CPPFLAGS -I$withval/include"
575                 with_libpthread="yes"
576         else
577                 if test "x$withval" = "xno"
578                 then
579                         with_libpthread="no (disabled)"
580                 fi
581         fi
582 ], [with_libpthread="yes"])
583 if test "x$with_libpthread" = "xyes"
584 then
585         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
586 fi
587 if test "x$with_libpthread" = "xyes"
588 then
589         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
590 fi
591 if test "x$with_libpthread" = "xyes"
592 then
593         collect_pthread=1
594 else
595         collect_pthread=0
596 fi
597 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
598         [Wether or not to use pthread (POSIX threads) library])
599 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
600
601 if test "$ac_system" = "Solaris"
602 then
603         with_kstat="yes"
604         with_devinfo="yes"
605 else
606         with_kstat="no (Solaris only)"
607         with_devinfo="no (Solaris only)"
608 fi
609
610 if test "x$with_kstat" = "xyes"
611 then
612         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
613 fi
614 if test "x$with_kstat" = "xyes"
615 then
616         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
617         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
618 fi
619 if test "x$with_kstat" = "xyes"
620 then
621         collect_kstat=1
622 else
623         collect_kstat=0
624 fi
625 AC_DEFINE_UNQUOTED(COLLECT_KSTAT, [$collect_kstat],
626         [Wether or not to use kstat library (Solaris)])
627 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
628 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
629
630 ### BEGIN of check for libcurl ###
631 with_curl_config="curl-config"
632 with_curl_prefix=0
633 with_curl_libs=""
634 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
635 [
636         if test "x$withval" != "xno" -a "x$withval" != "xyes"
637         then
638                 if test -x "$withval/bin/curl-config"
639                 then
640                         with_curl_config="$withval/bin/curl-config"
641                         with_curl_prefix=1
642                 fi
643         fi
644         if test "x$withval" = "xno"
645         then
646                 with_libcurl="no"
647         else
648                 with_libcurl="yes"
649         fi
650 ],
651 [
652         with_libcurl="yes"
653 ])
654 if test "x$with_libcurl" = "xyes"
655 then
656         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
657         curl_config_status=$?
658
659         if test $curl_config_status -ne 0
660         then
661                 with_libcurl="no"
662         else
663                 AC_CHECK_LIB(curl, curl_easy_init,
664                 [
665                         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
666                         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
667                 ],
668                 [
669                         with_libcurl="no"
670                 ],
671                 [$with_curl_libs])
672         fi
673 fi
674 if test "x$with_libcurl" = "xyes" -a $with_curl_prefix -ne 0
675 then
676         with_curl_prefix=`$with_curl_config --libs 2>/dev/null`
677         curl_config_status=$?
678
679         if test $curl_config_status -ne 0
680         then
681                 with_libcurl="no"
682         else
683                 if test -d "$with_curl_prefix/include"
684                 then
685                         CPPFLAGS="$CPPFLAGS -I$with_curl_prefix/include"
686                 fi
687         fi
688 fi
689
690 with_libcurl_numeric=0
691 if test "x$with_libcurl" = "xyes"
692 then
693         with_libcurl_numeric=1
694 fi
695 AC_DEFINE_UNQUOTED(HAVE_LIBCURL, [$with_libcurl_numeric], [Define to 1 if you have the 'curl' library (-lcurl).])
696 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
697 ### END of check for libcurl ###
698
699 with_libiokit="no"
700 collectd_libiokit=0
701 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
702 [
703         with_libiokit="yes"
704         collectd_libiokit=1
705 ], 
706 [
707         with_libiokit="no"
708         collectd_libiokit=0
709 ])
710 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
711 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
712
713 with_libstatgrab="yes"
714 with_libdevstat="no"
715 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
716 [
717         if test "x$withval" != "xno" -a "x$withval" != "xyes"
718         then
719                 LDFLAGS="$LDFLAGS -L$withval/lib"
720                 CPPFLAGS="$CPPFLAGS -I$withval/include"
721                 with_libstatgrab="yes"
722         fi
723 ],
724 [
725         if test "x$ac_system" == "xunknown"
726         then
727                 with_libstatgrab="yes"
728         else
729                 with_libstatgrab="no"
730         fi
731 ])
732 if test "x$with_libstatgrab" = "xyes"
733 then
734         AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"])
735 fi
736 if test "x$with_libstatgrab" = "xyes"
737 then
738         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
739 fi
740 if test "x$with_libstatgrab" = "xyes"
741 then
742         AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"])
743 fi
744 if test "x$with_libstatgrab" = "xyes"
745 then
746         collect_libstatgrab=1
747 else
748         collect_libstatgrab=0
749 fi
750 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
751         [Wether or not to use statgrab library])
752 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
753 AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT,  test "x$with_libdevstat"  = "xyes")
754
755 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
756 if test "x$with_libkvm" = "xyes"
757 then
758         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
759 fi
760 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
761
762 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
763 [
764         if test "x$withval" != "xno" && test "x$withval" != "xyes"
765         then
766                 LDFLAGS="$LDFLAGS -L$withval/lib"
767                 CPPFLAGS="$CPPFLAGS -I$withval/include"
768                 with_lm_sensors="yes"
769         fi
770 ],
771 [
772         if test "x$ac_system" = "xLinux"
773         then
774                 with_lm_sensors="yes"
775         else
776                 with_lm_sensors="no"
777         fi
778 ])
779 if test "x$with_lm_sensors" = "xyes"
780 then
781         AC_CHECK_LIB(sensors, sensors_init,
782         [
783                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
784         ],
785         [with_lm_sensors="no (libsensors not found)"])
786 fi
787 if test "x$with_lm_sensors" = "xyes"
788 then
789         AC_CHECK_HEADERS(sensors/sensors.h,
790         [
791                 AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
792         ],
793         [with_lm_sensors="no (sensors/sensors.h not found)"])
794 fi
795 if test "x$with_lm_sensors" = "xyes"
796 then
797         collect_lm_sensors=1
798 else
799         collect_lm_sensors=0
800 fi
801 AC_DEFINE_UNQUOTED(COLLECT_LM_SENSORS, [$collect_lm_sensors],
802         [Wether or not to use sensors library])
803 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
804
805 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
806 [
807         if test "x$withval" != "xno" && test "x$withval" != "xyes"
808         then
809                 LDFLAGS="$LDFLAGS -L$withval/lib"
810                 CPPFLAGS="$CPPFLAGS -I$withval/include"
811                 with_libmysql="yes"
812         fi
813 ],
814 [
815         with_libmysql="yes"
816 ])
817 if test "x$with_libmysql" = "xyes"
818 then
819         AC_CHECK_LIB(mysqlclient, mysql_init,
820         [
821                 AC_DEFINE(HAVE_LIBMYSQLCLIENT, 1, [Define to 1 if you have the mysqlclient library (-lmysqlclient).])
822         ], [with_libmysql="no (libmysql not found)"])
823 fi
824 if test "x$with_libmysql" = "xyes"
825 then
826         AC_CHECK_HEADERS(mysql/mysql.h,
827         [
828                 AC_DEFINE(HAVE_MYSQL_MYSQL_H, 1, [Define to 1 if you have the <mysql/mysql.h> header file.])
829         ], [with_libmysql="no (mysql/mysql.h not found)"])
830 fi
831 if test "x$with_libmysql" = "xyes"
832 then
833         collect_libmysql=1
834 else
835         collect_libmysql=0
836 fi
837 AC_DEFINE_UNQUOTED(COLLECT_LIBMYSQL, [$collect_libmysql],
838         [Wether or not to use mysql library])
839 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
840
841 #with_liboping="yes"
842 with_own_liboping="no"
843 liboping_LDFLAGS="$LDFLAGS"
844 liboping_CPPFLAGS="$CPPFLAGS"
845 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
846 [
847         if test "x$withval" != "xno" && test "x$withval" != "xyes"
848         then
849                 if test -d "$withval/lib"
850                 then
851                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
852                 fi
853                 if test -d "$withval/include"
854                 then
855                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
856                 fi
857         fi
858         if test "x$withval" = "xno"
859         then
860                 with_liboping="no"
861                 with_own_liboping="no"
862         fi
863 ],
864 [
865         #753
866         with_liboping="yes"
867 ])
868
869 if test "x$with_liboping" = "xyes"
870 then
871         save_LDFLAGS="$LDFLAGS"
872         save_CPPFLAGS="$CPPFLAGS"
873         LDFLAGS="$liboping_LDFLAGS"
874         CPPFLAGS="$liboping_CPPFLAGS"
875         AC_CHECK_LIB(oping, ping_construct,
876         [
877                 with_liboping="yes"
878                 with_own_liboping="no"
879         ],
880         [
881                 with_liboping="yes"
882                 with_own_liboping="yes"
883                 LDFLAGS="$save_LDFLAGS"
884                 CPPFLAGS="$save_CPPFLAGS"
885         ])
886 fi
887 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
888 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
889 if test "x$with_liboping" = "xyes" -a "x$with_own_liboping" = "xyes"
890 then
891         with_liboping="yes (shipped version)"
892 fi
893
894 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
895 [
896         if test "x$withval" != "xno" && test "x$withval" != "xyes"
897         then
898                 LDFLAGS="$LDFLAGS -L$withval/lib"
899                 CPPFLAGS="$CPPFLAGS -I$withval/include"
900                 with_libpcap="yes"
901         fi
902 ],
903 [
904         with_libpcap="yes"
905 ])
906 if test "x$with_libpcap" = "xyes"
907 then
908         AC_CHECK_LIB(pcap, pcap_open_live,
909         [
910                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
911         ], [with_libpcap="no (libpcap not found)"])
912 fi
913 if test "x$with_libpcap" = "xyes"
914 then
915         AC_CHECK_HEADERS(pcap.h,
916         [
917                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
918         ], [with_libpcap="no (pcap.h not found)"])
919 fi
920 if test "x$with_libpcap" = "xyes"
921 then
922         collect_libpcap=1
923 else
924         collect_libpcap=0
925 fi
926 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
927         [Wether or not to use the pcap library])
928 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
929
930 # Define `step' and `hearbeat' values..
931 declare -i collectd_step=10
932 declare -i collectd_heartbeat=25
933 AC_ARG_WITH(step, [AS_HELP_STRING([--with-step=SECONDS], [Interval in which plugins are queried.])],
934 [
935         if test "x$withval" != "xno" -a "x$withval" != "xyes"
936         then
937                 declare -i tmp_collectd_step="$withval"
938                 if test $tmp_collectd_step -gt 0
939                 then
940                         collectd_step=$tmp_collectd_step
941                         let "collectd_heartbeat=$collectd_step*2"
942                 fi
943         fi
944 ], [])
945 AC_ARG_WITH(heartbeat, [AS_HELP_STRING([--with-heartbeat=SECONDS], [Heartbeat of the DS in generated RRD files.])],
946 [
947         if test "x$withval" != "xno" -a "x$withval" != "xyes"
948         then
949                 declare -i tmp_collectd_heartbeat="$withval"
950                 if test $tmp_collectd_heartbeat -gt 0
951                 then
952                         collectd_heartbeat=$tmp_collectd_heartbeat
953                 fi
954         fi
955 ], [])
956
957 if test $collectd_step -ne 10
958 then
959         AC_DEFINE_UNQUOTED(COLLECTD_STEP, "$collectd_step", [Interval in which plugins are queried.])
960 fi
961 if test $collectd_heartbeat -ne 25
962 then
963         AC_DEFINE_UNQUOTED(COLLECTD_HEARTBEAT, "$collectd_heartbeat", [Interval in which plugins are queried.])
964 fi
965
966 # Check for enabled/disabled features
967 #
968
969 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
970 # ------------------------------------------------------------
971 dnl
972 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
973 dnl
974 AC_DEFUN(
975         [AC_COLLECTD],
976         [
977         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
978         m4_if(
979                 [$2],
980                 [enable],
981                 [dnl
982                 m4_define([EnDis],[disabled])dnl
983                 m4_define([YesNo],[no])dnl
984                 ],dnl
985                 [m4_if(
986                         [$2],
987                         [disable],
988                         [dnl
989                         m4_define([EnDis],[enabled])dnl
990                         m4_define([YesNo],[yes])dnl
991                         ],
992                         [dnl
993                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
994                         ]dnl
995                 )]dnl
996         )dnl
997         m4_if([$3], [feature], [],
998                 [m4_if(
999                         [$3], [module], [],
1000                         [dnl
1001                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
1002                         ]dnl
1003                 )]dnl
1004         )dnl
1005         AC_ARG_ENABLE(
1006                 [$1],
1007                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
1008                 [],
1009                 enable_$1='[YesNo]'dnl
1010         )# AC_ARG_ENABLE
1011 if test "x$enable_$1" = "xno"
1012 then
1013         collectd_$1=0
1014 else
1015         if test "x$enable_$1" = "xyes"
1016         then
1017                 collectd_$1=1
1018         else
1019                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
1020                 collectd_$1=1
1021                 enable_$1='yes'
1022         fi
1023 fi
1024         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
1025         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
1026         ]dnl
1027 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
1028
1029 m4_divert_once([HELP_ENABLE], [
1030 collectd features:])
1031 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
1032 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
1033 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
1034
1035 m4_divert_once([HELP_ENABLE], [
1036 collectd modules:])
1037 AC_COLLECTD([apache],    [disable], [module], [Apache httpd statistics])
1038 AC_COLLECTD([apcups],    [disable], [module], [Statistics of UPSes by APC])
1039 AC_COLLECTD([apple_sensors], [disable], [module], [Apple's hardware sensors])
1040 AC_COLLECTD([battery],   [disable], [module], [battery statistics])
1041 AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
1042 AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
1043 AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
1044 AC_COLLECTD([df],        [disable], [module], [df statistics])
1045 AC_COLLECTD([dns],       [disable], [module], [dns statistics])
1046 AC_COLLECTD([email],     [disable], [module], [email statistics])
1047 AC_COLLECTD([quota],     [enable],  [module], [quota statistics (experimental)])
1048 AC_COLLECTD([hddtemp],   [disable], [module], [hdd temperature statistics])
1049 AC_COLLECTD([iptables],  [disable], [module], [IPtables statistics])
1050 AC_COLLECTD([load],      [disable], [module], [system load statistics])
1051 AC_COLLECTD([mbmon],     [disable], [module], [motherboard monitor statistics])
1052 AC_COLLECTD([memory],    [disable], [module], [memory statistics])
1053 AC_COLLECTD([multimeter],[disable], [module], [multimeter statistics])
1054 AC_COLLECTD([mysql],     [disable], [module], [mysql statistics])
1055 AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
1056 AC_COLLECTD([ntpd],      [disable], [module], [nfs statistics])
1057 AC_COLLECTD([ping],      [disable], [module], [ping statistics])
1058 AC_COLLECTD([processes], [disable], [module], [processes statistics])
1059 AC_COLLECTD([sensors],   [disable], [module], [lm_sensors statistics])
1060 AC_COLLECTD([serial],    [disable], [module], [serial statistics])
1061 AC_COLLECTD([swap],      [disable], [module], [swap statistics])
1062 AC_COLLECTD([tape],      [disable], [module], [tape statistics])
1063 AC_COLLECTD([traffic],   [disable], [module], [system traffic statistics])
1064 AC_COLLECTD([users],     [disable], [module], [user count statistics])
1065 AC_COLLECTD([vserver],   [disable], [module], [vserver statistics])
1066 AC_COLLECTD([wireless],  [disable], [module], [wireless link statistics])
1067
1068 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libconfig/Makefile src/liboping/Makefile src/libiptc/Makefile )
1069
1070 cat <<EOF;
1071
1072 Configuration:
1073   Libraries:
1074     libcurl . . . . . . $with_libcurl
1075     libiokit  . . . . . $with_libiokit
1076     liboping  . . . . . $with_liboping
1077     librrd  . . . . . . $with_rrdtool
1078     lm_sensors  . . . . $with_lm_sensors
1079     libstatgrab . . . . $with_libstatgrab
1080     libkstat  . . . . . $with_kstat
1081     libmysql  . . . . . $with_libmysql
1082     libpcap . . . . . . $with_libpcap
1083     libpthread  . . . . $with_libpthread
1084
1085   Features:
1086     debug . . . . . . . $enable_debug
1087     daemon mode . . . . $enable_daemon
1088     step  . . . . . . . $collectd_step seconds
1089     heartbeat . . . . . $collectd_heartbeat seconds
1090
1091   Modules:
1092     apache  . . . . . . $enable_apache
1093     apcups  . . . . . . $enable_apcups
1094     apple_sensors . . . $enable_apple_sensors
1095     battery . . . . . . $enable_battery
1096     cpu . . . . . . . . $enable_cpu
1097     cpufreq . . . . . . $enable_cpufreq
1098     df  . . . . . . . . $enable_df
1099     disk  . . . . . . . $enable_disk
1100     dns . . . . . . . . $enable_dns
1101     email . . . . . . . $enable_email
1102     hddtemp . . . . . . $enable_hddtemp
1103     load  . . . . . . . $enable_load
1104     mbmon . . . . . . . $enable_mbmon
1105     memory  . . . . . . $enable_memory
1106     multimeter  . . . . $enable_multimeter
1107     mysql . . . . . . . $enable_mysql
1108     nfs . . . . . . . . $enable_nfs
1109     ntpd  . . . . . . . $enable_ntpd
1110     ping  . . . . . . . $enable_ping
1111     processes . . . . . $enable_processes
1112     sensors . . . . . . $enable_sensors
1113     serial  . . . . . . $enable_serial
1114     swap  . . . . . . . $enable_swap
1115     tape  . . . . . . . $enable_tape
1116     traffic . . . . . . $enable_traffic
1117     users . . . . . . . $enable_users
1118     vserver . . . . . . $enable_vserver
1119     wireless  . . . . . $enable_wireless
1120
1121 EOF