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