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