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