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