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