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