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