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