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