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