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