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