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