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