Merge branch 'ff/oracle'
[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_PROG_CC_C_O
21 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
22
23 dnl configure libtool
24 AC_DISABLE_STATIC
25 AC_LIBLTDL_CONVENIENCE
26 AC_SUBST(LTDLINCL)
27 AC_SUBST(LIBLTDL)
28 AC_LIBTOOL_DLOPEN
29 AC_PROG_LIBTOOL
30 AC_PROG_LEX
31 AC_PROG_YACC
32 PKG_PROG_PKG_CONFIG
33 AC_CONFIG_SUBDIRS(libltdl)
34
35 AC_MSG_CHECKING([for kernel type ($host_os)])
36 case $host_os in
37         *linux*)
38         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
39         ac_system="Linux"
40         ;;
41         *solaris*)
42         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
43         ac_system="Solaris"
44         ;;
45         *darwin*)
46         ac_system="Darwin"
47         ;;
48         *openbsd*)
49         ac_system="OpenBSD"
50         ;;
51         *)
52         ac_system="unknown"
53 esac
54 AC_MSG_RESULT([$ac_system])
55
56 if test "x$ac_system" = "xLinux"
57 then
58         AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
59         if test -z "$KERNEL_DIR"
60         then
61                 KERNEL_DIR="/lib/modules/`uname -r`/source"
62         fi
63
64         KERNEL_CFLAGS="-I$KERNEL_DIR/include"
65         AC_SUBST(KERNEL_CFLAGS)
66 fi
67
68 #
69 # Checks for header files.
70 #
71 AC_HEADER_STDC
72 AC_HEADER_SYS_WAIT
73 AC_HEADER_DIRENT
74
75 AC_CHECK_HEADERS(stdio.h stdint.h stdbool.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 sys/isa_defs.h)
76
77 # For ping library
78 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
79 [#if HAVE_STDINT_H
80 # include <stdint.h>
81 #endif
82 #if HAVE_SYS_TYPES_H
83 # include <sys/types.h>
84 #endif
85 ])
86 AC_CHECK_HEADERS(netinet/in.h, [], [],
87 [#if HAVE_STDINT_H
88 # include <stdint.h>
89 #endif
90 #if HAVE_SYS_TYPES_H
91 # include <sys/types.h>
92 #endif
93 #if HAVE_NETINET_IN_SYSTM_H
94 # include <netinet/in_systm.h>
95 #endif
96 ])
97 AC_CHECK_HEADERS(netinet/ip.h, [], [],
98 [#if HAVE_STDINT_H
99 # include <stdint.h>
100 #endif
101 #if HAVE_SYS_TYPES_H
102 # include <sys/types.h>
103 #endif
104 #if HAVE_NETINET_IN_SYSTM_H
105 # include <netinet/in_systm.h>
106 #endif
107 #if HAVE_NETINET_IN_H
108 # include <netinet/in.h>
109 #endif
110 ])
111 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
112 [#if HAVE_STDINT_H
113 # include <stdint.h>
114 #endif
115 #if HAVE_SYS_TYPES_H
116 # include <sys/types.h>
117 #endif
118 #if HAVE_NETINET_IN_SYSTM_H
119 # include <netinet/in_systm.h>
120 #endif
121 #if HAVE_NETINET_IN_H
122 # include <netinet/in.h>
123 #endif
124 #if HAVE_NETINET_IP_H
125 # include <netinet/ip.h>
126 #endif
127 ])
128 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
129 [#if HAVE_STDINT_H
130 # include <stdint.h>
131 #endif
132 #if HAVE_SYS_TYPES_H
133 # include <sys/types.h>
134 #endif
135 #if HAVE_NETINET_IN_SYSTM_H
136 # include <netinet/in_systm.h>
137 #endif
138 #if HAVE_NETINET_IN_H
139 # include <netinet/in.h>
140 #endif
141 #if HAVE_NETINET_IP_H
142 # include <netinet/ip.h>
143 #endif
144 ])
145 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
146 [#if HAVE_STDINT_H
147 # include <stdint.h>
148 #endif
149 #if HAVE_SYS_TYPES_H
150 # include <sys/types.h>
151 #endif
152 #if HAVE_NETINET_IN_SYSTM_H
153 # include <netinet/in_systm.h>
154 #endif
155 #if HAVE_NETINET_IN_H
156 # include <netinet/in.h>
157 #endif
158 ])
159 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
160 [#if HAVE_STDINT_H
161 # include <stdint.h>
162 #endif
163 #if HAVE_SYS_TYPES_H
164 # include <sys/types.h>
165 #endif
166 #if HAVE_NETINET_IN_SYSTM_H
167 # include <netinet/in_systm.h>
168 #endif
169 #if HAVE_NETINET_IN_H
170 # include <netinet/in.h>
171 #endif
172 #if HAVE_NETINET_IP6_H
173 # include <netinet/ip6.h>
174 #endif
175 ])
176 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
177 [#if HAVE_STDINT_H
178 # include <stdint.h>
179 #endif
180 #if HAVE_SYS_TYPES_H
181 # include <sys/types.h>
182 #endif
183 #if HAVE_NETINET_IN_SYSTM_H
184 # include <netinet/in_systm.h>
185 #endif
186 #if HAVE_NETINET_IN_H
187 # include <netinet/in.h>
188 #endif
189 #if HAVE_NETINET_IP_H
190 # include <netinet/ip.h>
191 #endif
192 ])
193 AC_CHECK_HEADERS(netinet/udp.h, [], [],
194 [#if HAVE_STDINT_H
195 # include <stdint.h>
196 #endif
197 #if HAVE_SYS_TYPES_H
198 # include <sys/types.h>
199 #endif
200 #if HAVE_NETINET_IN_SYSTM_H
201 # include <netinet/in_systm.h>
202 #endif
203 #if HAVE_NETINET_IN_H
204 # include <netinet/in.h>
205 #endif
206 #if HAVE_NETINET_IP_H
207 # include <netinet/ip.h>
208 #endif
209 ])
210
211 # For cpu modules
212 AC_CHECK_HEADERS(sys/dkstat.h)
213 if test "x$ac_system" = "xDarwin"
214 then
215         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)
216         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
217 fi
218 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
219 [
220 #if HAVE_SYS_TYPES_H
221 #  include <sys/types.h>
222 #endif
223 #if HAVE_SYS_PARAM_H
224 # include <sys/param.h>
225 #endif
226 ])
227
228 # For hddtemp module
229 AC_CHECK_HEADERS(linux/major.h libgen.h)
230
231 # For the battery plugin
232 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
233 [
234 #if HAVE_IOKIT_IOKITLIB_H
235 #  include <IOKit/IOKitLib.h>
236 #endif
237 #if HAVE_IOKIT_IOTYPES_H
238 #  include <IOKit/IOTypes.h>
239 #endif
240 ])
241
242 # For the swap module
243 AC_CHECK_HEADERS(sys/swap.h, [], [],
244 [
245 #if HAVE_SYS_TYPES_H
246 #  include <sys/types.h>
247 #endif
248 #if HAVE_SYS_PARAM_H
249 # include <sys/param.h>
250 #endif
251 ])
252
253 # For load module
254 # For the processes plugin
255 # For users module
256 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
257
258 # For interface plugin
259 AC_CHECK_HEADERS(ifaddrs.h)
260 AC_CHECK_HEADERS(net/if.h, [], [],
261 [
262 #if HAVE_SYS_TYPES_H
263 #  include <sys/types.h>
264 #endif
265 #if HAVE_SYS_SOCKET_H
266 #  include <sys/socket.h>
267 #endif
268 ])
269 AC_CHECK_HEADERS(linux/if.h, [], [],
270 [
271 #if HAVE_SYS_TYPES_H
272 #  include <sys/types.h>
273 #endif
274 #if HAVE_SYS_SOCKET_H
275 #  include <sys/socket.h>
276 #endif
277 ])
278 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
279 [
280 #if HAVE_SYS_TYPES_H
281 #  include <sys/types.h>
282 #endif
283 #if HAVE_SYS_SOCKET_H
284 #  include <sys/socket.h>
285 #endif
286 #if HAVE_LINUX_IF_H
287 # include <linux/if.h>
288 #endif
289 ])
290
291 # For ipvs module
292 have_net_ip_vs_h="no"
293 have_ip_vs_h="no"
294 if test "x$ac_system" = "xLinux"
295 then
296         SAVE_CFLAGS=$CFLAGS
297         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
298
299         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
300         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
301
302         CFLAGS=$SAVE_CFLAGS
303 fi
304
305 # For quota module
306 AC_CHECK_HEADERS(sys/ucred.h, [], [],
307 [
308 #if HAVE_SYS_TYPES_H
309 #  include <sys/types.h>
310 #endif
311 #if HAVE_SYS_PARAM_H
312 # include <sys/param.h>
313 #endif
314 ])
315
316 # For mount interface
317 AC_CHECK_HEADERS(sys/mount.h, [], [],
318 [
319 #if HAVE_SYS_TYPES_H
320 #  include <sys/types.h>
321 #endif
322 #if HAVE_SYS_PARAM_H
323 # include <sys/param.h>
324 #endif
325 ])
326
327 # For the email plugin
328 AC_CHECK_HEADERS(linux/un.h, [], [],
329 [
330 #if HAVE_SYS_SOCKET_H
331 #       include <sys/socket.h>
332 #endif
333 ])
334
335 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 wordexp.h)
336
337 # For the dns plugin
338 AC_CHECK_HEADERS(arpa/nameser.h)
339 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
340 [
341 #if HAVE_ARPA_NAMESER_H
342 # include <arpa/nameser.h>
343 #endif
344 ])
345
346 AC_CHECK_HEADERS(net/if_arp.h, [], [],
347 [#if HAVE_SYS_SOCKET_H
348 # include <sys/socket.h>
349 #endif
350 ])
351 AC_CHECK_HEADERS(net/ppp_defs.h)
352 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
353 [#if HAVE_NET_PPP_DEFS_H
354 # include <net/ppp_defs.h>
355 #endif
356 ])
357 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
358 [#if HAVE_STDINT_H
359 # include <stdint.h>
360 #endif
361 #if HAVE_SYS_TYPES_H
362 # include <sys/types.h>
363 #endif
364 #if HAVE_SYS_SOCKET_H
365 # include <sys/socket.h>
366 #endif
367 #if HAVE_NET_IF_H
368 # include <net/if.h>
369 #endif
370 #if HAVE_NETINET_IN_H
371 # include <netinet/in.h>
372 #endif
373 ])
374
375 # For the multimeter plugin
376 have_termios_h="no"
377 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
378
379 #
380 # Checks for typedefs, structures, and compiler characteristics.
381 #
382 AC_C_CONST
383 AC_TYPE_PID_T
384 AC_TYPE_SIZE_T
385 AC_TYPE_UID_T
386 AC_HEADER_TIME
387
388 #
389 # Checks for library functions.
390 #
391 AC_PROG_GCC_TRADITIONAL
392 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog)
393
394 AC_FUNC_STRERROR_R
395
396 AC_CACHE_CHECK([for strtok_r],
397   [have_strtok_r_default],
398   AC_LINK_IFELSE(
399     AC_LANG_PROGRAM(
400     [[[[
401 #include <stdlib.h>
402 #include <stdio.h>
403 #include <string.h>
404     ]]]],
405     [[[[
406       char buffer[] = "foo,bar,baz";
407       char *token;
408       char *dummy;
409       char *saveptr;
410
411       dummy = buffer;
412       saveptr = NULL;
413       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
414       {
415         dummy = NULL;
416         printf ("token = %s;\n", token);
417       }
418     ]]]]),
419     [have_strtok_r_default="yes"],
420     [have_strtok_r_default="no"]
421   )
422 )
423
424 if test "x$have_strtok_r_default" = "xno"
425 then
426   SAVE_CFLAGS="$CFLAGS"
427   CFLAGS="$CFLAGS -D_REENTRANT=1"
428
429   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
430     [have_strtok_r_reentrant],
431     AC_LINK_IFELSE(
432       AC_LANG_PROGRAM(
433       [[[[
434 #include <stdlib.h>
435 #include <stdio.h>
436 #include <string.h>
437       ]]]],
438       [[[[
439         char buffer[] = "foo,bar,baz";
440         char *token;
441         char *dummy;
442         char *saveptr;
443
444         dummy = buffer;
445         saveptr = NULL;
446         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
447         {
448           dummy = NULL;
449           printf ("token = %s;\n", token);
450         }
451       ]]]]),
452       [have_strtok_r_reentrant="yes"],
453       [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
454     )
455   )
456 fi
457
458 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
459
460 socket_needs_socket="no"
461 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
462 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
463
464 nanosleep_needs_rt="no"
465 AC_CHECK_FUNCS(nanosleep, [], AC_CHECK_LIB(rt, nanosleep, [nanosleep_needs_rt="yes"], AC_MSG_ERROR(cannot find nanosleep)))
466 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
467
468 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
469 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
470 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
471 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
472 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
473 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
474 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
475 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
476 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
477 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
478
479 # For load module
480 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
481
482 # Check for NAN
483 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
484 [
485  if test "x$withval" = "xno"; then
486          nan_type="none"
487  else if test "x$withval" = "xyes"; then
488          nan_type="zero"
489  else
490          nan_type="$withval"
491  fi; fi
492 ],
493 [nan_type="none"])
494 if test "x$nan_type" = "xnone"; then
495   AC_CACHE_CHECK([whether NAN is defined by default],
496     [have_nan_default],
497     AC_COMPILE_IFELSE(
498       AC_LANG_PROGRAM(
499       [[
500 #include <stdlib.h>
501 #include <math.h>
502 static float foo = NAN;
503       ]],
504       [[
505        if (isnan (foo))
506         return 0;
507        else
508         return 1;
509       ]]),
510       [have_nan_default="yes"],
511       [have_nan_default="no"]
512     )
513   )
514   if test "x$have_nan_default" = "xyes"
515   then
516     nan_type="default"
517   fi
518 fi
519 if test "x$nan_type" = "xnone"; then
520   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
521     [have_nan_isoc],
522     AC_COMPILE_IFELSE(
523       AC_LANG_PROGRAM(
524       [[
525 #include <stdlib.h>
526 #define __USE_ISOC99 1
527 #include <math.h>
528 static float foo = NAN;
529       ]],
530       [[
531        if (isnan (foo))
532         return 0;
533        else
534         return 1;
535       ]]),
536       [have_nan_isoc="yes"],
537       [have_nan_isoc="no"]
538     )
539   )
540   if test "x$have_nan_isoc" = "xyes"
541   then
542     nan_type="isoc99"
543   fi
544 fi
545 if test "x$nan_type" = "xnone"; then
546   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
547     [have_nan_zero],
548     AC_RUN_IFELSE(
549       AC_LANG_PROGRAM(
550       [[
551 #include <stdlib.h>
552 #include <math.h>
553 #ifdef NAN
554 # undef NAN
555 #endif
556 #define NAN (0.0 / 0.0)
557 #ifndef isnan
558 # define isnan(f) ((f) != (f))
559 #endif
560 static float foo = NAN;
561       ]],
562       [[
563        if (isnan (foo))
564         return 0;
565        else
566         return 1;
567       ]]),
568       [have_nan_zero="yes"],
569       [have_nan_zero="no"]
570     )
571   )
572   if test "x$have_nan_zero" = "xyes"
573   then
574     nan_type="zero"
575   fi
576 fi
577
578 if test "x$nan_type" = "xdefault"; then
579   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
580     [Define if NAN is defined by default and can initialize static variables.])
581 else if test "x$nan_type" = "xisoc99"; then
582   AC_DEFINE(NAN_STATIC_ISOC, 1,
583     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
584 else if test "x$nan_type" = "xzero"; then
585   AC_DEFINE(NAN_ZERO_ZERO, 1,
586     [Define if NAN can be defined as (0.0 / 0.0)])
587 else
588   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
589 fi; fi; fi
590
591 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
592 [
593  if test "x$withval" = "xnothing"; then
594         fp_layout_type="nothing"
595  else if test "x$withval" = "xendianflip"; then
596         fp_layout_type="endianflip"
597  else if test "x$withval" = "xintswap"; then
598         fp_layout_type="intswap"
599  else
600         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
601 fi; fi; fi
602 ],
603 [fp_layout_type="unknown"])
604
605 if test "x$fp_layout_type" = "xunknown"; then
606   AC_CACHE_CHECK([if doubles are stored in x86 representation],
607     [fp_layout_need_nothing],
608     AC_RUN_IFELSE(
609       AC_LANG_PROGRAM(
610       [[[[
611 #include <stdlib.h>
612 #include <stdio.h>
613 #include <stdint.h>
614 #include <string.h>
615       ]]]],
616       [[[[
617         uint64_t i0;
618         uint64_t i1;
619         uint8_t c[8];
620         double d;
621
622         d = 8.642135e130; 
623         memcpy ((void *) &i0, (void *) &d, 8);
624
625         i1 = i0;
626         memcpy ((void *) c, (void *) &i1, 8);
627
628         if ((c[0] == 0x2f) && (c[1] == 0x25)
629                         && (c[2] == 0xc0) && (c[3] == 0xc7)
630                         && (c[4] == 0x43) && (c[5] == 0x2b)
631                         && (c[6] == 0x1f) && (c[7] == 0x5b))
632                 return (0);
633         else
634                 return (1);
635       ]]]]),
636       [fp_layout_need_nothing="yes"],
637       [fp_layout_need_nothing="no"]
638     )
639   )
640   if test "x$fp_layout_need_nothing" = "xyes"; then
641     fp_layout_type="nothing"
642   fi
643 fi
644 if test "x$fp_layout_type" = "xunknown"; then
645   AC_CACHE_CHECK([if endianflip converts to x86 representation],
646     [fp_layout_need_endianflip],
647     AC_RUN_IFELSE(
648       AC_LANG_PROGRAM(
649       [[[[
650 #include <stdlib.h>
651 #include <stdio.h>
652 #include <stdint.h>
653 #include <string.h>
654 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
655                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
656                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
657                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
658                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
659                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
660                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
661                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
662       ]]]],
663       [[[[
664         uint64_t i0;
665         uint64_t i1;
666         uint8_t c[8];
667         double d;
668
669         d = 8.642135e130; 
670         memcpy ((void *) &i0, (void *) &d, 8);
671
672         i1 = endianflip (i0);
673         memcpy ((void *) c, (void *) &i1, 8);
674
675         if ((c[0] == 0x2f) && (c[1] == 0x25)
676                         && (c[2] == 0xc0) && (c[3] == 0xc7)
677                         && (c[4] == 0x43) && (c[5] == 0x2b)
678                         && (c[6] == 0x1f) && (c[7] == 0x5b))
679                 return (0);
680         else
681                 return (1);
682       ]]]]),
683       [fp_layout_need_endianflip="yes"],
684       [fp_layout_need_endianflip="no"]
685     )
686   )
687   if test "x$fp_layout_need_endianflip" = "xyes"; then
688     fp_layout_type="endianflip"
689   fi
690 fi
691 if test "x$fp_layout_type" = "xunknown"; then
692   AC_CACHE_CHECK([if intswap converts to x86 representation],
693     [fp_layout_need_intswap],
694     AC_RUN_IFELSE(
695       AC_LANG_PROGRAM(
696       [[[[
697 #include <stdlib.h>
698 #include <stdio.h>
699 #include <stdint.h>
700 #include <string.h>
701 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
702                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
703       ]]]],
704       [[[[
705         uint64_t i0;
706         uint64_t i1;
707         uint8_t c[8];
708         double d;
709
710         d = 8.642135e130; 
711         memcpy ((void *) &i0, (void *) &d, 8);
712
713         i1 = intswap (i0);
714         memcpy ((void *) c, (void *) &i1, 8);
715
716         if ((c[0] == 0x2f) && (c[1] == 0x25)
717                         && (c[2] == 0xc0) && (c[3] == 0xc7)
718                         && (c[4] == 0x43) && (c[5] == 0x2b)
719                         && (c[6] == 0x1f) && (c[7] == 0x5b))
720                 return (0);
721         else
722                 return (1);
723       ]]]]),
724       [fp_layout_need_intswap="yes"],
725       [fp_layout_need_intswap="no"]
726     )
727   )
728   if test "x$fp_layout_need_intswap" = "xyes"; then
729     fp_layout_type="intswap"
730   fi
731 fi
732
733 if test "x$fp_layout_type" = "xnothing"; then
734   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
735   [Define if doubles are stored in x86 representation.])
736 else if test "x$fp_layout_type" = "xendianflip"; then
737   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
738   [Define if endianflip is needed to convert to x86 representation.])
739 else if test "x$fp_layout_type" = "xintswap"; then
740   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
741   [Define if intswap is needed to convert to x86 representation.])
742 else
743   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
744 fi; fi; fi
745
746 have_getfsstat="no"
747 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
748 have_getvfsstat="no"
749 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
750 have_listmntent="no"
751 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
752
753 have_getmntent="no"
754 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
755 if test "x$have_getmntent" = "xno"; then
756         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
757 fi
758 if test "x$have_getmntent" = "xno"; then
759         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
760 fi
761 if test "x$have_getmntent" = "xno"; then
762         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
763 fi
764
765 if test "x$have_getmntent" = "xc"; then
766         AC_CACHE_CHECK([whether getmntent takes one argument],
767                 [have_one_getmntent],
768                 AC_COMPILE_IFELSE(
769                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
770 #include <mntent.h>
771 #include "$srcdir/src/utils_mount.h"]],
772                                 [[
773                                  FILE *fh;
774                                  struct mntent *me;
775                                  fh = setmntent ("/etc/mtab", "r");
776                                  me = getmntent (fh);
777                                 ]]
778                         ),
779                         [have_one_getmntent="yes"],
780                         [have_one_getmntent="no"]
781                 )
782         )
783         AC_CACHE_CHECK([whether getmntent takes two arguments],
784                 [have_two_getmntent],
785                 AC_COMPILE_IFELSE(
786                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
787 #include <sys/mnttab.h>
788 #include "$srcdir/src/utils_mount.h"]],
789                                 [[
790                                  FILE *fh;
791                                  struct mnttab mt;
792                                  int status;
793                                  fh = fopen ("/etc/mnttab", "r");
794                                  status = getmntent (fh, &mt);
795                                 ]]
796                         ),
797                         [have_two_getmntent="yes"],
798                         [have_two_getmntent="no"]
799                 )
800         )
801 fi
802
803 # Check for different versions of `getmntent' here..
804
805 if test "x$have_getmntent" = "xc"; then
806         if test "x$have_one_getmntent" = "xyes"; then
807                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
808                           [Define if the function getmntent exists and takes one argument.])
809         fi
810         if test "x$have_two_getmntent" = "xyes"; then
811                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
812                           [Define if the function getmntent exists and takes two arguments.])
813         fi
814 fi
815 if test "x$have_getmntent" = "xsun"; then
816         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
817                   [Define if the function getmntent exists. It's the version from libsun.])
818 fi
819 if test "x$have_getmntent" = "xseq"; then
820         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
821                   [Define if the function getmntent exists. It's the version from libseq.])
822 fi
823 if test "x$have_getmntent" = "xgen"; then
824         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
825                   [Define if the function getmntent exists. It's the version from libgen.])
826 fi
827
828 # Check for structures
829 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
830         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
831         [],
832         [
833         #include <sys/types.h>
834         #include <sys/socket.h>
835         #include <net/if.h>
836         ])
837 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
838         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
839         [],
840         [
841         #include <sys/types.h>
842         #include <sys/socket.h>
843         #include <linux/if.h>
844         #include <linux/netdevice.h>
845         ])
846
847 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
848 [#if HAVE_STDINT_H
849 # include <stdint.h>
850 #endif
851 #if HAVE_SYS_TYPES_H
852 # include <sys/types.h>
853 #endif
854 #if HAVE_NETINET_IN_SYSTM_H
855 # include <netinet/in_systm.h>
856 #endif
857 #if HAVE_NETINET_IN_H
858 # include <netinet/in.h>
859 #endif
860 #if HAVE_NETINET_IP_H
861 # include <netinet/ip.h>
862 #endif
863 #if HAVE_NETINET_UDP_H
864 # include <netinet/udp.h>
865 #endif
866 ])
867 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
868 [#if HAVE_STDINT_H
869 # include <stdint.h>
870 #endif
871 #if HAVE_SYS_TYPES_H
872 # include <sys/types.h>
873 #endif
874 #if HAVE_NETINET_IN_SYSTM_H
875 # include <netinet/in_systm.h>
876 #endif
877 #if HAVE_NETINET_IN_H
878 # include <netinet/in.h>
879 #endif
880 #if HAVE_NETINET_IP_H
881 # include <netinet/ip.h>
882 #endif
883 #if HAVE_NETINET_UDP_H
884 # include <netinet/udp.h>
885 #endif
886 ])
887
888 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
889         [],
890         [],
891         [
892 #if HAVE_KSTAT_H
893 # include <kstat.h>
894 #endif
895         ])
896
897 #
898 # Checks for libraries begin here
899 #
900 with_libresolv="yes"
901 AC_CHECK_LIB(resolv, res_search,
902 [
903         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
904 ],
905 [with_libresolv="no"])
906 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
907
908 dnl Check for HAL (hardware abstraction library)
909 with_libhal="yes"
910 AC_CHECK_LIB(hal,libhal_device_property_exists,
911              [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
912              [with_libhal="no"])
913 if test "x$with_libhal" = "xyes"; then
914         if test "x$PKG_CONFIG" != "x"; then
915                 BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
916                 BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
917                 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
918                 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
919         fi
920 fi
921
922 m4_divert_once([HELP_WITH], [
923 collectd additional packages:])
924
925 if test "x$ac_system" = "xSolaris"
926 then
927         with_kstat="yes"
928         with_devinfo="yes"
929 else
930         with_kstat="no (Solaris only)"
931         with_devinfo="no (Solaris only)"
932 fi
933
934 if test "x$with_kstat" = "xyes"
935 then
936         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
937 fi
938 if test "x$with_kstat" = "xyes"
939 then
940         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
941         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
942 fi
943 if test "x$with_kstat" = "xyes"
944 then
945         AC_DEFINE(HAVE_LIBKSTAT, 1,
946                   [Define to 1 if you have the 'kstat' library (-lkstat)])
947 fi
948 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
949 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
950
951 with_libiokit="no"
952 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
953 [
954         with_libiokit="yes"
955 ], 
956 [
957         with_libiokit="no"
958 ])
959 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
960
961 with_libkvm="no"
962 AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
963 if test "x$with_kvm_getprocs" = "xyes"
964 then
965         AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
966                   [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
967         with_libkvm="yes"
968 fi
969 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
970
971 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
972 if test "x$with_kvm_getswapinfo" = "xyes"
973 then
974         AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
975                   [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
976         with_libkvm="yes"
977 fi
978 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
979
980 AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
981 if test "x$with_kvm_nlist" = "xyes"
982 then
983         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
984                   [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
985         with_libkvm="yes"
986 fi
987 AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
988
989 # --with-libcurl {{{
990 with_curl_config="curl-config"
991 with_curl_cflags=""
992 with_curl_libs=""
993 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
994 [
995         if test "x$withval" = "xno"
996         then
997                 with_libcurl="no"
998         else if test "x$withval" = "xyes"
999         then
1000                 with_libcurl="yes"
1001         else
1002                 if test -f "$withval" && test -x "$withval"
1003                 then
1004                         with_curl_config="$withval"
1005                         with_libcurl="yes"
1006                 else if test -x "$withval/bin/curl-config"
1007                 then
1008                         with_curl_config="$withval/bin/curl-config"
1009                         with_libcurl="yes"
1010                 fi; fi
1011                 with_libcurl="yes"
1012         fi; fi
1013 ],
1014 [
1015         with_libcurl="yes"
1016 ])
1017 if test "x$with_libcurl" = "xyes"
1018 then
1019         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1020         curl_config_status=$?
1021
1022         if test $curl_config_status -ne 0
1023         then
1024                 with_libcurl="no ($with_curl_config failed)"
1025         else
1026                 SAVE_CPPFLAGS="$CPPFLAGS"
1027                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1028
1029                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1030
1031                 CPPFLAGS="$SAVE_CPPFLAGS"
1032         fi
1033 fi
1034 if test "x$with_libcurl" = "xyes"
1035 then
1036         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1037         curl_config_status=$?
1038
1039         if test $curl_config_status -ne 0
1040         then
1041                 with_libcurl="no ($with_curl_config failed)"
1042         else
1043                 AC_CHECK_LIB(curl, curl_easy_init,
1044                  [with_libcurl="yes"],
1045                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1046                  [$with_curl_libs])
1047         fi
1048 fi
1049 if test "x$with_libcurl" = "xyes"
1050 then
1051         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1052         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1053         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1054         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1055 fi
1056 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1057 # }}}
1058
1059 # --with-libdbi {{{
1060 with_libdbi_cppflags=""
1061 with_libdbi_ldflags=""
1062 AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
1063 [
1064         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1065         then
1066                 with_libdbi_cppflags="-I$withval/include"
1067                 with_libdbi_ldflags="-L$withval/lib"
1068                 with_libdbi="yes"
1069         else
1070                 with_libdbi="$withval"
1071         fi
1072 ],
1073 [
1074         with_libdbi="yes"
1075 ])
1076 if test "x$with_libdbi" = "xyes"
1077 then
1078         SAVE_CPPFLAGS="$CPPFLAGS"
1079         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1080
1081         AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
1082
1083         CPPFLAGS="$SAVE_CPPFLAGS"
1084 fi
1085 if test "x$with_libdbi" = "xyes"
1086 then
1087         SAVE_CPPFLAGS="$CPPFLAGS"
1088         SAVE_LDFLAGS="$LDFLAGS"
1089         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1090         LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
1091
1092         AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
1093
1094         CPPFLAGS="$SAVE_CPPFLAGS"
1095         LDFLAGS="$SAVE_LDFLAGS"
1096 fi
1097 if test "x$with_libdbi" = "xyes"
1098 then
1099         BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
1100         BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
1101         BUILD_WITH_LIBDBI_LIBS="-ldbi"
1102         AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
1103         AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
1104         AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
1105 fi
1106 AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
1107 # }}}
1108
1109 # --with-libesmtp {{{
1110 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
1111 [
1112         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1113         then
1114                 LDFLAGS="$LDFLAGS -L$withval/lib"
1115                 CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
1116                 with_libesmtp="yes"
1117         else
1118                 with_libesmtp="$withval"
1119         fi
1120 ],
1121 [
1122         with_libesmtp="yes"
1123 ])
1124 if test "x$with_libesmtp" = "xyes"
1125 then
1126         AC_CHECK_LIB(esmtp, smtp_create_session,
1127         [
1128                 AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
1129         ], [with_libesmtp="no (libesmtp not found)"])
1130 fi
1131 if test "x$with_libesmtp" = "xyes"
1132 then
1133         AC_CHECK_HEADERS(libesmtp.h,
1134         [
1135                 AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
1136         ], [with_libesmtp="no (libesmtp.h not found)"])
1137 fi
1138 if test "x$with_libesmtp" = "xyes"
1139 then
1140         collect_libesmtp=1
1141 else
1142         collect_libesmtp=0
1143 fi
1144 AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
1145         [Wether or not to use the esmtp library])
1146 AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
1147 # }}}
1148
1149 # --with-libiptc {{{
1150 with_own_libiptc="no"
1151 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1152 [
1153         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1154         then
1155                 LDFLAGS="$LDFLAGS -L$withval/lib"
1156                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1157                 with_libiptc="yes"
1158         else
1159                 with_libiptc="$withval"
1160         fi
1161 ],
1162 [
1163         if test "x$ac_system" = "xLinux"
1164         then
1165                 with_libiptc="yes"
1166         else
1167                 with_libiptc="no (Linux only)"
1168         fi
1169 ])
1170 if test "x$with_libiptc" = "xyes"
1171 then
1172         AC_CHECK_LIB(iptc, iptc_init,
1173         [
1174                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1175         ],
1176         [
1177                 with_libiptc="yes"
1178                 with_own_libiptc="yes"
1179         ])
1180 fi
1181 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes"
1182 then
1183         AC_CHECK_HEADERS(libiptc/libiptc.h,
1184         [
1185                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1186         ],
1187         [
1188                 with_libiptc="yes"
1189                 with_own_libiptc="yes"
1190         ])
1191 fi
1192 if test "x$with_libiptc" = "xyes"
1193 then
1194         SAVE_CFLAGS=$CFLAGS
1195         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
1196
1197         AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
1198         [
1199                 with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)"
1200                 with_own_libiptc="no"
1201         ],
1202         [
1203 #include "$srcdir/src/libiptc/ipt_kernel_headers.h"
1204         ])
1205
1206         CFLAGS=$SAVE_CFLAGS
1207 fi
1208 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1209 AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
1210 if test "x$with_own_libiptc" = "xyes"
1211 then
1212         AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
1213 fi
1214 # }}}
1215
1216 # --with-libmysql {{{
1217 with_mysql_config="mysql_config"
1218 with_mysql_cflags=""
1219 with_mysql_libs=""
1220 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1221 [
1222         if test "x$withval" = "xno"
1223         then
1224                 with_libmysql="no"
1225         else if test "x$withval" = "xyes"
1226         then
1227                 with_libmysql="yes"
1228         else
1229                 if test -f "$withval" && test -x "$withval";
1230                 then
1231                         with_mysql_config="$withval"
1232                 else if test -x "$withval/bin/mysql_config"
1233                 then
1234                         with_mysql_config="$withval/bin/mysql_config"
1235                 fi; fi
1236                 with_libmysql="yes"
1237         fi; fi
1238 ],
1239 [
1240         with_libmysql="yes"
1241 ])
1242 if test "x$with_libmysql" = "xyes"
1243 then
1244         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1245         mysql_config_status=$?
1246
1247         if test $mysql_config_status -ne 0
1248         then
1249                 with_libmysql="no"
1250         else
1251                 SAVE_CPPFLAGS="$CPPFLAGS"
1252                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1253
1254                 AC_CHECK_HEADERS(mysql/mysql.h, [], [with_libmysql="no (mysql/mysql.h not found)"], [])
1255
1256                 CPPFLAGS="$SAVE_CPPFLAGS"
1257         fi
1258 fi
1259 if test "x$with_libmysql" = "xyes"
1260 then
1261         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1262         mysql_config_status=$?
1263
1264         if test $mysql_config_status -ne 0
1265         then
1266                 with_libmysql="no"
1267         else
1268                 AC_CHECK_LIB(mysqlclient, mysql_init,
1269                  [with_libmysql="yes"],
1270                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1271                  [$with_mysql_libs])
1272         fi
1273 fi
1274 if test "x$with_libmysql" = "xyes"
1275 then
1276         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1277         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1278         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1279         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1280 fi
1281 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1282 # }}}
1283
1284 # --with-libnetlink {{{
1285 with_libnetlink_cflags=""
1286 with_libnetlink_libs="-lnetlink"
1287 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1288 [
1289  echo "libnetlink: withval = $withval"
1290  if test "x$withval" = "xyes"
1291  then
1292          with_libnetlink="yes"
1293  else if test "x$withval" = "xno"
1294  then
1295          with_libnetlink="no"
1296  else
1297          if test -d "$withval/include"
1298          then
1299                  with_libnetlink_cflags="-I$withval/include"
1300                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1301                  with_libnetlink="yes"
1302          else
1303                  AC_MSG_ERROR("no such directory: $withval/include")
1304          fi
1305  fi; fi
1306 ],
1307 [
1308  if test "x$ac_system" = "xLinux"
1309  then
1310          with_libnetlink="yes"
1311  else
1312          with_libnetlink="no (Linux only library)"
1313  fi
1314 ])
1315 if test "x$with_libnetlink" = "xyes"
1316 then
1317         SAVE_CFLAGS=$CFLAGS
1318         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1319
1320         with_libnetlink="no (libnetlink.h not found)"
1321
1322         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1323         [
1324          with_libnetlink="yes"
1325          break
1326         ], [],
1327 [#include <stdio.h>
1328 #include <sys/types.h>
1329 #include <asm/types.h>
1330 #include <sys/socket.h>
1331 #include <linux/netlink.h>
1332 #include <linux/rtnetlink.h>])
1333         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1334 [#include <stdio.h>
1335 #include <sys/types.h>
1336 #include <asm/types.h>
1337 #include <sys/socket.h>])
1338
1339         AC_COMPILE_IFELSE(
1340 [#include <stdio.h>
1341 #include <sys/types.h>
1342 #include <asm/types.h>
1343 #include <sys/socket.h>
1344 #include <linux/netlink.h>
1345 #include <linux/rtnetlink.h>
1346
1347 int main (void)
1348 {
1349         int retval = TCA_STATS2;
1350         return (retval);
1351 }],
1352         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1353         []);
1354
1355         AC_COMPILE_IFELSE(
1356 [#include <stdio.h>
1357 #include <sys/types.h>
1358 #include <asm/types.h>
1359 #include <sys/socket.h>
1360 #include <linux/netlink.h>
1361 #include <linux/rtnetlink.h>
1362
1363 int main (void)
1364 {
1365         int retval = TCA_STATS;
1366         return (retval);
1367 }],
1368         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1369         []);
1370
1371         CFLAGS="$SAVE_CFLAGS"
1372 fi
1373 if test "x$with_libnetlink" = "xyes"
1374 then
1375         AC_CHECK_LIB(netlink, rtnl_open,
1376                      [with_libnetlink="yes"],
1377                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1378                      [$with_libnetlink_libs])
1379 fi
1380 if test "x$with_libnetlink" = "xyes"
1381 then
1382         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1383         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1384         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1385         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1386 fi
1387 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1388 # }}}
1389
1390 # --with-libnetsnmp {{{
1391 with_snmp_config="net-snmp-config"
1392 with_snmp_cflags=""
1393 with_snmp_libs=""
1394 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1395 [
1396         if test "x$withval" = "xno"
1397         then
1398                 with_libnetsnmp="no"
1399         else if test "x$withval" = "xyes"
1400         then
1401                 with_libnetsnmp="yes"
1402         else
1403                 if test -x "$withval"
1404                 then
1405                         with_snmp_config="$withval"
1406                         with_libnetsnmp="yes"
1407                 else
1408                         with_snmp_config="$withval/bin/net-snmp-config"
1409                         with_libnetsnmp="yes"
1410                 fi
1411         fi; fi
1412 ],
1413 [with_libnetsnmp="yes"])
1414 if test "x$with_libnetsnmp" = "xyes"
1415 then
1416         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1417         snmp_config_status=$?
1418
1419         if test $snmp_config_status -ne 0
1420         then
1421                 with_libnetsnmp="no ($with_snmp_config failed)"
1422         else
1423                 SAVE_CPPFLAGS="$CPPFLAGS"
1424                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1425                 
1426                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1427
1428                 CPPFLAGS="$SAVE_CPPFLAGS"
1429         fi
1430 fi
1431 if test "x$with_libnetsnmp" = "xyes"
1432 then
1433         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1434         snmp_config_status=$?
1435
1436         if test $snmp_config_status -ne 0
1437         then
1438                 with_libnetsnmp="no ($with_snmp_config failed)"
1439         else
1440                 AC_CHECK_LIB(netsnmp, init_snmp,
1441                 [with_libnetsnmp="yes"],
1442                 [with_libnetsnmp="no (libnetsnmp not found)"],
1443                 [$with_snmp_libs])
1444         fi
1445 fi
1446 if test "x$with_libnetsnmp" = "xyes"
1447 then
1448         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1449         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1450         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1451         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1452 fi
1453 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1454 # }}}
1455
1456 # --with-liboconfig {{{
1457 with_own_liboconfig="no"
1458 liboconfig_LDFLAGS="$LDFLAGS"
1459 liboconfig_CPPFLAGS="$CPPFLAGS"
1460 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1461 [
1462         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1463         then
1464                 if test -d "$withval/lib"
1465                 then
1466                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1467                 fi
1468                 if test -d "$withval/include"
1469                 then
1470                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1471                 fi
1472         fi
1473         if test "x$withval" = "xno"
1474         then
1475                 AC_MSG_ERROR("liboconfig is required")
1476         fi
1477 ],
1478 [
1479         with_liboconfig="yes"
1480 ])
1481
1482 save_LDFLAGS="$LDFLAGS"
1483 save_CPPFLAGS="$CPPFLAGS"
1484 LDFLAGS="$liboconfig_LDFLAGS"
1485 CPPFLAGS="$liboconfig_CPPFLAGS"
1486 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1487 [
1488         with_liboconfig="yes"
1489         with_own_liboconfig="no"
1490 ],
1491 [
1492         with_liboconfig="yes"
1493         with_own_liboconfig="yes"
1494         LDFLAGS="$save_LDFLAGS"
1495         CPPFLAGS="$save_CPPFLAGS"
1496 ])
1497
1498 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1499 if test "x$with_own_liboconfig" = "xyes"
1500 then
1501         with_liboconfig="yes (shipped version)"
1502 fi
1503 # }}}
1504
1505 # --with-liboping {{{
1506 with_own_liboping="no"
1507 liboping_LDFLAGS="$LDFLAGS"
1508 liboping_CPPFLAGS="$CPPFLAGS"
1509 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1510 [
1511         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1512         then
1513                 if test -d "$withval/lib"
1514                 then
1515                         liboping_LDFLAGS="$LDFLAGS -L$withval/lib"
1516                 fi
1517                 if test -d "$withval/include"
1518                 then
1519                         liboping_CPPFLAGS="$CPPFLAGS -I$withval/include"
1520                 fi
1521         fi
1522         if test "x$withval" = "xno"
1523         then
1524                 with_liboping="no"
1525                 with_own_liboping="no"
1526         else if test "x$withval" = "xyes"
1527         then
1528                 with_liboping="yes"
1529         fi; fi
1530 ],
1531 [
1532         with_liboping="yes"
1533 ])
1534
1535 if test "x$with_liboping" = "xyes"
1536 then
1537         save_LDFLAGS="$LDFLAGS"
1538         save_CPPFLAGS="$CPPFLAGS"
1539         LDFLAGS="$liboping_LDFLAGS"
1540         CPPFLAGS="$liboping_CPPFLAGS"
1541         AC_CHECK_LIB(oping, ping_construct,
1542         [
1543                 with_liboping="yes"
1544                 with_own_liboping="no"
1545         ],
1546         [
1547                 with_liboping="yes"
1548                 with_own_liboping="yes"
1549                 LDFLAGS="$save_LDFLAGS"
1550                 CPPFLAGS="$save_CPPFLAGS"
1551         ])
1552 fi
1553 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1554 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOPING, test "x$with_own_liboping" = "xyes")
1555 # }}}
1556
1557 # --with-oracle {{{
1558 with_oracle_cppflags=""
1559 with_oracle_libs=""
1560 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
1561 [
1562         if test "x$withval" = "xyes"
1563         then
1564                 if test "x$ORACLE_HOME" = "x"
1565                 then
1566                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
1567                 fi
1568                 with_oracle="yes"
1569         else if test "x$withval" = "xno"
1570         then
1571                 with_oracle="no"
1572         else
1573                 with_oracle="yes"
1574                 ORACLE_HOME="$withval"
1575         fi; fi
1576 ],
1577 [
1578         if test "x$ORACLE_HOME" = "x"
1579         then
1580                 with_oracle="no (ORACLE_HOME is not set)"
1581         else
1582                 with_oracle="yes"
1583         fi
1584 ])
1585 if test "x$ORACLE_HOME" != "x"
1586 then
1587         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
1588
1589         if test -e "$ORACLE_HOME/lib/ldflags"
1590         then
1591                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
1592         fi
1593         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
1594         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
1595 fi
1596 if test "x$with_oracle" = "xyes"
1597 then
1598         SAVE_CPPFLAGS="$CPPFLAGS"
1599         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
1600
1601         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
1602
1603         CPPFLAGS="$SAVE_CPPFLAGS"
1604 fi
1605 if test "x$with_oracle" = "xyes"
1606 then
1607         SAVE_CPPFLAGS="$CPPFLAGS"
1608         SAVE_LDFLAGS="$LDFLAGS"
1609         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
1610         LDFLAGS="$LDFLAGS $with_oracle_libs"
1611
1612         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
1613
1614         CPPFLAGS="$SAVE_CPPFLAGS"
1615         LDFLAGS="$SAVE_LDFLAGS"
1616 fi
1617 if test "x$with_oracle" = "xyes"
1618 then
1619         BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
1620         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
1621         AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
1622         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
1623 fi
1624 # }}}
1625
1626 # --with-libowcapi {{{
1627 with_libowcapi_cppflags=""
1628 with_libowcapi_libs="-lowcapi"
1629 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
1630 [
1631         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1632         then
1633                 with_libowcapi_cppflags="-I$withval/include"
1634                 with_libowcapi_libs="-L$withval/lib -lowcapi"
1635                 with_libowcapi="yes"
1636         else
1637                 with_libowcapi="$withval"
1638         fi
1639 ],
1640 [
1641         with_libowcapi="yes"
1642 ])
1643 if test "x$with_libowcapi" = "xyes"
1644 then
1645         SAVE_CPPFLAGS="$CPPFLAGS"
1646         CPPFLAGS="$with_libowcapi_cppflags"
1647         
1648         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
1649
1650         CPPFLAGS="$SAVE_CPPFLAGS"
1651 fi
1652 if test "x$with_libowcapi" = "xyes"
1653 then
1654         SAVE_LDFLAGS="$LDFLAGS"
1655         SAVE_CPPFLAGS="$CPPFLAGS"
1656         LDFLAGS="$with_libowcapi_libs"
1657         CPPFLAGS="$with_libowcapi_cppflags"
1658         
1659         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
1660
1661         LDFLAGS="$SAVE_LDFLAGS"
1662         CPPFLAGS="$SAVE_CPPFLAGS"
1663 fi
1664 if test "x$with_libowcapi" = "xyes"
1665 then
1666         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
1667         BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
1668         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
1669         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
1670 fi
1671 # }}}
1672
1673 # --with-libpcap {{{
1674 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
1675 [
1676         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1677         then
1678                 LDFLAGS="$LDFLAGS -L$withval/lib"
1679                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1680                 with_libpcap="yes"
1681         else
1682                 with_libpcap="$withval"
1683         fi
1684 ],
1685 [
1686         with_libpcap="yes"
1687 ])
1688 if test "x$with_libpcap" = "xyes"
1689 then
1690         AC_CHECK_LIB(pcap, pcap_open_live,
1691         [
1692                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
1693         ], [with_libpcap="no (libpcap not found)"])
1694 fi
1695 if test "x$with_libpcap" = "xyes"
1696 then
1697         AC_CHECK_HEADERS(pcap.h,
1698         [
1699                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1700         ], [with_libpcap="no (pcap.h not found)"])
1701 fi
1702 if test "x$with_libpcap" = "xyes"
1703 then
1704         collect_libpcap=1
1705 else
1706         collect_libpcap=0
1707 fi
1708 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
1709         [Wether or not to use the pcap library])
1710 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
1711 # }}}
1712
1713 # --with-libpcre {{{
1714 with_pcre_config="pcre-config"
1715 with_pcre_cflags=""
1716 with_pcre_libs=""
1717 AC_ARG_WITH(libpcre, [AS_HELP_STRING([--with-libpcre@<:@=PREFIX@:>@],
1718         [Path to libpcre.])],
1719         [
1720                 if test "x$withval" = "xno"
1721                 then
1722                         with_libpcre="no"
1723                 else if test "x$withval" = "xyes"
1724                 then
1725                         with_libpcre="yes"
1726                 else
1727                         if test -f "$withval" && test -x "$withval"
1728                         then
1729                                 with_pcre_config="$withval"
1730                         else if test -x "$withval/bin/pcre-config"
1731                         then
1732                                 with_pcre_config="$withval/bin/pcre-config"
1733                         fi; fi
1734                         with_libpcre="yes"
1735                 fi; fi
1736         ],
1737         [
1738                 with_libpcre="yes"
1739         ])
1740
1741 if test "x$with_libpcre" = "xyes"
1742 then
1743         with_pcre_cflags=`$with_pcre_config --cflags 2>/dev/null`
1744         pcre_config_status=$?
1745
1746         if test $pcre_config_status -ne 0
1747         then
1748                 with_libpcre="no ($with_pcre_config failed)"
1749         else
1750                 SAVE_CPPFLAGS="$CPPFLAGS"
1751                 CPPFLAGS="$CPPFLAGS $with_pcre_cflags"
1752
1753                 AC_CHECK_HEADERS(pcre.h, [], [with_libpcre="no (pcre.h not found)"], [])
1754
1755                 CPPFLAGS="$SAVE_CPPFLAGS"
1756         fi
1757 fi
1758
1759 if test "x$with_libpcre" = "xyes"
1760 then
1761         with_pcre_libs=`$with_pcre_config --libs 2>/dev/null`
1762         pcre_config_status=$?
1763
1764         if test $pcre_config_status -ne 0
1765         then
1766                 with_libpcre="no ($with_pcre_config failed)"
1767         else
1768                 AC_CHECK_LIB(pcre, pcre_compile,
1769                         [with_libpcre="yes"],
1770                         [with_libpcre="no (symbol 'pcre_compile' not found)"],
1771                         [$with_pcre_libs])
1772         fi
1773 fi
1774
1775 if test "x$with_libpcre" = "xyes"
1776 then
1777         BUILD_WITH_LIBPCRE_CFLAGS="$with_pcre_cflags"
1778         BUILD_WITH_LIBPCRE_LIBS="$with_pcre_libs"
1779         AC_SUBST(BUILD_WITH_LIBPCRE_CFLAGS)
1780         AC_SUBST(BUILD_WITH_LIBPCRE_LIBS)
1781 fi
1782 AM_CONDITIONAL(BUILD_WITH_LIBPCRE, test "x$with_libpcre" = "xyes")
1783 # }}}
1784
1785 # --with-libperl {{{
1786 perl_interpreter="perl"
1787 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
1788 [
1789         if test -x "$withval"
1790         then
1791                 perl_interpreter="$withval"
1792                 with_libperl="yes"
1793         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
1794         then
1795                 LDFLAGS="$LDFLAGS -L$withval/lib"
1796                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1797                 perl_interpreter="$withval/bin/perl"
1798                 with_libperl="yes"
1799         else
1800                 with_libperl="$withval"
1801         fi; fi
1802 ],
1803 [
1804         with_libperl="yes"
1805 ])
1806
1807 AC_MSG_CHECKING([for perl])
1808 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
1809 if test -x "$perl_interpreter"
1810 then
1811         AC_MSG_RESULT([yes ($perl_interpreter)])
1812 else
1813         perl_interpreter=""
1814         AC_MSG_RESULT([no])
1815 fi
1816
1817 AC_SUBST(PERL, "$perl_interpreter")
1818
1819 if test "x$with_libperl" = "xyes" \
1820         && test -n "$perl_interpreter"
1821 then
1822   SAVE_CFLAGS=$CFLAGS
1823   SAVE_LDFLAGS=$LDFLAGS
1824   PERL_CFLAGS=`$perl_interpreter -MExtUtils::Embed -e ccopts`
1825   PERL_LDFLAGS=`$perl_interpreter -MExtUtils::Embed -e ldopts`
1826   CFLAGS="$CFLAGS $PERL_CFLAGS"
1827   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1828
1829   AC_CACHE_CHECK([for libperl],
1830     [have_libperl],
1831     AC_LINK_IFELSE(
1832       AC_LANG_PROGRAM(
1833       [[
1834 #define PERL_NO_GET_CONTEXT
1835 #include <EXTERN.h>
1836 #include <perl.h>
1837 #include <XSUB.h>
1838       ]],
1839       [[
1840        dTHX;
1841        load_module (PERL_LOADMOD_NOIMPORT,
1842                          newSVpv ("Collectd::Plugin::FooBar", 24),
1843                          Nullsv);
1844       ]]),
1845       [have_libperl="yes"],
1846       [have_libperl="no"]
1847     )
1848   )
1849
1850   if test "x$have_libperl" = "xyes"
1851   then
1852           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
1853           AC_SUBST(PERL_CFLAGS)
1854           AC_SUBST(PERL_LDFLAGS)
1855   else
1856           with_libperl="no"
1857   fi
1858
1859   CFLAGS=$SAVE_CFLAGS
1860   LDFLAGS=$SAVE_LDFLAGS
1861 else if test -z "$perl_interpreter"; then
1862   with_libperl="no (no perl interpreter found)"
1863   have_libperl="no"
1864 fi; fi
1865 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
1866
1867 if test "x$with_libperl" = "xyes"
1868 then
1869         SAVE_CFLAGS=$CFLAGS
1870         SAVE_LDFLAGS=$LDFLAGS
1871         CFLAGS="$CFLAGS $PERL_CFLAGS"
1872         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
1873
1874         AC_CACHE_CHECK([if perl supports ithreads],
1875                 [have_perl_ithreads],
1876                 AC_LINK_IFELSE(
1877                         AC_LANG_PROGRAM(
1878                         [[
1879 #include <EXTERN.h>
1880 #include <perl.h>
1881 #include <XSUB.h>
1882
1883 #if !defined(USE_ITHREADS)
1884 # error "Perl does not support ithreads!"
1885 #endif /* !defined(USE_ITHREADS) */
1886                         ]],
1887                         [[ ]]),
1888                         [have_perl_ithreads="yes"],
1889                         [have_perl_ithreads="no"]
1890                 )
1891         )
1892
1893         if test "x$have_perl_ithreads" = "xyes"
1894         then
1895                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
1896         fi
1897
1898         CFLAGS=$SAVE_CFLAGS
1899         LDFLAGS=$SAVE_LDFLAGS
1900 fi
1901 # }}}
1902
1903 # --with-libpq {{{
1904 with_pg_config="pg_config"
1905 with_libpq_includedir=""
1906 with_libpq_libdir=""
1907 with_libpq_cppflags=""
1908 with_libpq_ldflags=""
1909 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
1910         [Path to libpq.])],
1911 [
1912         if test "x$withval" = "xno"
1913         then
1914                 with_libpq="no"
1915         else if test "x$withval" = "xyes"
1916         then
1917                 with_libpq="yes"
1918         else
1919                 if test -f "$withval" && test -x "$withval";
1920                 then
1921                         with_pg_config="$withval"
1922                 else if test -x "$withval/bin/pg_config"
1923                 then
1924                         with_pg_config="$withval/bin/pg_config"
1925                 fi; fi
1926                 with_libpq="yes"
1927         fi; fi
1928 ],
1929 [
1930         with_libpq="yes"
1931 ])
1932 if test "x$with_libpq" = "xyes"
1933 then
1934         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
1935         pg_config_status=$?
1936
1937         if test $pg_config_status -eq 0
1938         then
1939                 if test -n "$with_libpq_includedir"; then
1940                         for dir in $with_libpq_includedir; do
1941                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
1942                         done
1943                 fi
1944         else
1945                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
1946         fi
1947
1948         SAVE_CPPFLAGS="$CPPFLAGS"
1949         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
1950
1951         AC_CHECK_HEADERS(libpq-fe.h, [],
1952                 [with_libpq="no (libpq-fe.h not found)"], [])
1953
1954         CPPFLAGS="$SAVE_CPPFLAGS"
1955 fi
1956 if test "x$with_libpq" = "xyes"
1957 then
1958         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
1959         pg_config_status=$?
1960
1961         if test $pg_config_status -eq 0
1962         then
1963                 if test -n "$with_libpq_libdir"; then
1964                         for dir in $with_libpq_libdir; do
1965                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
1966                         done
1967                 fi
1968         else
1969                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
1970         fi
1971
1972         SAVE_LDFLAGS="$LDFLAGS"
1973         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
1974
1975         AC_CHECK_LIB(pq, PQconnectdb,
1976                 [with_libpq="yes"],
1977                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
1978
1979         LDFLAGS="$SAVE_LDFLAGS"
1980 fi
1981 if test "x$with_libpq" = "xyes"
1982 then
1983         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
1984         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
1985         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
1986         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
1987 fi
1988 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
1989 # }}}
1990
1991 # --with-libpthread {{{
1992 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
1993 [       if test "x$withval" != "xno" \
1994                 && test "x$withval" != "xyes"
1995         then
1996                 LDFLAGS="$LDFLAGS -L$withval/lib"
1997                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1998                 with_libpthread="yes"
1999         else
2000                 if test "x$withval" = "xno"
2001                 then
2002                         with_libpthread="no (disabled)"
2003                 fi
2004         fi
2005 ], [with_libpthread="yes"])
2006 if test "x$with_libpthread" = "xyes"
2007 then
2008         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
2009 fi
2010 if test "x$with_libpthread" = "xyes"
2011 then
2012         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
2013 fi
2014 if test "x$with_libpthread" = "xyes"
2015 then
2016         collect_pthread=1
2017 else
2018         collect_pthread=0
2019 fi
2020 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
2021         [Wether or not to use pthread (POSIX threads) library])
2022 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
2023 # }}}
2024
2025 # --with-librrd {{{
2026 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
2027 librrd_cflags=""
2028 librrd_ldflags=""
2029 librrd_threadsafe="yes"
2030 librrd_rrdc_update="no"
2031 AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
2032 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
2033         then
2034                 librrd_cflags="-I$withval/include"
2035                 librrd_ldflags="-L$withval/lib"
2036                 with_librrd="yes"
2037         else
2038                 with_librrd="$withval"
2039         fi
2040 ], [with_librrd="yes"])
2041 if test "x$with_librrd" = "xyes"
2042 then
2043         SAVE_CPPFLAGS="$CPPFLAGS"
2044         SAVE_LDFLAGS="$LDFLAGS"
2045
2046         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2047         LDFLAGS="$LDFLAGS $librrd_ldflags"
2048
2049         AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
2050
2051         CPPFLAGS="$SAVE_CPPFLAGS"
2052         LDFLAGS="$SAVE_LDFLAGS"
2053 fi
2054 if test "x$with_librrd" = "xyes"
2055 then
2056         SAVE_CPPFLAGS="$CPPFLAGS"
2057         SAVE_LDFLAGS="$LDFLAGS"
2058
2059         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2060         LDFLAGS="$LDFLAGS $librrd_ldflags"
2061
2062         AC_CHECK_LIB(rrd_th, rrd_update_r,
2063         [with_librrd="yes"
2064          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
2065         ],
2066         [librrd_threadsafe="no"
2067          AC_CHECK_LIB(rrd, rrd_update,
2068          [with_librrd="yes"
2069           librrd_ldflags="$librrd_ldflags -lrrd -lm"
2070          ],
2071          [with_librrd="no (symbol 'rrd_update' not found)"],
2072          [-lm])
2073         ],
2074         [-lm])
2075
2076         if test "x$librrd_threadsafe" = "xyes"
2077         then
2078                 AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2079         else
2080                 AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2081         fi
2082
2083         CPPFLAGS="$SAVE_CPPFLAGS"
2084         LDFLAGS="$SAVE_LDFLAGS"
2085 fi
2086 if test "x$with_librrd" = "xyes"
2087 then
2088         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
2089         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
2090         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
2091         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
2092 fi
2093 if test "x$librrd_threadsafe" = "xyes"
2094 then
2095         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
2096 fi
2097 # }}}
2098
2099 # --with-libsensors {{{
2100 with_sensors_cflags=""
2101 with_sensors_ldflags=""
2102 AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
2103 [
2104         if test "x$withval" = "xno"
2105         then
2106                 with_libsensors="no"
2107         else
2108                 with_libsensors="yes"
2109                 if test "x$withval" != "xyes"
2110                 then
2111                         with_sensors_cflags="-I$withval/include"
2112                         with_sensors_ldflags="-L$withval/lib"
2113                         with_libsensors="yes"
2114                 fi
2115         fi
2116 ],
2117 [
2118         if test "x$ac_system" = "xLinux"
2119         then
2120                 with_libsensors="yes"
2121         else
2122                 with_libsensors="no (Linux only library)"
2123         fi
2124 ])
2125 if test "x$with_libsensors" = "xyes"
2126 then
2127         SAVE_CPPFLAGS="$CPPFLAGS"
2128         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2129
2130 #       AC_CHECK_HEADERS(sensors/sensors.h,
2131 #       [
2132 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
2133 #       ],
2134 #       [with_libsensors="no (sensors/sensors.h not found)"])
2135         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
2136
2137         CPPFLAGS="$SAVE_CPPFLAGS"
2138 fi
2139 if test "x$with_libsensors" = "xyes"
2140 then
2141         SAVE_CPPFLAGS="$CPPFLAGS"
2142         SAVE_LDFLAGS="$LDFLAGS"
2143         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2144         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
2145
2146         AC_CHECK_LIB(sensors, sensors_init,
2147         [
2148                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
2149         ],
2150         [with_libsensors="no (libsensors not found)"])
2151
2152         CPPFLAGS="$SAVE_CPPFLAGS"
2153         LDFLAGS="$SAVE_LDFLAGS"
2154 fi
2155 if test "x$with_libsensors" = "xyes"
2156 then
2157         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
2158         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
2159         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
2160         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
2161 fi
2162 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
2163 # }}}
2164
2165 # --with-libstatgrab {{{
2166 with_libstatgrab_cflags=""
2167 with_libstatgrab_ldflags=""
2168 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
2169 [
2170         if test "x$withval" != "xno" \
2171                 && test "x$withval" != "xyes"
2172         then
2173                 with_libstatgrab_cflags="-I$withval/include"
2174                 with_libstatgrab_ldflags="-L$withval/lib"
2175                 with_libstatgrab="yes"
2176         else
2177                 with_libstatgrab="$withval"
2178         fi
2179 ],
2180 [
2181         if test "x$ac_system" = "xunknown"
2182         then
2183                 with_libstatgrab="yes"
2184         else
2185                 with_libstatgrab="no"
2186         fi
2187 ])
2188 with_libstatgrab_pkg_config="yes"
2189 if test "x$with_libstatgrab" = "xyes" \
2190   && test "x$PKG_CONFIG" != "x"
2191 then
2192   AC_MSG_CHECKING([pkg-config for libstatgrab])
2193   temp_result="found"
2194   $PKG_CONFIG --exists libstatgrab 2>/dev/null
2195   if test "$?" != "0"
2196   then
2197     with_libstatgrab_pkg_config="no"
2198     temp_result="not found"
2199   fi
2200   AC_MSG_RESULT([$temp_result])
2201 else
2202   AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
2203   with_libstatgrab_pkg_config="no"
2204   with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
2205 fi
2206
2207 if test "x$with_libstatgrab" = "xyes" \
2208   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2209   && test "x$with_libstatgrab_cflags" = "x"
2210 then
2211   AC_MSG_CHECKING([for libstatgrab CFLAGS])
2212   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
2213   if test "$?" = "0"
2214   then
2215     with_libstatgrab_cflags="$temp_result"
2216   else
2217     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
2218     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
2219   fi
2220   AC_MSG_RESULT([$temp_result])
2221 fi
2222
2223 if test "x$with_libstatgrab" = "xyes" \
2224   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2225   && test "x$with_libstatgrab_ldflags" = "x"
2226 then
2227   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
2228   temp_result="`$PKG_CONFIG --libs libstatgrab`"
2229   if test "$?" = "0"
2230   then
2231     with_libstatgrab_ldflags="$temp_result"
2232   else
2233     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
2234     temp_result="$PKG_CONFIG --libs libstatgrab failed"
2235   fi
2236   AC_MSG_RESULT([$temp_result])
2237 fi
2238
2239 if test "x$with_libstatgrab" = "xyes"
2240 then
2241   SAVE_CPPFLAGS="$CPPFLAGS"
2242   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
2243
2244   AC_CHECK_HEADERS(statgrab.h,
2245                    [with_libstatgrab="yes"],
2246                    [with_libstatgrab="no (statgrab.h not found)"])
2247
2248   CPPFLAGS="$SAVE_CPPFLAGS"
2249 fi
2250
2251 if test "x$with_libstatgrab" = "xyes"
2252 then
2253   SAVE_CFLAGS="$CFLAGS"
2254   SAVE_LDFLAGS="$LDFLAGS"
2255
2256   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
2257   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
2258
2259   AC_CHECK_LIB(statgrab, sg_init,
2260                [with_libstatgrab="yes"],
2261                [with_libstatgrab="no (symbol sg_init not found)"])
2262
2263   CFLAGS="$SAVE_CFLAGS"
2264   LDFLAGS="$SAVE_LDFLAGS"
2265 fi
2266
2267 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
2268 if test "x$with_libstatgrab" = "xyes"
2269 then
2270   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
2271   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
2272   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
2273   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
2274   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
2275 fi
2276 # }}}
2277
2278 # --with-libxmms {{{
2279 with_xmms_config="xmms-config"
2280 with_xmms_cflags=""
2281 with_xmms_libs=""
2282 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
2283 [
2284         if test "x$withval" != "xno" \
2285                 && test "x$withval" != "xyes"
2286         then
2287                 if test -f "$withval" && test -x "$withval";
2288                 then
2289                         with_xmms_config="$withval"
2290                 else if test -x "$withval/bin/xmms-config"
2291                 then
2292                         with_xmms_config="$withval/bin/xmms-config"
2293                 fi; fi
2294                 with_libxmms="yes"
2295         else if test "x$withval" = "xno"
2296         then
2297                 with_libxmms="no"
2298         else
2299                 with_libxmms="yes"
2300         fi; fi
2301 ],
2302 [
2303         with_libxmms="yes"
2304 ])
2305 if test "x$with_libxmms" = "xyes"
2306 then
2307         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
2308         xmms_config_status=$?
2309
2310         if test $xmms_config_status -ne 0
2311         then
2312                 with_libxmms="no"
2313         fi
2314 fi
2315 if test "x$with_libxmms" = "xyes"
2316 then
2317         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
2318         xmms_config_status=$?
2319
2320         if test $xmms_config_status -ne 0
2321         then
2322                 with_libxmms="no"
2323         fi
2324 fi
2325 if test "x$with_libxmms" = "xyes"
2326 then
2327         AC_CHECK_LIB(xmms, xmms_remote_get_info,
2328         [
2329                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
2330                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
2331                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
2332                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
2333         ],
2334         [
2335                 with_libxmms="no"
2336         ],
2337         [$with_xmms_libs])
2338 fi
2339 with_libxmms_numeric=0
2340 if test "x$with_libxmms" = "xyes"
2341 then
2342         with_libxmms_numeric=1
2343 fi
2344 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
2345 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
2346 # }}}
2347
2348 # pkg-config --exists 'libupsclient' {{{
2349 with_libupsclient="no (pkg-config isn't available)"
2350 with_libupsclient_cflags=""
2351 with_libupsclient_libs=""
2352 if test "x$PKG_CONFIG" != "x"
2353 then
2354         pkg-config --exists 'libupsclient' 2>/dev/null
2355         if test "$?" = "0"
2356         then
2357                 with_libupsclient="yes"
2358         else
2359                 with_libupsclient="no (pkg-config doesn't know library)"
2360         fi
2361 fi
2362 if test "x$with_libupsclient" = "xyes"
2363 then
2364         with_libupsclient_cflags="`pkg-config --cflags 'libupsclient'`"
2365         if test $? -ne 0
2366         then
2367                 with_libupsclient="no"
2368         fi
2369         with_libupsclient_libs="`pkg-config --libs 'libupsclient'`"
2370         if test $? -ne 0
2371         then
2372                 with_libupsclient="no"
2373         fi
2374 fi
2375 if test "x$with_libupsclient" = "xyes"
2376 then
2377         SAVE_CPPFLAGS="$CPPFLAGS"
2378         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2379
2380         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
2381
2382         CPPFLAGS="$SAVE_CPPFLAGS"
2383 fi
2384 if test "x$with_libupsclient" = "xyes"
2385 then
2386         SAVE_CPPFLAGS="$CPPFLAGS"
2387         SAVE_LDFLAGS="$LDFLAGS"
2388
2389         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2390         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
2391
2392         AC_CHECK_LIB(upsclient, upscli_connect,
2393                      [with_libupsclient="yes"],
2394                      [with_libupsclient="no (symbol upscli_connect not found)"])
2395
2396         CPPFLAGS="$SAVE_CPPFLAGS"
2397         LDFLAGS="$SAVE_LDFLAGS"
2398 fi
2399 if test "x$with_libupsclient" = "xyes"
2400 then
2401         SAVE_CPPFLAGS="$CPPFLAGS"
2402         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2403
2404         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
2405 [#include <stdlib.h>
2406 #include <stdio.h>
2407 #include <upsclient.h>])
2408
2409         CPPFLAGS="$SAVE_CPPFLAGS"
2410 fi
2411 if test "x$with_libupsclient" = "xyes"
2412 then
2413         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
2414         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
2415         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
2416         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
2417 fi
2418 # }}}
2419
2420 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
2421 with_libxml2="no (pkg-config isn't available)"
2422 with_libxml2_cflags=""
2423 with_libxml2_ldflags=""
2424 with_libvirt="no (pkg-config isn't available)"
2425 with_libvirt_cflags=""
2426 with_libvirt_ldflags=""
2427 if test "x$PKG_CONFIG" != "x"
2428 then
2429         pkg-config --exists 'libxml-2.0' 2>/dev/null
2430         if test "$?" = "0"
2431         then
2432                 with_libxml2="yes"
2433         else
2434                 with_libxml2="no (pkg-config doesn't know library)"
2435         fi
2436
2437         pkg-config --exists libvirt 2>/dev/null
2438         if test "$?" = "0"
2439         then
2440                 with_libvirt="yes"
2441         else
2442                 with_libvirt="no (pkg-config doesn't know library)"
2443         fi
2444 fi
2445 if test "x$with_libxml2" = "xyes"
2446 then
2447         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
2448         if test $? -ne 0
2449         then
2450                 with_libxml2="no"
2451         fi
2452         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
2453         if test $? -ne 0
2454         then
2455                 with_libxml2="no"
2456         fi
2457 fi
2458 if test "x$with_libxml2" = "xyes"
2459 then
2460         SAVE_CPPFLAGS="$CPPFLAGS"
2461         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
2462
2463         AC_CHECK_HEADERS(libxml/parser.h, [],
2464                       [with_libxml2="no (libxml/parser.h not found)"])
2465
2466         CPPFLAGS="$SAVE_CPPFLAGS"
2467 fi
2468 if test "x$with_libxml2" = "xyes"
2469 then
2470         SAVE_CFLAGS="$CFLAGS"
2471         SAVE_LDFLAGS="$LDFLAGS"
2472
2473         CFLAGS="$CFLAGS $with_libxml2_cflags"
2474         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
2475
2476         AC_CHECK_LIB(xml2, xmlXPathEval,
2477                      [with_libxml2="yes"],
2478                      [with_libxml2="no (symbol xmlXPathEval not found)"])
2479
2480         CFLAGS="$SAVE_CFLAGS"
2481         LDFLAGS="$SAVE_LDFLAGS"
2482 fi
2483 dnl Add the right compiler flags and libraries.
2484 if test "x$with_libxml2" = "xyes"; then
2485         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
2486         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
2487         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
2488         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
2489 fi
2490 if test "x$with_libvirt" = "xyes"
2491 then
2492         with_libvirt_cflags="`pkg-config --cflags libvirt`"
2493         if test $? -ne 0
2494         then
2495                 with_libvirt="no"
2496         fi
2497         with_libvirt_ldflags="`pkg-config --libs libvirt`"
2498         if test $? -ne 0
2499         then
2500                 with_libvirt="no"
2501         fi
2502 fi
2503 if test "x$with_libvirt" = "xyes"
2504 then
2505         SAVE_CPPFLAGS="$CPPFLAGS"
2506         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
2507
2508         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
2509                       [with_libvirt="no (libvirt/libvirt.h not found)"])
2510
2511         CPPFLAGS="$SAVE_CPPFLAGS"
2512 fi
2513 if test "x$with_libvirt" = "xyes"
2514 then
2515         SAVE_CFLAGS="$CFLAGS"
2516         SAVE_LDFLAGS="$LDFLAGS"
2517
2518         CFLAGS="$CFLAGS $with_libvirt_cflags"
2519         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
2520
2521         AC_CHECK_LIB(virt, virDomainBlockStats,
2522                      [with_libvirt="yes"],
2523                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
2524
2525         CFLAGS="$SAVE_CFLAGS"
2526         LDFLAGS="$SAVE_LDFLAGS"
2527 fi
2528 dnl Add the right compiler flags and libraries.
2529 if test "x$with_libvirt" = "xyes"; then
2530         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
2531         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
2532         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
2533         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
2534 fi
2535 # }}}
2536
2537 # $PKG_CONFIG --exists OpenIPMIpthread {{{
2538 with_libopenipmipthread="yes"
2539 with_libopenipmipthread_cflags=""
2540 with_libopenipmipthread_libs=""
2541
2542 AC_MSG_CHECKING([for pkg-config])
2543 temp_result="no"
2544 if test "x$PKG_CONFIG" = "x"
2545 then
2546         with_libopenipmipthread="no"
2547         temp_result="no"
2548 else
2549         temp_result="$PKG_CONFIG"
2550 fi
2551 AC_MSG_RESULT([$temp_result])
2552
2553 if test "x$with_libopenipmipthread" = "xyes"
2554 then
2555         AC_MSG_CHECKING([for libOpenIPMIpthread])
2556         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
2557         if test "$?" != "0"
2558         then
2559                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
2560         fi
2561         AC_MSG_RESULT([$with_libopenipmipthread])
2562 fi
2563
2564 if test "x$with_libopenipmipthread" = "xyes"
2565 then
2566         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
2567         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
2568         if test "$?" = "0"
2569         then
2570                 with_libopenipmipthread_cflags="$temp_result"
2571         else
2572                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
2573                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
2574         fi
2575         AC_MSG_RESULT([$temp_result])
2576 fi
2577
2578 if test "x$with_libopenipmipthread" = "xyes"
2579 then
2580         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
2581         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
2582         if test "$?" = "0"
2583         then
2584                 with_libopenipmipthread_ldflags="$temp_result"
2585         else
2586                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
2587                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
2588         fi
2589         AC_MSG_RESULT([$temp_result])
2590 fi
2591
2592 if test "x$with_libopenipmipthread" = "xyes"
2593 then
2594         SAVE_CPPFLAGS="$CPPFLAGS"
2595         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
2596
2597         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
2598                          [with_libopenipmipthread="yes"],
2599                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
2600 [#include <OpenIPMI/ipmiif.h>
2601 #include <OpenIPMI/ipmi_err.h>
2602 #include <OpenIPMI/ipmi_posix.h>
2603 #include <OpenIPMI/ipmi_conn.h>
2604 ])
2605
2606         CPPFLAGS="$SAVE_CPPFLAGS"
2607 fi
2608
2609 if test "x$with_libopenipmipthread" = "xyes"
2610 then
2611         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
2612         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
2613         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
2614         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
2615 fi
2616 # }}}
2617
2618 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
2619                 [with_libnotify="yes"],
2620                 [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
2621
2622 # Check for enabled/disabled features
2623 #
2624
2625 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
2626 # ------------------------------------------------------------
2627 dnl
2628 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
2629 dnl
2630 AC_DEFUN(
2631         [AC_COLLECTD],
2632         [
2633         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
2634         m4_if(
2635                 [$2],
2636                 [enable],
2637                 [dnl
2638                 m4_define([EnDis],[disabled])dnl
2639                 m4_define([YesNo],[no])dnl
2640                 ],dnl
2641                 [m4_if(
2642                         [$2],
2643                         [disable],
2644                         [dnl
2645                         m4_define([EnDis],[enabled])dnl
2646                         m4_define([YesNo],[yes])dnl
2647                         ],
2648                         [dnl
2649                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
2650                         ]dnl
2651                 )]dnl
2652         )dnl
2653         m4_if([$3], [feature], [],
2654                 [m4_if(
2655                         [$3], [module], [],
2656                         [dnl
2657                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
2658                         ]dnl
2659                 )]dnl
2660         )dnl
2661         AC_ARG_ENABLE(
2662                 [$1],
2663                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
2664                 [],
2665                 enable_$1='[YesNo]'dnl
2666         )# AC_ARG_ENABLE
2667 if test "x$enable_$1" = "xno"
2668 then
2669         collectd_$1=0
2670 else
2671         if test "x$enable_$1" = "xyes"
2672         then
2673                 collectd_$1=1
2674         else
2675                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
2676                 collectd_$1=1
2677                 enable_$1='yes'
2678         fi
2679 fi
2680         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
2681         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
2682         ]dnl
2683 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
2684
2685 # AC_PLUGIN(name, default, info)
2686 # ------------------------------------------------------------
2687 dnl
2688 AC_DEFUN(
2689   [AC_PLUGIN],
2690   [
2691     enable_plugin="no"
2692     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
2693     [
2694      if test "x$enableval" = "xyes"
2695      then
2696              enable_plugin="yes"
2697      else
2698              enable_plugin="no"
2699      fi
2700     ],
2701     [
2702      if test "x$2" = "xyes"
2703      then
2704              enable_plugin="yes"
2705      else
2706              enable_plugin="no"
2707      fi
2708     ])
2709     if test "x$enable_plugin" = "xyes"
2710     then
2711             if test "x$2" = "xyes"
2712             then
2713                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
2714             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
2715                     dependency_error="yes"
2716                     enable_plugin="no (dependency error)"
2717             fi
2718     fi
2719     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
2720     enable_$1="$enable_plugin"
2721   ]
2722 )# AC_PLUGIN(name, default, info)
2723
2724 m4_divert_once([HELP_ENABLE], [
2725 collectd features:])
2726 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
2727 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
2728 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
2729 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
2730
2731 dependency_error="no"
2732 plugin_ascent="no"
2733 plugin_battery="no"
2734 plugin_cpu="no"
2735 plugin_cpufreq="no"
2736 plugin_df="no"
2737 plugin_disk="no"
2738 plugin_entropy="no"
2739 plugin_interface="no"
2740 plugin_ipmi="no"
2741 plugin_ipvs="no"
2742 plugin_irq="no"
2743 plugin_libvirt="no"
2744 plugin_load="no"
2745 plugin_memory="no"
2746 plugin_multimeter="no"
2747 plugin_nfs="no"
2748 plugin_perl="no"
2749 plugin_processes="no"
2750 plugin_serial="no"
2751 plugin_swap="no"
2752 plugin_tape="no"
2753 plugin_tcpconns="no"
2754 plugin_thermal="no"
2755 plugin_users="no"
2756 plugin_vmem="no"
2757 plugin_vserver="no"
2758 plugin_wireless="no"
2759
2760 # Linux
2761 if test "x$ac_system" = "xLinux"
2762 then
2763         plugin_battery="yes"
2764         plugin_cpu="yes"
2765         plugin_cpufreq="yes"
2766         plugin_disk="yes"
2767         plugin_entropy="yes"
2768         plugin_interface="yes"
2769         plugin_irq="yes"
2770         plugin_load="yes"
2771         plugin_memory="yes"
2772         plugin_nfs="yes"
2773         plugin_processes="yes"
2774         plugin_serial="yes"
2775         plugin_swap="yes"
2776         plugin_tcpconns="yes"
2777         plugin_thermal="yes"
2778         plugin_vmem="yes"
2779         plugin_vserver="yes"
2780         plugin_wireless="yes"
2781
2782         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
2783         then
2784                 plugin_ipvs="yes"
2785         fi
2786 fi
2787
2788 if test "x$ac_system" = "xOpenBSD"
2789 then
2790         plugin_tcpconns="yes"
2791 fi
2792
2793 # Mac OS X devices
2794 if test "x$with_libiokit" = "xyes"
2795 then
2796         plugin_battery="yes"
2797         plugin_disk="yes"
2798 fi
2799
2800 # Solaris
2801 if test "x$with_devinfo$with_kstat" = "xyesyes"
2802 then
2803         plugin_cpu="yes"
2804         plugin_disk="yes"
2805         plugin_interface="yes"
2806         plugin_memory="yes"
2807         plugin_swap="yes"
2808         plugin_tape="yes"
2809 fi
2810
2811 # libstatgrab
2812 if test "x$with_libstatgrab" = "xyes"
2813 then
2814         plugin_cpu="yes"
2815         plugin_disk="yes"
2816         plugin_interface="yes"
2817         plugin_load="yes"
2818         plugin_memory="yes"
2819         plugin_swap="yes"
2820         plugin_users="yes"
2821 fi
2822
2823 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
2824 then
2825         plugin_ascent="yes"
2826 fi
2827
2828 if test "x$with_libopenipmipthread" = "xyes"
2829 then
2830         plugin_ipmi="yes"
2831 fi
2832
2833 if test "x$have_processor_info" = "xyes"
2834 then
2835         plugin_cpu="yes"
2836 fi
2837 if test "x$have_sysctlbyname" = "xyes"
2838 then
2839         plugin_cpu="yes"
2840         plugin_memory="yes"
2841         plugin_tcpconns="yes"
2842 fi
2843
2844 if test "x$have_statfs" = "xyes"
2845 then
2846         plugin_df="yes"
2847 fi
2848 if test "x$have_statvfs" = "xyes"
2849 then
2850         plugin_df="yes"
2851 fi
2852
2853 if test "x$have_getifaddrs" = "xyes"
2854 then
2855         plugin_interface="yes"
2856 fi
2857
2858 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
2859 then
2860         plugin_libvirt="yes"
2861 fi
2862
2863 if test "x$have_getloadavg" = "xyes"
2864 then
2865         plugin_load="yes"
2866 fi
2867
2868 if test "x$have_libperl$have_perl_ithreads" = "xyesyes"
2869 then
2870         plugin_perl="yes"
2871 fi
2872
2873 # Mac OS X memory interface
2874 if test "x$have_host_statistics" = "xyes"
2875 then
2876         plugin_memory="yes"
2877 fi
2878
2879 if test "x$have_termios_h" = "xyes"
2880 then
2881         plugin_multimeter="yes"
2882 fi
2883
2884 if test "x$have_thread_info" = "xyes"
2885 then
2886         plugin_processes="yes"
2887 fi
2888
2889 if test "x$with_kvm_getprocs" = "xyes"
2890 then
2891         plugin_processes="yes"
2892 fi
2893
2894 if test "x$with_kvm_getswapinfo" = "xyes"
2895 then
2896         plugin_swap="yes"
2897 fi
2898
2899 if test "x$with_kvm_nlist" = "xyes"
2900 then
2901         plugin_tcpconns="yes"
2902 fi
2903
2904 if test "x$have_getutent" = "xyes"
2905 then
2906         plugin_users="yes"
2907 fi
2908 if test "x$have_getutxent" = "xyes"
2909 then
2910         plugin_users="yes"
2911 fi
2912
2913 # FIXME: sysctl for swap plugin
2914
2915 m4_divert_once([HELP_ENABLE], [
2916 collectd plugins:])
2917
2918 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
2919 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
2920 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
2921 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
2922 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
2923 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
2924 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
2925 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
2926 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
2927 AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
2928 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
2929 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
2930 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
2931 AC_PLUGIN([email],       [yes],                [EMail statistics])
2932 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
2933 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
2934 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
2935 AC_PLUGIN([filter_ignore], [yes],                [Ignore specific values])
2936 AC_PLUGIN([filter_pcre], [$with_libpcre],      [Filter based on PCRE])
2937 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
2938 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
2939 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
2940 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
2941 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
2942 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
2943 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
2944 AC_PLUGIN([load],        [$plugin_load],       [System load])
2945 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
2946 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
2947 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
2948 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
2949 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
2950 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
2951 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
2952 AC_PLUGIN([network],     [yes],                [Network communication plugin])
2953 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
2954 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
2955 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
2956 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
2957 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
2958 AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
2959 AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
2960 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
2961 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
2962 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
2963 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
2964 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
2965 AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
2966 AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
2967 AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
2968 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
2969 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
2970 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
2971 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
2972 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
2973 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
2974 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
2975 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
2976 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
2977 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
2978 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
2979 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
2980 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
2981 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
2982 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
2983 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
2984
2985 dnl ip_vs.h
2986 if test "x$ac_system" = "xLinux" \
2987         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
2988 then
2989         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
2990 fi
2991
2992 dnl Perl bindings
2993 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
2994 [
2995         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2996         then
2997                 PERL_BINDINGS_OPTIONS="$withval"
2998                 with_perl_bindings="yes"
2999         else
3000                 PERL_BINDINGS_OPTIONS=""
3001                 with_perl_bindings="$withval"
3002         fi
3003 ],
3004 [
3005         PERL_BINDINGS_OPTIONS=""
3006         if test -n "$perl_interpreter"
3007         then
3008                 with_perl_bindings="yes"
3009         else
3010                 with_perl_bindings="no (no perl interpreter found)"
3011         fi
3012 ])
3013 if test "x$with_perl_bindings" = "xyes"
3014 then
3015         PERL_BINDINGS="perl"
3016 else
3017         PERL_BINDINGS=""
3018 fi
3019 AC_SUBST(PERL_BINDINGS)
3020 AC_SUBST(PERL_BINDINGS_OPTIONS)
3021
3022 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/liboconfig/Makefile src/liboping/Makefile bindings/Makefile)
3023
3024 if test "x$with_librrd" = "xyes" \
3025         && test "x$librrd_threadsafe" != "xyes"
3026 then
3027         with_librrd="yes (warning: librrd is not thread-safe)"
3028 fi
3029
3030 if test "x$with_liboping" = "xyes" \
3031         && test "x$with_own_liboping" = "xyes"
3032 then
3033         with_liboping="yes (shipped version)"
3034 fi
3035
3036 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
3037 then
3038         with_libiptc="yes (shipped version)"
3039 fi
3040
3041 if test "x$with_libperl" = "xyes"
3042 then
3043         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
3044 else
3045         enable_perl="no (needs libperl)"
3046 fi
3047
3048 if test "x$with_perl_bindings" = "xyes" \
3049         && test "x$PERL_BINDINGS_OPTIONS" != "x"
3050 then
3051         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
3052 fi
3053
3054 cat <<EOF;
3055
3056 Configuration:
3057   Libraries:
3058     libcurl . . . . . . . $with_libcurl
3059     libdbi  . . . . . . . $with_libdbi
3060     libesmtp  . . . . . . $with_libesmtp
3061     libiokit  . . . . . . $with_libiokit
3062     libiptc . . . . . . . $with_libiptc
3063     libkstat  . . . . . . $with_kstat
3064     libkvm  . . . . . . . $with_libkvm
3065     libmysql  . . . . . . $with_libmysql
3066     libnetlink  . . . . . $with_libnetlink
3067     libnetsnmp  . . . . . $with_libnetsnmp
3068     libnotify . . . . . . $with_libnotify
3069     liboconfig  . . . . . $with_liboconfig
3070     libopenipmi . . . . . $with_libopenipmipthread
3071     liboping  . . . . . . $with_liboping
3072     libpcap . . . . . . . $with_libpcap
3073     libpcre . . . . . . . $with_libpcre
3074     libperl . . . . . . . $with_libperl
3075     libpthread  . . . . . $with_libpthread
3076     libpq . . . . . . . . $with_libpq
3077     librrd  . . . . . . . $with_librrd
3078     libsensors  . . . . . $with_libsensors
3079     libstatgrab . . . . . $with_libstatgrab
3080     libupsclient  . . . . $with_libupsclient
3081     libvirt . . . . . . . $with_libvirt
3082     libxml2 . . . . . . . $with_libxml2
3083     libxmms . . . . . . . $with_libxmms
3084     oracle  . . . . . . . $with_oracle
3085
3086   Features:
3087     daemon mode . . . . . $enable_daemon
3088     debug . . . . . . . . $enable_debug
3089
3090   Bindings:
3091     perl  . . . . . . . . $with_perl_bindings
3092
3093   Modules:
3094     apache  . . . . . . . $enable_apache
3095     apcups  . . . . . . . $enable_apcups
3096     apple_sensors . . . . $enable_apple_sensors
3097     ascent  . . . . . . . $enable_ascent
3098     battery . . . . . . . $enable_battery
3099     cpu . . . . . . . . . $enable_cpu
3100     cpufreq . . . . . . . $enable_cpufreq
3101     csv . . . . . . . . . $enable_csv
3102     dbi . . . . . . . . . $enable_dbi
3103     df  . . . . . . . . . $enable_df
3104     disk  . . . . . . . . $enable_disk
3105     dns . . . . . . . . . $enable_dns
3106     email . . . . . . . . $enable_email
3107     entropy . . . . . . . $enable_entropy
3108     exec  . . . . . . . . $enable_exec
3109     filecount . . . . . . $enable_filecount
3110     filter_ignore . . . . $enable_filter_ignore
3111     filter_pcre . . . . . $enable_filter_pcre
3112     hddtemp . . . . . . . $enable_hddtemp
3113     interface . . . . . . $enable_interface
3114     iptables  . . . . . . $enable_iptables
3115     ipmi  . . . . . . . . $enable_ipmi
3116     ipvs  . . . . . . . . $enable_ipvs
3117     irq . . . . . . . . . $enable_irq
3118     libvirt . . . . . . . $enable_libvirt
3119     load  . . . . . . . . $enable_load
3120     logfile . . . . . . . $enable_logfile
3121     mbmon . . . . . . . . $enable_mbmon
3122     memcached . . . . . . $enable_memcached
3123     memory  . . . . . . . $enable_memory
3124     multimeter  . . . . . $enable_multimeter
3125     mysql . . . . . . . . $enable_mysql
3126     netlink . . . . . . . $enable_netlink
3127     network . . . . . . . $enable_network
3128     nfs . . . . . . . . . $enable_nfs
3129     nginx . . . . . . . . $enable_nginx
3130     notify_desktop  . . . $enable_notify_desktop
3131     notify_email  . . . . $enable_notify_email
3132     ntpd  . . . . . . . . $enable_ntpd
3133     nut . . . . . . . . . $enable_nut
3134     onewire . . . . . . . $enable_onewire
3135     oracle  . . . . . . . $enable_oracle
3136     perl  . . . . . . . . $enable_perl
3137     ping  . . . . . . . . $enable_ping
3138     postgresql  . . . . . $enable_postgresql
3139     powerdns  . . . . . . $enable_powerdns
3140     processes . . . . . . $enable_processes
3141     rrdtool . . . . . . . $enable_rrdtool
3142     rrdcached . . . . . . $enable_rrdcached
3143     sensors . . . . . . . $enable_sensors
3144     serial  . . . . . . . $enable_serial
3145     snmp  . . . . . . . . $enable_snmp
3146     swap  . . . . . . . . $enable_swap
3147     syslog  . . . . . . . $enable_syslog
3148     tail  . . . . . . . . $enable_tail
3149     tape  . . . . . . . . $enable_tape
3150     tcpconns  . . . . . . $enable_tcpconns
3151     teamspeak2  . . . . . $enable_teamspeak2
3152     thermal . . . . . . . $enable_thermal
3153     unixsock  . . . . . . $enable_unixsock
3154     users . . . . . . . . $enable_users
3155     uuid  . . . . . . . . $enable_uuid
3156     vmem  . . . . . . . . $enable_vmem
3157     vserver . . . . . . . $enable_vserver
3158     wireless  . . . . . . $enable_wireless
3159     xmms  . . . . . . . . $enable_xmms
3160
3161 EOF
3162
3163 if test "x$dependency_error" = "xyes"; then
3164         AC_MSG_ERROR("Some plugins are missing dependencies - see above summary for details")
3165 fi
3166
3167 # vim: set fdm=marker :