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