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