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