build system: Use the libs provided by `mysql_config' to check for the lib itself.
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, 4.0.6)
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 AC_SYS_LARGEFILE
11
12 #
13 # Checks for programs.
14 #
15 AC_PROG_CC
16 AC_PROG_CPP
17 AC_PROG_INSTALL
18 AC_PROG_LN_S
19 AC_PROG_MAKE_SET
20 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
21
22 dnl configure libtool
23 AC_DISABLE_STATIC
24 AC_LIBLTDL_CONVENIENCE
25 AC_SUBST(LTDLINCL)
26 AC_SUBST(LIBLTDL)
27 AC_LIBTOOL_DLOPEN
28 AC_PROG_LIBTOOL
29 AC_PROG_LEX
30 AC_PROG_YACC
31 AC_CONFIG_SUBDIRS(libltdl)
32
33 #
34 # Checks for header files.
35 #
36 AC_HEADER_STDC
37 AC_HEADER_SYS_WAIT
38 AC_HEADER_DIRENT
39 AC_CHECK_HEADERS(stdint.h)
40 AC_CHECK_HEADERS(stdio.h)
41 AC_CHECK_HEADERS(errno.h)
42 AC_CHECK_HEADERS(math.h)
43 AC_CHECK_HEADERS(syslog.h)
44 AC_CHECK_HEADERS(fcntl.h)
45 AC_CHECK_HEADERS(signal.h)
46 AC_CHECK_HEADERS(assert.h)
47 AC_CHECK_HEADERS(sys/types.h)
48 AC_CHECK_HEADERS(sys/socket.h)
49 AC_CHECK_HEADERS(sys/select.h)
50 AC_CHECK_HEADERS(poll.h)
51 AC_CHECK_HEADERS(netdb.h)
52 AC_CHECK_HEADERS(arpa/inet.h)
53 AC_CHECK_HEADERS(sys/resource.h)
54 AC_CHECK_HEADERS(sys/param.h)
55 AC_CHECK_HEADERS(kstat.h)
56
57 # For ping library
58 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
59 [#if HAVE_STDINT_H
60 # include <stdint.h>
61 #endif
62 #if HAVE_SYS_TYPES_H
63 # include <sys/types.h>
64 #endif
65 ])
66 AC_CHECK_HEADERS(netinet/in.h, [], [],
67 [#if HAVE_STDINT_H
68 # include <stdint.h>
69 #endif
70 #if HAVE_SYS_TYPES_H
71 # include <sys/types.h>
72 #endif
73 #if HAVE_NETINET_IN_SYSTM_H
74 # include <netinet/in_systm.h>
75 #endif
76 ])
77 AC_CHECK_HEADERS(netinet/ip.h, [], [],
78 [#if HAVE_STDINT_H
79 # include <stdint.h>
80 #endif
81 #if HAVE_SYS_TYPES_H
82 # include <sys/types.h>
83 #endif
84 #if HAVE_NETINET_IN_SYSTM_H
85 # include <netinet/in_systm.h>
86 #endif
87 #if HAVE_NETINET_IN_H
88 # include <netinet/in.h>
89 #endif
90 ])
91 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
92 [#if HAVE_STDINT_H
93 # include <stdint.h>
94 #endif
95 #if HAVE_SYS_TYPES_H
96 # include <sys/types.h>
97 #endif
98 #if HAVE_NETINET_IN_SYSTM_H
99 # include <netinet/in_systm.h>
100 #endif
101 #if HAVE_NETINET_IN_H
102 # include <netinet/in.h>
103 #endif
104 #if HAVE_NETINET_IP_H
105 # include <netinet/ip.h>
106 #endif
107 ])
108 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
109 [#if HAVE_STDINT_H
110 # include <stdint.h>
111 #endif
112 #if HAVE_SYS_TYPES_H
113 # include <sys/types.h>
114 #endif
115 #if HAVE_NETINET_IN_SYSTM_H
116 # include <netinet/in_systm.h>
117 #endif
118 #if HAVE_NETINET_IN_H
119 # include <netinet/in.h>
120 #endif
121 #if HAVE_NETINET_IP_H
122 # include <netinet/ip.h>
123 #endif
124 ])
125 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
126 [#if HAVE_STDINT_H
127 # include <stdint.h>
128 #endif
129 #if HAVE_SYS_TYPES_H
130 # include <sys/types.h>
131 #endif
132 #if HAVE_NETINET_IN_SYSTM_H
133 # include <netinet/in_systm.h>
134 #endif
135 #if HAVE_NETINET_IN_H
136 # include <netinet/in.h>
137 #endif
138 ])
139 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
140 [#if HAVE_STDINT_H
141 # include <stdint.h>
142 #endif
143 #if HAVE_SYS_TYPES_H
144 # include <sys/types.h>
145 #endif
146 #if HAVE_NETINET_IN_SYSTM_H
147 # include <netinet/in_systm.h>
148 #endif
149 #if HAVE_NETINET_IN_H
150 # include <netinet/in.h>
151 #endif
152 #if HAVE_NETINET_IP6_H
153 # include <netinet/ip6.h>
154 #endif
155 ])
156 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
157 [#if HAVE_STDINT_H
158 # include <stdint.h>
159 #endif
160 #if HAVE_SYS_TYPES_H
161 # include <sys/types.h>
162 #endif
163 #if HAVE_NETINET_IN_SYSTM_H
164 # include <netinet/in_systm.h>
165 #endif
166 #if HAVE_NETINET_IN_H
167 # include <netinet/in.h>
168 #endif
169 #if HAVE_NETINET_IP_H
170 # include <netinet/ip.h>
171 #endif
172 ])
173 AC_CHECK_HEADERS(netinet/udp.h, [], [],
174 [#if HAVE_STDINT_H
175 # include <stdint.h>
176 #endif
177 #if HAVE_SYS_TYPES_H
178 # include <sys/types.h>
179 #endif
180 #if HAVE_NETINET_IN_SYSTM_H
181 # include <netinet/in_systm.h>
182 #endif
183 #if HAVE_NETINET_IN_H
184 # include <netinet/in.h>
185 #endif
186 #if HAVE_NETINET_IP_H
187 # include <netinet/ip.h>
188 #endif
189 ])
190
191 # For cpu modules
192 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
193 [
194 #if HAVE_SYS_TYPES_H
195 #  include <sys/types.h>
196 #endif
197 #if HAVE_SYS_PARAM_H
198 # include <sys/param.h>
199 #endif
200 ])
201 AC_CHECK_HEADERS(sys/dkstat.h)
202 AC_CHECK_HEADERS(mach/mach_init.h)
203 AC_CHECK_HEADERS(mach/host_priv.h)
204 AC_CHECK_HEADERS(mach/mach_error.h)
205 AC_CHECK_HEADERS(mach/mach_host.h)
206 AC_CHECK_HEADERS(mach/mach_port.h)
207 AC_CHECK_HEADERS(mach/mach_types.h)
208 AC_CHECK_HEADERS(mach/message.h)
209 AC_CHECK_HEADERS(mach/processor_set.h)
210 AC_CHECK_HEADERS(mach/processor.h)
211 AC_CHECK_HEADERS(mach/processor_info.h)
212 AC_CHECK_HEADERS(mach/task.h)
213 AC_CHECK_HEADERS(mach/thread_act.h)
214 AC_CHECK_HEADERS(mach/vm_region.h)
215 AC_CHECK_HEADERS(mach/vm_map.h)
216 AC_CHECK_HEADERS(mach/vm_prot.h)
217 AC_CHECK_HEADERS(mach/vm_statistics.h)
218 AC_CHECK_HEADERS(mach/kern_return.h)
219
220 # For hddtemp module
221 AC_CHECK_HEADERS(linux/major.h)
222 AC_CHECK_HEADERS(libgen.h)
223
224 # For the apple_sensors module
225 AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h)
226 AC_CHECK_HEADERS(IOKit/IOKitLib.h)
227 AC_CHECK_HEADERS(IOKit/IOTypes.h)
228
229 # For the battery plugin
230 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
231 [
232 #if HAVE_IOKIT_IOKITLIB_H
233 #  include <IOKit/IOKitLib.h>
234 #endif
235 #if HAVE_IOKIT_IOTYPES_H
236 #  include <IOKit/IOTypes.h>
237 #endif
238 ])
239 AC_CHECK_HEADERS(IOKit/ps/IOPSKeys.h)
240
241 # For the `disk' plugin
242 AC_CHECK_HEADERS(IOKit/IOBSD.h)
243 AC_CHECK_HEADERS(IOKit/storage/IOBlockStorageDriver.h)
244
245 # For load module
246 AC_CHECK_HEADERS(sys/loadavg.h)
247
248 # For the processes plugin
249 AC_CHECK_HEADERS(linux/config.h)
250
251 # For the swap module
252 AC_CHECK_HEADERS(sys/swap.h, [], [],
253 [
254 #if HAVE_SYS_TYPES_H
255 #  include <sys/types.h>
256 #endif
257 #if HAVE_SYS_PARAM_H
258 # include <sys/param.h>
259 #endif
260 ])
261
262 # For users module
263 AC_CHECK_HEADERS(utmp.h)
264 AC_CHECK_HEADERS(utmpx.h)
265
266 # For interface plugin
267 AC_CHECK_HEADERS(ifaddrs.h)
268 AC_CHECK_HEADERS(net/if.h, [], [],
269 [
270 #if HAVE_SYS_TYPES_H
271 #  include <sys/types.h>
272 #endif
273 #if HAVE_SYS_SOCKET_H
274 #  include <sys/socket.h>
275 #endif
276 ])
277 AC_CHECK_HEADERS(linux/if.h, [], [],
278 [
279 #if HAVE_SYS_TYPES_H
280 #  include <sys/types.h>
281 #endif
282 #if HAVE_SYS_SOCKET_H
283 #  include <sys/socket.h>
284 #endif
285 ])
286 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
287 [
288 #if HAVE_SYS_TYPES_H
289 #  include <sys/types.h>
290 #endif
291 #if HAVE_SYS_SOCKET_H
292 #  include <sys/socket.h>
293 #endif
294 #if HAVE_LINUX_IF_H
295 # include <linux/if.h>
296 #endif
297 ])
298
299 # For apache plugin
300 AC_CHECK_HEADERS(curl/curl.h)
301
302 # For quota module
303 AC_CHECK_HEADERS(pwd.h)
304 AC_CHECK_HEADERS(sys/ucred.h, [], [],
305 [
306 #if HAVE_SYS_TYPES_H
307 #  include <sys/types.h>
308 #endif
309 #if HAVE_SYS_PARAM_H
310 # include <sys/param.h>
311 #endif
312 ])
313 AC_CHECK_HEADERS(ctype.h)
314 AC_CHECK_HEADERS(limits.h)
315 AC_CHECK_HEADERS(sys/quota.h)
316 AC_CHECK_HEADERS(xfs/xqm.h)
317
318 # For mount interface
319 AC_CHECK_HEADERS(fs_info.h)
320 AC_CHECK_HEADERS(fshelp.h)
321 AC_CHECK_HEADERS(paths.h)
322 AC_CHECK_HEADERS(mntent.h)
323 AC_CHECK_HEADERS(mnttab.h)
324 AC_CHECK_HEADERS(sys/fstyp.h)
325 AC_CHECK_HEADERS(sys/fs_types.h)
326 AC_CHECK_HEADERS(sys/mntent.h)
327 AC_CHECK_HEADERS(sys/mnttab.h)
328 AC_CHECK_HEADERS(sys/mount.h, [], [],
329 [
330 #if HAVE_SYS_TYPES_H
331 #  include <sys/types.h>
332 #endif
333 #if HAVE_SYS_PARAM_H
334 # include <sys/param.h>
335 #endif
336 ])
337 AC_CHECK_HEADERS(sys/statfs.h)
338 AC_CHECK_HEADERS(sys/statvfs.h)
339 AC_CHECK_HEADERS(sys/vfs.h)
340 AC_CHECK_HEADERS(sys/vfstab.h)
341
342 # For the swap plugin, FreeBSD
343 AC_CHECK_HEADERS(kvm.h)
344
345 # For the email plugin
346 AC_CHECK_HEADERS(linux/un.h, [], [],
347 [
348 #if HAVE_SYS_SOCKET_H
349 #       include <sys/socket.h>
350 #endif
351 ])
352 AC_CHECK_HEADERS(sys/un.h)
353 AC_CHECK_HEADERS(grp.h)
354
355 # For debugging interface (variable number of arguments)
356 AC_CHECK_HEADERS(stdarg.h)
357
358 # Regular expressions for the ignorelist.
359 AC_CHECK_HEADERS(regex.h)
360
361 # For the dns plugin
362 AC_CHECK_HEADERS(arpa/nameser.h)
363 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
364 [
365 #if HAVE_ARPA_NAMESER_H
366 # include <arpa/nameser.h>
367 #endif
368 ])
369
370 AC_CHECK_HEADERS(net/if_arp.h, [], [],
371 [#if HAVE_SYS_SOCKET_H
372 # include <sys/socket.h>
373 #endif
374 ])
375 AC_CHECK_HEADERS(net/ppp_defs.h)
376 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
377 [#if HAVE_NET_PPP_DEFS_H
378 # include <net/ppp_defs.h>
379 #endif
380 ])
381 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
382 [#if HAVE_STDINT_H
383 # include <stdint.h>
384 #endif
385 #if HAVE_SYS_TYPES_H
386 # include <sys/types.h>
387 #endif
388 #if HAVE_SYS_SOCKET_H
389 # include <sys/socket.h>
390 #endif
391 #if HAVE_NET_IF_H
392 # include <net/if.h>
393 #endif
394 #if HAVE_NETINET_IN_H
395 # include <netinet/in.h>
396 #endif
397 ])
398
399 # For the multimeter plugin
400 AC_CHECK_HEADERS(termios.h)
401 AC_CHECK_HEADERS(sys/ioctl.h)
402
403 #
404 # Checking for libraries
405 #
406 AC_CHECK_LIB(m, ext)
407
408 #
409 # Checks for typedefs, structures, and compiler characteristics.
410 #
411 AC_C_CONST
412 AC_TYPE_PID_T
413 AC_TYPE_SIZE_T
414 AC_TYPE_UID_T
415 AC_HEADER_TIME
416
417 #
418 # Checks for library functions.
419 #
420 AC_PROG_GCC_TRADITIONAL
421 AC_CHECK_FUNCS(gettimeofday select strdup strtol)
422 AC_CHECK_FUNCS(getaddrinfo getnameinfo)
423 AC_CHECK_FUNCS(strchr memcpy strstr strcmp strncmp strncpy strlen)
424 AC_CHECK_FUNCS(strncasecmp strcasecmp)
425 AC_CHECK_FUNCS(openlog syslog closelog)
426
427 AC_CHECK_FUNCS(getpwnam_r)
428 AC_CHECK_FUNCS(getgrnam_r)
429
430 socket_needs_socket="no"
431 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
432 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
433
434 nanosleep_needs_rt="no"
435 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
436 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
437
438 # Regular expressions for the ignorelist.
439 AC_CHECK_FUNCS(regcomp regerror regexec regfree)
440
441 # For cpu module
442 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
443
444 # For df module
445 AC_CHECK_FUNCS(statfs statvfs)
446
447 # For load module
448 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
449
450 # For the `processes' plugin
451 AC_CHECK_FUNCS(thread_info)
452
453 # For users module
454 AC_CHECK_FUNCS(getutent getutxent)
455
456 # For interface module
457 AC_CHECK_FUNCS(getifaddrs)
458
459 # Check for NAN
460 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
461 [
462  if test "x$withval" = "xno"; then
463          nan_type="none"
464  else if test "x$withval" = "xyes"; then
465          nan_type="zero"
466  else
467          nan_type="$withval"
468  fi; fi
469 ],
470 [nan_type="none"])
471 if test "x$nan_type" = "xnone"; then
472   AC_CACHE_CHECK([whether NAN is defined by default],
473     [have_nan_default],
474     AC_COMPILE_IFELSE(
475       AC_LANG_PROGRAM(
476       [[
477 #include <stdlib.h>
478 #include <math.h>
479 static float foo = NAN;
480       ]],
481       [[
482        if (isnan (foo))
483         return 0;
484        else
485         return 1;
486       ]]),
487       [have_nan_default="yes"],
488       [have_nan_default="no"]
489     )
490   )
491   if test "x$have_nan_default" = "xyes"
492   then
493     nan_type="default"
494   fi
495 fi
496 if test "x$nan_type" = "xnone"; then
497   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
498     [have_nan_isoc],
499     AC_COMPILE_IFELSE(
500       AC_LANG_PROGRAM(
501       [[
502 #include <stdlib.h>
503 #define __USE_ISOC99 1
504 #include <math.h>
505 static float foo = NAN;
506       ]],
507       [[
508        if (isnan (foo))
509         return 0;
510        else
511         return 1;
512       ]]),
513       [have_nan_isoc="yes"],
514       [have_nan_isoc="no"]
515     )
516   )
517   if test "x$have_nan_isoc" = "xyes"
518   then
519     nan_type="isoc99"
520   fi
521 fi
522 if test "x$nan_type" = "xnone"; then
523   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
524     [have_nan_zero],
525     AC_RUN_IFELSE(
526       AC_LANG_PROGRAM(
527       [[
528 #include <stdlib.h>
529 #include <math.h>
530 #ifdef NAN
531 # undef NAN
532 #endif
533 #define NAN (0.0 / 0.0)
534 #ifndef isnan
535 # define isnan(f) ((f) != (f))
536 #endif
537 static float foo = NAN;
538       ]],
539       [[
540        if (isnan (foo))
541         return 0;
542        else
543         return 1;
544       ]]),
545       [have_nan_zero="yes"],
546       [have_nan_zero="no"]
547     )
548   )
549   if test "x$have_nan_zero" = "xyes"
550   then
551     nan_type="zero"
552   fi
553 fi
554
555 if test "x$nan_type" = "xdefault"; then
556   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
557     [Define if NAN is defined by default and can initialize static variables.])
558 else if test "x$nan_type" = "xisoc99"; then
559   AC_DEFINE(NAN_STATIC_ISOC, 1,
560     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
561 else if test "x$nan_type" = "xzero"; then
562   AC_DEFINE(NAN_ZERO_ZERO, 1,
563     [Define if NAN can be defined as (0.0 / 0.0)])
564 else
565   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
566 fi; fi; fi
567
568 # For mount interface
569 #AC_CHECK_FUNCS(getfsent getvfsent)
570
571 have_getfsstat="no"
572 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
573 have_getvfsstat="no"
574 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
575 have_listmntent="no"
576 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
577
578 have_getmntent="no"
579 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
580 if test "x$have_getmntent" = "xno"; then
581         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
582 fi
583 if test "x$have_getmntent" = "xno"; then
584         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
585 fi
586 if test "x$have_getmntent" = "xno"; then
587         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
588 fi
589
590 if test "x$have_getmntent" = "xc"; then
591         AC_CACHE_CHECK([whether getmntent takes one argument],
592                 [have_one_getmntent],
593                 AC_COMPILE_IFELSE(
594                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
595 #include <mntent.h>
596 #include "$srcdir/src/utils_mount.h"]],
597                                 [[
598                                  FILE *fh;
599                                  struct mntent *me;
600                                  fh = setmntent ("/etc/mtab", "r");
601                                  me = getmntent (fh);
602                                 ]]
603                         ),
604                         [have_one_getmntent="yes"],
605                         [have_one_getmntent="no"]
606                 )
607         )
608         AC_CACHE_CHECK([whether getmntent takes two arguments],
609                 [have_two_getmntent],
610                 AC_COMPILE_IFELSE(
611                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
612 #include <sys/mnttab.h>
613 #include "$srcdir/src/utils_mount.h"]],
614                                 [[
615                                  FILE *fh;
616                                  struct mnttab mt;
617                                  int status;
618                                  fh = fopen ("/etc/mnttab", "r");
619                                  status = getmntent (fh, &mt);
620                                 ]]
621                         ),
622                         [have_two_getmntent="yes"],
623                         [have_two_getmntent="no"]
624                 )
625         )
626 fi
627
628 # Check for different versions of `getmntent' here..
629
630 if test "x$have_getmntent" = "xc"; then
631         if test "x$have_one_getmntent" = "xyes"; then
632                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
633                           [Define if the function getmntent exists and takes one argument.])
634         fi
635         if test "x$have_two_getmntent" = "xyes"; then
636                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
637                           [Define if the function getmntent exists and takes two arguments.])
638         fi
639 fi
640 if test "x$have_getmntent" = "xsun"; then
641         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
642                   [Define if the function getmntent exists. It's the version from libsun.])
643 fi
644 if test "x$have_getmntent" = "xseq"; then
645         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
646                   [Define if the function getmntent exists. It's the version from libseq.])
647 fi
648 if test "x$have_getmntent" = "xgen"; then
649         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
650                   [Define if the function getmntent exists. It's the version from libgen.])
651 fi
652
653 # Check for structures
654 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
655         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
656         [],
657         [
658         #include <sys/types.h>
659         #include <sys/socket.h>
660         #include <net/if.h>
661         ])
662 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
663         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
664         [],
665         [
666         #include <sys/types.h>
667         #include <sys/socket.h>
668         #include <linux/if.h>
669         #include <linux/netdevice.h>
670         ])
671
672 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
673 [#if HAVE_STDINT_H
674 # include <stdint.h>
675 #endif
676 #if HAVE_SYS_TYPES_H
677 # include <sys/types.h>
678 #endif
679 #if HAVE_NETINET_IN_SYSTM_H
680 # include <netinet/in_systm.h>
681 #endif
682 #if HAVE_NETINET_IN_H
683 # include <netinet/in.h>
684 #endif
685 #if HAVE_NETINET_IP_H
686 # include <netinet/ip.h>
687 #endif
688 #if HAVE_NETINET_UDP_H
689 # include <netinet/udp.h>
690 #endif
691 ])
692 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
693 [#if HAVE_STDINT_H
694 # include <stdint.h>
695 #endif
696 #if HAVE_SYS_TYPES_H
697 # include <sys/types.h>
698 #endif
699 #if HAVE_NETINET_IN_SYSTM_H
700 # include <netinet/in_systm.h>
701 #endif
702 #if HAVE_NETINET_IN_H
703 # include <netinet/in.h>
704 #endif
705 #if HAVE_NETINET_IP_H
706 # include <netinet/ip.h>
707 #endif
708 #if HAVE_NETINET_UDP_H
709 # include <netinet/udp.h>
710 #endif
711 ])
712
713 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
714         [],
715         [],
716         [
717 #if HAVE_KSTAT_H
718 # include <kstat.h>
719 #endif
720         ])
721
722 AC_MSG_CHECKING([for kernel type ($host_os)])
723 case $host_os in
724         *linux*)
725         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
726         ac_system="Linux"
727         ;;
728         *solaris*)
729         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
730         ac_system="Solaris"
731         ;;
732         *)
733         ac_system="unknown"
734 esac
735 AC_MSG_RESULT([$ac_system])
736
737 with_libresolv="yes"
738 AC_CHECK_LIB(resolv, res_search,
739 [
740         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
741 ],
742 [with_libresolv="no"])
743 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
744
745
746 m4_divert_once([HELP_WITH], [
747 collectd additional packages:])
748
749 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
750 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
751 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
752         then
753                 LDFLAGS="$LDFLAGS -L$withval/lib"
754                 CPPFLAGS="$CPPFLAGS -I$withval/include"
755                 with_rrdtool="yes"
756         fi
757 ], [with_rrdtool="yes"])
758 if test "x$with_rrdtool" = "xyes"
759 then
760         AC_CHECK_LIB(rrd, rrd_update,
761         [
762                 AC_DEFINE(HAVE_LIBRRD, 1, [Define to 1 if you have the rrd library (-lrrd).])
763         ],
764         [with_rrdtool="no (librrd not found)"], [-lm])
765 fi
766 if test "x$with_rrdtool" = "xyes"
767 then
768         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
769 fi
770 if test "x$with_rrdtool" = "xyes"
771 then
772         collect_rrdtool=1
773 else
774         collect_rrdtool=0
775 fi
776 AC_DEFINE_UNQUOTED(COLLECT_RRDTOOL, [$collect_rrdtool],
777         [Wether or not to use rrdtool library])
778 AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
779
780 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
781 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
782         then
783                 LDFLAGS="$LDFLAGS -L$withval/lib"
784                 CPPFLAGS="$CPPFLAGS -I$withval/include"
785                 with_libpthread="yes"
786         else
787                 if test "x$withval" = "xno"
788                 then
789                         with_libpthread="no (disabled)"
790                 fi
791         fi
792 ], [with_libpthread="yes"])
793 if test "x$with_libpthread" = "xyes"
794 then
795         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
796 fi
797 if test "x$with_libpthread" = "xyes"
798 then
799         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
800 fi
801 if test "x$with_libpthread" = "xyes"
802 then
803         collect_pthread=1
804 else
805         collect_pthread=0
806 fi
807 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
808         [Wether or not to use pthread (POSIX threads) library])
809 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
810
811 if test "$ac_system" = "Solaris"
812 then
813         with_kstat="yes"
814         with_devinfo="yes"
815 else
816         with_kstat="no (Solaris only)"
817         with_devinfo="no (Solaris only)"
818 fi
819
820 if test "x$with_kstat" = "xyes"
821 then
822         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
823 fi
824 if test "x$with_kstat" = "xyes"
825 then
826         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
827         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
828 fi
829 if test "x$with_kstat" = "xyes"
830 then
831         AC_DEFINE(HAVE_LIBKSTAT, 1,
832                   [Define to 1 if you have the 'kstat' library (-lkstat)])
833 fi
834 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
835 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
836
837 ### BEGIN of check for libcurl ###
838 with_curl_config="curl-config"
839 with_curl_prefix=0
840 with_curl_libs=""
841 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
842 [
843         if test "x$withval" != "xno" -a "x$withval" != "xyes"
844         then
845                 if test -x "$withval/bin/curl-config"
846                 then
847                         with_curl_config="$withval/bin/curl-config"
848                         with_curl_prefix=1
849                 fi
850         fi
851         if test "x$withval" = "xno"
852         then
853                 with_libcurl="no"
854         else
855                 with_libcurl="yes"
856         fi
857 ],
858 [
859         with_libcurl="yes"
860 ])
861 if test "x$with_libcurl" = "xyes"
862 then
863         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
864         curl_config_status=$?
865
866         if test $curl_config_status -ne 0
867         then
868                 with_libcurl="no"
869         else
870                 AC_CHECK_LIB(curl, curl_easy_init,
871                 [
872                         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
873                         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
874                 ],
875                 [
876                         with_libcurl="no"
877                 ],
878                 [$with_curl_libs])
879         fi
880 fi
881 if test "x$with_libcurl" = "xyes" -a $with_curl_prefix -ne 0
882 then
883         with_curl_prefix=`$with_curl_config --libs 2>/dev/null`
884         curl_config_status=$?
885
886         if test $curl_config_status -ne 0
887         then
888                 with_libcurl="no"
889         else
890                 if test -d "$with_curl_prefix/include"
891                 then
892                         CPPFLAGS="$CPPFLAGS -I$with_curl_prefix/include"
893                 fi
894         fi
895 fi
896
897 with_libcurl_numeric=0
898 if test "x$with_libcurl" = "xyes"
899 then
900         with_libcurl_numeric=1
901 fi
902 AC_DEFINE_UNQUOTED(HAVE_LIBCURL, [$with_libcurl_numeric], [Define to 1 if you have the 'curl' library (-lcurl).])
903 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
904 ### END of check for libcurl ###
905
906 with_libiokit="no"
907 collectd_libiokit=0
908 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
909 [
910         with_libiokit="yes"
911         collectd_libiokit=1
912 ], 
913 [
914         with_libiokit="no"
915         collectd_libiokit=0
916 ])
917 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
918 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
919
920 with_libstatgrab="yes"
921 with_libdevstat="no"
922 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
923 [
924         if test "x$withval" != "xno" -a "x$withval" != "xyes"
925         then
926                 LDFLAGS="$LDFLAGS -L$withval/lib"
927                 CPPFLAGS="$CPPFLAGS -I$withval/include"
928                 with_libstatgrab="yes"
929         fi
930 ],
931 [
932         if test "x$ac_system" == "xunknown"
933         then
934                 with_libstatgrab="yes"
935         else
936                 with_libstatgrab="no"
937         fi
938 ])
939 if test "x$with_libstatgrab" = "xyes"
940 then
941         AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"])
942 fi
943 if test "x$with_libstatgrab" = "xyes"
944 then
945         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
946 fi
947 if test "x$with_libstatgrab" = "xyes"
948 then
949         AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"])
950 fi
951 if test "x$with_libstatgrab" = "xyes"
952 then
953         collect_libstatgrab=1
954 else
955         collect_libstatgrab=0
956 fi
957 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
958         [Wether or not to use statgrab library])
959 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
960 AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT,  test "x$with_libdevstat"  = "xyes")
961
962 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
963 if test "x$with_libkvm" = "xyes"
964 then
965         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
966 fi
967 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
968
969 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
970 [
971         if test "x$withval" != "xno" && test "x$withval" != "xyes"
972         then
973                 LDFLAGS="$LDFLAGS -L$withval/lib"
974                 CPPFLAGS="$CPPFLAGS -I$withval/include"
975                 with_lm_sensors="yes"
976         fi
977 ],
978 [
979         if test "x$ac_system" = "xLinux"
980         then
981                 with_lm_sensors="yes"
982         else
983                 with_lm_sensors="no"
984         fi
985 ])
986 if test "x$with_lm_sensors" = "xyes"
987 then
988         AC_CHECK_LIB(sensors, sensors_init,
989         [
990                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
991         ],
992         [with_lm_sensors="no (libsensors not found)"])
993 fi
994 if test "x$with_lm_sensors" = "xyes"
995 then
996         AC_CHECK_HEADERS(sensors/sensors.h,
997         [
998                 AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
999         ],
1000         [with_lm_sensors="no (sensors/sensors.h not found)"])
1001 fi
1002 if test "x$with_lm_sensors" = "xyes"
1003 then
1004         collect_lm_sensors=1
1005 else
1006         collect_lm_sensors=0
1007 fi
1008 AC_DEFINE_UNQUOTED(COLLECT_LM_SENSORS, [$collect_lm_sensors],
1009         [Wether or not to use sensors library])
1010 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
1011
1012 with_mysql_config="mysql_config"
1013 with_mysql_prefix=0
1014 with_mysql_cflags=""
1015 with_mysql_libs=""
1016 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1017 [
1018         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1019         then
1020                 if test -x "$withval/bin/mysql_config"
1021                 then
1022                         with_mysql_config="$withval/bin/mysql_config"
1023                         with_mysql_prefix=1
1024                 fi
1025         fi
1026         if test "x$withval" = "xno"
1027         then
1028                 with_libmysql="no"
1029         else
1030                 with_libmysql="yes"
1031         fi
1032 ],
1033 [
1034         with_libmysql="yes"
1035 ])
1036 if test "x$with_libmysql" = "xyes"
1037 then
1038         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1039         mysql_config_status=$?
1040
1041         if test $mysql_config_status -ne 0
1042         then
1043                 with_libmysql="no"
1044         else
1045                 SAVE_CFLAGS=$CFLAGS
1046                 CFLAGS="$CFLAGS $with_mysql_cflags"
1047
1048                 AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
1049
1050                 CFLAGS="$SAVE_CFLAGS"
1051         fi
1052 fi
1053 if test "x$with_libmysql" = "xyes"
1054 then
1055         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1056         AC_CHECK_LIB(mysqlclient, mysql_init,
1057         [
1058                 AC_DEFINE(HAVE_LIBMYSQLCLIENT, 1,
1059                           [Define to 1 if you have the mysqlclient library (-lmysqlclient).])
1060         ],
1061         [
1062                 with_libmysql="no (libmysql not found)"
1063         ],
1064         [$with_mysql_libs])
1065 fi
1066 if test "x$with_libmysql" = "xyes"
1067 then
1068         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1069         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1070         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1071         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1072 fi
1073 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1074
1075 with_own_liboconfig="no"
1076 liboconfig_LDFLAGS="$LDFLAGS"
1077 liboconfig_CPPFLAGS="$CPPFLAGS"
1078 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1079 [
1080         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1081         then
1082                 if test -d "$withval/lib"
1083                 then
1084                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1085                 fi
1086                 if test -d "$withval/include"
1087                 then
1088                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1089                 fi
1090         fi
1091         if test "x$withval" = "xno"
1092         then
1093                 AC_MSG_ERROR("liboconfig is required")
1094         fi
1095 ],
1096 [
1097         with_liboconfig="yes"
1098 ])
1099
1100 save_LDFLAGS="$LDFLAGS"
1101 save_CPPFLAGS="$CPPFLAGS"
1102 LDFLAGS="$liboconfig_LDFLAGS"
1103 CPPFLAGS="$liboconfig_CPPFLAGS"
1104 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1105 [
1106         with_liboconfig="yes"
1107         with_own_liboconfig="no"
1108 ],
1109 [
1110         with_liboconfig="yes"
1111         with_own_liboconfig="yes"
1112         LDFLAGS="$save_LDFLAGS"
1113         CPPFLAGS="$save_CPPFLAGS"
1114 ])
1115
1116 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1117 if test "x$with_own_liboconfig" = "xyes"
1118 then
1119         with_liboconfig="yes (shipped version)"
1120 fi
1121
1122 #with_liboping="yes"
1123 with_own_liboping="no"
1124 liboping_LDFLAGS="$LDFLAGS"
1125 liboping_CPPFLAGS="$CPPFLAGS"
1126 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1127 [
1128         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1129         then
1130                 if test -d "$withval/lib"
1131                 then
1132                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1133                 fi
1134                 if test -d "$withval/include"
1135                 then
1136                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1137                 fi
1138         fi
1139         if test "x$withval" = "xno"
1140         then
1141                 with_liboping="no"
1142                 with_own_liboping="no"
1143         fi
1144 ],
1145 [
1146         #753
1147         with_liboping="yes"
1148 ])
1149
1150 if test "x$with_liboping" = "xyes"
1151 then
1152         save_LDFLAGS="$LDFLAGS"
1153         save_CPPFLAGS="$CPPFLAGS"
1154         LDFLAGS="$liboping_LDFLAGS"
1155         CPPFLAGS="$liboping_CPPFLAGS"
1156         AC_CHECK_LIB(oping, ping_construct,
1157         [
1158                 with_liboping="yes"
1159                 with_own_liboping="no"
1160         ],
1161         [
1162                 with_liboping="yes"
1163                 with_own_liboping="yes"
1164                 LDFLAGS="$save_LDFLAGS"
1165                 CPPFLAGS="$save_CPPFLAGS"
1166         ])
1167 fi
1168 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1169 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1170 if test "x$with_liboping" = "xyes" -a "x$with_own_liboping" = "xyes"
1171 then
1172         with_liboping="yes (shipped version)"
1173 fi
1174
1175 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1176 [
1177         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1178         then
1179                 LDFLAGS="$LDFLAGS -L$withval/lib"
1180                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1181                 with_libpcap="yes"
1182         fi
1183 ],
1184 [
1185         with_libpcap="yes"
1186 ])
1187 if test "x$with_libpcap" = "xyes"
1188 then
1189         AC_CHECK_LIB(pcap, pcap_open_live,
1190         [
1191                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1192         ], [with_libpcap="no (libpcap not found)"])
1193 fi
1194 if test "x$with_libpcap" = "xyes"
1195 then
1196         AC_CHECK_HEADERS(pcap.h,
1197         [
1198                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1199         ], [with_libpcap="no (pcap.h not found)"])
1200 fi
1201 if test "x$with_libpcap" = "xyes"
1202 then
1203         collect_libpcap=1
1204 else
1205         collect_libpcap=0
1206 fi
1207 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1208         [Wether or not to use the pcap library])
1209 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1210
1211 perl_interpreter="perl"
1212 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1213 [
1214         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1215         then
1216                 LDFLAGS="$LDFLAGS -L$withval/lib"
1217                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1218                 perl_interpreter="$withval/bin/perl"
1219                 with_libperl="yes"
1220         fi
1221 ],
1222 [
1223         with_libperl="yes"
1224 ])
1225 if test "x$with_libperl" = "xyes"
1226 then
1227   SAVE_CFLAGS=$CFLAGS
1228   SAVE_LDFLAGS=$LDFLAGS
1229   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1230   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1231   CFLAGS="$CFLAGS $PERL_CFLAGS"
1232   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1233
1234   AC_CACHE_CHECK([for libperl],
1235     [have_libperl],
1236     AC_LINK_IFELSE(
1237       AC_LANG_PROGRAM(
1238       [[
1239 #include <EXTERN.h>
1240 #include <perl.h>
1241 #include <XSUB.h>
1242       ]],
1243       [[
1244        PerlInterpreter *perl = NULL;
1245        Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
1246                          newSVpv ("Collectd::Plugin::FooBar", 24),
1247                          Nullsv);
1248       ]]),
1249       [have_libperl="yes"],
1250       [have_libperl="no"]
1251     )
1252   )
1253
1254   if test "x$have_libperl" = "xyes"
1255   then
1256           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1257           AC_SUBST(PERL_CFLAGS)
1258           AC_SUBST(PERL_LDFLAGS)
1259   else
1260           with_libperl="no"
1261   fi
1262
1263   CFLAGS=$SAVE_CFLAGS
1264   LDFLAGS=$SAVE_LDFLAGS
1265 fi
1266 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1267
1268 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1269 [
1270         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1271         then
1272                 LDFLAGS="$LDFLAGS -L$withval/lib"
1273                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1274                 with_libiptc="yes"
1275         fi
1276 ],
1277 [
1278         if test "x$ac_system" = "xLinux"
1279         then
1280                 with_libiptc="yes"
1281         else
1282                 with_libiptc="no (Linux only)"
1283         fi
1284 ])
1285 if test "x$with_libiptc" = "xyes"
1286 then
1287         AC_CHECK_LIB(iptc, iptc_init,
1288         [
1289                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1290         ], [with_libiptc="no (libiptc not found)"])
1291 fi
1292 if test "x$with_libiptc" = "xyes"
1293 then
1294         AC_CHECK_HEADERS(libiptc/libiptc.h,
1295         [
1296                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1297         ], [with_libiptc="no (libiptc/libiptc.h not found)"])
1298 fi
1299 if test "x$with_libiptc" = "xyes"
1300 then
1301         collect_libiptc=1
1302 else
1303         collect_libiptc=0
1304 fi
1305 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1306
1307 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
1308 [
1309         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1310         then
1311                 LDFLAGS="$LDFLAGS -L$withval/lib"
1312                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1313                 with_libupsclient="yes"
1314         fi
1315 ],
1316 [
1317         with_libupsclient="yes"
1318 ])
1319 if test "x$with_libupsclient" = "xyes"
1320 then
1321         AC_CHECK_LIB(upsclient, upscli_connect,
1322         [
1323                 AC_DEFINE(HAVE_LIBUPSCLIENT, 1, [Define to 1 if you have the upsclient library (-lupsclient).])
1324         ], [with_libupsclient="no (libupsclient not found)"])
1325 fi
1326 if test "x$with_libupsclient" = "xyes"
1327 then
1328         AC_CHECK_HEADERS(upsclient.h,
1329         [
1330                 AC_DEFINE(HAVE_UPSCLIENT_H, 1, [Define to 1 if you have the <upsclient.h> header file.])
1331         ], [with_libupsclient="no (upsclient.h not found)"])
1332 fi
1333 AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
1334
1335 # Check for enabled/disabled features
1336 #
1337
1338 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
1339 # ------------------------------------------------------------
1340 dnl
1341 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
1342 dnl
1343 AC_DEFUN(
1344         [AC_COLLECTD],
1345         [
1346         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
1347         m4_if(
1348                 [$2],
1349                 [enable],
1350                 [dnl
1351                 m4_define([EnDis],[disabled])dnl
1352                 m4_define([YesNo],[no])dnl
1353                 ],dnl
1354                 [m4_if(
1355                         [$2],
1356                         [disable],
1357                         [dnl
1358                         m4_define([EnDis],[enabled])dnl
1359                         m4_define([YesNo],[yes])dnl
1360                         ],
1361                         [dnl
1362                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
1363                         ]dnl
1364                 )]dnl
1365         )dnl
1366         m4_if([$3], [feature], [],
1367                 [m4_if(
1368                         [$3], [module], [],
1369                         [dnl
1370                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
1371                         ]dnl
1372                 )]dnl
1373         )dnl
1374         AC_ARG_ENABLE(
1375                 [$1],
1376                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
1377                 [],
1378                 enable_$1='[YesNo]'dnl
1379         )# AC_ARG_ENABLE
1380 if test "x$enable_$1" = "xno"
1381 then
1382         collectd_$1=0
1383 else
1384         if test "x$enable_$1" = "xyes"
1385         then
1386                 collectd_$1=1
1387         else
1388                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
1389                 collectd_$1=1
1390                 enable_$1='yes'
1391         fi
1392 fi
1393         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
1394         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
1395         ]dnl
1396 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
1397
1398 m4_divert_once([HELP_ENABLE], [
1399 collectd features:])
1400 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
1401 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
1402 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
1403
1404 m4_divert_once([HELP_ENABLE], [
1405 collectd modules:])
1406 AC_COLLECTD([apache],    [disable], [module], [Apache httpd statistics])
1407 AC_COLLECTD([apcups],    [disable], [module], [Statistics of UPSes by APC])
1408 AC_COLLECTD([apple_sensors], [disable], [module], [Apple's hardware sensors])
1409 AC_COLLECTD([battery],   [disable], [module], [battery statistics])
1410 AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
1411 AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
1412 AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
1413 AC_COLLECTD([csv],       [disable], [module], [csv output plugin])
1414 AC_COLLECTD([df],        [disable], [module], [df statistics])
1415 AC_COLLECTD([dns],       [disable], [module], [dns statistics])
1416 AC_COLLECTD([email],     [disable], [module], [email statistics])
1417 AC_COLLECTD([entropy],   [disable], [module], [entropy statistics])
1418 AC_COLLECTD([exec],      [disable], [module], [exec of external programs])
1419 AC_COLLECTD([hddtemp],   [disable], [module], [hdd temperature statistics])
1420 AC_COLLECTD([interface], [disable], [module], [interface statistics])
1421 AC_COLLECTD([iptables],  [disable], [module], [IPtables statistics])
1422 AC_COLLECTD([irq],       [disable], [module], [irq statistics])
1423 AC_COLLECTD([load],      [disable], [module], [system load statistics])
1424 AC_COLLECTD([mbmon],     [disable], [module], [motherboard monitor statistics])
1425 AC_COLLECTD([memory],    [disable], [module], [memory statistics])
1426 AC_COLLECTD([multimeter],[disable], [module], [multimeter statistics])
1427 AC_COLLECTD([mysql],     [disable], [module], [mysql statistics])
1428 AC_COLLECTD([network],   [disable], [module], [network functionality])
1429 AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
1430 AC_COLLECTD([ntpd],      [disable], [module], [ntpd statistics])
1431 AC_COLLECTD([nut],       [disable], [module], [network UPS tools statistics])
1432 AC_COLLECTD([perl],      [disable], [module], [embedded perl interpreter])
1433 AC_COLLECTD([ping],      [disable], [module], [ping statistics])
1434 AC_COLLECTD([processes], [disable], [module], [processes statistics])
1435 AC_COLLECTD([sensors],   [disable], [module], [lm_sensors statistics])
1436 AC_COLLECTD([serial],    [disable], [module], [serial statistics])
1437 AC_COLLECTD([logfile],   [disable], [module], [logfile log facility])
1438 AC_COLLECTD([swap],      [disable], [module], [swap statistics])
1439 AC_COLLECTD([syslog],    [disable], [module], [syslog log facility])
1440 AC_COLLECTD([tape],      [disable], [module], [tape statistics])
1441 AC_COLLECTD([unixsock],  [disable], [module], [UNIX socket plugin])
1442 AC_COLLECTD([users],     [disable], [module], [user count statistics])
1443 AC_COLLECTD([vserver],   [disable], [module], [vserver statistics])
1444 AC_COLLECTD([wireless],  [disable], [module], [wireless link statistics])
1445
1446 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile)
1447
1448 if test "x$with_libperl" = "xyes"
1449 then
1450         with_libperl="yes (version `perl -MConfig -e 'print $Config{version};'`)"
1451 else
1452         enable_perl="no (needs libperl)"
1453 fi
1454
1455 cat <<EOF;
1456
1457 Configuration:
1458   Libraries:
1459     libcurl . . . . . . $with_libcurl
1460     libiokit  . . . . . $with_libiokit
1461     libiptc . . . . . . $with_libiptc
1462     libkstat  . . . . . $with_kstat
1463     libmysql  . . . . . $with_libmysql
1464     liboconfig  . . . . $with_liboconfig
1465     liboping  . . . . . $with_liboping
1466     libpcap . . . . . . $with_libpcap
1467     libperl . . . . . . $with_libperl
1468     libpthread  . . . . $with_libpthread
1469     librrd  . . . . . . $with_rrdtool
1470     libsensors  . . . . $with_lm_sensors
1471     libstatgrab . . . . $with_libstatgrab
1472     libupsclient  . . . $with_libupsclient
1473
1474   Features:
1475     daemon mode . . . . $enable_daemon
1476     debug . . . . . . . $enable_debug
1477
1478   Modules:
1479     apache  . . . . . . $enable_apache
1480     apcups  . . . . . . $enable_apcups
1481     apple_sensors . . . $enable_apple_sensors
1482     battery . . . . . . $enable_battery
1483     cpu . . . . . . . . $enable_cpu
1484     cpufreq . . . . . . $enable_cpufreq
1485     csv . . . . . . . . $enable_csv
1486     df  . . . . . . . . $enable_df
1487     disk  . . . . . . . $enable_disk
1488     dns . . . . . . . . $enable_dns
1489     email . . . . . . . $enable_email
1490     entropy . . . . . . $enable_entropy
1491     exec  . . . . . . . $enable_exec
1492     hddtemp . . . . . . $enable_hddtemp
1493     interface . . . . . $enable_interface
1494     iptables  . . . . . $enable_iptables
1495     irq . . . . . . . . $enable_irq
1496     load  . . . . . . . $enable_load
1497     logfile . . . . . . $enable_logfile
1498     mbmon . . . . . . . $enable_mbmon
1499     memory  . . . . . . $enable_memory
1500     multimeter  . . . . $enable_multimeter
1501     mysql . . . . . . . $enable_mysql
1502     network . . . . . . $enable_network
1503     nfs . . . . . . . . $enable_nfs
1504     ntpd  . . . . . . . $enable_ntpd
1505     nut . . . . . . . . $enable_nut
1506     perl  . . . . . . . $enable_perl
1507     ping  . . . . . . . $enable_ping
1508     processes . . . . . $enable_processes
1509     sensors . . . . . . $enable_sensors
1510     serial  . . . . . . $enable_serial
1511     swap  . . . . . . . $enable_swap
1512     syslog  . . . . . . $enable_syslog
1513     tape  . . . . . . . $enable_tape
1514     unixsock  . . . . . $enable_unixsock
1515     users . . . . . . . $enable_users
1516     vserver . . . . . . $enable_vserver
1517     wireless  . . . . . $enable_wireless
1518
1519 EOF