Bumped version to 4.0.9; Updated ChangeLog.
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, 4.0.9)
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_FUNC_STRERROR_R
428
429 AC_CHECK_FUNCS(getpwnam_r)
430 AC_CHECK_FUNCS(getgrnam_r)
431
432 socket_needs_socket="no"
433 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
434 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
435
436 nanosleep_needs_rt="no"
437 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
438 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
439
440 # Regular expressions for the ignorelist.
441 AC_CHECK_FUNCS(regcomp regerror regexec regfree)
442
443 # For cpu module
444 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
445
446 # For df module
447 AC_CHECK_FUNCS(statfs statvfs)
448
449 # For load module
450 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
451
452 # For the `processes' plugin
453 AC_CHECK_FUNCS(thread_info)
454
455 # For users module
456 AC_CHECK_FUNCS(getutent getutxent)
457
458 # For interface module
459 AC_CHECK_FUNCS(getifaddrs)
460
461 # Check for NAN
462 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
463 [
464  if test "x$withval" = "xno"; then
465          nan_type="none"
466  else if test "x$withval" = "xyes"; then
467          nan_type="zero"
468  else
469          nan_type="$withval"
470  fi; fi
471 ],
472 [nan_type="none"])
473 if test "x$nan_type" = "xnone"; then
474   AC_CACHE_CHECK([whether NAN is defined by default],
475     [have_nan_default],
476     AC_COMPILE_IFELSE(
477       AC_LANG_PROGRAM(
478       [[
479 #include <stdlib.h>
480 #include <math.h>
481 static float foo = NAN;
482       ]],
483       [[
484        if (isnan (foo))
485         return 0;
486        else
487         return 1;
488       ]]),
489       [have_nan_default="yes"],
490       [have_nan_default="no"]
491     )
492   )
493   if test "x$have_nan_default" = "xyes"
494   then
495     nan_type="default"
496   fi
497 fi
498 if test "x$nan_type" = "xnone"; then
499   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
500     [have_nan_isoc],
501     AC_COMPILE_IFELSE(
502       AC_LANG_PROGRAM(
503       [[
504 #include <stdlib.h>
505 #define __USE_ISOC99 1
506 #include <math.h>
507 static float foo = NAN;
508       ]],
509       [[
510        if (isnan (foo))
511         return 0;
512        else
513         return 1;
514       ]]),
515       [have_nan_isoc="yes"],
516       [have_nan_isoc="no"]
517     )
518   )
519   if test "x$have_nan_isoc" = "xyes"
520   then
521     nan_type="isoc99"
522   fi
523 fi
524 if test "x$nan_type" = "xnone"; then
525   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
526     [have_nan_zero],
527     AC_RUN_IFELSE(
528       AC_LANG_PROGRAM(
529       [[
530 #include <stdlib.h>
531 #include <math.h>
532 #ifdef NAN
533 # undef NAN
534 #endif
535 #define NAN (0.0 / 0.0)
536 #ifndef isnan
537 # define isnan(f) ((f) != (f))
538 #endif
539 static float foo = NAN;
540       ]],
541       [[
542        if (isnan (foo))
543         return 0;
544        else
545         return 1;
546       ]]),
547       [have_nan_zero="yes"],
548       [have_nan_zero="no"]
549     )
550   )
551   if test "x$have_nan_zero" = "xyes"
552   then
553     nan_type="zero"
554   fi
555 fi
556
557 if test "x$nan_type" = "xdefault"; then
558   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
559     [Define if NAN is defined by default and can initialize static variables.])
560 else if test "x$nan_type" = "xisoc99"; then
561   AC_DEFINE(NAN_STATIC_ISOC, 1,
562     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
563 else if test "x$nan_type" = "xzero"; then
564   AC_DEFINE(NAN_ZERO_ZERO, 1,
565     [Define if NAN can be defined as (0.0 / 0.0)])
566 else
567   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
568 fi; fi; fi
569
570 # For mount interface
571 #AC_CHECK_FUNCS(getfsent getvfsent)
572
573 have_getfsstat="no"
574 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
575 have_getvfsstat="no"
576 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
577 have_listmntent="no"
578 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
579
580 have_getmntent="no"
581 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
582 if test "x$have_getmntent" = "xno"; then
583         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
584 fi
585 if test "x$have_getmntent" = "xno"; then
586         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
587 fi
588 if test "x$have_getmntent" = "xno"; then
589         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
590 fi
591
592 if test "x$have_getmntent" = "xc"; then
593         AC_CACHE_CHECK([whether getmntent takes one argument],
594                 [have_one_getmntent],
595                 AC_COMPILE_IFELSE(
596                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
597 #include <mntent.h>
598 #include "$srcdir/src/utils_mount.h"]],
599                                 [[
600                                  FILE *fh;
601                                  struct mntent *me;
602                                  fh = setmntent ("/etc/mtab", "r");
603                                  me = getmntent (fh);
604                                 ]]
605                         ),
606                         [have_one_getmntent="yes"],
607                         [have_one_getmntent="no"]
608                 )
609         )
610         AC_CACHE_CHECK([whether getmntent takes two arguments],
611                 [have_two_getmntent],
612                 AC_COMPILE_IFELSE(
613                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
614 #include <sys/mnttab.h>
615 #include "$srcdir/src/utils_mount.h"]],
616                                 [[
617                                  FILE *fh;
618                                  struct mnttab mt;
619                                  int status;
620                                  fh = fopen ("/etc/mnttab", "r");
621                                  status = getmntent (fh, &mt);
622                                 ]]
623                         ),
624                         [have_two_getmntent="yes"],
625                         [have_two_getmntent="no"]
626                 )
627         )
628 fi
629
630 # Check for different versions of `getmntent' here..
631
632 if test "x$have_getmntent" = "xc"; then
633         if test "x$have_one_getmntent" = "xyes"; then
634                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
635                           [Define if the function getmntent exists and takes one argument.])
636         fi
637         if test "x$have_two_getmntent" = "xyes"; then
638                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
639                           [Define if the function getmntent exists and takes two arguments.])
640         fi
641 fi
642 if test "x$have_getmntent" = "xsun"; then
643         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
644                   [Define if the function getmntent exists. It's the version from libsun.])
645 fi
646 if test "x$have_getmntent" = "xseq"; then
647         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
648                   [Define if the function getmntent exists. It's the version from libseq.])
649 fi
650 if test "x$have_getmntent" = "xgen"; then
651         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
652                   [Define if the function getmntent exists. It's the version from libgen.])
653 fi
654
655 # Check for structures
656 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
657         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
658         [],
659         [
660         #include <sys/types.h>
661         #include <sys/socket.h>
662         #include <net/if.h>
663         ])
664 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
665         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
666         [],
667         [
668         #include <sys/types.h>
669         #include <sys/socket.h>
670         #include <linux/if.h>
671         #include <linux/netdevice.h>
672         ])
673
674 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
675 [#if HAVE_STDINT_H
676 # include <stdint.h>
677 #endif
678 #if HAVE_SYS_TYPES_H
679 # include <sys/types.h>
680 #endif
681 #if HAVE_NETINET_IN_SYSTM_H
682 # include <netinet/in_systm.h>
683 #endif
684 #if HAVE_NETINET_IN_H
685 # include <netinet/in.h>
686 #endif
687 #if HAVE_NETINET_IP_H
688 # include <netinet/ip.h>
689 #endif
690 #if HAVE_NETINET_UDP_H
691 # include <netinet/udp.h>
692 #endif
693 ])
694 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
695 [#if HAVE_STDINT_H
696 # include <stdint.h>
697 #endif
698 #if HAVE_SYS_TYPES_H
699 # include <sys/types.h>
700 #endif
701 #if HAVE_NETINET_IN_SYSTM_H
702 # include <netinet/in_systm.h>
703 #endif
704 #if HAVE_NETINET_IN_H
705 # include <netinet/in.h>
706 #endif
707 #if HAVE_NETINET_IP_H
708 # include <netinet/ip.h>
709 #endif
710 #if HAVE_NETINET_UDP_H
711 # include <netinet/udp.h>
712 #endif
713 ])
714
715 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
716         [],
717         [],
718         [
719 #if HAVE_KSTAT_H
720 # include <kstat.h>
721 #endif
722         ])
723
724 AC_MSG_CHECKING([for kernel type ($host_os)])
725 case $host_os in
726         *linux*)
727         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
728         ac_system="Linux"
729         ;;
730         *solaris*)
731         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
732         ac_system="Solaris"
733         ;;
734         *)
735         ac_system="unknown"
736 esac
737 AC_MSG_RESULT([$ac_system])
738
739 with_libresolv="yes"
740 AC_CHECK_LIB(resolv, res_search,
741 [
742         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
743 ],
744 [with_libresolv="no"])
745 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
746
747
748 m4_divert_once([HELP_WITH], [
749 collectd additional packages:])
750
751 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
752 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
753 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
754         then
755                 LDFLAGS="$LDFLAGS -L$withval/lib"
756                 CPPFLAGS="$CPPFLAGS -I$withval/include"
757                 with_rrdtool="yes"
758         fi
759 ], [with_rrdtool="yes"])
760 if test "x$with_rrdtool" = "xyes"
761 then
762         AC_CHECK_LIB(rrd, rrd_update,
763         [
764                 AC_DEFINE(HAVE_LIBRRD, 1, [Define to 1 if you have the rrd library (-lrrd).])
765         ],
766         [with_rrdtool="no (librrd not found)"], [-lm])
767 fi
768 if test "x$with_rrdtool" = "xyes"
769 then
770         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
771 fi
772 if test "x$with_rrdtool" = "xyes"
773 then
774         collect_rrdtool=1
775 else
776         collect_rrdtool=0
777 fi
778 AC_DEFINE_UNQUOTED(COLLECT_RRDTOOL, [$collect_rrdtool],
779         [Wether or not to use rrdtool library])
780 AM_CONDITIONAL(BUILD_WITH_RRDTOOL, test "x$with_rrdtool" = "xyes")
781
782 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
783 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
784         then
785                 LDFLAGS="$LDFLAGS -L$withval/lib"
786                 CPPFLAGS="$CPPFLAGS -I$withval/include"
787                 with_libpthread="yes"
788         else
789                 if test "x$withval" = "xno"
790                 then
791                         with_libpthread="no (disabled)"
792                 fi
793         fi
794 ], [with_libpthread="yes"])
795 if test "x$with_libpthread" = "xyes"
796 then
797         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
798 fi
799 if test "x$with_libpthread" = "xyes"
800 then
801         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
802 fi
803 if test "x$with_libpthread" = "xyes"
804 then
805         collect_pthread=1
806 else
807         collect_pthread=0
808 fi
809 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
810         [Wether or not to use pthread (POSIX threads) library])
811 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
812
813 if test "$ac_system" = "Solaris"
814 then
815         with_kstat="yes"
816         with_devinfo="yes"
817 else
818         with_kstat="no (Solaris only)"
819         with_devinfo="no (Solaris only)"
820 fi
821
822 if test "x$with_kstat" = "xyes"
823 then
824         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
825 fi
826 if test "x$with_kstat" = "xyes"
827 then
828         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
829         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
830 fi
831 if test "x$with_kstat" = "xyes"
832 then
833         AC_DEFINE(HAVE_LIBKSTAT, 1,
834                   [Define to 1 if you have the 'kstat' library (-lkstat)])
835 fi
836 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
837 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
838
839 ### BEGIN of check for libcurl ###
840 with_curl_config="curl-config"
841 with_curl_cflags=""
842 with_curl_libs=""
843 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
844 [
845         if test "x$withval" = "xno"
846         then
847                 with_libcurl="no"
848         else if test "x$withval" = "xyes"
849         then
850                 with_libcurl="yes"
851         else
852                 if test -x "$withval"
853                 then
854                         with_curl_config="$withval"
855                 else if test -x "$withval/bin/curl-config"
856                 then
857                         with_curl_config="$withval/bin/curl-config"
858                 fi; fi
859         fi; fi
860 ],
861 [
862         with_libcurl="yes"
863 ])
864 if test "x$with_libcurl" = "xyes"
865 then
866         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
867         curl_config_status=$?
868
869         if test $curl_config_status -ne 0
870         then
871                 with_libcurl="no"
872         else
873                 SAVE_CFLAGS=$CFLAGS
874                 CFLAGS="$CFLAGS $with_curl_cflags"
875
876                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
877
878                 CFLAGS="$SAVE_CFLAGS"
879         fi
880 fi
881 if test "x$with_libcurl" = "xyes"
882 then
883         with_curl_libs=`$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                 AC_CHECK_LIB(curl, curl_easy_init,
891                  [
892                   # We need to do this to have `HAVE_LIBCURL' defined but
893                   # `-lcurl' NOT added to the default LDFLAGS.
894                         AC_DEFINE(HAVE_LIBCURL, 1,
895                                   [Define to 1 if you have the curl library.])
896                  ],
897                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
898                  [$with_curl_libs])
899         fi
900 fi
901 if test "x$with_libcurl" = "xyes"
902 then
903         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
904         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
905         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
906         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
907 fi
908 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
909 ### END of check for libcurl ###
910
911 with_libiokit="no"
912 collectd_libiokit=0
913 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
914 [
915         with_libiokit="yes"
916         collectd_libiokit=1
917 ], 
918 [
919         with_libiokit="no"
920         collectd_libiokit=0
921 ])
922 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
923 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
924
925 with_libstatgrab="yes"
926 with_libdevstat="no"
927 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
928 [
929         if test "x$withval" != "xno" -a "x$withval" != "xyes"
930         then
931                 LDFLAGS="$LDFLAGS -L$withval/lib"
932                 CPPFLAGS="$CPPFLAGS -I$withval/include"
933                 with_libstatgrab="yes"
934         fi
935 ],
936 [
937         if test "x$ac_system" == "xunknown"
938         then
939                 with_libstatgrab="yes"
940         else
941                 with_libstatgrab="no"
942         fi
943 ])
944 if test "x$with_libstatgrab" = "xyes"
945 then
946         AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"])
947 fi
948 if test "x$with_libstatgrab" = "xyes"
949 then
950         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
951 fi
952 if test "x$with_libstatgrab" = "xyes"
953 then
954         AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"])
955 fi
956 if test "x$with_libstatgrab" = "xyes"
957 then
958         collect_libstatgrab=1
959 else
960         collect_libstatgrab=0
961 fi
962 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
963         [Wether or not to use statgrab library])
964 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
965 AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT,  test "x$with_libdevstat"  = "xyes")
966
967 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
968 if test "x$with_libkvm" = "xyes"
969 then
970         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
971 fi
972 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
973
974 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
975 [
976         if test "x$withval" != "xno" && test "x$withval" != "xyes"
977         then
978                 LDFLAGS="$LDFLAGS -L$withval/lib"
979                 CPPFLAGS="$CPPFLAGS -I$withval/include"
980                 with_lm_sensors="yes"
981         fi
982 ],
983 [
984         if test "x$ac_system" = "xLinux"
985         then
986                 with_lm_sensors="yes"
987         else
988                 with_lm_sensors="no"
989         fi
990 ])
991 if test "x$with_lm_sensors" = "xyes"
992 then
993         AC_CHECK_LIB(sensors, sensors_init,
994         [
995                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
996         ],
997         [with_lm_sensors="no (libsensors not found)"])
998 fi
999 if test "x$with_lm_sensors" = "xyes"
1000 then
1001         AC_CHECK_HEADERS(sensors/sensors.h,
1002         [
1003                 AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
1004         ],
1005         [with_lm_sensors="no (sensors/sensors.h not found)"])
1006 fi
1007 if test "x$with_lm_sensors" = "xyes"
1008 then
1009         collect_lm_sensors=1
1010 else
1011         collect_lm_sensors=0
1012 fi
1013 AC_DEFINE_UNQUOTED(COLLECT_LM_SENSORS, [$collect_lm_sensors],
1014         [Wether or not to use sensors library])
1015 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
1016
1017 with_mysql_config="mysql_config"
1018 with_mysql_cflags=""
1019 with_mysql_libs=""
1020 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1021 [
1022         if test "x$withval" = "xno"
1023         then
1024                 with_libmysql="no"
1025         else if test "x$withval" = "xyes"
1026         then
1027                 with_libmysql="yes"
1028         else
1029                 if test -x "$withval";
1030                 then
1031                         with_mysql_config="$withval"
1032                 else if test -x "$withval/bin/mysql_config"
1033                 then
1034                         with_mysql_config="$withval/bin/mysql_config"
1035                 fi; fi
1036         fi; fi
1037 ],
1038 [
1039         with_libmysql="yes"
1040 ])
1041 if test "x$with_libmysql" = "xyes"
1042 then
1043         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1044         mysql_config_status=$?
1045
1046         if test $mysql_config_status -ne 0
1047         then
1048                 with_libmysql="no"
1049         else
1050                 SAVE_CFLAGS=$CFLAGS
1051                 CFLAGS="$CFLAGS $with_mysql_cflags"
1052
1053                 AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
1054
1055                 CFLAGS="$SAVE_CFLAGS"
1056         fi
1057 fi
1058 if test "x$with_libmysql" = "xyes"
1059 then
1060         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1061         mysql_config_status=$?
1062
1063         if test $mysql_config_status -ne 0
1064         then
1065                 with_libmysql="no"
1066         else
1067                 AC_CHECK_LIB(mysqlclient, mysql_init,
1068                  [
1069                   # We need to do this to have `HAVE_LIBMYSQLCLIENT' defined
1070                   # but `-lmysqlclient' NOT added to the default LDFLAGS.
1071                         AC_DEFINE(HAVE_LIBMYSQLCLIENT, 1,
1072                                   [Define to 1 if you have the mysqlclient library.])
1073                  ],
1074                  [with_libmysql="no (libmysql not found)"],
1075                  [$with_mysql_libs])
1076         fi
1077 fi
1078 if test "x$with_libmysql" = "xyes"
1079 then
1080         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1081         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1082         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1083         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1084 fi
1085 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1086
1087 with_own_liboconfig="no"
1088 liboconfig_LDFLAGS="$LDFLAGS"
1089 liboconfig_CPPFLAGS="$CPPFLAGS"
1090 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1091 [
1092         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1093         then
1094                 if test -d "$withval/lib"
1095                 then
1096                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1097                 fi
1098                 if test -d "$withval/include"
1099                 then
1100                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1101                 fi
1102         fi
1103         if test "x$withval" = "xno"
1104         then
1105                 AC_MSG_ERROR("liboconfig is required")
1106         fi
1107 ],
1108 [
1109         with_liboconfig="yes"
1110 ])
1111
1112 save_LDFLAGS="$LDFLAGS"
1113 save_CPPFLAGS="$CPPFLAGS"
1114 LDFLAGS="$liboconfig_LDFLAGS"
1115 CPPFLAGS="$liboconfig_CPPFLAGS"
1116 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1117 [
1118         with_liboconfig="yes"
1119         with_own_liboconfig="no"
1120 ],
1121 [
1122         with_liboconfig="yes"
1123         with_own_liboconfig="yes"
1124         LDFLAGS="$save_LDFLAGS"
1125         CPPFLAGS="$save_CPPFLAGS"
1126 ])
1127
1128 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1129 if test "x$with_own_liboconfig" = "xyes"
1130 then
1131         with_liboconfig="yes (shipped version)"
1132 fi
1133
1134 #with_liboping="yes"
1135 with_own_liboping="no"
1136 liboping_LDFLAGS="$LDFLAGS"
1137 liboping_CPPFLAGS="$CPPFLAGS"
1138 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1139 [
1140         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1141         then
1142                 if test -d "$withval/lib"
1143                 then
1144                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1145                 fi
1146                 if test -d "$withval/include"
1147                 then
1148                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1149                 fi
1150         fi
1151         if test "x$withval" = "xno"
1152         then
1153                 with_liboping="no"
1154                 with_own_liboping="no"
1155         fi
1156 ],
1157 [
1158         #753
1159         with_liboping="yes"
1160 ])
1161
1162 if test "x$with_liboping" = "xyes"
1163 then
1164         save_LDFLAGS="$LDFLAGS"
1165         save_CPPFLAGS="$CPPFLAGS"
1166         LDFLAGS="$liboping_LDFLAGS"
1167         CPPFLAGS="$liboping_CPPFLAGS"
1168         AC_CHECK_LIB(oping, ping_construct,
1169         [
1170                 with_liboping="yes"
1171                 with_own_liboping="no"
1172         ],
1173         [
1174                 with_liboping="yes"
1175                 with_own_liboping="yes"
1176                 LDFLAGS="$save_LDFLAGS"
1177                 CPPFLAGS="$save_CPPFLAGS"
1178         ])
1179 fi
1180 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1181 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1182 if test "x$with_liboping" = "xyes" -a "x$with_own_liboping" = "xyes"
1183 then
1184         with_liboping="yes (shipped version)"
1185 fi
1186
1187 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1188 [
1189         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1190         then
1191                 LDFLAGS="$LDFLAGS -L$withval/lib"
1192                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1193                 with_libpcap="yes"
1194         fi
1195 ],
1196 [
1197         with_libpcap="yes"
1198 ])
1199 if test "x$with_libpcap" = "xyes"
1200 then
1201         AC_CHECK_LIB(pcap, pcap_open_live,
1202         [
1203                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1204         ], [with_libpcap="no (libpcap not found)"])
1205 fi
1206 if test "x$with_libpcap" = "xyes"
1207 then
1208         AC_CHECK_HEADERS(pcap.h,
1209         [
1210                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1211         ], [with_libpcap="no (pcap.h not found)"])
1212 fi
1213 if test "x$with_libpcap" = "xyes"
1214 then
1215         collect_libpcap=1
1216 else
1217         collect_libpcap=0
1218 fi
1219 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1220         [Wether or not to use the pcap library])
1221 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1222
1223 perl_interpreter="perl"
1224 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1225 [
1226         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1227         then
1228                 LDFLAGS="$LDFLAGS -L$withval/lib"
1229                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1230                 perl_interpreter="$withval/bin/perl"
1231                 with_libperl="yes"
1232         fi
1233 ],
1234 [
1235         with_libperl="yes"
1236 ])
1237 if test "x$with_libperl" = "xyes"
1238 then
1239   SAVE_CFLAGS=$CFLAGS
1240   SAVE_LDFLAGS=$LDFLAGS
1241   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1242   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1243   CFLAGS="$CFLAGS $PERL_CFLAGS"
1244   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1245
1246   AC_CACHE_CHECK([for libperl],
1247     [have_libperl],
1248     AC_LINK_IFELSE(
1249       AC_LANG_PROGRAM(
1250       [[
1251 #include <EXTERN.h>
1252 #include <perl.h>
1253 #include <XSUB.h>
1254       ]],
1255       [[
1256        PerlInterpreter *perl = NULL;
1257        Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
1258                          newSVpv ("Collectd::Plugin::FooBar", 24),
1259                          Nullsv);
1260       ]]),
1261       [have_libperl="yes"],
1262       [have_libperl="no"]
1263     )
1264   )
1265
1266   if test "x$have_libperl" = "xyes"
1267   then
1268           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1269           AC_SUBST(PERL_CFLAGS)
1270           AC_SUBST(PERL_LDFLAGS)
1271   else
1272           with_libperl="no"
1273   fi
1274
1275   CFLAGS=$SAVE_CFLAGS
1276   LDFLAGS=$SAVE_LDFLAGS
1277 fi
1278 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1279
1280 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1281 [
1282         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1283         then
1284                 LDFLAGS="$LDFLAGS -L$withval/lib"
1285                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1286                 with_libiptc="yes"
1287         fi
1288 ],
1289 [
1290         if test "x$ac_system" = "xLinux"
1291         then
1292                 with_libiptc="yes"
1293         else
1294                 with_libiptc="no (Linux only)"
1295         fi
1296 ])
1297 if test "x$with_libiptc" = "xyes"
1298 then
1299         AC_CHECK_LIB(iptc, iptc_init,
1300         [
1301                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1302         ], [with_libiptc="no (libiptc not found)"])
1303 fi
1304 if test "x$with_libiptc" = "xyes"
1305 then
1306         AC_CHECK_HEADERS(libiptc/libiptc.h,
1307         [
1308                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1309         ], [with_libiptc="no (libiptc/libiptc.h not found)"])
1310 fi
1311 if test "x$with_libiptc" = "xyes"
1312 then
1313         collect_libiptc=1
1314 else
1315         collect_libiptc=0
1316 fi
1317 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1318
1319 # TODO: Use `libupsclient-config' here.
1320 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
1321 [
1322         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1323         then
1324                 LDFLAGS="$LDFLAGS -L$withval/lib"
1325                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1326                 with_libupsclient="yes"
1327         fi
1328 ],
1329 [
1330         with_libupsclient="yes"
1331 ])
1332 if test "x$with_libupsclient" = "xyes"
1333 then
1334         AC_CHECK_LIB(upsclient, upscli_connect,
1335         [
1336                 AC_DEFINE(HAVE_LIBUPSCLIENT, 1, [Define to 1 if you have the upsclient library (-lupsclient).])
1337         ], [with_libupsclient="no (libupsclient not found)"])
1338 fi
1339 if test "x$with_libupsclient" = "xyes"
1340 then
1341         AC_CHECK_HEADERS(upsclient.h,
1342         [
1343                 AC_DEFINE(HAVE_UPSCLIENT_H, 1, [Define to 1 if you have the <upsclient.h> header file.])
1344         ], [with_libupsclient="no (upsclient.h not found)"])
1345 fi
1346 if test "x$with_libupsclient" = "xyes"
1347 then
1348         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [], 
1349 [#include <stdlib.h>
1350 #include <stdio.h>
1351 #include <upsclient.h>])
1352 fi
1353 AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
1354
1355 # Check for enabled/disabled features
1356 #
1357
1358 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
1359 # ------------------------------------------------------------
1360 dnl
1361 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
1362 dnl
1363 AC_DEFUN(
1364         [AC_COLLECTD],
1365         [
1366         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
1367         m4_if(
1368                 [$2],
1369                 [enable],
1370                 [dnl
1371                 m4_define([EnDis],[disabled])dnl
1372                 m4_define([YesNo],[no])dnl
1373                 ],dnl
1374                 [m4_if(
1375                         [$2],
1376                         [disable],
1377                         [dnl
1378                         m4_define([EnDis],[enabled])dnl
1379                         m4_define([YesNo],[yes])dnl
1380                         ],
1381                         [dnl
1382                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
1383                         ]dnl
1384                 )]dnl
1385         )dnl
1386         m4_if([$3], [feature], [],
1387                 [m4_if(
1388                         [$3], [module], [],
1389                         [dnl
1390                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
1391                         ]dnl
1392                 )]dnl
1393         )dnl
1394         AC_ARG_ENABLE(
1395                 [$1],
1396                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
1397                 [],
1398                 enable_$1='[YesNo]'dnl
1399         )# AC_ARG_ENABLE
1400 if test "x$enable_$1" = "xno"
1401 then
1402         collectd_$1=0
1403 else
1404         if test "x$enable_$1" = "xyes"
1405         then
1406                 collectd_$1=1
1407         else
1408                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
1409                 collectd_$1=1
1410                 enable_$1='yes'
1411         fi
1412 fi
1413         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
1414         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
1415         ]dnl
1416 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
1417
1418 m4_divert_once([HELP_ENABLE], [
1419 collectd features:])
1420 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
1421 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
1422 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
1423
1424 m4_divert_once([HELP_ENABLE], [
1425 collectd modules:])
1426 AC_COLLECTD([apache],    [disable], [module], [Apache httpd statistics])
1427 AC_COLLECTD([apcups],    [disable], [module], [Statistics of UPSes by APC])
1428 AC_COLLECTD([apple_sensors], [disable], [module], [Apple's hardware sensors])
1429 AC_COLLECTD([battery],   [disable], [module], [battery statistics])
1430 AC_COLLECTD([cpu],       [disable], [module], [cpu usage statistics])
1431 AC_COLLECTD([cpufreq],   [disable], [module], [system cpu frequency statistics])
1432 AC_COLLECTD([disk],      [disable], [module], [disk/partition statistics])
1433 AC_COLLECTD([csv],       [disable], [module], [csv output plugin])
1434 AC_COLLECTD([df],        [disable], [module], [df statistics])
1435 AC_COLLECTD([dns],       [disable], [module], [dns statistics])
1436 AC_COLLECTD([email],     [disable], [module], [email statistics])
1437 AC_COLLECTD([entropy],   [disable], [module], [entropy statistics])
1438 AC_COLLECTD([exec],      [disable], [module], [exec of external programs])
1439 AC_COLLECTD([hddtemp],   [disable], [module], [hdd temperature statistics])
1440 AC_COLLECTD([interface], [disable], [module], [interface statistics])
1441 AC_COLLECTD([iptables],  [disable], [module], [IPtables statistics])
1442 AC_COLLECTD([irq],       [disable], [module], [irq statistics])
1443 AC_COLLECTD([load],      [disable], [module], [system load statistics])
1444 AC_COLLECTD([mbmon],     [disable], [module], [motherboard monitor statistics])
1445 AC_COLLECTD([memory],    [disable], [module], [memory statistics])
1446 AC_COLLECTD([multimeter],[disable], [module], [multimeter statistics])
1447 AC_COLLECTD([mysql],     [disable], [module], [mysql statistics])
1448 AC_COLLECTD([network],   [disable], [module], [network functionality])
1449 AC_COLLECTD([nfs],       [disable], [module], [nfs statistics])
1450 AC_COLLECTD([ntpd],      [disable], [module], [ntpd statistics])
1451 AC_COLLECTD([nut],       [disable], [module], [network UPS tools statistics])
1452 AC_COLLECTD([perl],      [disable], [module], [embedded perl interpreter])
1453 AC_COLLECTD([ping],      [disable], [module], [ping statistics])
1454 AC_COLLECTD([processes], [disable], [module], [processes statistics])
1455 AC_COLLECTD([sensors],   [disable], [module], [lm_sensors statistics])
1456 AC_COLLECTD([serial],    [disable], [module], [serial statistics])
1457 AC_COLLECTD([logfile],   [disable], [module], [logfile log facility])
1458 AC_COLLECTD([swap],      [disable], [module], [swap statistics])
1459 AC_COLLECTD([syslog],    [disable], [module], [syslog log facility])
1460 AC_COLLECTD([tape],      [disable], [module], [tape statistics])
1461 AC_COLLECTD([unixsock],  [disable], [module], [UNIX socket plugin])
1462 AC_COLLECTD([users],     [disable], [module], [user count statistics])
1463 AC_COLLECTD([vserver],   [disable], [module], [vserver statistics])
1464 AC_COLLECTD([wireless],  [disable], [module], [wireless link statistics])
1465
1466 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile)
1467
1468 if test "x$with_libperl" = "xyes"
1469 then
1470         with_libperl="yes (version `perl -MConfig -e 'print $Config{version};'`)"
1471 else
1472         enable_perl="no (needs libperl)"
1473 fi
1474
1475 cat <<EOF;
1476
1477 Configuration:
1478   Libraries:
1479     libcurl . . . . . . $with_libcurl
1480     libiokit  . . . . . $with_libiokit
1481     libiptc . . . . . . $with_libiptc
1482     libkstat  . . . . . $with_kstat
1483     libmysql  . . . . . $with_libmysql
1484     liboconfig  . . . . $with_liboconfig
1485     liboping  . . . . . $with_liboping
1486     libpcap . . . . . . $with_libpcap
1487     libperl . . . . . . $with_libperl
1488     libpthread  . . . . $with_libpthread
1489     librrd  . . . . . . $with_rrdtool
1490     libsensors  . . . . $with_lm_sensors
1491     libstatgrab . . . . $with_libstatgrab
1492     libupsclient  . . . $with_libupsclient
1493
1494   Features:
1495     daemon mode . . . . $enable_daemon
1496     debug . . . . . . . $enable_debug
1497
1498   Modules:
1499     apache  . . . . . . $enable_apache
1500     apcups  . . . . . . $enable_apcups
1501     apple_sensors . . . $enable_apple_sensors
1502     battery . . . . . . $enable_battery
1503     cpu . . . . . . . . $enable_cpu
1504     cpufreq . . . . . . $enable_cpufreq
1505     csv . . . . . . . . $enable_csv
1506     df  . . . . . . . . $enable_df
1507     disk  . . . . . . . $enable_disk
1508     dns . . . . . . . . $enable_dns
1509     email . . . . . . . $enable_email
1510     entropy . . . . . . $enable_entropy
1511     exec  . . . . . . . $enable_exec
1512     hddtemp . . . . . . $enable_hddtemp
1513     interface . . . . . $enable_interface
1514     iptables  . . . . . $enable_iptables
1515     irq . . . . . . . . $enable_irq
1516     load  . . . . . . . $enable_load
1517     logfile . . . . . . $enable_logfile
1518     mbmon . . . . . . . $enable_mbmon
1519     memory  . . . . . . $enable_memory
1520     multimeter  . . . . $enable_multimeter
1521     mysql . . . . . . . $enable_mysql
1522     network . . . . . . $enable_network
1523     nfs . . . . . . . . $enable_nfs
1524     ntpd  . . . . . . . $enable_ntpd
1525     nut . . . . . . . . $enable_nut
1526     perl  . . . . . . . $enable_perl
1527     ping  . . . . . . . $enable_ping
1528     processes . . . . . $enable_processes
1529     sensors . . . . . . $enable_sensors
1530     serial  . . . . . . $enable_serial
1531     swap  . . . . . . . $enable_swap
1532     syslog  . . . . . . $enable_syslog
1533     tape  . . . . . . . $enable_tape
1534     unixsock  . . . . . $enable_unixsock
1535     users . . . . . . . $enable_users
1536     vserver . . . . . . $enable_vserver
1537     wireless  . . . . . $enable_wireless
1538
1539 EOF