configure: Build perl bindings only if a perl interpreter is available.
[collectd.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(collectd, m4_esyscmd(./version-gen.sh))
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 AC_MSG_CHECKING([for kernel type ($host_os)])
34 case $host_os in
35         *linux*)
36         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
37         ac_system="Linux"
38         ;;
39         *solaris*)
40         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
41         ac_system="Solaris"
42         ;;
43         *darwin*)
44         ac_system="Darwin"
45         ;;
46         *)
47         ac_system="unknown"
48 esac
49 AC_MSG_RESULT([$ac_system])
50
51 #
52 # Checks for header files.
53 #
54 AC_HEADER_STDC
55 AC_HEADER_SYS_WAIT
56 AC_HEADER_DIRENT
57
58 AC_CHECK_HEADERS(stdint.h stdio.h errno.h math.h stdarg.h syslog.h fcntl.h signal.h assert.h sys/types.h sys/socket.h sys/select.h poll.h netdb.h arpa/inet.h sys/resource.h sys/param.h kstat.h regex.h sys/ioctl.h endian.h)
59
60 # For ping library
61 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
62 [#if HAVE_STDINT_H
63 # include <stdint.h>
64 #endif
65 #if HAVE_SYS_TYPES_H
66 # include <sys/types.h>
67 #endif
68 ])
69 AC_CHECK_HEADERS(netinet/in.h, [], [],
70 [#if HAVE_STDINT_H
71 # include <stdint.h>
72 #endif
73 #if HAVE_SYS_TYPES_H
74 # include <sys/types.h>
75 #endif
76 #if HAVE_NETINET_IN_SYSTM_H
77 # include <netinet/in_systm.h>
78 #endif
79 ])
80 AC_CHECK_HEADERS(netinet/ip.h, [], [],
81 [#if HAVE_STDINT_H
82 # include <stdint.h>
83 #endif
84 #if HAVE_SYS_TYPES_H
85 # include <sys/types.h>
86 #endif
87 #if HAVE_NETINET_IN_SYSTM_H
88 # include <netinet/in_systm.h>
89 #endif
90 #if HAVE_NETINET_IN_H
91 # include <netinet/in.h>
92 #endif
93 ])
94 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
95 [#if HAVE_STDINT_H
96 # include <stdint.h>
97 #endif
98 #if HAVE_SYS_TYPES_H
99 # include <sys/types.h>
100 #endif
101 #if HAVE_NETINET_IN_SYSTM_H
102 # include <netinet/in_systm.h>
103 #endif
104 #if HAVE_NETINET_IN_H
105 # include <netinet/in.h>
106 #endif
107 #if HAVE_NETINET_IP_H
108 # include <netinet/ip.h>
109 #endif
110 ])
111 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
112 [#if HAVE_STDINT_H
113 # include <stdint.h>
114 #endif
115 #if HAVE_SYS_TYPES_H
116 # include <sys/types.h>
117 #endif
118 #if HAVE_NETINET_IN_SYSTM_H
119 # include <netinet/in_systm.h>
120 #endif
121 #if HAVE_NETINET_IN_H
122 # include <netinet/in.h>
123 #endif
124 #if HAVE_NETINET_IP_H
125 # include <netinet/ip.h>
126 #endif
127 ])
128 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
129 [#if HAVE_STDINT_H
130 # include <stdint.h>
131 #endif
132 #if HAVE_SYS_TYPES_H
133 # include <sys/types.h>
134 #endif
135 #if HAVE_NETINET_IN_SYSTM_H
136 # include <netinet/in_systm.h>
137 #endif
138 #if HAVE_NETINET_IN_H
139 # include <netinet/in.h>
140 #endif
141 ])
142 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
143 [#if HAVE_STDINT_H
144 # include <stdint.h>
145 #endif
146 #if HAVE_SYS_TYPES_H
147 # include <sys/types.h>
148 #endif
149 #if HAVE_NETINET_IN_SYSTM_H
150 # include <netinet/in_systm.h>
151 #endif
152 #if HAVE_NETINET_IN_H
153 # include <netinet/in.h>
154 #endif
155 #if HAVE_NETINET_IP6_H
156 # include <netinet/ip6.h>
157 #endif
158 ])
159 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
160 [#if HAVE_STDINT_H
161 # include <stdint.h>
162 #endif
163 #if HAVE_SYS_TYPES_H
164 # include <sys/types.h>
165 #endif
166 #if HAVE_NETINET_IN_SYSTM_H
167 # include <netinet/in_systm.h>
168 #endif
169 #if HAVE_NETINET_IN_H
170 # include <netinet/in.h>
171 #endif
172 #if HAVE_NETINET_IP_H
173 # include <netinet/ip.h>
174 #endif
175 ])
176 AC_CHECK_HEADERS(netinet/udp.h, [], [],
177 [#if HAVE_STDINT_H
178 # include <stdint.h>
179 #endif
180 #if HAVE_SYS_TYPES_H
181 # include <sys/types.h>
182 #endif
183 #if HAVE_NETINET_IN_SYSTM_H
184 # include <netinet/in_systm.h>
185 #endif
186 #if HAVE_NETINET_IN_H
187 # include <netinet/in.h>
188 #endif
189 #if HAVE_NETINET_IP_H
190 # include <netinet/ip.h>
191 #endif
192 ])
193
194 # For cpu modules
195 AC_CHECK_HEADERS(sys/dkstat.h)
196 if test "x$ac_system" = "xDarwin"
197 then
198         AC_CHECK_HEADERS(mach/mach_init.h mach/host_priv.h mach/mach_error.h mach/mach_host.h mach/mach_port.h mach/mach_types.h mach/message.h mach/processor_set.h mach/processor.h mach/processor_info.h mach/task.h mach/thread_act.h mach/vm_region.h mach/vm_map.h mach/vm_prot.h mach/vm_statistics.h mach/kern_return.h)
199         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
200 fi
201 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
202 [
203 #if HAVE_SYS_TYPES_H
204 #  include <sys/types.h>
205 #endif
206 #if HAVE_SYS_PARAM_H
207 # include <sys/param.h>
208 #endif
209 ])
210
211 # For hddtemp module
212 AC_CHECK_HEADERS(linux/major.h libgen.h)
213
214 # For the battery plugin
215 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
216 [
217 #if HAVE_IOKIT_IOKITLIB_H
218 #  include <IOKit/IOKitLib.h>
219 #endif
220 #if HAVE_IOKIT_IOTYPES_H
221 #  include <IOKit/IOTypes.h>
222 #endif
223 ])
224
225 # For the swap module
226 AC_CHECK_HEADERS(sys/swap.h, [], [],
227 [
228 #if HAVE_SYS_TYPES_H
229 #  include <sys/types.h>
230 #endif
231 #if HAVE_SYS_PARAM_H
232 # include <sys/param.h>
233 #endif
234 ])
235
236 # For load module
237 # For the processes plugin
238 # For users module
239 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
240
241 # For interface plugin
242 AC_CHECK_HEADERS(ifaddrs.h)
243 AC_CHECK_HEADERS(net/if.h, [], [],
244 [
245 #if HAVE_SYS_TYPES_H
246 #  include <sys/types.h>
247 #endif
248 #if HAVE_SYS_SOCKET_H
249 #  include <sys/socket.h>
250 #endif
251 ])
252 AC_CHECK_HEADERS(linux/if.h, [], [],
253 [
254 #if HAVE_SYS_TYPES_H
255 #  include <sys/types.h>
256 #endif
257 #if HAVE_SYS_SOCKET_H
258 #  include <sys/socket.h>
259 #endif
260 ])
261 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
262 [
263 #if HAVE_SYS_TYPES_H
264 #  include <sys/types.h>
265 #endif
266 #if HAVE_SYS_SOCKET_H
267 #  include <sys/socket.h>
268 #endif
269 #if HAVE_LINUX_IF_H
270 # include <linux/if.h>
271 #endif
272 ])
273
274 # For ipvs module
275 have_net_ip_vs_h="no"
276 have_ip_vs_h="no"
277 if test "x$ac_system" = "xLinux"
278 then
279         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
280         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
281 fi
282
283 # For quota module
284 AC_CHECK_HEADERS(sys/ucred.h, [], [],
285 [
286 #if HAVE_SYS_TYPES_H
287 #  include <sys/types.h>
288 #endif
289 #if HAVE_SYS_PARAM_H
290 # include <sys/param.h>
291 #endif
292 ])
293
294 # For mount interface
295 AC_CHECK_HEADERS(sys/mount.h, [], [],
296 [
297 #if HAVE_SYS_TYPES_H
298 #  include <sys/types.h>
299 #endif
300 #if HAVE_SYS_PARAM_H
301 # include <sys/param.h>
302 #endif
303 ])
304
305 # For the email plugin
306 AC_CHECK_HEADERS(linux/un.h, [], [],
307 [
308 #if HAVE_SYS_SOCKET_H
309 #       include <sys/socket.h>
310 #endif
311 ])
312
313 AC_CHECK_HEADERS(pwd.h grp.h sys/un.h ctype.h limits.h sys/quota.h xfs/xqm.h fs_info.h fshelp.h paths.h mntent.h mnttab.h sys/fstyp.h sys/fs_types.h sys/mntent.h sys/mnttab.h sys/statfs.h sys/statvfs.h sys/vfs.h sys/vfstab.h kvm.h)
314
315 # For the dns plugin
316 AC_CHECK_HEADERS(arpa/nameser.h)
317 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
318 [
319 #if HAVE_ARPA_NAMESER_H
320 # include <arpa/nameser.h>
321 #endif
322 ])
323
324 AC_CHECK_HEADERS(net/if_arp.h, [], [],
325 [#if HAVE_SYS_SOCKET_H
326 # include <sys/socket.h>
327 #endif
328 ])
329 AC_CHECK_HEADERS(net/ppp_defs.h)
330 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
331 [#if HAVE_NET_PPP_DEFS_H
332 # include <net/ppp_defs.h>
333 #endif
334 ])
335 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
336 [#if HAVE_STDINT_H
337 # include <stdint.h>
338 #endif
339 #if HAVE_SYS_TYPES_H
340 # include <sys/types.h>
341 #endif
342 #if HAVE_SYS_SOCKET_H
343 # include <sys/socket.h>
344 #endif
345 #if HAVE_NET_IF_H
346 # include <net/if.h>
347 #endif
348 #if HAVE_NETINET_IN_H
349 # include <netinet/in.h>
350 #endif
351 ])
352
353 # For the multimeter plugin
354 have_termios_h="no"
355 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
356
357 #
358 # Checks for typedefs, structures, and compiler characteristics.
359 #
360 AC_C_CONST
361 AC_TYPE_PID_T
362 AC_TYPE_SIZE_T
363 AC_TYPE_UID_T
364 AC_HEADER_TIME
365
366 #
367 # Checks for library functions.
368 #
369 AC_PROG_GCC_TRADITIONAL
370 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog)
371
372 AC_FUNC_STRERROR_R
373
374 AC_CACHE_CHECK([for strtok_r],
375   [have_strtok_r_default],
376   AC_LINK_IFELSE(
377     AC_LANG_PROGRAM(
378     [[[[
379 #include <stdlib.h>
380 #include <stdio.h>
381 #include <string.h>
382     ]]]],
383     [[[[
384       char buffer[] = "foo,bar,baz";
385       char *token;
386       char *dummy;
387       char *saveptr;
388
389       dummy = buffer;
390       saveptr = NULL;
391       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
392       {
393         dummy = NULL;
394         printf ("token = %s;\n", token);
395       }
396     ]]]]),
397     [have_strtok_r_default="yes"],
398     [have_strtok_r_default="no"]
399   )
400 )
401
402 if test "x$have_strtok_r_default" = "xno"
403 then
404   SAVE_CFLAGS="$CFLAGS"
405   CFLAGS="$CFLAGS -D_REENTRANT=1"
406
407   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
408     [have_strtok_r_reentrant],
409     AC_LINK_IFELSE(
410       AC_LANG_PROGRAM(
411       [[[[
412 #include <stdlib.h>
413 #include <stdio.h>
414 #include <string.h>
415       ]]]],
416       [[[[
417         char buffer[] = "foo,bar,baz";
418         char *token;
419         char *dummy;
420         char *saveptr;
421
422         dummy = buffer;
423         saveptr = NULL;
424         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
425         {
426           dummy = NULL;
427           printf ("token = %s;\n", token);
428         }
429       ]]]]),
430       [have_strtok_r_reentrant="yes"],
431       [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
432     )
433   )
434 fi
435
436 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
437
438 socket_needs_socket="no"
439 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
440 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
441
442 nanosleep_needs_rt="no"
443 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
444 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
445
446 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
447 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
448 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
449 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
450 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
451 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
452 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
453 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
454 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
455 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
456
457 # For load module
458 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
459
460 # Check for NAN
461 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
462 [
463  if test "x$withval" = "xno"; then
464          nan_type="none"
465  else if test "x$withval" = "xyes"; then
466          nan_type="zero"
467  else
468          nan_type="$withval"
469  fi; fi
470 ],
471 [nan_type="none"])
472 if test "x$nan_type" = "xnone"; then
473   AC_CACHE_CHECK([whether NAN is defined by default],
474     [have_nan_default],
475     AC_COMPILE_IFELSE(
476       AC_LANG_PROGRAM(
477       [[
478 #include <stdlib.h>
479 #include <math.h>
480 static float foo = NAN;
481       ]],
482       [[
483        if (isnan (foo))
484         return 0;
485        else
486         return 1;
487       ]]),
488       [have_nan_default="yes"],
489       [have_nan_default="no"]
490     )
491   )
492   if test "x$have_nan_default" = "xyes"
493   then
494     nan_type="default"
495   fi
496 fi
497 if test "x$nan_type" = "xnone"; then
498   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
499     [have_nan_isoc],
500     AC_COMPILE_IFELSE(
501       AC_LANG_PROGRAM(
502       [[
503 #include <stdlib.h>
504 #define __USE_ISOC99 1
505 #include <math.h>
506 static float foo = NAN;
507       ]],
508       [[
509        if (isnan (foo))
510         return 0;
511        else
512         return 1;
513       ]]),
514       [have_nan_isoc="yes"],
515       [have_nan_isoc="no"]
516     )
517   )
518   if test "x$have_nan_isoc" = "xyes"
519   then
520     nan_type="isoc99"
521   fi
522 fi
523 if test "x$nan_type" = "xnone"; then
524   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
525     [have_nan_zero],
526     AC_RUN_IFELSE(
527       AC_LANG_PROGRAM(
528       [[
529 #include <stdlib.h>
530 #include <math.h>
531 #ifdef NAN
532 # undef NAN
533 #endif
534 #define NAN (0.0 / 0.0)
535 #ifndef isnan
536 # define isnan(f) ((f) != (f))
537 #endif
538 static float foo = NAN;
539       ]],
540       [[
541        if (isnan (foo))
542         return 0;
543        else
544         return 1;
545       ]]),
546       [have_nan_zero="yes"],
547       [have_nan_zero="no"]
548     )
549   )
550   if test "x$have_nan_zero" = "xyes"
551   then
552     nan_type="zero"
553   fi
554 fi
555
556 if test "x$nan_type" = "xdefault"; then
557   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
558     [Define if NAN is defined by default and can initialize static variables.])
559 else if test "x$nan_type" = "xisoc99"; then
560   AC_DEFINE(NAN_STATIC_ISOC, 1,
561     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
562 else if test "x$nan_type" = "xzero"; then
563   AC_DEFINE(NAN_ZERO_ZERO, 1,
564     [Define if NAN can be defined as (0.0 / 0.0)])
565 else
566   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
567 fi; fi; fi
568
569 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
570 [
571  if test "x$withval" = "xnothing"; then
572         fp_layout_type="nothing"
573  else if test "x$withval" = "xendianflip"; then
574         fp_layout_type="endianflip"
575  else if test "x$withval" = "xintswap"; then
576         fp_layout_type="intswap"
577  else
578         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
579 fi; fi; fi
580 ],
581 [fp_layout_type="unknown"])
582
583 if test "x$fp_layout_type" = "xunknown"; then
584   AC_CACHE_CHECK([if doubles are stored in x86 representation],
585     [fp_layout_need_nothing],
586     AC_RUN_IFELSE(
587       AC_LANG_PROGRAM(
588       [[[[
589 #include <stdlib.h>
590 #include <stdio.h>
591 #include <stdint.h>
592 #include <string.h>
593       ]]]],
594       [[[[
595         uint64_t i0;
596         uint64_t i1;
597         uint8_t c[8];
598         double d;
599
600         d = 8.642135e130; 
601         memcpy ((void *) &i0, (void *) &d, 8);
602
603         i1 = i0;
604         memcpy ((void *) c, (void *) &i1, 8);
605
606         if ((c[0] == 0x2f) && (c[1] == 0x25)
607                         && (c[2] == 0xc0) && (c[3] == 0xc7)
608                         && (c[4] == 0x43) && (c[5] == 0x2b)
609                         && (c[6] == 0x1f) && (c[7] == 0x5b))
610                 return (0);
611         else
612                 return (1);
613       ]]]]),
614       [fp_layout_need_nothing="yes"],
615       [fp_layout_need_nothing="no"]
616     )
617   )
618   if test "x$fp_layout_need_nothing" = "xyes"; then
619     fp_layout_type="nothing"
620   fi
621 fi
622 if test "x$fp_layout_type" = "xunknown"; then
623   AC_CACHE_CHECK([if endianflip converts to x86 representation],
624     [fp_layout_need_endianflip],
625     AC_RUN_IFELSE(
626       AC_LANG_PROGRAM(
627       [[[[
628 #include <stdlib.h>
629 #include <stdio.h>
630 #include <stdint.h>
631 #include <string.h>
632 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
633                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
634                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
635                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
636                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
637                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
638                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
639                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
640       ]]]],
641       [[[[
642         uint64_t i0;
643         uint64_t i1;
644         uint8_t c[8];
645         double d;
646
647         d = 8.642135e130; 
648         memcpy ((void *) &i0, (void *) &d, 8);
649
650         i1 = endianflip (i0);
651         memcpy ((void *) c, (void *) &i1, 8);
652
653         if ((c[0] == 0x2f) && (c[1] == 0x25)
654                         && (c[2] == 0xc0) && (c[3] == 0xc7)
655                         && (c[4] == 0x43) && (c[5] == 0x2b)
656                         && (c[6] == 0x1f) && (c[7] == 0x5b))
657                 return (0);
658         else
659                 return (1);
660       ]]]]),
661       [fp_layout_need_endianflip="yes"],
662       [fp_layout_need_endianflip="no"]
663     )
664   )
665   if test "x$fp_layout_need_endianflip" = "xyes"; then
666     fp_layout_type="endianflip"
667   fi
668 fi
669 if test "x$fp_layout_type" = "xunknown"; then
670   AC_CACHE_CHECK([if intswap converts to x86 representation],
671     [fp_layout_need_intswap],
672     AC_RUN_IFELSE(
673       AC_LANG_PROGRAM(
674       [[[[
675 #include <stdlib.h>
676 #include <stdio.h>
677 #include <stdint.h>
678 #include <string.h>
679 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
680                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
681       ]]]],
682       [[[[
683         uint64_t i0;
684         uint64_t i1;
685         uint8_t c[8];
686         double d;
687
688         d = 8.642135e130; 
689         memcpy ((void *) &i0, (void *) &d, 8);
690
691         i1 = intswap (i0);
692         memcpy ((void *) c, (void *) &i1, 8);
693
694         if ((c[0] == 0x2f) && (c[1] == 0x25)
695                         && (c[2] == 0xc0) && (c[3] == 0xc7)
696                         && (c[4] == 0x43) && (c[5] == 0x2b)
697                         && (c[6] == 0x1f) && (c[7] == 0x5b))
698                 return (0);
699         else
700                 return (1);
701       ]]]]),
702       [fp_layout_need_intswap="yes"],
703       [fp_layout_need_intswap="no"]
704     )
705   )
706   if test "x$fp_layout_need_intswap" = "xyes"; then
707     fp_layout_type="intswap"
708   fi
709 fi
710
711 if test "x$fp_layout_type" = "xnothing"; then
712   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
713   [Define if doubles are stored in x86 representation.])
714 else if test "x$fp_layout_type" = "xendianflip"; then
715   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
716   [Define if endianflip is needed to convert to x86 representation.])
717 else if test "x$fp_layout_type" = "xintswap"; then
718   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
719   [Define if intswap is needed to convert to x86 representation.])
720 else
721   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
722 fi; fi; fi
723
724 have_getfsstat="no"
725 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
726 have_getvfsstat="no"
727 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
728 have_listmntent="no"
729 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
730
731 have_getmntent="no"
732 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
733 if test "x$have_getmntent" = "xno"; then
734         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
735 fi
736 if test "x$have_getmntent" = "xno"; then
737         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
738 fi
739 if test "x$have_getmntent" = "xno"; then
740         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
741 fi
742
743 if test "x$have_getmntent" = "xc"; then
744         AC_CACHE_CHECK([whether getmntent takes one argument],
745                 [have_one_getmntent],
746                 AC_COMPILE_IFELSE(
747                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
748 #include <mntent.h>
749 #include "$srcdir/src/utils_mount.h"]],
750                                 [[
751                                  FILE *fh;
752                                  struct mntent *me;
753                                  fh = setmntent ("/etc/mtab", "r");
754                                  me = getmntent (fh);
755                                 ]]
756                         ),
757                         [have_one_getmntent="yes"],
758                         [have_one_getmntent="no"]
759                 )
760         )
761         AC_CACHE_CHECK([whether getmntent takes two arguments],
762                 [have_two_getmntent],
763                 AC_COMPILE_IFELSE(
764                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
765 #include <sys/mnttab.h>
766 #include "$srcdir/src/utils_mount.h"]],
767                                 [[
768                                  FILE *fh;
769                                  struct mnttab mt;
770                                  int status;
771                                  fh = fopen ("/etc/mnttab", "r");
772                                  status = getmntent (fh, &mt);
773                                 ]]
774                         ),
775                         [have_two_getmntent="yes"],
776                         [have_two_getmntent="no"]
777                 )
778         )
779 fi
780
781 # Check for different versions of `getmntent' here..
782
783 if test "x$have_getmntent" = "xc"; then
784         if test "x$have_one_getmntent" = "xyes"; then
785                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
786                           [Define if the function getmntent exists and takes one argument.])
787         fi
788         if test "x$have_two_getmntent" = "xyes"; then
789                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
790                           [Define if the function getmntent exists and takes two arguments.])
791         fi
792 fi
793 if test "x$have_getmntent" = "xsun"; then
794         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
795                   [Define if the function getmntent exists. It's the version from libsun.])
796 fi
797 if test "x$have_getmntent" = "xseq"; then
798         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
799                   [Define if the function getmntent exists. It's the version from libseq.])
800 fi
801 if test "x$have_getmntent" = "xgen"; then
802         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
803                   [Define if the function getmntent exists. It's the version from libgen.])
804 fi
805
806 # Check for structures
807 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
808         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
809         [],
810         [
811         #include <sys/types.h>
812         #include <sys/socket.h>
813         #include <net/if.h>
814         ])
815 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
816         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
817         [],
818         [
819         #include <sys/types.h>
820         #include <sys/socket.h>
821         #include <linux/if.h>
822         #include <linux/netdevice.h>
823         ])
824
825 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
826 [#if HAVE_STDINT_H
827 # include <stdint.h>
828 #endif
829 #if HAVE_SYS_TYPES_H
830 # include <sys/types.h>
831 #endif
832 #if HAVE_NETINET_IN_SYSTM_H
833 # include <netinet/in_systm.h>
834 #endif
835 #if HAVE_NETINET_IN_H
836 # include <netinet/in.h>
837 #endif
838 #if HAVE_NETINET_IP_H
839 # include <netinet/ip.h>
840 #endif
841 #if HAVE_NETINET_UDP_H
842 # include <netinet/udp.h>
843 #endif
844 ])
845 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
846 [#if HAVE_STDINT_H
847 # include <stdint.h>
848 #endif
849 #if HAVE_SYS_TYPES_H
850 # include <sys/types.h>
851 #endif
852 #if HAVE_NETINET_IN_SYSTM_H
853 # include <netinet/in_systm.h>
854 #endif
855 #if HAVE_NETINET_IN_H
856 # include <netinet/in.h>
857 #endif
858 #if HAVE_NETINET_IP_H
859 # include <netinet/ip.h>
860 #endif
861 #if HAVE_NETINET_UDP_H
862 # include <netinet/udp.h>
863 #endif
864 ])
865
866 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
867         [],
868         [],
869         [
870 #if HAVE_KSTAT_H
871 # include <kstat.h>
872 #endif
873         ])
874
875 with_libresolv="yes"
876 AC_CHECK_LIB(resolv, res_search,
877 [
878         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
879 ],
880 [with_libresolv="no"])
881 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
882
883
884 m4_divert_once([HELP_WITH], [
885 collectd additional packages:])
886
887 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
888 librrd_cflags=""
889 librrd_ldflags=""
890 librrd_threadsafe="yes"
891 AC_ARG_WITH(rrdtool, [AS_HELP_STRING([--with-rrdtool@<:@=PREFIX@:>@], [Path to rrdtool.])],
892 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
893         then
894                 librrd_cflags="-I$withval/include"
895                 librrd_ldflags="-L$withval/lib"
896                 with_rrdtool="yes"
897         fi
898 ], [with_rrdtool="yes"])
899 if test "x$with_rrdtool" = "xyes"
900 then
901         SAVE_CPPFLAGS="$CPPFLAGS"
902         SAVE_LDFLAGS="$LDFLAGS"
903
904         CPPFLAGS="$CPPFLAGS $librrd_cflags"
905         LDFLAGS="$LDFLAGS $librrd_ldflags"
906
907         AC_CHECK_HEADERS(rrd.h,, [with_rrdtool="no (rrd.h not found)"])
908
909         CPPFLAGS="$SAVE_CPPFLAGS"
910         LDFLAGS="$SAVE_LDFLAGS"
911 fi
912 if test "x$with_rrdtool" = "xyes"
913 then
914         SAVE_CPPFLAGS="$CPPFLAGS"
915         SAVE_LDFLAGS="$LDFLAGS"
916
917         CPPFLAGS="$CPPFLAGS $librrd_cflags"
918         LDFLAGS="$LDFLAGS $librrd_ldflags"
919
920         AC_CHECK_LIB(rrd_th, rrd_update_r,
921         [with_rrdtool="yes"
922          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
923         ],
924         [librrd_threadsafe="no"
925          AC_CHECK_LIB(rrd, rrd_update,
926          [with_rrdtool="yes"
927           librrd_ldflags="$librrd_ldflags -lrrd -lm"
928          ],
929          [with_rrdtool="no (symbol 'rrd_update' not found)"],
930          [-lm])
931         ],
932         [-lm])
933
934         CPPFLAGS="$SAVE_CPPFLAGS"
935         LDFLAGS="$SAVE_LDFLAGS"
936 fi
937 if test "x$with_rrdtool" = "xyes"
938 then
939         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
940         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
941         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
942         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
943 fi
944 if test "x$librrd_threadsafe" = "xyes"
945 then
946         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
947 fi
948
949 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
950 [       if test "x$withval" != "xno" -a "x$withval" != "xyes"
951         then
952                 LDFLAGS="$LDFLAGS -L$withval/lib"
953                 CPPFLAGS="$CPPFLAGS -I$withval/include"
954                 with_libpthread="yes"
955         else
956                 if test "x$withval" = "xno"
957                 then
958                         with_libpthread="no (disabled)"
959                 fi
960         fi
961 ], [with_libpthread="yes"])
962 if test "x$with_libpthread" = "xyes"
963 then
964         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
965 fi
966 if test "x$with_libpthread" = "xyes"
967 then
968         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
969 fi
970 if test "x$with_libpthread" = "xyes"
971 then
972         collect_pthread=1
973 else
974         collect_pthread=0
975 fi
976 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
977         [Wether or not to use pthread (POSIX threads) library])
978 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
979
980 if test "x$ac_system" = "xSolaris"
981 then
982         with_kstat="yes"
983         with_devinfo="yes"
984 else
985         with_kstat="no (Solaris only)"
986         with_devinfo="no (Solaris only)"
987 fi
988
989 if test "x$with_kstat" = "xyes"
990 then
991         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
992 fi
993 if test "x$with_kstat" = "xyes"
994 then
995         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
996         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
997 fi
998 if test "x$with_kstat" = "xyes"
999 then
1000         AC_DEFINE(HAVE_LIBKSTAT, 1,
1001                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1002 fi
1003 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1004 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1005
1006 ### BEGIN of check for libcurl ###
1007 with_curl_config="curl-config"
1008 with_curl_cflags=""
1009 with_curl_libs=""
1010 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
1011 [
1012         if test "x$withval" = "xno"
1013         then
1014                 with_libcurl="no"
1015         else if test "x$withval" = "xyes"
1016         then
1017                 with_libcurl="yes"
1018         else
1019                 if test -f "$withval" && test -x "$withval"
1020                 then
1021                         with_curl_config="$withval"
1022                         with_libcurl="yes"
1023                 else if test -x "$withval/bin/curl-config"
1024                 then
1025                         with_curl_config="$withval/bin/curl-config"
1026                         with_libcurl="yes"
1027                 fi; fi
1028                 with_libcurl="yes"
1029         fi; fi
1030 ],
1031 [
1032         with_libcurl="yes"
1033 ])
1034 if test "x$with_libcurl" = "xyes"
1035 then
1036         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1037         curl_config_status=$?
1038
1039         if test $curl_config_status -ne 0
1040         then
1041                 with_libcurl="no ($with_curl_config failed)"
1042         else
1043                 SAVE_CPPFLAGS="$CPPFLAGS"
1044                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1045
1046                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1047
1048                 CPPFLAGS="$SAVE_CPPFLAGS"
1049         fi
1050 fi
1051 if test "x$with_libcurl" = "xyes"
1052 then
1053         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1054         curl_config_status=$?
1055
1056         if test $curl_config_status -ne 0
1057         then
1058                 with_libcurl="no ($with_curl_config failed)"
1059         else
1060                 AC_CHECK_LIB(curl, curl_easy_init,
1061                  [with_libcurl="yes"],
1062                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1063                  [$with_curl_libs])
1064         fi
1065 fi
1066 if test "x$with_libcurl" = "xyes"
1067 then
1068         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1069         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1070         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1071         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1072 fi
1073 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1074 ### END of check for libcurl ###
1075
1076 with_libiokit="no"
1077 collectd_libiokit=0
1078 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1079 [
1080         with_libiokit="yes"
1081         collectd_libiokit=1
1082 ], 
1083 [
1084         with_libiokit="no"
1085         collectd_libiokit=0
1086 ])
1087 AC_DEFINE_UNQUOTED(COLLECT_LIBIOKIT, [$collect_libiokit], [Wether or not to use the IOKit library])
1088 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1089
1090 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
1091 [
1092         if test "x$withval" != "xno" -a "x$withval" != "xyes"
1093         then
1094                 LDFLAGS="$LDFLAGS -L$withval/lib"
1095                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1096                 with_libstatgrab="yes"
1097         fi
1098 ],
1099 [
1100         if test "x$ac_system" == "xunknown"
1101         then
1102                 with_libstatgrab="yes"
1103         else
1104                 with_libstatgrab="no"
1105         fi
1106 ])
1107 if test "x$with_libstatgrab" = "xyes"
1108 then
1109         AC_CHECK_LIB(statgrab, sg_init, [with_libstatgrab="yes"], [with_libstatgrab="no (libstatgrab not found)"])
1110 fi
1111 if test "x$with_libstatgrab" = "xyes"
1112 then
1113         AC_CHECK_HEADERS(statgrab.h,,    [with_libstatgrab="no (statgrab.h not found)"])
1114 fi
1115 if test "x$with_libstatgrab" = "xyes"
1116 then
1117         AC_CHECK_LIB(devstat, getdevs, [with_libdevstat="yes"], [with_libdevstat="no"])
1118 fi
1119 if test "x$with_libstatgrab" = "xyes"
1120 then
1121         collect_libstatgrab=1
1122 else
1123         collect_libstatgrab=0
1124 fi
1125 AC_DEFINE_UNQUOTED(COLLECT_LIBSTATGRAB, [$collect_libstatgrab],
1126         [Wether or not to use statgrab library])
1127 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
1128 AM_CONDITIONAL(BUILD_WITH_LIBDEVSTAT,  test "x$with_libdevstat"  = "xyes")
1129
1130 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_libkvm="yes"], [with_libkvm="no"])
1131 if test "x$with_libkvm" = "xyes"
1132 then
1133         AC_DEFINE(HAVE_LIBKVM, 1, [Define to 1 if you have the 'kvm' library (-lkvm)])
1134 fi
1135 AM_CONDITIONAL(BUILD_WITH_LIBKVM, test "x$with_libkvm" = "xyes")
1136
1137 with_sensors_cflags=""
1138 with_sensors_ldflags=""
1139 AC_ARG_WITH(lm-sensors, [AS_HELP_STRING([--with-lm-sensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
1140 [
1141         if test "x$withval" = "xno"
1142         then
1143                 with_lm_sensors="no"
1144         else
1145                 with_lm_sensors="yes"
1146                 if test "x$withval" != "xyes"
1147                 then
1148                         with_sensors_cflags="-I$withval/include"
1149                         with_sensors_ldflags="-L$withval/lib"
1150                         with_lm_sensors="yes"
1151                 fi
1152         fi
1153 ],
1154 [
1155         if test "x$ac_system" = "xLinux"
1156         then
1157                 with_lm_sensors="yes"
1158         else
1159                 with_lm_sensors="no (Linux only library)"
1160         fi
1161 ])
1162 if test "x$with_lm_sensors" = "xyes"
1163 then
1164         SAVE_CPPFLAGS="$CPPFLAGS"
1165         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1166
1167 #       AC_CHECK_HEADERS(sensors/sensors.h,
1168 #       [
1169 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
1170 #       ],
1171 #       [with_lm_sensors="no (sensors/sensors.h not found)"])
1172         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_lm_sensors="no (sensors/sensors.h not found)"])
1173
1174         CPPFLAGS="$SAVE_CPPFLAGS"
1175 fi
1176 if test "x$with_lm_sensors" = "xyes"
1177 then
1178         SAVE_CPPFLAGS="$CPPFLAGS"
1179         SAVE_LDFLAGS="$LDFLAGS"
1180         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
1181         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
1182
1183         AC_CHECK_LIB(sensors, sensors_init,
1184         [
1185                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
1186         ],
1187         [with_lm_sensors="no (libsensors not found)"])
1188
1189         CPPFLAGS="$SAVE_CPPFLAGS"
1190         LDFLAGS="$SAVE_LDFLAGS"
1191 fi
1192 if test "x$with_lm_sensors" = "xyes"
1193 then
1194         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
1195         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
1196         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
1197         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
1198 fi
1199 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_lm_sensors" = "xyes")
1200
1201 with_mysql_config="mysql_config"
1202 with_mysql_cflags=""
1203 with_mysql_libs=""
1204 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1205 [
1206         if test "x$withval" = "xno"
1207         then
1208                 with_libmysql="no"
1209         else if test "x$withval" = "xyes"
1210         then
1211                 with_libmysql="yes"
1212         else
1213                 if test -f "$withval" && test -x "$withval";
1214                 then
1215                         with_mysql_config="$withval"
1216                 else if test -x "$withval/bin/mysql_config"
1217                 then
1218                         with_mysql_config="$withval/bin/mysql_config"
1219                 fi; fi
1220                 with_libmysql="yes"
1221         fi; fi
1222 ],
1223 [
1224         with_libmysql="yes"
1225 ])
1226 if test "x$with_libmysql" = "xyes"
1227 then
1228         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1229         mysql_config_status=$?
1230
1231         if test $mysql_config_status -ne 0
1232         then
1233                 with_libmysql="no"
1234         else
1235                 SAVE_CPPFLAGS="$CPPFLAGS"
1236                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1237
1238                 AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
1239
1240                 CPPFLAGS="$SAVE_CPPFLAGS"
1241         fi
1242 fi
1243 if test "x$with_libmysql" = "xyes"
1244 then
1245         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1246         mysql_config_status=$?
1247
1248         if test $mysql_config_status -ne 0
1249         then
1250                 with_libmysql="no"
1251         else
1252                 AC_CHECK_LIB(mysqlclient, mysql_init,
1253                  [with_libmysql="yes"],
1254                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1255                  [$with_mysql_libs])
1256         fi
1257 fi
1258 if test "x$with_libmysql" = "xyes"
1259 then
1260         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1261         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1262         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1263         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1264 fi
1265 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1266
1267 with_own_liboconfig="no"
1268 liboconfig_LDFLAGS="$LDFLAGS"
1269 liboconfig_CPPFLAGS="$CPPFLAGS"
1270 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1271 [
1272         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1273         then
1274                 if test -d "$withval/lib"
1275                 then
1276                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1277                 fi
1278                 if test -d "$withval/include"
1279                 then
1280                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1281                 fi
1282         fi
1283         if test "x$withval" = "xno"
1284         then
1285                 AC_MSG_ERROR("liboconfig is required")
1286         fi
1287 ],
1288 [
1289         with_liboconfig="yes"
1290 ])
1291
1292 save_LDFLAGS="$LDFLAGS"
1293 save_CPPFLAGS="$CPPFLAGS"
1294 LDFLAGS="$liboconfig_LDFLAGS"
1295 CPPFLAGS="$liboconfig_CPPFLAGS"
1296 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1297 [
1298         with_liboconfig="yes"
1299         with_own_liboconfig="no"
1300 ],
1301 [
1302         with_liboconfig="yes"
1303         with_own_liboconfig="yes"
1304         LDFLAGS="$save_LDFLAGS"
1305         CPPFLAGS="$save_CPPFLAGS"
1306 ])
1307
1308 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1309 if test "x$with_own_liboconfig" = "xyes"
1310 then
1311         with_liboconfig="yes (shipped version)"
1312 fi
1313
1314 #with_liboping="yes"
1315 with_own_liboping="no"
1316 liboping_LDFLAGS="$LDFLAGS"
1317 liboping_CPPFLAGS="$CPPFLAGS"
1318 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1319 [
1320         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1321         then
1322                 if test -d "$withval/lib"
1323                 then
1324                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1325                 fi
1326                 if test -d "$withval/include"
1327                 then
1328                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1329                 fi
1330         fi
1331         if test "x$withval" = "xno"
1332         then
1333                 with_liboping="no"
1334                 with_own_liboping="no"
1335         fi
1336 ],
1337 [
1338         #753
1339         with_liboping="yes"
1340 ])
1341
1342 if test "x$with_liboping" = "xyes"
1343 then
1344         save_LDFLAGS="$LDFLAGS"
1345         save_CPPFLAGS="$CPPFLAGS"
1346         LDFLAGS="$liboping_LDFLAGS"
1347         CPPFLAGS="$liboping_CPPFLAGS"
1348         AC_CHECK_LIB(oping, ping_construct,
1349         [
1350                 with_liboping="yes"
1351                 with_own_liboping="no"
1352         ],
1353         [
1354                 with_liboping="yes"
1355                 with_own_liboping="yes"
1356                 LDFLAGS="$save_LDFLAGS"
1357                 CPPFLAGS="$save_CPPFLAGS"
1358         ])
1359 fi
1360 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1361 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1362
1363 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1364 [
1365         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1366         then
1367                 LDFLAGS="$LDFLAGS -L$withval/lib"
1368                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1369                 with_libpcap="yes"
1370         fi
1371 ],
1372 [
1373         with_libpcap="yes"
1374 ])
1375 if test "x$with_libpcap" = "xyes"
1376 then
1377         AC_CHECK_LIB(pcap, pcap_open_live,
1378         [
1379                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1380         ], [with_libpcap="no (libpcap not found)"])
1381 fi
1382 if test "x$with_libpcap" = "xyes"
1383 then
1384         AC_CHECK_HEADERS(pcap.h,
1385         [
1386                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1387         ], [with_libpcap="no (pcap.h not found)"])
1388 fi
1389 if test "x$with_libpcap" = "xyes"
1390 then
1391         collect_libpcap=1
1392 else
1393         collect_libpcap=0
1394 fi
1395 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1396         [Wether or not to use the pcap library])
1397 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1398
1399 perl_interpreter="perl"
1400 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1401 [
1402         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1403         then
1404                 LDFLAGS="$LDFLAGS -L$withval/lib"
1405                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1406                 perl_interpreter="$withval/bin/perl"
1407                 with_libperl="yes"
1408         fi
1409 ],
1410 [
1411         with_libperl="yes"
1412 ])
1413
1414 AC_MSG_CHECKING([for perl])
1415 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
1416 if test -x "$perl_interpreter"
1417 then
1418         AC_MSG_RESULT([yes])
1419 else
1420         perl_interpreter=""
1421         AC_MSG_RESULT([no])
1422 fi
1423
1424 AC_SUBST(PERL, "$perl_interpreter")
1425
1426 if test "x$with_libperl" = "xyes" -a -n "$perl_interpreter"
1427 then
1428   SAVE_CFLAGS=$CFLAGS
1429   SAVE_LDFLAGS=$LDFLAGS
1430   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1431   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1432   CFLAGS="$CFLAGS $PERL_CFLAGS"
1433   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1434
1435   AC_CACHE_CHECK([for libperl],
1436     [have_libperl],
1437     AC_LINK_IFELSE(
1438       AC_LANG_PROGRAM(
1439       [[
1440 #include <EXTERN.h>
1441 #include <perl.h>
1442 #include <XSUB.h>
1443       ]],
1444       [[
1445        PerlInterpreter *perl = NULL;
1446        Perl_load_module (perl, PERL_LOADMOD_NOIMPORT,
1447                          newSVpv ("Collectd::Plugin::FooBar", 24),
1448                          Nullsv);
1449       ]]),
1450       [have_libperl="yes"],
1451       [have_libperl="no"]
1452     )
1453   )
1454
1455   if test "x$have_libperl" = "xyes"
1456   then
1457           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1458           AC_SUBST(PERL_CFLAGS)
1459           AC_SUBST(PERL_LDFLAGS)
1460   else
1461           with_libperl="no"
1462   fi
1463
1464   CFLAGS=$SAVE_CFLAGS
1465   LDFLAGS=$SAVE_LDFLAGS
1466 else if test -z "$perl_interpreter"; then
1467   with_libperl="no (no perl interpreter found)"
1468   have_libperl="no"
1469 fi; fi
1470 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1471
1472 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1473 [
1474         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1475         then
1476                 LDFLAGS="$LDFLAGS -L$withval/lib"
1477                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1478                 with_libiptc="yes"
1479         fi
1480 ],
1481 [
1482         if test "x$ac_system" = "xLinux"
1483         then
1484                 with_libiptc="yes"
1485         else
1486                 with_libiptc="no (Linux only)"
1487         fi
1488 ])
1489 if test "x$with_libiptc" = "xyes"
1490 then
1491         AC_CHECK_LIB(iptc, iptc_init,
1492         [
1493                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1494         ], [with_libiptc="no (libiptc not found)"])
1495 fi
1496 if test "x$with_libiptc" = "xyes"
1497 then
1498         AC_CHECK_HEADERS(libiptc/libiptc.h,
1499         [
1500                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1501         ], [with_libiptc="no (libiptc/libiptc.h not found)"])
1502 fi
1503 if test "x$with_libiptc" = "xyes"
1504 then
1505         collect_libiptc=1
1506 else
1507         collect_libiptc=0
1508 fi
1509 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1510
1511 with_snmp_config="net-snmp-config"
1512 with_snmp_cflags=""
1513 with_snmp_libs=""
1514 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1515 [
1516         if test "x$withval" = "xno"
1517         then
1518                 with_libnetsnmp="no"
1519         else if test "x$withval" = "xyes"
1520         then
1521                 with_libnetsnmp="yes"
1522         else
1523                 if test -x "$withval"
1524                 then
1525                         with_snmp_config="$withval"
1526                         with_libnetsnmp="yes"
1527                 else
1528                         with_snmp_config="$withval/bin/net-snmp-config"
1529                         with_libnetsnmp="yes"
1530                 fi
1531         fi; fi
1532 ],
1533 [with_libnetsnmp="yes"])
1534 if test "x$with_libnetsnmp" = "xyes"
1535 then
1536         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1537         snmp_config_status=$?
1538
1539         if test $snmp_config_status -ne 0
1540         then
1541                 with_libnetsnmp="no ($with_snmp_config failed)"
1542         else
1543                 SAVE_CPPFLAGS="$CPPFLAGS"
1544                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1545                 
1546                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1547
1548                 CPPFLAGS="$SAVE_CPPFLAGS"
1549         fi
1550 fi
1551 if test "x$with_libnetsnmp" = "xyes"
1552 then
1553         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1554         snmp_config_status=$?
1555
1556         if test $snmp_config_status -ne 0
1557         then
1558                 with_libnetsnmp="no ($with_snmp_config failed)"
1559         else
1560                 AC_CHECK_LIB(netsnmp, init_snmp,
1561                 [with_libnetsnmp="yes"],
1562                 [with_libnetsnmp="no (libnetsnmp not found)"],
1563                 [$with_snmp_libs])
1564         fi
1565 fi
1566 if test "x$with_libnetsnmp" = "xyes"
1567 then
1568         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1569         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1570         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1571         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1572 fi
1573 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1574
1575 with_upsclient_config="libupsclient-config"
1576 with_upsclient_cflags=""
1577 with_upsclient_libs=""
1578 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to libupsclient.])],
1579 [
1580         if test "x$withval" = "xno"
1581         then
1582                 with_libupsclient="no"
1583         else
1584                 if test "x$withval" != "xyes"
1585                 then
1586                         if test -f "$withval" && test -x "$withval";
1587                         then
1588                                 with_upsclient_config="$withval"
1589                         else
1590                                 with_upsclient_config="$withval/bin/libupsclient-config"
1591                         fi
1592                 fi
1593                 with_libupsclient="yes"
1594         fi
1595 ],
1596 [
1597         with_libupsclient="yes"
1598 ])
1599 if test "x$with_libupsclient" = "xyes"
1600 then
1601         with_upsclient_cflags=`$with_upsclient_config --cflags 2>/dev/null`
1602         upsclient_config_status=$?
1603
1604         if test $upsclient_config_status -ne 0
1605         then
1606                 with_libupsclient="no ($with_upsclient_config failed)"
1607         fi
1608 fi
1609 if test "x$with_libupsclient" = "xyes"
1610 then
1611         SAVE_CPPFLAGS="$CPPFLAGS"
1612         CPPFLAGS="$CPPFLAGS $with_upsclient_cflags"
1613
1614         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
1615
1616         CPPFLAGS="$SAVE_CPPFLAGS"
1617 fi
1618 if test "x$with_libupsclient" = "xyes"
1619 then
1620         with_upsclient_libs=`$with_upsclient_config --libs 2>/dev/null`
1621         upsclient_config_status=$?
1622
1623         if test $upsclient_config_status -ne 0
1624         then
1625                 with_libupsclient="no ($with_upsclient_config failed)"
1626         fi
1627 fi
1628 if test "x$with_libupsclient" = "xyes"
1629 then
1630         AC_CHECK_LIB(upsclient, upscli_connect,
1631         [
1632                 BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_upsclient_cflags"
1633                 BUILD_WITH_LIBUPSCLIENT_LIBS="$with_upsclient_libs"
1634                 AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
1635                 AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
1636         ],
1637         [
1638                 with_libupsclient="no (symbol 'upscli_connect' not found)"
1639         ], [$with_upsclient_libs])
1640 fi
1641 if test "x$with_libupsclient" = "xyes"
1642 then
1643         SAVE_CPPFLAGS="$CPPFLAGS"
1644         CPPFLAGS="$CPPFLAGS $with_upsclient_cflags"
1645
1646         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [], 
1647 [#include <stdlib.h>
1648 #include <stdio.h>
1649 #include <upsclient.h>])
1650
1651         CPPFLAGS="$SAVE_CPPFLAGS"
1652 fi
1653 AM_CONDITIONAL(BUILD_WITH_LIBUPSCLIENT, test "x$with_libupsclient" = "xyes")
1654
1655 ### BEGIN of check for libxmms ###
1656 with_xmms_config="xmms-config"
1657 with_xmms_cflags=""
1658 with_xmms_libs=""
1659 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
1660 [
1661         if test "x$withval" != "xno" -a "x$withval" != "xyes"
1662         then
1663                 if test -f "$withval" && test -x "$withval";
1664                 then
1665                         with_xmms_config="$withval"
1666                 else if test -x "$withval/bin/xmms-config"
1667                 then
1668                         with_xmms_config="$withval/bin/xmms-config"
1669                 fi; fi
1670                 with_libxmms="yes"
1671         else if test "x$withval" = "xno"
1672         then
1673                 with_libxmms="no"
1674         else
1675                 with_libxmms="yes"
1676         fi; fi
1677 ],
1678 [
1679         with_libxmms="yes"
1680 ])
1681 if test "x$with_libxmms" = "xyes"
1682 then
1683         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
1684         xmms_config_status=$?
1685
1686         if test $xmms_config_status -ne 0
1687         then
1688                 with_libxmms="no"
1689         fi
1690 fi
1691 if test "x$with_libxmms" = "xyes"
1692 then
1693         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
1694         xmms_config_status=$?
1695
1696         if test $xmms_config_status -ne 0
1697         then
1698                 with_libxmms="no"
1699         fi
1700 fi
1701 if test "x$with_libxmms" = "xyes"
1702 then
1703         AC_CHECK_LIB(xmms, xmms_remote_get_info,
1704         [
1705                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
1706                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
1707                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
1708                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
1709         ],
1710         [
1711                 with_libxmms="no"
1712         ],
1713         [$with_xmms_libs])
1714 fi
1715 with_libxmms_numeric=0
1716 if test "x$with_libxmms" = "xyes"
1717 then
1718         with_libxmms_numeric=1
1719 fi
1720 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
1721 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
1722 ### END of check for libxmms ###
1723
1724 with_libnetlink_cflags=""
1725 with_libnetlink_libs="-lnetlink"
1726 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1727 [
1728  echo "libnetlink: withval = $withval"
1729  if test "x$withval" = "xyes"
1730  then
1731          with_libnetlink="yes"
1732  else if test "x$withval" = "xno"
1733  then
1734          with_libnetlink="no"
1735  else
1736          if test -d "$withval/include"
1737          then
1738                  with_libnetlink_cflags="-I$withval/include"
1739                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1740                  with_libnetlink="yes"
1741          else
1742                  AC_MSG_ERROR("no such directory: $withval/include")
1743          fi
1744  fi; fi
1745 ],
1746 [
1747  if test "x$ac_system" = "xLinux"
1748  then
1749          with_libnetlink="yes"
1750  else
1751          with_libnetlink="no (Linux only library)"
1752  fi
1753 ])
1754 if test "x$with_libnetlink" = "xyes"
1755 then
1756         SAVE_CFLAGS=$CFLAGS
1757         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1758
1759         with_libnetlink="no (libnetlink.h not found)"
1760
1761         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1762         [
1763          with_libnetlink="yes"
1764          break
1765         ], [],
1766 [#include <stdio.h>
1767 #include <sys/types.h>
1768 #include <asm/types.h>
1769 #include <sys/socket.h>
1770 #include <linux/netlink.h>
1771 #include <linux/rtnetlink.h>])
1772         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1773 [#include <stdio.h>
1774 #include <sys/types.h>
1775 #include <asm/types.h>
1776 #include <sys/socket.h>])
1777
1778         AC_COMPILE_IFELSE(
1779 [#include <stdio.h>
1780 #include <sys/types.h>
1781 #include <asm/types.h>
1782 #include <sys/socket.h>
1783 #include <linux/netlink.h>
1784 #include <linux/rtnetlink.h>
1785
1786 int main (void)
1787 {
1788         int retval = TCA_STATS2;
1789         return (retval);
1790 }],
1791         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1792         []);
1793
1794         AC_COMPILE_IFELSE(
1795 [#include <stdio.h>
1796 #include <sys/types.h>
1797 #include <asm/types.h>
1798 #include <sys/socket.h>
1799 #include <linux/netlink.h>
1800 #include <linux/rtnetlink.h>
1801
1802 int main (void)
1803 {
1804         int retval = TCA_STATS;
1805         return (retval);
1806 }],
1807         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1808         []);
1809
1810         CFLAGS="$SAVE_CFLAGS"
1811 fi
1812 if test "x$with_libnetlink" = "xyes"
1813 then
1814         AC_CHECK_LIB(netlink, rtnl_open,
1815                      [with_libnetlink="yes"],
1816                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1817                      [$with_libnetlink_libs])
1818 fi
1819 if test "x$with_libnetlink" = "xyes"
1820 then
1821         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1822         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1823         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1824         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1825 fi
1826 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1827
1828 # Check for enabled/disabled features
1829 #
1830
1831 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
1832 # ------------------------------------------------------------
1833 dnl
1834 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
1835 dnl
1836 AC_DEFUN(
1837         [AC_COLLECTD],
1838         [
1839         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
1840         m4_if(
1841                 [$2],
1842                 [enable],
1843                 [dnl
1844                 m4_define([EnDis],[disabled])dnl
1845                 m4_define([YesNo],[no])dnl
1846                 ],dnl
1847                 [m4_if(
1848                         [$2],
1849                         [disable],
1850                         [dnl
1851                         m4_define([EnDis],[enabled])dnl
1852                         m4_define([YesNo],[yes])dnl
1853                         ],
1854                         [dnl
1855                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
1856                         ]dnl
1857                 )]dnl
1858         )dnl
1859         m4_if([$3], [feature], [],
1860                 [m4_if(
1861                         [$3], [module], [],
1862                         [dnl
1863                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
1864                         ]dnl
1865                 )]dnl
1866         )dnl
1867         AC_ARG_ENABLE(
1868                 [$1],
1869                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
1870                 [],
1871                 enable_$1='[YesNo]'dnl
1872         )# AC_ARG_ENABLE
1873 if test "x$enable_$1" = "xno"
1874 then
1875         collectd_$1=0
1876 else
1877         if test "x$enable_$1" = "xyes"
1878         then
1879                 collectd_$1=1
1880         else
1881                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
1882                 collectd_$1=1
1883                 enable_$1='yes'
1884         fi
1885 fi
1886         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
1887         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
1888         ]dnl
1889 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
1890
1891 # AC_PLUGIN(name, default, info)
1892 # ------------------------------------------------------------
1893 dnl
1894 AC_DEFUN(
1895   [AC_PLUGIN],
1896   [
1897     enable_plugin="no"
1898     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
1899     [
1900      if test "x$enableval" = "xyes"
1901      then
1902              enable_plugin="yes"
1903      else
1904              enable_plugin="no"
1905      fi
1906     ],
1907     [
1908      if test "x$2" = "xyes"
1909      then
1910              enable_plugin="yes"
1911      else
1912              enable_plugin="no"
1913      fi
1914     ])
1915     if test "x$enable_plugin" = "xyes"
1916     then
1917             AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
1918     fi
1919     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
1920     enable_$1="$enable_plugin"
1921   ]
1922 )# AC_PLUGIN(name, default, info)
1923
1924 m4_divert_once([HELP_ENABLE], [
1925 collectd features:])
1926 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
1927 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
1928 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
1929 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
1930
1931 plugin_battery="no"
1932 plugin_cpu="no"
1933 plugin_cpufreq="no"
1934 plugin_df="no"
1935 plugin_disk="no"
1936 plugin_entropy="no"
1937 plugin_interface="no"
1938 plugin_ipvs="no"
1939 plugin_irq="no"
1940 plugin_load="no"
1941 plugin_memory="no"
1942 plugin_multimeter="no"
1943 plugin_nfs="no"
1944 plugin_processes="no"
1945 plugin_serial="no"
1946 plugin_swap="no"
1947 plugin_tape="no"
1948 plugin_tcpconns="no"
1949 plugin_users="no"
1950 plugin_vserver="no"
1951 plugin_wireless="no"
1952
1953 # Linux
1954 if test "x$ac_system" = "xLinux"
1955 then
1956         plugin_battery="yes"
1957         plugin_cpu="yes"
1958         plugin_cpufreq="yes"
1959         plugin_disk="yes"
1960         plugin_entropy="yes"
1961         plugin_interface="yes"
1962         plugin_irq="yes"
1963         plugin_load="yes"
1964         plugin_memory="yes"
1965         plugin_nfs="yes"
1966         plugin_processes="yes"
1967         plugin_serial="yes"
1968         plugin_swap="yes"
1969         plugin_tcpconns="yes"
1970         plugin_vserver="yes"
1971         plugin_wireless="yes"
1972
1973         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
1974         then
1975                 plugin_ipvs="yes"
1976         fi
1977 fi
1978
1979 # Mac OS X devices
1980 if test "x$with_libiokit" = "xyes"
1981 then
1982         plugin_battery="yes"
1983         plugin_disk="yes"
1984 fi
1985
1986 # Solaris
1987 if test "x$with_devinfo$with_kstat" = "xyesyes"
1988 then
1989         plugin_cpu="yes"
1990         plugin_disk="yes"
1991         plugin_interface="yes"
1992         plugin_memory="yes"
1993         plugin_swap="yes"
1994         plugin_tape="yes"
1995 fi
1996
1997 # libstatgrab
1998 if test "x$with_libstatgrab" = "xyes"
1999 then
2000         plugin_interface="yes"
2001         plugin_load="yes"
2002         plugin_memory="yes"
2003         plugin_swap="yes"
2004 fi
2005
2006 if test "x$have_processor_info" = "xyes"
2007 then
2008         plugin_cpu="yes"
2009 fi
2010 if test "x$have_sysctlbyname" = "xyes"
2011 then
2012         plugin_cpu="yes"
2013         plugin_memory="yes"
2014         plugin_tcpconns="yes"
2015 fi
2016
2017 if test "x$have_statfs" = "xyes"
2018 then
2019         plugin_df="yes"
2020 fi
2021 if test "x$have_statvfs" = "xyes"
2022 then
2023         plugin_df="yes"
2024 fi
2025
2026 if test "x$have_getifaddrs" = "xyes"
2027 then
2028         plugin_interface="yes"
2029 fi
2030
2031 if test "x$have_getloadavg" = "xyes"
2032 then
2033         plugin_load="yes"
2034 fi
2035
2036 # Mac OS X memory interface
2037 if test "x$have_host_statistics" = "xyes"
2038 then
2039         plugin_memory="yes"
2040 fi
2041
2042 if test "x$have_termios_h" = "xyes"
2043 then
2044         plugin_multimeter="yes"
2045 fi
2046
2047 if test "x$have_thread_info" = "xyes"
2048 then
2049         plugin_processes="yes"
2050 fi
2051
2052 if test "x$with_libkvm" = "xyes"
2053 then
2054         plugin_swap="yes"
2055 fi
2056
2057 if test "x$have_getutent" = "xyes"
2058 then
2059         plugin_users="yes"
2060 fi
2061 if test "x$have_getutxent" = "xyes"
2062 then
2063         plugin_users="yes"
2064 fi
2065
2066 # FIXME: sysctl for swap plugin
2067
2068 m4_divert_once([HELP_ENABLE], [
2069 collectd plugins:])
2070
2071 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
2072 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
2073 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
2074 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
2075 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
2076 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
2077 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
2078 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
2079 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
2080 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
2081 AC_PLUGIN([email],       [yes],                [EMail statistics])
2082 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
2083 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
2084 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
2085 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
2086 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
2087 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
2088 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
2089 AC_PLUGIN([load],        [$plugin_load],       [System load])
2090 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
2091 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
2092 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
2093 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
2094 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
2095 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
2096 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
2097 AC_PLUGIN([network],     [yes],                [Network communication plugin])
2098 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
2099 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
2100 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
2101 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
2102 AC_PLUGIN([perl],        [$with_libperl],      [Embed a Perl interpreter])
2103 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
2104 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
2105 AC_PLUGIN([rrdtool],     [$with_rrdtool],      [RRDTool output plugin])
2106 AC_PLUGIN([sensors],     [$with_lm_sensors],   [lm_sensors statistics])
2107 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
2108 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
2109 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
2110 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
2111 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
2112 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
2113 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
2114 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
2115 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
2116 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
2117 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
2118
2119 dnl ip_vs.h
2120 if test "x$ac_system" = "xLinux" -a "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
2121 then
2122         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
2123 fi
2124
2125 dnl Perl bindings
2126 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
2127 [
2128         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2129         then
2130                 PERL_BINDINGS_OPTIONS="$withval"
2131                 with_perl_bindings="yes"
2132         else
2133                 PERL_BINDINGS_OPTIONS=""
2134                 with_perl_bindings="$withval"
2135         fi
2136 ],
2137 [
2138         PERL_BINDINGS_OPTIONS=""
2139         if test -n "$perl_interpreter"
2140         then
2141                 with_perl_bindings="yes"
2142         else
2143                 with_perl_bindings="no (no perl interpreter found)"
2144         fi
2145 ])
2146 if test "x$with_perl_bindings" = "xyes"
2147 then
2148         PERL_BINDINGS="perl"
2149 else
2150         PERL_BINDINGS=""
2151 fi
2152 AC_SUBST(PERL_BINDINGS)
2153 AC_SUBST(PERL_BINDINGS_OPTIONS)
2154
2155 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
2156
2157 if test "x$with_liboping" = "xyes" -a "x$with_own_liboping" = "xyes"
2158 then
2159         with_liboping="yes (shipped version)"
2160 fi
2161
2162 if test "x$with_libperl" = "xyes"
2163 then
2164         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
2165 else
2166         enable_perl="no (needs libperl)"
2167 fi
2168
2169 if test "x$with_perl_bindings" = "xyes" -a "x$PERL_BINDINGS_OPTIONS" != "x"
2170 then
2171         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
2172 fi
2173
2174 cat <<EOF;
2175
2176 Configuration:
2177   Libraries:
2178     libcurl . . . . . . $with_libcurl
2179     libiokit  . . . . . $with_libiokit
2180     libiptc . . . . . . $with_libiptc
2181     libkstat  . . . . . $with_kstat
2182     libkvm  . . . . . . $with_libkvm
2183     libmysql  . . . . . $with_libmysql
2184     libnetlink  . . . . $with_libnetlink
2185     libnetsnmp  . . . . $with_libnetsnmp
2186     liboconfig  . . . . $with_liboconfig
2187     liboping  . . . . . $with_liboping
2188     libpcap . . . . . . $with_libpcap
2189     libperl . . . . . . $with_libperl
2190     libpthread  . . . . $with_libpthread
2191     librrd  . . . . . . $with_rrdtool
2192     libsensors  . . . . $with_lm_sensors
2193     libstatgrab . . . . $with_libstatgrab
2194     libupsclient  . . . $with_libupsclient
2195     libxmms . . . . . . $with_libxmms
2196
2197   Features:
2198     daemon mode . . . . $enable_daemon
2199     debug . . . . . . . $enable_debug
2200
2201   Bindings:
2202     perl  . . . . . . . $with_perl_bindings
2203
2204   Modules:
2205     apache  . . . . . . $enable_apache
2206     apcups  . . . . . . $enable_apcups
2207     apple_sensors . . . $enable_apple_sensors
2208     battery . . . . . . $enable_battery
2209     cpu . . . . . . . . $enable_cpu
2210     cpufreq . . . . . . $enable_cpufreq
2211     csv . . . . . . . . $enable_csv
2212     df  . . . . . . . . $enable_df
2213     disk  . . . . . . . $enable_disk
2214     dns . . . . . . . . $enable_dns
2215     email . . . . . . . $enable_email
2216     entropy . . . . . . $enable_entropy
2217     exec  . . . . . . . $enable_exec
2218     hddtemp . . . . . . $enable_hddtemp
2219     interface . . . . . $enable_interface
2220     iptables  . . . . . $enable_iptables
2221     ipvs  . . . . . . . $enable_ipvs
2222     irq . . . . . . . . $enable_irq
2223     load  . . . . . . . $enable_load
2224     logfile . . . . . . $enable_logfile
2225     mbmon . . . . . . . $enable_mbmon
2226     memcached . . . . . $enable_memcached
2227     memory  . . . . . . $enable_memory
2228     multimeter  . . . . $enable_multimeter
2229     mysql . . . . . . . $enable_mysql
2230     netlink . . . . . . $enable_netlink
2231     network . . . . . . $enable_network
2232     nfs . . . . . . . . $enable_nfs
2233     nginx . . . . . . . $enable_nginx
2234     ntpd  . . . . . . . $enable_ntpd
2235     nut . . . . . . . . $enable_nut
2236     perl  . . . . . . . $enable_perl
2237     ping  . . . . . . . $enable_ping
2238     processes . . . . . $enable_processes
2239     rrdtool . . . . . . $enable_rrdtool
2240     sensors . . . . . . $enable_sensors
2241     serial  . . . . . . $enable_serial
2242     snmp  . . . . . . . $enable_snmp
2243     swap  . . . . . . . $enable_swap
2244     syslog  . . . . . . $enable_syslog
2245     tape  . . . . . . . $enable_tape
2246     tcpconns  . . . . . $enable_tcpconns
2247     unixsock  . . . . . $enable_unixsock
2248     users . . . . . . . $enable_users
2249     vserver . . . . . . $enable_vserver
2250     wireless  . . . . . $enable_wireless
2251     xmms  . . . . . . . $enable_xmms
2252
2253 EOF