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