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