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