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