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