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