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