apache plugin: Replace C++-style comments.
[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-libgcrypt {{{
1267 GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
1268 GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
1269 GCRYPT_LIBS="$GCRYPT_LIBS"
1270 AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
1271 [
1272  if test -f "$withval" && test -x "$withval"
1273  then
1274          with_libgcrypt_config="$withval"
1275          with_libgcrypt="yes"
1276  else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
1277  then
1278          with_libgcrypt_config="$withval/bin/gcrypt-config"
1279          with_libgcrypt="yes"
1280  else if test -d "$withval"
1281  then
1282          GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
1283          GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
1284          with_libgcrypt="yes"
1285  else
1286          with_libgcrypt_config="gcrypt-config"
1287          with_libgcrypt="$withval"
1288  fi; fi; fi
1289 ],
1290 [
1291  with_libgcrypt_config="libgcrypt-config"
1292  with_libgcrypt="yes"
1293 ])
1294
1295 if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
1296 then
1297         if test "x$GCRYPT_CPPFLAGS" = "x"
1298         then
1299                 GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
1300         fi
1301
1302         if test "x$GCRYPT_LDFLAGS" = "x"
1303         then
1304                 gcrypt_exec_prefix=`"$with_libgcrypt_config" --exec-prefix 2>/dev/null`
1305                 GCRYPT_LDFLAGS="-L$gcrypt_exec_prefix/lib"
1306         fi
1307
1308         if test "x$GCRYPT_LIBS" = "x"
1309         then
1310                 GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
1311         fi
1312 fi
1313
1314 SAVE_CPPFLAGS="$CPPFLAGS"
1315 SAVE_LDFLAGS="$LDFLAGS"
1316 CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
1317 LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
1318
1319 if test "x$with_libgcrypt" = "xyes"
1320 then
1321         if test "x$GCRYPT_CPPFLAGS" != "x"
1322         then
1323                 AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
1324         fi
1325         AC_CHECK_HEADERS(gcrypt.h,
1326                 [with_libgcrypt="yes"],
1327                 [with_libgcrypt="no (gcrypt.h not found)"])
1328 fi
1329
1330 if test "x$with_libgcrypt" = "xyes"
1331 then
1332         if test "x$GCRYPT_LDFLAGS" != "x"
1333         then
1334                 AC_MSG_NOTICE([gcrypt LDFLAGS: $GCRYPT_LDFLAGS])
1335         fi
1336         AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
1337                 [with_libgcrypt="yes"],
1338                 [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
1339 fi
1340
1341 CPPFLAGS="$SAVE_CPPFLAGS"
1342 LDFLAGS="$SAVE_LDFLAGS"
1343
1344 AC_SUBST(GCRYPT_CPPFLAGS)
1345 AC_SUBST(GCRYPT_LDFLAGS)
1346 AC_SUBST(GCRYPT_LIBS)
1347 AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
1348 # }}}
1349
1350 # --with-libiptc {{{
1351 with_own_libiptc="no"
1352 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1353 [
1354         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1355         then
1356                 LDFLAGS="$LDFLAGS -L$withval/lib"
1357                 CPPFLAGS="$CPPFLAGS -I$withval/include"
1358                 with_libiptc="yes"
1359         else
1360                 with_libiptc="$withval"
1361         fi
1362 ],
1363 [
1364         if test "x$ac_system" = "xLinux"
1365         then
1366                 with_libiptc="yes"
1367         else
1368                 with_libiptc="no (Linux only)"
1369         fi
1370 ])
1371 if test "x$with_libiptc" = "xyes"
1372 then
1373         AC_CHECK_LIB(iptc, iptc_init,
1374         [
1375                 AC_DEFINE(HAVE_LIBIPTC, 1, [Define to 1 if you have the iptc library (-liptc).])
1376         ],
1377         [
1378                 with_libiptc="yes"
1379                 with_own_libiptc="yes"
1380         ])
1381 fi
1382 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" != "xyes"
1383 then
1384         AC_CHECK_HEADERS(libiptc/libiptc.h,
1385         [
1386                 AC_DEFINE(HAVE_LIBIPTC_LIBIPTC_H, 1, [Define to 1 if you have the <libiptc/libiptc.h> header file.])
1387         ],
1388         [
1389                 with_libiptc="yes"
1390                 with_own_libiptc="yes"
1391         ])
1392 fi
1393 if test "x$with_libiptc" = "xyes"
1394 then
1395         SAVE_CFLAGS=$CFLAGS
1396         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
1397
1398         AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h, [],
1399         [
1400                 with_libiptc="no (Linux iptables headers not found - check KERNEL_DIR)"
1401                 with_own_libiptc="no"
1402         ],
1403         [
1404 #include "$srcdir/src/libiptc/ipt_kernel_headers.h"
1405         ])
1406
1407         CFLAGS=$SAVE_CFLAGS
1408 fi
1409 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1410 AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_own_libiptc" = "xyes")
1411 if test "x$with_own_libiptc" = "xyes"
1412 then
1413         AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
1414 fi
1415 # }}}
1416
1417 # --with-java {{{
1418 with_java_home="$JAVA_HOME"
1419 with_java_vmtype="client"
1420 with_java_cflags=""
1421 with_java_libs=""
1422 AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
1423 [
1424         if test "x$withval" = "xno"
1425         then
1426                 with_java="no"
1427         else if test "x$withval" = "xyes"
1428         then
1429                 with_java="yes"
1430         else
1431                 with_java_home="$withval"
1432                 with_java="yes"
1433         fi; fi
1434 ],
1435 [with_java="yes"])
1436 if test "x$with_java" = "xyes"
1437 then
1438         if test -d "$with_java_home"
1439         then
1440                 if test -d "$with_java_home/include"
1441                 then
1442                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$with_java_home/include"
1443                 else
1444                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$with_java_home"
1445                 fi
1446                 
1447                 if test -d "$with_java_home/lib"
1448                 then
1449                         JAVA_LDFLAGS="$JAVA_LDFLAGS -L$with_java_home/lib"
1450                 else
1451                         JAVA_LDFLAGS="$JAVA_LDFLAGS -L$with_java_home"
1452                 fi
1453         else if test "x$with_java_home" != "x"
1454         then
1455                 AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
1456         fi; fi
1457 fi
1458
1459 if test "x$JAVA_CPPFLAGS" != "x"
1460 then
1461         AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
1462 fi
1463 if test "x$JAVA_CFLAGS" != "x"
1464 then
1465         AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
1466 fi
1467 if test "x$JAVA_LDFLAGS" != "x"
1468 then
1469         AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
1470 fi
1471
1472 SAVE_CPPFLAGS="$CPPFLAGS"
1473 SAVE_CFLAGS="$CFLAGS"
1474 SAVE_LDFLAGS="$LDFLAGS"
1475 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
1476 CFLAGS="$CFLAGS $JAVA_CFLAGS"
1477 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
1478
1479 if test "x$with_java" = "xyes"
1480 then
1481         AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
1482 fi
1483 if test "x$with_java" = "xyes"
1484 then
1485         AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
1486         [with_java="yes"],
1487         [with_java="no (libjvm not found)"],
1488         [$JAVA_LIBS])
1489 fi
1490 if test "x$with_java" = "xyes"
1491 then
1492         JAVA_LIBS="$JAVA_LIBS -ljvm"
1493         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
1494 fi
1495
1496 CPPFLAGS="$SAVE_CPPFLAGS"
1497 CFLAGS="$SAVE_CFLAGS"
1498 LDFLAGS="$SAVE_LDFLAGS"
1499
1500 AC_SUBST(JAVA_CPPFLAGS)
1501 AC_SUBST(JAVA_CFLAGS)
1502 AC_SUBST(JAVA_LDFLAGS)
1503 AC_SUBST(JAVA_LIBS)
1504 AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
1505 # }}}
1506
1507 # --with-libmemcached {{{
1508 with_libmemcached_cppflags=""
1509 with_libmemcached_ldflags=""
1510 AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
1511 [
1512         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1513         then
1514                 with_libmemcached_cppflags="-I$withval/include"
1515                 with_libmemcached_ldflags="-L$withval/lib"
1516                 with_libmemcached="yes"
1517         else
1518                 with_libmemcached="$withval"
1519         fi
1520 ],
1521 [
1522         with_libmemcached="yes"
1523 ])
1524 if test "x$with_libmemcached" = "xyes"
1525 then
1526         SAVE_CPPFLAGS="$CPPFLAGS"
1527         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
1528
1529         AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
1530
1531         CPPFLAGS="$SAVE_CPPFLAGS"
1532 fi
1533 if test "x$with_libmemcached" = "xyes"
1534 then
1535         SAVE_CPPFLAGS="$CPPFLAGS"
1536         SAVE_LDFLAGS="$LDFLAGS"
1537         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
1538         LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
1539
1540         AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
1541
1542         CPPFLAGS="$SAVE_CPPFLAGS"
1543         LDFLAGS="$SAVE_LDFLAGS"
1544 fi
1545 if test "x$with_libmemcached" = "xyes"
1546 then
1547         BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
1548         BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
1549         BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
1550         AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
1551         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
1552         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
1553         AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
1554 fi
1555 AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
1556 # }}}
1557
1558 # --with-libmysql {{{
1559 with_mysql_config="mysql_config"
1560 with_mysql_cflags=""
1561 with_mysql_libs=""
1562 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
1563 [
1564         if test "x$withval" = "xno"
1565         then
1566                 with_libmysql="no"
1567         else if test "x$withval" = "xyes"
1568         then
1569                 with_libmysql="yes"
1570         else
1571                 if test -f "$withval" && test -x "$withval";
1572                 then
1573                         with_mysql_config="$withval"
1574                 else if test -x "$withval/bin/mysql_config"
1575                 then
1576                         with_mysql_config="$withval/bin/mysql_config"
1577                 fi; fi
1578                 with_libmysql="yes"
1579         fi; fi
1580 ],
1581 [
1582         with_libmysql="yes"
1583 ])
1584 if test "x$with_libmysql" = "xyes"
1585 then
1586         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
1587         mysql_config_status=$?
1588
1589         if test $mysql_config_status -ne 0
1590         then
1591                 with_libmysql="no ($with_mysql_config failed)"
1592         else
1593                 SAVE_CPPFLAGS="$CPPFLAGS"
1594                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
1595
1596                 have_mysql_h="no"
1597                 have_mysql_mysql_h="no"
1598                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
1599
1600                 if test "x$have_mysql_h" = "xno"
1601                 then
1602                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
1603                 fi
1604
1605                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
1606                 then
1607                         with_libmysql="no (mysql.h not found)"
1608                 fi
1609
1610                 CPPFLAGS="$SAVE_CPPFLAGS"
1611         fi
1612 fi
1613 if test "x$with_libmysql" = "xyes"
1614 then
1615         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
1616         mysql_config_status=$?
1617
1618         if test $mysql_config_status -ne 0
1619         then
1620                 with_libmysql="no ($with_mysql_config failed)"
1621         else
1622                 AC_CHECK_LIB(mysqlclient, mysql_init,
1623                  [with_libmysql="yes"],
1624                  [with_libmysql="no (symbol 'mysql_init' not found)"],
1625                  [$with_mysql_libs])
1626         fi
1627 fi
1628 if test "x$with_libmysql" = "xyes"
1629 then
1630         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
1631         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
1632         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
1633         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
1634 fi
1635 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
1636 # }}}
1637
1638 # --with-libnetlink {{{
1639 with_libnetlink_cflags=""
1640 with_libnetlink_libs="-lnetlink"
1641 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
1642 [
1643  echo "libnetlink: withval = $withval"
1644  if test "x$withval" = "xyes"
1645  then
1646          with_libnetlink="yes"
1647  else if test "x$withval" = "xno"
1648  then
1649          with_libnetlink="no"
1650  else
1651          if test -d "$withval/include"
1652          then
1653                  with_libnetlink_cflags="-I$withval/include"
1654                  with_libnetlink_libs="-L$withval/lib -lnetlink"
1655                  with_libnetlink="yes"
1656          else
1657                  AC_MSG_ERROR("no such directory: $withval/include")
1658          fi
1659  fi; fi
1660 ],
1661 [
1662  if test "x$ac_system" = "xLinux"
1663  then
1664          with_libnetlink="yes"
1665  else
1666          with_libnetlink="no (Linux only library)"
1667  fi
1668 ])
1669 if test "x$with_libnetlink" = "xyes"
1670 then
1671         SAVE_CFLAGS=$CFLAGS
1672         CFLAGS="$CFLAGS $with_libnetlink_cflags"
1673
1674         with_libnetlink="no (libnetlink.h not found)"
1675
1676         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
1677         [
1678          with_libnetlink="yes"
1679          break
1680         ], [],
1681 [#include <stdio.h>
1682 #include <sys/types.h>
1683 #include <asm/types.h>
1684 #include <sys/socket.h>
1685 #include <linux/netlink.h>
1686 #include <linux/rtnetlink.h>])
1687         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
1688 [#include <stdio.h>
1689 #include <sys/types.h>
1690 #include <asm/types.h>
1691 #include <sys/socket.h>])
1692
1693         AC_COMPILE_IFELSE(
1694 [#include <stdio.h>
1695 #include <sys/types.h>
1696 #include <asm/types.h>
1697 #include <sys/socket.h>
1698 #include <linux/netlink.h>
1699 #include <linux/rtnetlink.h>
1700
1701 int main (void)
1702 {
1703         int retval = TCA_STATS2;
1704         return (retval);
1705 }],
1706         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
1707         []);
1708
1709         AC_COMPILE_IFELSE(
1710 [#include <stdio.h>
1711 #include <sys/types.h>
1712 #include <asm/types.h>
1713 #include <sys/socket.h>
1714 #include <linux/netlink.h>
1715 #include <linux/rtnetlink.h>
1716
1717 int main (void)
1718 {
1719         int retval = TCA_STATS;
1720         return (retval);
1721 }],
1722         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
1723         []);
1724
1725         CFLAGS="$SAVE_CFLAGS"
1726 fi
1727 if test "x$with_libnetlink" = "xyes"
1728 then
1729         AC_CHECK_LIB(netlink, rtnl_open,
1730                      [with_libnetlink="yes"],
1731                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
1732                      [$with_libnetlink_libs])
1733 fi
1734 if test "x$with_libnetlink" = "xyes"
1735 then
1736         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
1737         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
1738         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
1739         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
1740 fi
1741 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
1742 # }}}
1743
1744 # --with-libnetsnmp {{{
1745 with_snmp_config="net-snmp-config"
1746 with_snmp_cflags=""
1747 with_snmp_libs=""
1748 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
1749 [
1750         if test "x$withval" = "xno"
1751         then
1752                 with_libnetsnmp="no"
1753         else if test "x$withval" = "xyes"
1754         then
1755                 with_libnetsnmp="yes"
1756         else
1757                 if test -x "$withval"
1758                 then
1759                         with_snmp_config="$withval"
1760                         with_libnetsnmp="yes"
1761                 else
1762                         with_snmp_config="$withval/bin/net-snmp-config"
1763                         with_libnetsnmp="yes"
1764                 fi
1765         fi; fi
1766 ],
1767 [with_libnetsnmp="yes"])
1768 if test "x$with_libnetsnmp" = "xyes"
1769 then
1770         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
1771         snmp_config_status=$?
1772
1773         if test $snmp_config_status -ne 0
1774         then
1775                 with_libnetsnmp="no ($with_snmp_config failed)"
1776         else
1777                 SAVE_CPPFLAGS="$CPPFLAGS"
1778                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
1779                 
1780                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
1781
1782                 CPPFLAGS="$SAVE_CPPFLAGS"
1783         fi
1784 fi
1785 if test "x$with_libnetsnmp" = "xyes"
1786 then
1787         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
1788         snmp_config_status=$?
1789
1790         if test $snmp_config_status -ne 0
1791         then
1792                 with_libnetsnmp="no ($with_snmp_config failed)"
1793         else
1794                 AC_CHECK_LIB(netsnmp, init_snmp,
1795                 [with_libnetsnmp="yes"],
1796                 [with_libnetsnmp="no (libnetsnmp not found)"],
1797                 [$with_snmp_libs])
1798         fi
1799 fi
1800 if test "x$with_libnetsnmp" = "xyes"
1801 then
1802         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
1803         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
1804         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
1805         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
1806 fi
1807 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
1808 # }}}
1809
1810 # --with-liboconfig {{{
1811 with_own_liboconfig="no"
1812 liboconfig_LDFLAGS="$LDFLAGS"
1813 liboconfig_CPPFLAGS="$CPPFLAGS"
1814 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
1815 [
1816         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1817         then
1818                 if test -d "$withval/lib"
1819                 then
1820                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
1821                 fi
1822                 if test -d "$withval/include"
1823                 then
1824                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
1825                 fi
1826         fi
1827         if test "x$withval" = "xno"
1828         then
1829                 AC_MSG_ERROR("liboconfig is required")
1830         fi
1831 ],
1832 [
1833         with_liboconfig="yes"
1834 ])
1835
1836 save_LDFLAGS="$LDFLAGS"
1837 save_CPPFLAGS="$CPPFLAGS"
1838 LDFLAGS="$liboconfig_LDFLAGS"
1839 CPPFLAGS="$liboconfig_CPPFLAGS"
1840 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
1841 [
1842         with_liboconfig="yes"
1843         with_own_liboconfig="no"
1844 ],
1845 [
1846         with_liboconfig="yes"
1847         with_own_liboconfig="yes"
1848         LDFLAGS="$save_LDFLAGS"
1849         CPPFLAGS="$save_CPPFLAGS"
1850 ])
1851
1852 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
1853 if test "x$with_own_liboconfig" = "xyes"
1854 then
1855         with_liboconfig="yes (shipped version)"
1856 fi
1857 # }}}
1858
1859 # --with-liboping {{{
1860 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
1861 [
1862  if test "x$withval" = "xyes"
1863  then
1864          with_liboping="yes"
1865  else if test "x$withval" = "xno"
1866  then
1867          with_liboping="no"
1868  else
1869          with_liboping="yes"
1870          LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
1871          LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
1872  fi; fi
1873 ],
1874 [with_liboping="yes"])
1875
1876 SAVE_CPPFLAGS="$CPPFLAGS"
1877 SAVE_LDFLAGS="$LDFLAGS"
1878
1879 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
1880 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
1881
1882 if test "x$with_liboping" = "xyes"
1883 then
1884         if test "x$LIBOPING_CPPFLAGS" != "x"
1885         then
1886                 AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
1887         fi
1888         AC_CHECK_HEADERS(oping.h,
1889         [with_liboping="yes"],
1890         [with_liboping="no ('oping.h' not found)"])
1891 fi
1892 if test "x$with_liboping" = "xyes"
1893 then
1894         if test "x$LIBOPING_LDFLAGS" != "x"
1895         then
1896                 AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
1897         fi
1898         AC_CHECK_LIB(oping, ping_construct,
1899         [with_liboping="yes"],
1900         [with_liboping="no (symbol 'ping_construct' not found)"])
1901 fi
1902
1903 CPPFLAGS="$SAVE_CPPFLAGS"
1904 LDFLAGS="$SAVE_LDFLAGS"
1905
1906 if test "x$with_liboping" = "xyes"
1907 then
1908         BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
1909         BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
1910         AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
1911         AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
1912 fi
1913 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
1914 # }}}
1915
1916 # --with-oracle {{{
1917 with_oracle_cppflags=""
1918 with_oracle_libs=""
1919 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
1920 [
1921         if test "x$withval" = "xyes"
1922         then
1923                 if test "x$ORACLE_HOME" = "x"
1924                 then
1925                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
1926                 fi
1927                 with_oracle="yes"
1928         else if test "x$withval" = "xno"
1929         then
1930                 with_oracle="no"
1931         else
1932                 with_oracle="yes"
1933                 ORACLE_HOME="$withval"
1934         fi; fi
1935 ],
1936 [
1937         if test "x$ORACLE_HOME" = "x"
1938         then
1939                 with_oracle="no (ORACLE_HOME is not set)"
1940         else
1941                 with_oracle="yes"
1942         fi
1943 ])
1944 if test "x$ORACLE_HOME" != "x"
1945 then
1946         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
1947
1948         if test -e "$ORACLE_HOME/lib/ldflags"
1949         then
1950                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
1951         fi
1952         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
1953         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
1954 fi
1955 if test "x$with_oracle" = "xyes"
1956 then
1957         SAVE_CPPFLAGS="$CPPFLAGS"
1958         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
1959
1960         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
1961
1962         CPPFLAGS="$SAVE_CPPFLAGS"
1963 fi
1964 if test "x$with_oracle" = "xyes"
1965 then
1966         SAVE_CPPFLAGS="$CPPFLAGS"
1967         SAVE_LDFLAGS="$LDFLAGS"
1968         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
1969         LDFLAGS="$LDFLAGS $with_oracle_libs"
1970
1971         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
1972
1973         CPPFLAGS="$SAVE_CPPFLAGS"
1974         LDFLAGS="$SAVE_LDFLAGS"
1975 fi
1976 if test "x$with_oracle" = "xyes"
1977 then
1978         BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
1979         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
1980         AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
1981         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
1982 fi
1983 # }}}
1984
1985 # --with-libowcapi {{{
1986 with_libowcapi_cppflags=""
1987 with_libowcapi_libs="-lowcapi"
1988 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
1989 [
1990         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1991         then
1992                 with_libowcapi_cppflags="-I$withval/include"
1993                 with_libowcapi_libs="-L$withval/lib -lowcapi"
1994                 with_libowcapi="yes"
1995         else
1996                 with_libowcapi="$withval"
1997         fi
1998 ],
1999 [
2000         with_libowcapi="yes"
2001 ])
2002 if test "x$with_libowcapi" = "xyes"
2003 then
2004         SAVE_CPPFLAGS="$CPPFLAGS"
2005         CPPFLAGS="$with_libowcapi_cppflags"
2006         
2007         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
2008
2009         CPPFLAGS="$SAVE_CPPFLAGS"
2010 fi
2011 if test "x$with_libowcapi" = "xyes"
2012 then
2013         SAVE_LDFLAGS="$LDFLAGS"
2014         SAVE_CPPFLAGS="$CPPFLAGS"
2015         LDFLAGS="$with_libowcapi_libs"
2016         CPPFLAGS="$with_libowcapi_cppflags"
2017         
2018         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
2019
2020         LDFLAGS="$SAVE_LDFLAGS"
2021         CPPFLAGS="$SAVE_CPPFLAGS"
2022 fi
2023 if test "x$with_libowcapi" = "xyes"
2024 then
2025         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
2026         BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
2027         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
2028         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
2029 fi
2030 # }}}
2031
2032 # --with-libpcap {{{
2033 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
2034 [
2035         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2036         then
2037                 LDFLAGS="$LDFLAGS -L$withval/lib"
2038                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2039                 with_libpcap="yes"
2040         else
2041                 with_libpcap="$withval"
2042         fi
2043 ],
2044 [
2045         with_libpcap="yes"
2046 ])
2047 if test "x$with_libpcap" = "xyes"
2048 then
2049         AC_CHECK_LIB(pcap, pcap_open_live,
2050         [
2051                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
2052         ], [with_libpcap="no (libpcap not found)"])
2053 fi
2054 if test "x$with_libpcap" = "xyes"
2055 then
2056         AC_CHECK_HEADERS(pcap.h,
2057         [
2058                 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
2059         ], [with_libpcap="no (pcap.h not found)"])
2060 fi
2061 if test "x$with_libpcap" = "xyes"
2062 then
2063         collect_libpcap=1
2064 else
2065         collect_libpcap=0
2066 fi
2067 AC_DEFINE_UNQUOTED(COLLECT_LIBPCAP, [$collect_libpcap],
2068         [Wether or not to use the pcap library])
2069 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
2070 # }}}
2071
2072 # --with-libperl {{{
2073 perl_interpreter="perl"
2074 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
2075 [
2076         if test -x "$withval"
2077         then
2078                 perl_interpreter="$withval"
2079                 with_libperl="yes"
2080         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
2081         then
2082                 LDFLAGS="$LDFLAGS -L$withval/lib"
2083                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2084                 perl_interpreter="$withval/bin/perl"
2085                 with_libperl="yes"
2086         else
2087                 with_libperl="$withval"
2088         fi; fi
2089 ],
2090 [
2091         with_libperl="yes"
2092 ])
2093
2094 AC_MSG_CHECKING([for perl])
2095 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
2096 if test -x "$perl_interpreter"
2097 then
2098         AC_MSG_RESULT([yes ($perl_interpreter)])
2099 else
2100         perl_interpreter=""
2101         AC_MSG_RESULT([no])
2102 fi
2103
2104 AC_SUBST(PERL, "$perl_interpreter")
2105
2106 if test "x$with_libperl" = "xyes" \
2107         && test -n "$perl_interpreter"
2108 then
2109   SAVE_CFLAGS=$CFLAGS
2110   SAVE_LDFLAGS=$LDFLAGS
2111 dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
2112   PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
2113   PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
2114   CFLAGS="$CFLAGS $PERL_CFLAGS"
2115   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2116
2117   AC_CACHE_CHECK([for libperl],
2118     [c_cv_have_libperl],
2119     AC_LINK_IFELSE(
2120       AC_LANG_PROGRAM(
2121       [[
2122 #define PERL_NO_GET_CONTEXT
2123 #include <EXTERN.h>
2124 #include <perl.h>
2125 #include <XSUB.h>
2126       ]],
2127       [[
2128        dTHX;
2129        load_module (PERL_LOADMOD_NOIMPORT,
2130                          newSVpv ("Collectd::Plugin::FooBar", 24),
2131                          Nullsv);
2132       ]]),
2133       [c_cv_have_libperl="yes"],
2134       [c_cv_have_libperl="no"]
2135     )
2136   )
2137
2138   if test "x$c_cv_have_libperl" = "xyes"
2139   then
2140           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
2141           AC_SUBST(PERL_CFLAGS)
2142           AC_SUBST(PERL_LDFLAGS)
2143   else
2144           with_libperl="no"
2145   fi
2146
2147   CFLAGS=$SAVE_CFLAGS
2148   LDFLAGS=$SAVE_LDFLAGS
2149 else if test -z "$perl_interpreter"; then
2150   with_libperl="no (no perl interpreter found)"
2151   c_cv_have_libperl="no"
2152 fi; fi
2153 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
2154
2155 if test "x$with_libperl" = "xyes"
2156 then
2157         SAVE_CFLAGS=$CFLAGS
2158         SAVE_LDFLAGS=$LDFLAGS
2159         CFLAGS="$CFLAGS $PERL_CFLAGS"
2160         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2161
2162         AC_CACHE_CHECK([if perl supports ithreads],
2163                 [c_cv_have_perl_ithreads],
2164                 AC_LINK_IFELSE(
2165                         AC_LANG_PROGRAM(
2166                         [[
2167 #include <EXTERN.h>
2168 #include <perl.h>
2169 #include <XSUB.h>
2170
2171 #if !defined(USE_ITHREADS)
2172 # error "Perl does not support ithreads!"
2173 #endif /* !defined(USE_ITHREADS) */
2174                         ]],
2175                         [[ ]]),
2176                         [c_cv_have_perl_ithreads="yes"],
2177                         [c_cv_have_perl_ithreads="no"]
2178                 )
2179         )
2180
2181         if test "x$c_cv_have_perl_ithreads" = "xyes"
2182         then
2183                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
2184         fi
2185
2186         CFLAGS=$SAVE_CFLAGS
2187         LDFLAGS=$SAVE_LDFLAGS
2188 fi
2189
2190 c_cv_have_broken_perl_load_module="no"
2191 if test "x$with_libperl" = "xyes"
2192 then
2193         SAVE_CFLAGS=$CFLAGS
2194         SAVE_LDFLAGS=$LDFLAGS
2195         # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
2196         # (see issues #41 and #42)
2197         CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
2198         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2199
2200         AC_CACHE_CHECK([for broken Perl_load_module()],
2201                 [c_cv_have_broken_perl_load_module],
2202                 AC_LINK_IFELSE(
2203                         AC_LANG_PROGRAM(
2204                         [[
2205 #define PERL_NO_GET_CONTEXT
2206 #include <EXTERN.h>
2207 #include <perl.h>
2208 #include <XSUB.h>
2209                         ]],
2210                         [[
2211                          dTHX;
2212                          load_module (PERL_LOADMOD_NOIMPORT,
2213                              newSVpv ("Collectd::Plugin::FooBar", 24),
2214                              Nullsv);
2215                         ]]),
2216                         [c_cv_have_broken_perl_load_module="no"],
2217                         [c_cv_have_broken_perl_load_module="yes"]
2218                 )
2219         )
2220
2221         CFLAGS=$SAVE_CFLAGS
2222         LDFLAGS=$SAVE_LDFLAGS
2223 fi
2224 AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
2225                 test "x$c_cv_have_broken_perl_load_module" = "xyes")
2226
2227 if test "x$with_libperl" = "xyes"
2228 then
2229         SAVE_CFLAGS=$CFLAGS
2230         SAVE_LDFLAGS=$LDFLAGS
2231         CFLAGS="$CFLAGS $PERL_CFLAGS"
2232         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2233
2234         AC_CHECK_MEMBER(
2235                 [struct mgvtbl.svt_local],
2236                 [have_struct_mgvtbl_svt_local="yes"],
2237                 [have_struct_mgvtbl_svt_local="no"],
2238                 [
2239 #include <EXTERN.h>
2240 #include <perl.h>
2241 #include <XSUB.h>
2242                 ])
2243
2244         if test "x$have_struct_mgvtbl_svt_local" = "xyes"
2245         then
2246                 AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
2247                                   [Define if Perl's struct mgvtbl has member svt_local.])
2248         fi
2249
2250         CFLAGS=$SAVE_CFLAGS
2251         LDFLAGS=$SAVE_LDFLAGS
2252 fi
2253 # }}}
2254
2255 # --with-libpq {{{
2256 with_pg_config="pg_config"
2257 with_libpq_includedir=""
2258 with_libpq_libdir=""
2259 with_libpq_cppflags=""
2260 with_libpq_ldflags=""
2261 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
2262         [Path to libpq.])],
2263 [
2264         if test "x$withval" = "xno"
2265         then
2266                 with_libpq="no"
2267         else if test "x$withval" = "xyes"
2268         then
2269                 with_libpq="yes"
2270         else
2271                 if test -f "$withval" && test -x "$withval";
2272                 then
2273                         with_pg_config="$withval"
2274                 else if test -x "$withval/bin/pg_config"
2275                 then
2276                         with_pg_config="$withval/bin/pg_config"
2277                 fi; fi
2278                 with_libpq="yes"
2279         fi; fi
2280 ],
2281 [
2282         with_libpq="yes"
2283 ])
2284 if test "x$with_libpq" = "xyes"
2285 then
2286         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
2287         pg_config_status=$?
2288
2289         if test $pg_config_status -eq 0
2290         then
2291                 if test -n "$with_libpq_includedir"; then
2292                         for dir in $with_libpq_includedir; do
2293                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
2294                         done
2295                 fi
2296         else
2297                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2298         fi
2299
2300         SAVE_CPPFLAGS="$CPPFLAGS"
2301         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
2302
2303         AC_CHECK_HEADERS(libpq-fe.h, [],
2304                 [with_libpq="no (libpq-fe.h not found)"], [])
2305
2306         CPPFLAGS="$SAVE_CPPFLAGS"
2307 fi
2308 if test "x$with_libpq" = "xyes"
2309 then
2310         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
2311         pg_config_status=$?
2312
2313         if test $pg_config_status -eq 0
2314         then
2315                 if test -n "$with_libpq_libdir"; then
2316                         for dir in $with_libpq_libdir; do
2317                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
2318                         done
2319                 fi
2320         else
2321                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2322         fi
2323
2324         SAVE_LDFLAGS="$LDFLAGS"
2325         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
2326
2327         AC_CHECK_LIB(pq, PQconnectdb,
2328                 [with_libpq="yes"],
2329                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
2330
2331         AC_CHECK_LIB(pq, PQserverVersion,
2332                 [with_libpq="yes"],
2333                 [with_libpq="no (symbol 'PQserverVersion' not found)"])
2334
2335         LDFLAGS="$SAVE_LDFLAGS"
2336 fi
2337 if test "x$with_libpq" = "xyes"
2338 then
2339         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
2340         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
2341         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
2342         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
2343 fi
2344 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
2345 # }}}
2346
2347 # --with-libpthread {{{
2348 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
2349 [       if test "x$withval" != "xno" \
2350                 && test "x$withval" != "xyes"
2351         then
2352                 LDFLAGS="$LDFLAGS -L$withval/lib"
2353                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2354                 with_libpthread="yes"
2355         else
2356                 if test "x$withval" = "xno"
2357                 then
2358                         with_libpthread="no (disabled)"
2359                 fi
2360         fi
2361 ], [with_libpthread="yes"])
2362 if test "x$with_libpthread" = "xyes"
2363 then
2364         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
2365 fi
2366
2367 if test "x$with_libpthread" = "xyes"
2368 then
2369         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
2370 fi
2371 if test "x$with_libpthread" = "xyes"
2372 then
2373         collect_pthread=1
2374 else
2375         collect_pthread=0
2376 fi
2377 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
2378         [Wether or not to use pthread (POSIX threads) library])
2379 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
2380 # }}}
2381
2382 # --with-librrd {{{
2383 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
2384 librrd_cflags=""
2385 librrd_ldflags=""
2386 librrd_threadsafe="yes"
2387 librrd_rrdc_update="no"
2388 AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
2389 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
2390         then
2391                 librrd_cflags="-I$withval/include"
2392                 librrd_ldflags="-L$withval/lib"
2393                 with_librrd="yes"
2394         else
2395                 with_librrd="$withval"
2396         fi
2397 ], [with_librrd="yes"])
2398 if test "x$with_librrd" = "xyes"
2399 then
2400         SAVE_CPPFLAGS="$CPPFLAGS"
2401         SAVE_LDFLAGS="$LDFLAGS"
2402
2403         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2404         LDFLAGS="$LDFLAGS $librrd_ldflags"
2405
2406         AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
2407
2408         CPPFLAGS="$SAVE_CPPFLAGS"
2409         LDFLAGS="$SAVE_LDFLAGS"
2410 fi
2411 if test "x$with_librrd" = "xyes"
2412 then
2413         SAVE_CPPFLAGS="$CPPFLAGS"
2414         SAVE_LDFLAGS="$LDFLAGS"
2415
2416         CPPFLAGS="$CPPFLAGS $librrd_cflags"
2417         LDFLAGS="$LDFLAGS $librrd_ldflags"
2418
2419         AC_CHECK_LIB(rrd_th, rrd_update_r,
2420         [with_librrd="yes"
2421          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
2422         ],
2423         [librrd_threadsafe="no"
2424          AC_CHECK_LIB(rrd, rrd_update,
2425          [with_librrd="yes"
2426           librrd_ldflags="$librrd_ldflags -lrrd -lm"
2427          ],
2428          [with_librrd="no (symbol 'rrd_update' not found)"],
2429          [-lm])
2430         ],
2431         [-lm])
2432
2433         if test "x$librrd_threadsafe" = "xyes"
2434         then
2435                 AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2436         else
2437                 AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
2438         fi
2439
2440         CPPFLAGS="$SAVE_CPPFLAGS"
2441         LDFLAGS="$SAVE_LDFLAGS"
2442 fi
2443 if test "x$with_librrd" = "xyes"
2444 then
2445         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
2446         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
2447         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
2448         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
2449 fi
2450 if test "x$librrd_threadsafe" = "xyes"
2451 then
2452         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
2453 fi
2454 # }}}
2455
2456 # --with-libsensors {{{
2457 with_sensors_cflags=""
2458 with_sensors_ldflags=""
2459 AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
2460 [
2461         if test "x$withval" = "xno"
2462         then
2463                 with_libsensors="no"
2464         else
2465                 with_libsensors="yes"
2466                 if test "x$withval" != "xyes"
2467                 then
2468                         with_sensors_cflags="-I$withval/include"
2469                         with_sensors_ldflags="-L$withval/lib"
2470                         with_libsensors="yes"
2471                 fi
2472         fi
2473 ],
2474 [
2475         if test "x$ac_system" = "xLinux"
2476         then
2477                 with_libsensors="yes"
2478         else
2479                 with_libsensors="no (Linux only library)"
2480         fi
2481 ])
2482 if test "x$with_libsensors" = "xyes"
2483 then
2484         SAVE_CPPFLAGS="$CPPFLAGS"
2485         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2486
2487 #       AC_CHECK_HEADERS(sensors/sensors.h,
2488 #       [
2489 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
2490 #       ],
2491 #       [with_libsensors="no (sensors/sensors.h not found)"])
2492         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
2493
2494         CPPFLAGS="$SAVE_CPPFLAGS"
2495 fi
2496 if test "x$with_libsensors" = "xyes"
2497 then
2498         SAVE_CPPFLAGS="$CPPFLAGS"
2499         SAVE_LDFLAGS="$LDFLAGS"
2500         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
2501         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
2502
2503         AC_CHECK_LIB(sensors, sensors_init,
2504         [
2505                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
2506         ],
2507         [with_libsensors="no (libsensors not found)"])
2508
2509         CPPFLAGS="$SAVE_CPPFLAGS"
2510         LDFLAGS="$SAVE_LDFLAGS"
2511 fi
2512 if test "x$with_libsensors" = "xyes"
2513 then
2514         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
2515         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
2516         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
2517         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
2518 fi
2519 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
2520 # }}}
2521
2522 # --with-libstatgrab {{{
2523 with_libstatgrab_cflags=""
2524 with_libstatgrab_ldflags=""
2525 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
2526 [
2527  if test "x$withval" != "xno" \
2528    && test "x$withval" != "xyes"
2529  then
2530    with_libstatgrab_cflags="-I$withval/include"
2531    with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
2532    with_libstatgrab="yes"
2533    with_libstatgrab_pkg_config="no"
2534  else
2535    with_libstatgrab="$withval"
2536    with_libstatgrab_pkg_config="yes"
2537  fi
2538  ],
2539 [
2540  with_libstatgrab="yes"
2541  with_libstatgrab_pkg_config="yes"
2542 ])
2543
2544 if test "x$with_libstatgrab" = "xyes" \
2545   && test "x$with_libstatgrab_pkg_config" = "xyes"
2546 then
2547   if test "x$PKG_CONFIG" != "x"
2548   then
2549     AC_MSG_CHECKING([pkg-config for libstatgrab])
2550     temp_result="found"
2551     $PKG_CONFIG --exists libstatgrab 2>/dev/null
2552     if test "$?" != "0"
2553     then
2554       with_libstatgrab_pkg_config="no"
2555       with_libstatgrab="no ($PKG_CONFIG doesn't know libstatgrab)"
2556       temp_result="not found"
2557     fi
2558     AC_MSG_RESULT([$temp_result])
2559   else
2560     AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
2561     with_libstatgrab_pkg_config="no"
2562     with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
2563   fi
2564 fi
2565
2566 if test "x$with_libstatgrab" = "xyes" \
2567   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2568   && test "x$with_libstatgrab_cflags" = "x"
2569 then
2570   AC_MSG_CHECKING([for libstatgrab CFLAGS])
2571   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
2572   if test "$?" = "0"
2573   then
2574     with_libstatgrab_cflags="$temp_result"
2575   else
2576     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
2577     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
2578   fi
2579   AC_MSG_RESULT([$temp_result])
2580 fi
2581
2582 if test "x$with_libstatgrab" = "xyes" \
2583   && test "x$with_libstatgrab_pkg_config" = "xyes" \
2584   && test "x$with_libstatgrab_ldflags" = "x"
2585 then
2586   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
2587   temp_result="`$PKG_CONFIG --libs libstatgrab`"
2588   if test "$?" = "0"
2589   then
2590     with_libstatgrab_ldflags="$temp_result"
2591   else
2592     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
2593     temp_result="$PKG_CONFIG --libs libstatgrab failed"
2594   fi
2595   AC_MSG_RESULT([$temp_result])
2596 fi
2597
2598 if test "x$with_libstatgrab" = "xyes"
2599 then
2600   SAVE_CPPFLAGS="$CPPFLAGS"
2601   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
2602
2603   AC_CHECK_HEADERS(statgrab.h,
2604                    [with_libstatgrab="yes"],
2605                    [with_libstatgrab="no (statgrab.h not found)"])
2606
2607   CPPFLAGS="$SAVE_CPPFLAGS"
2608 fi
2609
2610 if test "x$with_libstatgrab" = "xyes"
2611 then
2612   SAVE_CFLAGS="$CFLAGS"
2613   SAVE_LDFLAGS="$LDFLAGS"
2614
2615   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
2616   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
2617
2618   AC_CHECK_LIB(statgrab, sg_init,
2619                [with_libstatgrab="yes"],
2620                [with_libstatgrab="no (symbol sg_init not found)"])
2621
2622   CFLAGS="$SAVE_CFLAGS"
2623   LDFLAGS="$SAVE_LDFLAGS"
2624 fi
2625
2626 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
2627 if test "x$with_libstatgrab" = "xyes"
2628 then
2629   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
2630   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
2631   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
2632   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
2633   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
2634 fi
2635 # }}}
2636
2637 # --with-libupsclient {{{
2638 with_libupsclient_config=""
2639 with_libupsclient_cflags=""
2640 with_libupsclient_libs=""
2641 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
2642 [
2643         if test "x$withval" = "xno"
2644         then
2645                 with_libupsclient="no"
2646         else if test "x$withval" = "xyes"
2647         then
2648                 with_libupsclient="use_pkgconfig"
2649         else
2650                 if test -x "$withval"
2651                 then
2652                         with_libupsclient_config="$withval"
2653                         with_libupsclient="use_libupsclient_config"
2654                 else if test -x "$withval/bin/libupsclient-config"
2655                 then
2656                         with_libupsclient_config="$withval/bin/net-snmp-config"
2657                         with_libupsclient="use_libupsclient_config"
2658                 else
2659                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
2660                         with_libupsclient_cflags="-I$withval/include"
2661                         with_libupsclient_libs="-L$withval/lib -lupsclient"
2662                         with_libupsclient="yes"
2663                 fi; fi
2664         fi; fi
2665 ],
2666 [with_libupsclient="use_pkgconfig"])
2667
2668 # configure using libupsclient-config
2669 if test "x$with_libupsclient" = "xuse_libupsclient_config"
2670 then
2671         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
2672         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
2673         if test $? -ne 0
2674         then
2675                 with_libupsclient="no ($with_libupsclient_config failed)"
2676         fi
2677         with_libupsclient_libs="`$with_libupsclient_config --libs`"
2678         if test $? -ne 0
2679         then
2680                 with_libupsclient="no ($with_libupsclient_config failed)"
2681         fi
2682 fi
2683 if test "x$with_libupsclient" = "xuse_libupsclient_config"
2684 then
2685         with_libupsclient="yes"
2686 fi
2687
2688 # configure using pkg-config
2689 if test "x$with_libupsclient" = "xuse_pkgconfig"
2690 then
2691         if test "x$PKG_CONFIG" = "x"
2692         then
2693                 with_libupsclient="no (Don't have pkg-config)"
2694         fi
2695 fi
2696 if test "x$with_libupsclient" = "xuse_pkgconfig"
2697 then
2698         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
2699         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
2700         if test $? -ne 0
2701         then
2702                 with_libupsclient="no (pkg-config doesn't know library)"
2703         fi
2704 fi
2705 if test "x$with_libupsclient" = "xuse_pkgconfig"
2706 then
2707         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
2708         if test $? -ne 0
2709         then
2710                 with_libupsclient="no ($PKG_CONFIG failed)"
2711         fi
2712         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
2713         if test $? -ne 0
2714         then
2715                 with_libupsclient="no ($PKG_CONFIG failed)"
2716         fi
2717 fi
2718 if test "x$with_libupsclient" = "xuse_pkgconfig"
2719 then
2720         with_libupsclient="yes"
2721 fi
2722
2723 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
2724 # the actual checks.
2725 if test "x$with_libupsclient" = "xyes"
2726 then
2727         SAVE_CPPFLAGS="$CPPFLAGS"
2728         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2729
2730         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
2731
2732         CPPFLAGS="$SAVE_CPPFLAGS"
2733 fi
2734 if test "x$with_libupsclient" = "xyes"
2735 then
2736         SAVE_CPPFLAGS="$CPPFLAGS"
2737         SAVE_LDFLAGS="$LDFLAGS"
2738
2739         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2740         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
2741
2742         AC_CHECK_LIB(upsclient, upscli_connect,
2743                      [with_libupsclient="yes"],
2744                      [with_libupsclient="no (symbol upscli_connect not found)"])
2745
2746         CPPFLAGS="$SAVE_CPPFLAGS"
2747         LDFLAGS="$SAVE_LDFLAGS"
2748 fi
2749 if test "x$with_libupsclient" = "xyes"
2750 then
2751         SAVE_CPPFLAGS="$CPPFLAGS"
2752         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
2753
2754         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
2755 [#include <stdlib.h>
2756 #include <stdio.h>
2757 #include <upsclient.h>])
2758
2759         CPPFLAGS="$SAVE_CPPFLAGS"
2760 fi
2761 if test "x$with_libupsclient" = "xyes"
2762 then
2763         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
2764         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
2765         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
2766         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
2767 fi
2768 # }}}
2769
2770 # --with-libxmms {{{
2771 with_xmms_config="xmms-config"
2772 with_xmms_cflags=""
2773 with_xmms_libs=""
2774 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
2775 [
2776         if test "x$withval" != "xno" \
2777                 && test "x$withval" != "xyes"
2778         then
2779                 if test -f "$withval" && test -x "$withval";
2780                 then
2781                         with_xmms_config="$withval"
2782                 else if test -x "$withval/bin/xmms-config"
2783                 then
2784                         with_xmms_config="$withval/bin/xmms-config"
2785                 fi; fi
2786                 with_libxmms="yes"
2787         else if test "x$withval" = "xno"
2788         then
2789                 with_libxmms="no"
2790         else
2791                 with_libxmms="yes"
2792         fi; fi
2793 ],
2794 [
2795         with_libxmms="yes"
2796 ])
2797 if test "x$with_libxmms" = "xyes"
2798 then
2799         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
2800         xmms_config_status=$?
2801
2802         if test $xmms_config_status -ne 0
2803         then
2804                 with_libxmms="no"
2805         fi
2806 fi
2807 if test "x$with_libxmms" = "xyes"
2808 then
2809         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
2810         xmms_config_status=$?
2811
2812         if test $xmms_config_status -ne 0
2813         then
2814                 with_libxmms="no"
2815         fi
2816 fi
2817 if test "x$with_libxmms" = "xyes"
2818 then
2819         AC_CHECK_LIB(xmms, xmms_remote_get_info,
2820         [
2821                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
2822                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
2823                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
2824                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
2825         ],
2826         [
2827                 with_libxmms="no"
2828         ],
2829         [$with_xmms_libs])
2830 fi
2831 with_libxmms_numeric=0
2832 if test "x$with_libxmms" = "xyes"
2833 then
2834         with_libxmms_numeric=1
2835 fi
2836 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
2837 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
2838 # }}}
2839
2840 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
2841 with_libxml2="no (pkg-config isn't available)"
2842 with_libxml2_cflags=""
2843 with_libxml2_ldflags=""
2844 with_libvirt="no (pkg-config isn't available)"
2845 with_libvirt_cflags=""
2846 with_libvirt_ldflags=""
2847 if test "x$PKG_CONFIG" != "x"
2848 then
2849         pkg-config --exists 'libxml-2.0' 2>/dev/null
2850         if test "$?" = "0"
2851         then
2852                 with_libxml2="yes"
2853         else
2854                 with_libxml2="no (pkg-config doesn't know library)"
2855         fi
2856
2857         pkg-config --exists libvirt 2>/dev/null
2858         if test "$?" = "0"
2859         then
2860                 with_libvirt="yes"
2861         else
2862                 with_libvirt="no (pkg-config doesn't know library)"
2863         fi
2864 fi
2865 if test "x$with_libxml2" = "xyes"
2866 then
2867         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
2868         if test $? -ne 0
2869         then
2870                 with_libxml2="no"
2871         fi
2872         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
2873         if test $? -ne 0
2874         then
2875                 with_libxml2="no"
2876         fi
2877 fi
2878 if test "x$with_libxml2" = "xyes"
2879 then
2880         SAVE_CPPFLAGS="$CPPFLAGS"
2881         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
2882
2883         AC_CHECK_HEADERS(libxml/parser.h, [],
2884                       [with_libxml2="no (libxml/parser.h not found)"])
2885
2886         CPPFLAGS="$SAVE_CPPFLAGS"
2887 fi
2888 if test "x$with_libxml2" = "xyes"
2889 then
2890         SAVE_CFLAGS="$CFLAGS"
2891         SAVE_LDFLAGS="$LDFLAGS"
2892
2893         CFLAGS="$CFLAGS $with_libxml2_cflags"
2894         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
2895
2896         AC_CHECK_LIB(xml2, xmlXPathEval,
2897                      [with_libxml2="yes"],
2898                      [with_libxml2="no (symbol xmlXPathEval not found)"])
2899
2900         CFLAGS="$SAVE_CFLAGS"
2901         LDFLAGS="$SAVE_LDFLAGS"
2902 fi
2903 dnl Add the right compiler flags and libraries.
2904 if test "x$with_libxml2" = "xyes"; then
2905         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
2906         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
2907         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
2908         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
2909 fi
2910 if test "x$with_libvirt" = "xyes"
2911 then
2912         with_libvirt_cflags="`pkg-config --cflags libvirt`"
2913         if test $? -ne 0
2914         then
2915                 with_libvirt="no"
2916         fi
2917         with_libvirt_ldflags="`pkg-config --libs libvirt`"
2918         if test $? -ne 0
2919         then
2920                 with_libvirt="no"
2921         fi
2922 fi
2923 if test "x$with_libvirt" = "xyes"
2924 then
2925         SAVE_CPPFLAGS="$CPPFLAGS"
2926         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
2927
2928         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
2929                       [with_libvirt="no (libvirt/libvirt.h not found)"])
2930
2931         CPPFLAGS="$SAVE_CPPFLAGS"
2932 fi
2933 if test "x$with_libvirt" = "xyes"
2934 then
2935         SAVE_CFLAGS="$CFLAGS"
2936         SAVE_LDFLAGS="$LDFLAGS"
2937
2938         CFLAGS="$CFLAGS $with_libvirt_cflags"
2939         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
2940
2941         AC_CHECK_LIB(virt, virDomainBlockStats,
2942                      [with_libvirt="yes"],
2943                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
2944
2945         CFLAGS="$SAVE_CFLAGS"
2946         LDFLAGS="$SAVE_LDFLAGS"
2947 fi
2948 dnl Add the right compiler flags and libraries.
2949 if test "x$with_libvirt" = "xyes"; then
2950         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
2951         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
2952         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
2953         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
2954 fi
2955 # }}}
2956
2957 # $PKG_CONFIG --exists OpenIPMIpthread {{{
2958 with_libopenipmipthread="yes"
2959 with_libopenipmipthread_cflags=""
2960 with_libopenipmipthread_libs=""
2961
2962 AC_MSG_CHECKING([for pkg-config])
2963 temp_result="no"
2964 if test "x$PKG_CONFIG" = "x"
2965 then
2966         with_libopenipmipthread="no"
2967         temp_result="no"
2968 else
2969         temp_result="$PKG_CONFIG"
2970 fi
2971 AC_MSG_RESULT([$temp_result])
2972
2973 if test "x$with_libopenipmipthread" = "xyes"
2974 then
2975         AC_MSG_CHECKING([for libOpenIPMIpthread])
2976         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
2977         if test "$?" != "0"
2978         then
2979                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
2980         fi
2981         AC_MSG_RESULT([$with_libopenipmipthread])
2982 fi
2983
2984 if test "x$with_libopenipmipthread" = "xyes"
2985 then
2986         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
2987         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
2988         if test "$?" = "0"
2989         then
2990                 with_libopenipmipthread_cflags="$temp_result"
2991         else
2992                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
2993                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
2994         fi
2995         AC_MSG_RESULT([$temp_result])
2996 fi
2997
2998 if test "x$with_libopenipmipthread" = "xyes"
2999 then
3000         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
3001         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
3002         if test "$?" = "0"
3003         then
3004                 with_libopenipmipthread_ldflags="$temp_result"
3005         else
3006                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
3007                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
3008         fi
3009         AC_MSG_RESULT([$temp_result])
3010 fi
3011
3012 if test "x$with_libopenipmipthread" = "xyes"
3013 then
3014         SAVE_CPPFLAGS="$CPPFLAGS"
3015         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
3016
3017         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
3018                          [with_libopenipmipthread="yes"],
3019                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
3020 [#include <OpenIPMI/ipmiif.h>
3021 #include <OpenIPMI/ipmi_err.h>
3022 #include <OpenIPMI/ipmi_posix.h>
3023 #include <OpenIPMI/ipmi_conn.h>
3024 ])
3025
3026         CPPFLAGS="$SAVE_CPPFLAGS"
3027 fi
3028
3029 if test "x$with_libopenipmipthread" = "xyes"
3030 then
3031         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
3032         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
3033         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
3034         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
3035 fi
3036 # }}}
3037
3038 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
3039                 [with_libnotify="yes"],
3040                 [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
3041
3042 # Check for enabled/disabled features
3043 #
3044
3045 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
3046 # ------------------------------------------------------------
3047 dnl
3048 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
3049 dnl
3050 AC_DEFUN(
3051         [AC_COLLECTD],
3052         [
3053         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
3054         m4_if(
3055                 [$2],
3056                 [enable],
3057                 [dnl
3058                 m4_define([EnDis],[disabled])dnl
3059                 m4_define([YesNo],[no])dnl
3060                 ],dnl
3061                 [m4_if(
3062                         [$2],
3063                         [disable],
3064                         [dnl
3065                         m4_define([EnDis],[enabled])dnl
3066                         m4_define([YesNo],[yes])dnl
3067                         ],
3068                         [dnl
3069                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
3070                         ]dnl
3071                 )]dnl
3072         )dnl
3073         m4_if([$3], [feature], [],
3074                 [m4_if(
3075                         [$3], [module], [],
3076                         [dnl
3077                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
3078                         ]dnl
3079                 )]dnl
3080         )dnl
3081         AC_ARG_ENABLE(
3082                 [$1],
3083                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
3084                 [],
3085                 enable_$1='[YesNo]'dnl
3086         )# AC_ARG_ENABLE
3087 if test "x$enable_$1" = "xno"
3088 then
3089         collectd_$1=0
3090 else
3091         if test "x$enable_$1" = "xyes"
3092         then
3093                 collectd_$1=1
3094         else
3095                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
3096                 collectd_$1=1
3097                 enable_$1='yes'
3098         fi
3099 fi
3100         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
3101         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
3102         ]dnl
3103 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
3104
3105 # AC_PLUGIN(name, default, info)
3106 # ------------------------------------------------------------
3107 dnl
3108 AC_DEFUN(
3109   [AC_PLUGIN],
3110   [
3111     enable_plugin="no"
3112     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
3113     [
3114      if test "x$enableval" = "xyes"
3115      then
3116              enable_plugin="yes"
3117      else
3118              enable_plugin="no"
3119      fi
3120     ],
3121     [
3122      if test "x$2" = "xyes"
3123      then
3124              enable_plugin="yes"
3125      else
3126              enable_plugin="no"
3127      fi
3128     ])
3129     if test "x$enable_plugin" = "xyes"
3130     then
3131             if test "x$2" = "xyes"
3132             then
3133                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
3134             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
3135                     dependency_error="yes"
3136                     enable_plugin="no (dependency error)"
3137             fi
3138     fi
3139     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
3140     enable_$1="$enable_plugin"
3141   ]
3142 )# AC_PLUGIN(name, default, info)
3143
3144 m4_divert_once([HELP_ENABLE], [
3145 collectd features:])
3146 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
3147 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
3148 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
3149 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
3150
3151 dependency_error="no"
3152 plugin_ascent="no"
3153 plugin_battery="no"
3154 plugin_bind="no"
3155 plugin_conntrack="no"
3156 plugin_cpu="no"
3157 plugin_cpufreq="no"
3158 plugin_df="no"
3159 plugin_disk="no"
3160 plugin_entropy="no"
3161 plugin_interface="no"
3162 plugin_ipmi="no"
3163 plugin_ipvs="no"
3164 plugin_irq="no"
3165 plugin_libvirt="no"
3166 plugin_load="no"
3167 plugin_memory="no"
3168 plugin_multimeter="no"
3169 plugin_nfs="no"
3170 plugin_perl="no"
3171 plugin_processes="no"
3172 plugin_protocols="no"
3173 plugin_serial="no"
3174 plugin_swap="no"
3175 plugin_tape="no"
3176 plugin_tcpconns="no"
3177 plugin_ted="no"
3178 plugin_thermal="no"
3179 plugin_users="no"
3180 plugin_uptime="no"
3181 plugin_vmem="no"
3182 plugin_vserver="no"
3183 plugin_wireless="no"
3184
3185 # Linux
3186 if test "x$ac_system" = "xLinux"
3187 then
3188         plugin_battery="yes"
3189         plugin_conntrack="yes"
3190         plugin_cpu="yes"
3191         plugin_cpufreq="yes"
3192         plugin_disk="yes"
3193         plugin_entropy="yes"
3194         plugin_interface="yes"
3195         plugin_irq="yes"
3196         plugin_load="yes"
3197         plugin_memory="yes"
3198         plugin_nfs="yes"
3199         plugin_processes="yes"
3200         plugin_protocols="yes"
3201         plugin_serial="yes"
3202         plugin_swap="yes"
3203         plugin_tcpconns="yes"
3204         plugin_thermal="yes"
3205         plugin_uptime="yes"
3206         plugin_vmem="yes"
3207         plugin_vserver="yes"
3208         plugin_wireless="yes"
3209
3210         if test "x$have_net_ip_vs_h" = "xyes" -o "x$have_ip_vs_h" = "xyes"
3211         then
3212                 plugin_ipvs="yes"
3213         fi
3214 fi
3215
3216 if test "x$ac_system" = "xOpenBSD"
3217 then
3218         plugin_tcpconns="yes"
3219 fi
3220
3221 # Mac OS X devices
3222 if test "x$with_libiokit" = "xyes"
3223 then
3224         plugin_battery="yes"
3225         plugin_disk="yes"
3226 fi
3227
3228 # Solaris
3229 if test "x$with_kstat" = "xyes"
3230 then
3231         plugin_uptime="yes"
3232 fi
3233
3234 if test "x$with_devinfo$with_kstat" = "xyesyes"
3235 then
3236         plugin_cpu="yes"
3237         plugin_disk="yes"
3238         plugin_interface="yes"
3239         plugin_memory="yes"
3240         plugin_tape="yes"
3241 fi
3242
3243 if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris"
3244 then
3245         plugin_swap="yes"
3246 fi
3247
3248 # libstatgrab
3249 if test "x$with_libstatgrab" = "xyes"
3250 then
3251         plugin_cpu="yes"
3252         plugin_disk="yes"
3253         plugin_interface="yes"
3254         plugin_load="yes"
3255         plugin_memory="yes"
3256         plugin_swap="yes"
3257         plugin_users="yes"
3258 fi
3259
3260 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
3261 then
3262         plugin_ascent="yes"
3263         plugin_bind="yes"
3264 fi
3265
3266 if test "x$with_libopenipmipthread" = "xyes"
3267 then
3268         plugin_ipmi="yes"
3269 fi
3270
3271 if test "x$have_processor_info" = "xyes"
3272 then
3273         plugin_cpu="yes"
3274 fi
3275 if test "x$have_sysctl" = "xyes"
3276 then
3277         plugin_cpu="yes"
3278         plugin_memory="yes"
3279         plugin_swap="yes"
3280         plugin_uptime="yes"
3281 fi
3282 if test "x$have_sysctlbyname" = "xyes"
3283 then
3284         plugin_cpu="yes"
3285         plugin_memory="yes"
3286         plugin_tcpconns="yes"
3287 fi
3288
3289 if test "x$have_statfs" = "xyes"
3290 then
3291         plugin_df="yes"
3292 fi
3293 if test "x$have_statvfs" = "xyes"
3294 then
3295         plugin_df="yes"
3296 fi
3297
3298 if test "x$have_getifaddrs" = "xyes"
3299 then
3300         plugin_interface="yes"
3301 fi
3302
3303 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
3304 then
3305         plugin_libvirt="yes"
3306 fi
3307
3308 if test "x$have_getloadavg" = "xyes"
3309 then
3310         plugin_load="yes"
3311 fi
3312
3313 if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
3314 then
3315         plugin_perl="yes"
3316 fi
3317
3318 # Mac OS X memory interface
3319 if test "x$have_host_statistics" = "xyes"
3320 then
3321         plugin_memory="yes"
3322 fi
3323
3324 if test "x$have_termios_h" = "xyes"
3325 then
3326         plugin_multimeter="yes"
3327         plugin_ted="yes"
3328 fi
3329
3330 if test "x$have_thread_info" = "xyes"
3331 then
3332         plugin_processes="yes"
3333 fi
3334
3335 if test "x$with_kvm_getprocs" = "xyes"
3336 then
3337         plugin_processes="yes"
3338 fi
3339
3340 if test "x$with_kvm_getswapinfo" = "xyes"
3341 then
3342         plugin_swap="yes"
3343 fi
3344
3345 if test "x$have_swapctl" = "xyes"
3346 then
3347         plugin_swap="yes"
3348 fi
3349
3350 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
3351 then
3352         plugin_tcpconns="yes"
3353 fi
3354
3355 if test "x$have_getutent" = "xyes"
3356 then
3357         plugin_users="yes"
3358 fi
3359 if test "x$have_getutxent" = "xyes"
3360 then
3361         plugin_users="yes"
3362 fi
3363
3364 m4_divert_once([HELP_ENABLE], [
3365 collectd plugins:])
3366
3367 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
3368 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
3369 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
3370 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
3371 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
3372 AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
3373 AC_PLUGIN([conntrack],   [$plugin_conntrack],  [nf_conntrack statistics])
3374 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
3375 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
3376 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
3377 AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
3378 AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
3379 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
3380 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
3381 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
3382 AC_PLUGIN([email],       [yes],                [EMail statistics])
3383 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
3384 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
3385 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
3386 AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
3387 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
3388 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
3389 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
3390 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
3391 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
3392 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
3393 AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
3394 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
3395 AC_PLUGIN([load],        [$plugin_load],       [System load])
3396 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
3397 AC_PLUGIN([match_regex], [yes],                [The regex match])
3398 AC_PLUGIN([match_timediff], [yes],             [The timediff match])
3399 AC_PLUGIN([match_value], [yes],                [The value match])
3400 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
3401 AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
3402 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
3403 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
3404 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
3405 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
3406 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
3407 AC_PLUGIN([network],     [yes],                [Network communication plugin])
3408 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
3409 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
3410 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
3411 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
3412 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
3413 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
3414 AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
3415 AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
3416 AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
3417 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
3418 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
3419 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
3420 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
3421 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
3422 AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
3423 AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
3424 AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
3425 AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
3426 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
3427 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
3428 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
3429 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
3430 AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
3431 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
3432 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
3433 AC_PLUGIN([target_notification], [yes],        [The notification target])
3434 AC_PLUGIN([target_replace], [yes],             [The replace target])
3435 AC_PLUGIN([target_set],  [yes],                [The set target])
3436 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
3437 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
3438 AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
3439 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
3440 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
3441 AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
3442 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
3443 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
3444 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
3445 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
3446 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
3447 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
3448
3449 dnl Default configuration file
3450 # Load either syslog or logfile
3451 LOAD_PLUGIN_SYSLOG=""
3452 LOAD_PLUGIN_LOGFILE=""
3453
3454 AC_MSG_CHECKING([which default log plugin to load])
3455 default_log_plugin="none"
3456 if test "x$enable_syslog" = "xyes"
3457 then
3458         default_log_plugin="syslog"
3459 else
3460         LOAD_PLUGIN_SYSLOG="##"
3461 fi
3462
3463 if test "x$enable_logfile" = "xyes"
3464 then
3465         if test "x$default_log_plugin" = "xnone"
3466         then
3467                 default_log_plugin="logfile"
3468         else
3469                 LOAD_PLUGIN_LOGFILE="#"
3470         fi
3471 else
3472         LOAD_PLUGIN_LOGFILE="##"
3473 fi
3474 AC_MSG_RESULT([$default_log_plugin])
3475
3476 AC_SUBST(LOAD_PLUGIN_SYSLOG)
3477 AC_SUBST(LOAD_PLUGIN_LOGFILE)
3478
3479 DEFAULT_LOG_LEVEL="info"
3480 if test "x$enable_debug" = "xyes"
3481 then
3482         DEFAULT_LOG_LEVEL="debug"
3483 fi
3484 AC_SUBST(DEFAULT_LOG_LEVEL)
3485
3486 # Load only one of rrdtool, network, csv in the default config.
3487 LOAD_PLUGIN_RRDTOOL=""
3488 LOAD_PLUGIN_NETWORK=""
3489 LOAD_PLUGIN_CSV=""
3490
3491 AC_MSG_CHECKING([which default write plugin to load])
3492 default_write_plugin="none"
3493 if test "x$enable_rrdtool" = "xyes"
3494 then
3495         default_write_plugin="rrdtool"
3496 else
3497         LOAD_PLUGIN_RRDTOOL="##"
3498 fi
3499
3500 if test "x$enable_network" = "xyes"
3501 then
3502         if test "x$default_write_plugin" = "xnone"
3503         then
3504                 default_write_plugin="network"
3505         else
3506                 LOAD_PLUGIN_NETWORK="#"
3507         fi
3508 else
3509         LOAD_PLUGIN_NETWORK="##"
3510 fi
3511
3512 if test "x$enable_csv" = "xyes"
3513 then
3514         if test "x$default_write_plugin" = "xnone"
3515         then
3516                 default_write_plugin="csv"
3517         else
3518                 LOAD_PLUGIN_CSV="#"
3519         fi
3520 else
3521         LOAD_PLUGIN_CSV="##"
3522 fi
3523 AC_MSG_RESULT([$default_write_plugin])
3524
3525 AC_SUBST(LOAD_PLUGIN_RRDTOOL)
3526 AC_SUBST(LOAD_PLUGIN_NETWORK)
3527 AC_SUBST(LOAD_PLUGIN_CSV)
3528
3529 dnl ip_vs.h
3530 if test "x$ac_system" = "xLinux" \
3531         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
3532 then
3533         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
3534 fi
3535
3536 dnl Perl bindings
3537 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
3538 [
3539         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3540         then
3541                 PERL_BINDINGS_OPTIONS="$withval"
3542                 with_perl_bindings="yes"
3543         else
3544                 PERL_BINDINGS_OPTIONS=""
3545                 with_perl_bindings="$withval"
3546         fi
3547 ],
3548 [
3549         PERL_BINDINGS_OPTIONS=""
3550         if test -n "$perl_interpreter"
3551         then
3552                 with_perl_bindings="yes"
3553         else
3554                 with_perl_bindings="no (no perl interpreter found)"
3555         fi
3556 ])
3557 if test "x$with_perl_bindings" = "xyes"
3558 then
3559         PERL_BINDINGS="perl"
3560 else
3561         PERL_BINDINGS=""
3562 fi
3563 AC_SUBST(PERL_BINDINGS)
3564 AC_SUBST(PERL_BINDINGS_OPTIONS)
3565
3566 dnl libcollectdclient
3567 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
3568 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
3569 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
3570
3571 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
3572
3573 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
3574
3575 AC_SUBST(LCC_VERSION_MAJOR)
3576 AC_SUBST(LCC_VERSION_MINOR)
3577 AC_SUBST(LCC_VERSION_PATCH)
3578 AC_SUBST(LCC_VERSION_EXTRA)
3579 AC_SUBST(LCC_VERSION_STRING)
3580
3581 AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
3582
3583 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libiptc/Makefile src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile)
3584
3585 if test "x$with_librrd" = "xyes" \
3586         && test "x$librrd_threadsafe" != "xyes"
3587 then
3588         with_librrd="yes (warning: librrd is not thread-safe)"
3589 fi
3590
3591 if test "x$with_libiptc" = "xyes" -a "x$with_own_libiptc" = "xyes"
3592 then
3593         with_libiptc="yes (shipped version)"
3594 fi
3595
3596 if test "x$with_libperl" = "xyes"
3597 then
3598         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
3599 else
3600         enable_perl="no (needs libperl)"
3601 fi
3602
3603 if test "x$with_perl_bindings" = "xyes" \
3604         && test "x$PERL_BINDINGS_OPTIONS" != "x"
3605 then
3606         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
3607 fi
3608
3609 cat <<EOF;
3610
3611 Configuration:
3612   Libraries:
3613     libcurl . . . . . . . $with_libcurl
3614     libdbi  . . . . . . . $with_libdbi
3615     libesmtp  . . . . . . $with_libesmtp
3616     libiokit  . . . . . . $with_libiokit
3617     libiptc . . . . . . . $with_libiptc
3618     libjvm  . . . . . . . $with_java
3619     libkstat  . . . . . . $with_kstat
3620     libkvm  . . . . . . . $with_libkvm
3621     libmysql  . . . . . . $with_libmysql
3622     libnetlink  . . . . . $with_libnetlink
3623     libnetsnmp  . . . . . $with_libnetsnmp
3624     libnotify . . . . . . $with_libnotify
3625     liboconfig  . . . . . $with_liboconfig
3626     libopenipmi . . . . . $with_libopenipmipthread
3627     liboping  . . . . . . $with_liboping
3628     libpcap . . . . . . . $with_libpcap
3629     libperl . . . . . . . $with_libperl
3630     libpq . . . . . . . . $with_libpq
3631     libpthread  . . . . . $with_libpthread
3632     librrd  . . . . . . . $with_librrd
3633     libsensors  . . . . . $with_libsensors
3634     libstatgrab . . . . . $with_libstatgrab
3635     libupsclient  . . . . $with_libupsclient
3636     libvirt . . . . . . . $with_libvirt
3637     libxml2 . . . . . . . $with_libxml2
3638     libxmms . . . . . . . $with_libxmms
3639     oracle  . . . . . . . $with_oracle
3640
3641   Features:
3642     daemon mode . . . . . $enable_daemon
3643     debug . . . . . . . . $enable_debug
3644
3645   Bindings:
3646     perl  . . . . . . . . $with_perl_bindings
3647
3648   Modules:
3649     apache  . . . . . . . $enable_apache
3650     apcups  . . . . . . . $enable_apcups
3651     apple_sensors . . . . $enable_apple_sensors
3652     ascent  . . . . . . . $enable_ascent
3653     battery . . . . . . . $enable_battery
3654     bind  . . . . . . . . $enable_bind
3655     conntrack . . . . . . $enable_conntrack
3656     cpu . . . . . . . . . $enable_cpu
3657     cpufreq . . . . . . . $enable_cpufreq
3658     csv . . . . . . . . . $enable_csv
3659     curl  . . . . . . . . $enable_curl
3660     dbi . . . . . . . . . $enable_dbi
3661     df  . . . . . . . . . $enable_df
3662     disk  . . . . . . . . $enable_disk
3663     dns . . . . . . . . . $enable_dns
3664     email . . . . . . . . $enable_email
3665     entropy . . . . . . . $enable_entropy
3666     exec  . . . . . . . . $enable_exec
3667     filecount . . . . . . $enable_filecount
3668     gmond . . . . . . . . $enable_gmond
3669     hddtemp . . . . . . . $enable_hddtemp
3670     interface . . . . . . $enable_interface
3671     ipmi  . . . . . . . . $enable_ipmi
3672     iptables  . . . . . . $enable_iptables
3673     ipvs  . . . . . . . . $enable_ipvs
3674     irq . . . . . . . . . $enable_irq
3675     java  . . . . . . . . $enable_java
3676     libvirt . . . . . . . $enable_libvirt
3677     load  . . . . . . . . $enable_load
3678     logfile . . . . . . . $enable_logfile
3679     match_regex . . . . . $enable_match_regex
3680     match_timediff  . . . $enable_match_timediff
3681     match_value . . . . . $enable_match_value
3682     mbmon . . . . . . . . $enable_mbmon
3683     memcachec . . . . . . $enable_memcachec
3684     memcached . . . . . . $enable_memcached
3685     memory  . . . . . . . $enable_memory
3686     multimeter  . . . . . $enable_multimeter
3687     mysql . . . . . . . . $enable_mysql
3688     netlink . . . . . . . $enable_netlink
3689     network . . . . . . . $enable_network
3690     nfs . . . . . . . . . $enable_nfs
3691     nginx . . . . . . . . $enable_nginx
3692     notify_desktop  . . . $enable_notify_desktop
3693     notify_email  . . . . $enable_notify_email
3694     ntpd  . . . . . . . . $enable_ntpd
3695     nut . . . . . . . . . $enable_nut
3696     onewire . . . . . . . $enable_onewire
3697     openvpn . . . . . . . $enable_openvpn
3698     oracle  . . . . . . . $enable_oracle
3699     perl  . . . . . . . . $enable_perl
3700     ping  . . . . . . . . $enable_ping
3701     postgresql  . . . . . $enable_postgresql
3702     powerdns  . . . . . . $enable_powerdns
3703     processes . . . . . . $enable_processes
3704     protocols . . . . . . $enable_protocols
3705     rrdcached . . . . . . $enable_rrdcached
3706     rrdtool . . . . . . . $enable_rrdtool
3707     sensors . . . . . . . $enable_sensors
3708     serial  . . . . . . . $enable_serial
3709     snmp  . . . . . . . . $enable_snmp
3710     swap  . . . . . . . . $enable_swap
3711     syslog  . . . . . . . $enable_syslog
3712     table . . . . . . . . $enable_table
3713     tail  . . . . . . . . $enable_tail
3714     tape  . . . . . . . . $enable_tape
3715     target_notification . $enable_target_notification
3716     target_replace  . . . $enable_target_replace
3717     target_set  . . . . . $enable_target_set
3718     tcpconns  . . . . . . $enable_tcpconns
3719     teamspeak2  . . . . . $enable_teamspeak2
3720     ted . . . . . . . . . $enable_ted
3721     thermal . . . . . . . $enable_thermal
3722     unixsock  . . . . . . $enable_unixsock
3723     uptime  . . . . . . . $enable_uptime
3724     users . . . . . . . . $enable_users
3725     uuid  . . . . . . . . $enable_uuid
3726     vmem  . . . . . . . . $enable_vmem
3727     vserver . . . . . . . $enable_vserver
3728     wireless  . . . . . . $enable_wireless
3729     xmms  . . . . . . . . $enable_xmms
3730
3731 EOF
3732
3733 if test "x$dependency_error" = "xyes"; then
3734         AC_MSG_ERROR("Some plugins are missing dependencies - see above summary for details")
3735 fi
3736
3737 # vim: set fdm=marker :