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