Build system: enable the "df" plugin when getmntent_r() is available.
[collectd.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ([2.60])
3 AC_INIT([collectd],[m4_esyscmd(./version-gen.sh)])
4 AC_CONFIG_SRCDIR(src/target_set.c)
5 AC_CONFIG_HEADERS(src/config.h)
6 AC_CONFIG_AUX_DIR([libltdl/config])
7
8 dnl older automake's default of ARFLAGS=cru is noisy on newer binutils;
9 dnl we don't really need the 'u' even in older toolchains.  Then there is
10 dnl older libtool, which spelled it AR_FLAGS
11 m4_divert_text([DEFAULTS], [: "${ARFLAGS=cr} ${AR_FLAGS=cr}"])
12
13 m4_ifdef([LT_PACKAGE_VERSION],
14         # libtool >= 2.2
15         [
16          LT_CONFIG_LTDL_DIR([libltdl])
17          LT_INIT([dlopen])
18          LTDL_INIT([convenience])
19          AC_DEFINE(LIBTOOL_VERSION, 2, [Define to used libtool version.])
20         ]
21 ,
22         # libtool <= 1.5
23         [
24          AC_LIBLTDL_CONVENIENCE
25          AC_SUBST(LTDLINCL)
26          AC_SUBST(LIBLTDL)
27          AC_LIBTOOL_DLOPEN
28          AC_CONFIG_SUBDIRS(libltdl)
29          AC_DEFINE(LIBTOOL_VERSION, 1, [Define to used libtool version.])
30         ]
31 )
32
33 AM_CONDITIONAL([BUILD_INCLUDED_LTDL], [test "x$LTDLDEPS" != "x"])
34
35 AM_INIT_AUTOMAKE([subdir-objects tar-pax dist-bzip2 no-dist-gzip foreign])
36 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
37 AC_LANG(C)
38
39 AC_PREFIX_DEFAULT("/opt/collectd")
40
41 AC_SYS_LARGEFILE
42
43 #
44 # Checks for programs.
45 #
46 AC_PROG_CC_C99([],
47   [AC_MSG_ERROR([No compiler found that supports C99])]
48 )
49 AC_PROG_CXX
50 AC_PROG_CPP
51 AC_PROG_EGREP
52 AC_PROG_INSTALL
53 AC_PROG_LN_S
54 AC_PROG_MAKE_SET
55 AM_PROG_CC_C_O
56 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
57
58 AC_DISABLE_STATIC
59 AC_PROG_LIBTOOL
60 AC_PROG_LEX
61 AC_PROG_YACC
62
63 AC_PATH_PROG([VALGRIND], [valgrind])
64
65 # Warn when pkg.m4 is missing
66 m4_pattern_forbid([^_?PKG_[A-Z_]+$],[*** pkg.m4 missing, please install pkg-config])
67
68 PKG_PROG_PKG_CONFIG
69
70 AC_CACHE_CHECK([if bison is the parser generator],
71         [collectd_cv_prog_bison],
72         [AS_IF([$YACC --version 2>/dev/null | $EGREP -q '^bison '],
73                 [collectd_cv_prog_bison=yes], [collectd_cv_prog_bison=no]
74         )]
75 )
76
77 if test "x$collectd_cv_prog_bison" = "xno" && test ! -f "${srcdir}/src/liboconfig/parser.c"
78 then
79         AC_MSG_ERROR([bison is missing and you do not have ${srcdir}/src/liboconfig/parser.c. Please install bison])
80 fi
81
82 AC_ARG_VAR([PROTOC], [path to the protoc binary])
83 AC_PATH_PROG([PROTOC], [protoc])
84 have_protoc3="no"
85 if test "x$PROTOC" != "x"; then
86         AC_MSG_CHECKING([for protoc 3.0.0+])
87         if $PROTOC --version | $EGREP libprotoc.3 >/dev/null; then
88                 protoc3="yes (`$PROTOC --version`)"
89                 have_protoc3="yes"
90         else
91                 protoc3="no (`$PROTOC --version`)"
92         fi
93         AC_MSG_RESULT([$protoc3])
94 fi
95 AM_CONDITIONAL(HAVE_PROTOC3, test "x$have_protoc3" = "xyes")
96
97 AC_ARG_VAR([GRPC_CPP_PLUGIN], [path to the grpc_cpp_plugin binary])
98 AC_PATH_PROG([GRPC_CPP_PLUGIN], [grpc_cpp_plugin])
99 AM_CONDITIONAL(HAVE_GRPC_CPP, test "x$GRPC_CPP_PLUGIN" != "x")
100
101 AC_ARG_VAR([PROTOC_C], [path to the protoc-c binary])
102 AC_PATH_PROG([PROTOC_C], [protoc-c])
103 if test "x$PROTOC_C" = "x"
104 then
105   have_protoc_c="no (protoc-c compiler not found)"
106 else
107   have_protoc_c="yes"
108 fi
109
110 AC_MSG_CHECKING([for kernel type ($host_os)])
111 case $host_os in
112         *linux*)
113         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
114         ac_system="Linux"
115         ;;
116         *solaris*)
117         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
118         ac_system="Solaris"
119         ;;
120         *darwin*)
121         AC_DEFINE([KERNEL_DARWIN], 1, [True if program is to be compiled for a Darwin kernel])
122         ac_system="Darwin"
123         ;;
124         *openbsd*)
125         AC_DEFINE([KERNEL_OPENBSD], 1, [True if program is to be compiled for an OpenBSD kernel])
126         ac_system="OpenBSD"
127         ;;
128         *netbsd*)
129         AC_DEFINE([KERNEL_NETBSD], 1, [True if program is to be compiled for a NetBSD kernel])
130         ac_system="NetBSD"
131         ;;
132         *aix*)
133         AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
134         ac_system="AIX"
135         ;;
136         *freebsd*)
137         AC_DEFINE([KERNEL_FREEBSD], 1, [True if program is to be compiled for a FreeBSD kernel])
138         ac_system="FreeBSD"
139         ;;
140         *)
141         ac_system="unknown"
142 esac
143 AC_MSG_RESULT([$ac_system])
144
145 AM_CONDITIONAL([BUILD_AIX], [test "x$ac_system" = "xAIX"])
146 AM_CONDITIONAL([BUILD_DARWIN], [test "x$ac_system" = "xDarwin"])
147 AM_CONDITIONAL([BUILD_FREEBSD], [test "x$ac_system" = "xFreeBSD"])
148 AM_CONDITIONAL([BUILD_LINUX], [test "x$ac_system" = "xLinux"])
149 AM_CONDITIONAL([BUILD_OPENBSD], [test "x$ac_system" = "xOpenBSD"])
150 AM_CONDITIONAL([BUILD_SOLARIS], [test "x$ac_system" = "xSolaris"])
151
152 if test "x$ac_system" = "xLinux"
153 then
154         AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
155         if test -z "$KERNEL_DIR"
156         then
157                 KERNEL_DIR="/lib/modules/`uname -r`/source"
158         fi
159
160         KERNEL_CFLAGS="-I$KERNEL_DIR/include"
161         AC_SUBST(KERNEL_CFLAGS)
162 fi
163
164 if test "x$ac_system" = "xSolaris"
165 then
166         AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
167         AC_DEFINE(_REENTRANT,               1, [Define to enable reentrancy interfaces.])
168
169         AC_MSG_CHECKING([whether compiler builds 64bit binaries])
170         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
171                            #ifndef _LP64
172                            # error "Compiler not in 64bit mode."
173                            #endif
174                            ])],
175                            [AC_MSG_RESULT([yes])],
176                            [
177                             AC_MSG_RESULT([no])
178                             AC_MSG_NOTICE([Solaris detected. Please consider building a 64-bit binary.])
179                            ])
180 fi
181
182 if test "x$ac_system" = "xAIX"
183 then
184         AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.])
185 fi
186
187 # Where to install .pc files.
188 pkgconfigdir="${libdir}/pkgconfig"
189 AC_SUBST(pkgconfigdir)
190
191 # Check for standards compliance mode
192 AC_ARG_ENABLE(standards,
193               AS_HELP_STRING([--enable-standards], [Enable standards compliance mode]),
194               [enable_standards="$enableval"],
195               [enable_standards="no"])
196 if test "x$enable_standards" = "xyes"
197 then
198         AC_DEFINE(_ISOC99_SOURCE,        1, [Define to enforce ISO C99 compliance.])
199         AC_DEFINE(_POSIX_C_SOURCE, 200809L, [Define to enforce POSIX.1-2008 compliance.])
200         AC_DEFINE(_XOPEN_SOURCE,       700, [Define to enforce X/Open 7 (XSI) compliance.])
201         AC_DEFINE(_REENTRANT,            1, [Define to enable reentrancy interfaces.])
202         if test "x$GCC" = "xyes"
203         then
204                 CFLAGS="$CFLAGS -std=c99"
205         fi
206 fi
207 AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes")
208
209 #
210 # Checks for header files.
211 #
212 AC_HEADER_STDC
213 AC_HEADER_SYS_WAIT
214 AC_HEADER_DIRENT
215 AC_HEADER_STDBOOL
216
217 AC_CHECK_HEADERS([ \
218   arpa/inet.h \
219   assert.h \
220   ctype.h \
221   endian.h \
222   errno.h \
223   fcntl.h \
224   fnmatch.h \
225   fs_info.h \
226   fshelp.h \
227   grp.h \
228   kstat.h \
229   kvm.h \
230   libgen.h \
231   limits.h \
232   locale.h \
233   math.h \
234   mntent.h \
235   mnttab.h \
236   netdb.h \
237   paths.h \
238   poll.h \
239   pthread_np.h \
240   pwd.h \
241   regex.h \
242   signal.h \
243   stdarg.h \
244   stdio.h \
245   sys/fs_types.h \
246   sys/fstyp.h \
247   sys/ioctl.h \
248   sys/isa_defs.h \
249   sys/mntent.h \
250   sys/mnttab.h \
251   sys/param.h \
252   sys/resource.h \
253   sys/select.h \
254   sys/socket.h \
255   sys/statfs.h \
256   sys/statvfs.h \
257   sys/types.h \
258   sys/un.h \
259   sys/vfs.h \
260   sys/vfstab.h \
261   sys/vmmeter.h \
262   syslog.h \
263   wordexp.h \
264 ])
265
266 # For entropy plugin on newer NetBSD
267 AC_CHECK_HEADERS(sys/rndio.h, [], [],
268 [#if HAVE_SYS_TYPES_H
269 # include <sys/types.h>
270 #endif
271 #if HAVE_SYS_IOCTL_H
272 # include <sys/ioctl.h>
273 #endif
274 #if HAVE_SYS_PARAM_H
275 # include <sys/param.h>
276 #endif
277 ])
278
279 # For ping library
280 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
281 [#if HAVE_STDINT_H
282 # include <stdint.h>
283 #endif
284 #if HAVE_SYS_TYPES_H
285 # include <sys/types.h>
286 #endif
287 ])
288 AC_CHECK_HEADERS(netinet/in.h, [], [],
289 [#if HAVE_STDINT_H
290 # include <stdint.h>
291 #endif
292 #if HAVE_SYS_TYPES_H
293 # include <sys/types.h>
294 #endif
295 #if HAVE_NETINET_IN_SYSTM_H
296 # include <netinet/in_systm.h>
297 #endif
298 ])
299 AC_CHECK_HEADERS(netinet/ip.h, [], [],
300 [#if HAVE_STDINT_H
301 # include <stdint.h>
302 #endif
303 #if HAVE_SYS_TYPES_H
304 # include <sys/types.h>
305 #endif
306 #if HAVE_NETINET_IN_SYSTM_H
307 # include <netinet/in_systm.h>
308 #endif
309 #if HAVE_NETINET_IN_H
310 # include <netinet/in.h>
311 #endif
312 ])
313 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
314 [#if HAVE_STDINT_H
315 # include <stdint.h>
316 #endif
317 #if HAVE_SYS_TYPES_H
318 # include <sys/types.h>
319 #endif
320 #if HAVE_NETINET_IN_SYSTM_H
321 # include <netinet/in_systm.h>
322 #endif
323 #if HAVE_NETINET_IN_H
324 # include <netinet/in.h>
325 #endif
326 #if HAVE_NETINET_IP_H
327 # include <netinet/ip.h>
328 #endif
329 ])
330 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
331 [#if HAVE_STDINT_H
332 # include <stdint.h>
333 #endif
334 #if HAVE_SYS_TYPES_H
335 # include <sys/types.h>
336 #endif
337 #if HAVE_NETINET_IN_SYSTM_H
338 # include <netinet/in_systm.h>
339 #endif
340 #if HAVE_NETINET_IN_H
341 # include <netinet/in.h>
342 #endif
343 #if HAVE_NETINET_IP_H
344 # include <netinet/ip.h>
345 #endif
346 ])
347 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
348 [#if HAVE_STDINT_H
349 # include <stdint.h>
350 #endif
351 #if HAVE_SYS_TYPES_H
352 # include <sys/types.h>
353 #endif
354 #if HAVE_NETINET_IN_SYSTM_H
355 # include <netinet/in_systm.h>
356 #endif
357 #if HAVE_NETINET_IN_H
358 # include <netinet/in.h>
359 #endif
360 ])
361 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
362 [#if HAVE_STDINT_H
363 # include <stdint.h>
364 #endif
365 #if HAVE_SYS_TYPES_H
366 # include <sys/types.h>
367 #endif
368 #if HAVE_NETINET_IN_SYSTM_H
369 # include <netinet/in_systm.h>
370 #endif
371 #if HAVE_NETINET_IN_H
372 # include <netinet/in.h>
373 #endif
374 #if HAVE_NETINET_IP6_H
375 # include <netinet/ip6.h>
376 #endif
377 ])
378 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
379 [#if HAVE_STDINT_H
380 # include <stdint.h>
381 #endif
382 #if HAVE_SYS_TYPES_H
383 # include <sys/types.h>
384 #endif
385 #if HAVE_NETINET_IN_SYSTM_H
386 # include <netinet/in_systm.h>
387 #endif
388 #if HAVE_NETINET_IN_H
389 # include <netinet/in.h>
390 #endif
391 #if HAVE_NETINET_IP_H
392 # include <netinet/ip.h>
393 #endif
394 ])
395 AC_CHECK_HEADERS(netinet/udp.h, [], [],
396 [#if HAVE_STDINT_H
397 # include <stdint.h>
398 #endif
399 #if HAVE_SYS_TYPES_H
400 # include <sys/types.h>
401 #endif
402 #if HAVE_NETINET_IN_SYSTM_H
403 # include <netinet/in_systm.h>
404 #endif
405 #if HAVE_NETINET_IN_H
406 # include <netinet/in.h>
407 #endif
408 #if HAVE_NETINET_IP_H
409 # include <netinet/ip.h>
410 #endif
411 ])
412
413 have_ip6_ext="no"
414 AC_CHECK_TYPES([struct ip6_ext], [have_ip6_ext="yes"], [have_ip6_ext="no"],
415 [#if HAVE_STDINT_H
416 # include <stdint.h>
417 #endif
418 #if HAVE_SYS_TYPES_H
419 # include <sys/types.h>
420 #endif
421 #if HAVE_NETINET_IN_SYSTM_H
422 # include <netinet/in_systm.h>
423 #endif
424 #if HAVE_NETINET_IN_H
425 # include <netinet/in.h>
426 #endif
427 #if HAVE_NETINET_IP6_H
428 # include <netinet/ip6.h>
429 #endif
430 ])
431
432 if test "x$have_ip6_ext" = "xno"; then
433         SAVE_CFLAGS="$CFLAGS"
434         CFLAGS="$CFLAGS -DSOLARIS2=8"
435
436         AC_CHECK_TYPES([struct ip6_ext],
437                        [have_ip6_ext="yes, with -DSOLARIS2=8"],
438                        [have_ip6_ext="no"],
439 [#if HAVE_STDINT_H
440 # include <stdint.h>
441 #endif
442 #if HAVE_SYS_TYPES_H
443 # include <sys/types.h>
444 #endif
445 #if HAVE_NETINET_IN_SYSTM_H
446 # include <netinet/in_systm.h>
447 #endif
448 #if HAVE_NETINET_IN_H
449 # include <netinet/in.h>
450 #endif
451 #if HAVE_NETINET_IP6_H
452 # include <netinet/ip6.h>
453 #endif
454 ])
455
456         if test "x$have_ip6_ext" = "xno"; then
457                 CFLAGS="$SAVE_CFLAGS"
458         fi
459 fi
460
461 # For cpu modules
462 AC_CHECK_HEADERS(sys/dkstat.h)
463 if test "x$ac_system" = "xDarwin"
464 then
465         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)
466         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
467         # For the battery plugin
468         AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
469 [
470 #if HAVE_IOKIT_IOKITLIB_H
471 #  include <IOKit/IOKitLib.h>
472 #endif
473 #if HAVE_IOKIT_IOTYPES_H
474 #  include <IOKit/IOTypes.h>
475 #endif
476 ])
477
478 fi
479
480 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
481 [
482 #if HAVE_SYS_TYPES_H
483 #  include <sys/types.h>
484 #endif
485 #if HAVE_SYS_PARAM_H
486 # include <sys/param.h>
487 #endif
488 ])
489
490 AC_MSG_CHECKING([for sysctl kern.cp_times])
491 if test -x /sbin/sysctl
492 then
493         /sbin/sysctl kern.cp_times >/dev/null 2>&1
494         if test $? -eq 0
495         then
496                 AC_MSG_RESULT([yes])
497                 AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIMES, 1,
498                 [Define if sysctl supports kern.cp_times])
499         else
500                 AC_MSG_RESULT([no])
501         fi
502 else
503         AC_MSG_RESULT([no])
504 fi
505
506 AC_MSG_CHECKING([for sysctl kern.cp_time])
507 if test -x /sbin/sysctl
508 then
509         /sbin/sysctl kern.cp_time >/dev/null 2>&1
510         if test $? -eq 0
511         then
512                 AC_MSG_RESULT([yes])
513                 AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIME, 1,
514                         [Define if sysctl supports kern.cp_time])
515         else
516                 AC_MSG_RESULT([no])
517         fi
518 else
519         AC_MSG_RESULT([no])
520 fi
521
522 # For hddtemp module
523 AC_CHECK_HEADERS(linux/major.h)
524
525 # For md module (Linux only)
526 if test "x$ac_system" = "xLinux"
527 then
528         AC_CHECK_HEADERS(linux/raid/md_u.h,
529                          [have_linux_raid_md_u_h="yes"],
530                          [have_linux_raid_md_u_h="no"],
531 [
532 #include <sys/ioctl.h>
533 #include <linux/major.h>
534 #include <linux/types.h>
535 ])
536         AC_CHECK_HEADERS([sys/sysmacros.h])
537 else
538         have_linux_raid_md_u_h="no"
539 fi
540
541 # For the wireless module
542 have_linux_wireless_h="no"
543 if test "x$ac_system" = "xLinux"
544 then
545   AC_CHECK_HEADERS(linux/wireless.h,
546                    [have_linux_wireless_h="yes"],
547                    [have_linux_wireless_h="no"],
548 [
549 #include <dirent.h>
550 #include <sys/ioctl.h>
551 #include <sys/socket.h>
552 ])
553 fi
554
555 # For the swap module
556 have_sys_swap_h="yes"
557 AC_CHECK_HEADERS(sys/swap.h vm/anon.h, [], [have_sys_swap_h="no"],
558 [
559 #undef _FILE_OFFSET_BITS
560 #undef _LARGEFILE64_SOURCE
561 #if HAVE_SYS_TYPES_H
562 #  include <sys/types.h>
563 #endif
564 #if HAVE_SYS_PARAM_H
565 # include <sys/param.h>
566 #endif
567 ])
568
569 # For load module
570 # For the processes plugin
571 # For users module
572 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
573
574 # For interface plugin
575 AC_CHECK_HEADERS(ifaddrs.h)
576 AC_CHECK_HEADERS(net/if.h, [], [],
577 [
578 #if HAVE_SYS_TYPES_H
579 #  include <sys/types.h>
580 #endif
581 #if HAVE_SYS_SOCKET_H
582 #  include <sys/socket.h>
583 #endif
584 ])
585 AC_CHECK_HEADERS(linux/if.h, [], [],
586 [
587 #if HAVE_SYS_TYPES_H
588 #  include <sys/types.h>
589 #endif
590 #if HAVE_SYS_SOCKET_H
591 #  include <sys/socket.h>
592 #endif
593 ])
594 AC_CHECK_HEADERS(linux/inet_diag.h, [], [],
595 [
596 #if HAVE_SYS_TYPES_H
597 #  include <sys/types.h>
598 #endif
599 #if HAVE_SYS_SOCKET_H
600 #  include <sys/socket.h>
601 #endif
602 #if HAVE_LINUX_INET_DIAG_H
603 # include <linux/inet_diag.h>
604 #endif
605 ])
606 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
607 [
608 #if HAVE_SYS_TYPES_H
609 #  include <sys/types.h>
610 #endif
611 #if HAVE_SYS_SOCKET_H
612 #  include <sys/socket.h>
613 #endif
614 #if HAVE_LINUX_IF_H
615 # include <linux/if.h>
616 #endif
617 ])
618
619 # For ethstat module
620 AC_CHECK_HEADERS(linux/sockios.h,
621     [have_linux_sockios_h="yes"],
622     [have_linux_sockios_h="no"],
623     [
624 #if HAVE_SYS_IOCTL_H
625 # include <sys/ioctl.h>
626 #endif
627 #if HAVE_NET_IF_H
628 # include <net/if.h>
629 #endif
630     ])
631 AC_CHECK_HEADERS(linux/ethtool.h,
632     [have_linux_ethtool_h="yes"],
633     [have_linux_ethtool_h="no"],
634     [
635 #if HAVE_SYS_IOCTL_H
636 # include <sys/ioctl.h>
637 #endif
638 #if HAVE_NET_IF_H
639 # include <net/if.h>
640 #endif
641 #if HAVE_LINUX_SOCKIOS_H
642 # include <linux/sockios.h>
643 #endif
644     ])
645
646 # For ipvs module
647 have_linux_ip_vs_h="no"
648 have_net_ip_vs_h="no"
649 have_ip_vs_h="no"
650 ip_vs_h_needs_kernel_cflags="no"
651 if test "x$ac_system" = "xLinux"
652 then
653         AC_CHECK_HEADERS(linux/ip_vs.h, [have_linux_ip_vs_h="yes"])
654         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
655         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
656
657         if test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono" && test -d "$KERNEL_DIR"
658         then
659                 SAVE_CFLAGS="$CFLAGS"
660                 CFLAGS="$CFLAGS $KERNEL_CFLAGS"
661
662                 AC_MSG_NOTICE([Did not find ip_vs.h. Trying again using headers from $KERNEL_DIR.])
663
664                 AC_CHECK_HEADERS(linux/ip_vs.h, [have_linux_ip_vs_h="yes"])
665                 AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
666                 AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
667
668                 if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
669                 then
670                         ip_vs_h_needs_kernel_cflags="yes"
671                 fi
672
673                 CFLAGS="$SAVE_CFLAGS"
674         fi
675 fi
676 AM_CONDITIONAL(IP_VS_H_NEEDS_KERNEL_CFLAGS, test "x$ip_vs_h_needs_kernel_cflags" = "xyes")
677
678 # For quota module
679 AC_CHECK_HEADERS(sys/ucred.h, [], [],
680 [
681 #if HAVE_SYS_TYPES_H
682 #  include <sys/types.h>
683 #endif
684 #if HAVE_SYS_PARAM_H
685 # include <sys/param.h>
686 #endif
687 ])
688
689 # For mount interface
690 AC_CHECK_HEADERS(sys/mount.h, [], [],
691 [
692 #if HAVE_SYS_TYPES_H
693 #  include <sys/types.h>
694 #endif
695 #if HAVE_SYS_PARAM_H
696 # include <sys/param.h>
697 #endif
698 ])
699
700 # For the email plugin
701 AC_CHECK_HEADERS(linux/un.h, [], [],
702 [
703 #if HAVE_SYS_SOCKET_H
704 #       include <sys/socket.h>
705 #endif
706 ])
707
708 # --enable-xfs {{{
709 AC_ARG_ENABLE([xfs],
710   [AS_HELP_STRING([--enable-xfs], [xfs support in df plugin @<:@default=yes@:>@])],
711   [],
712   [enable_xfs="auto"]
713 )
714
715 if test "x$enable_xfs" != "xno"; then
716   AC_CHECK_HEADERS([xfs/xqm.h],
717     [],
718     [
719       if test "x$enable_xfs" = "xyes"; then
720         AC_MSG_ERROR([xfs/xqm.h not found])
721       fi
722     ],
723     [[#define _GNU_SOURCE]]
724   )
725 fi
726
727 # }}}
728
729 # For the dns plugin
730 AC_CHECK_HEADERS(arpa/nameser.h)
731 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
732 [
733 #if HAVE_ARPA_NAMESER_H
734 # include <arpa/nameser.h>
735 #endif
736 ])
737
738 AC_CHECK_HEADERS(net/if_arp.h, [], [],
739 [#if HAVE_SYS_SOCKET_H
740 # include <sys/socket.h>
741 #endif
742 ])
743 AC_CHECK_HEADERS(net/ppp_defs.h)
744 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
745 [#if HAVE_NET_PPP_DEFS_H
746 # include <net/ppp_defs.h>
747 #endif
748 ])
749 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
750 [#if HAVE_STDINT_H
751 # include <stdint.h>
752 #endif
753 #if HAVE_SYS_TYPES_H
754 # include <sys/types.h>
755 #endif
756 #if HAVE_SYS_SOCKET_H
757 # include <sys/socket.h>
758 #endif
759 #if HAVE_NET_IF_H
760 # include <net/if.h>
761 #endif
762 #if HAVE_NETINET_IN_H
763 # include <netinet/in.h>
764 #endif
765 ])
766
767 have_net_pfvar_h="no"
768 AC_CHECK_HEADERS(net/pfvar.h,
769                [have_net_pfvar_h="yes"],
770                [have_net_pfvar_h="no"],
771 [
772 #if HAVE_SYS_IOCTL_H
773 # include <sys/ioctl.h>
774 #endif
775 #if HAVE_SYS_SOCKET_H
776 # include <sys/socket.h>
777 #endif
778 #if HAVE_NET_IF_H
779 # include <net/if.h>
780 #endif
781 #if HAVE_NETINET_IN_H
782 # include <netinet/in.h>
783 #endif
784 ])
785
786 # For the multimeter plugin
787 have_termios_h="no"
788 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
789
790 # For cpusleep plugin
791 AC_CACHE_CHECK([whether clock_boottime and clock_monotonic are supported],
792                        [c_cv_have_clock_boottime_monotonic],
793                        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
794 [[
795 #include <time.h>
796 ]],
797 [[
798  struct timespec b, m;
799  clock_gettime(CLOCK_BOOTTIME, &b );
800  clock_gettime(CLOCK_MONOTONIC, &m );
801 ]]
802                        )],
803                        [c_cv_have_clock_boottime_monotonic="yes"],
804                        [c_cv_have_clock_boottime_monotonic="no"]))
805
806
807 # For the turbostat plugin
808 AC_CHECK_HEADERS([cpuid.h],
809   [have_cpuid_h="yes"],
810   [have_cpuid_h="no (cpuid.h not found)"]
811 )
812
813 have_capability="yes"
814 AC_CHECK_HEADERS(sys/capability.h,
815                  [have_capability="yes"],
816                  [have_capability="no (<sys/capability.h> not found)"])
817 if test "x$have_capability" = "xyes"; then
818 AC_CHECK_LIB(cap, cap_get_proc,
819                  [have_capability="yes"],
820                  [have_capability="no (cap_get_proc() not found)"])
821 fi
822 if test "x$have_capability" = "xyes"; then
823 AC_CHECK_DECL([CAP_IS_SUPPORTED],
824                  [have_capability="yes"],
825                  [have_capability="no (CAP_IS_SUPPORTED not found)"],
826                  [[#include <sys/capability.h>]])
827 fi
828 if test "x$have_capability" = "xyes"; then
829   AC_DEFINE(HAVE_CAPABILITY, 1, [Define to 1 if you have cap_get_proc() (-lcap).])
830 fi
831 AM_CONDITIONAL(BUILD_WITH_CAPABILITY, test "x$have_capability" = "xyes")
832
833 #
834 # Checks for typedefs, structures, and compiler characteristics.
835 #
836 AC_C_CONST
837 AC_TYPE_PID_T
838 AC_TYPE_SIZE_T
839 AC_TYPE_UID_T
840 AC_HEADER_TIME
841
842 #
843 # Checks for library functions.
844 #
845 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 asprintf)
846
847 AC_FUNC_STRERROR_R
848
849 test_cxx_flags() {
850         AC_LANG_PUSH([C++])
851         AC_LANG_CONFTEST([
852                 AC_LANG_SOURCE([[int main(void){}]])
853         ])
854         $CXX -c conftest.cpp $CXXFLAGS $@ > /dev/null 2> /dev/null
855         ret=$?
856         rm -f conftest.o
857         AC_LANG_POP([C++])
858         return $ret
859 }
860
861 SAVE_CFLAGS="$CFLAGS"
862 # Emulate behavior of src/Makefile.am
863 if test "x$GCC" = "xyes"
864 then
865         CFLAGS="$CFLAGS -Wall -Werror"
866 fi
867
868 AC_CACHE_CHECK([for strtok_r],
869   [c_cv_have_strtok_r_default],
870   AC_LINK_IFELSE(
871     [AC_LANG_PROGRAM(
872 [[[
873 #include <stdlib.h>
874 #include <stdio.h>
875 #include <string.h>
876 ]]],
877 [[[
878       char buffer[] = "foo,bar,baz";
879       char *token;
880       char *dummy;
881       char *saveptr;
882
883       dummy = buffer;
884       saveptr = NULL;
885       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
886       {
887         dummy = NULL;
888         printf ("token = %s;\n", token);
889       }
890 ]]]
891     )],
892     [c_cv_have_strtok_r_default="yes"],
893     [c_cv_have_strtok_r_default="no"]
894   )
895 )
896
897 if test "x$c_cv_have_strtok_r_default" = "xno"
898 then
899   CFLAGS="$CFLAGS -D_REENTRANT=1"
900
901   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
902     [c_cv_have_strtok_r_reentrant],
903     AC_LINK_IFELSE(
904       [AC_LANG_PROGRAM(
905 [[[
906 #include <stdlib.h>
907 #include <stdio.h>
908 #include <string.h>
909 ]]],
910 [[[
911         char buffer[] = "foo,bar,baz";
912         char *token;
913         char *dummy;
914         char *saveptr;
915
916         dummy = buffer;
917         saveptr = NULL;
918         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
919         {
920           dummy = NULL;
921           printf ("token = %s;\n", token);
922         }
923 ]]]
924       )],
925       [c_cv_have_strtok_r_reentrant="yes"],
926       [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
927     )
928   )
929 fi
930
931 CFLAGS="$SAVE_CFLAGS"
932 if test "x$c_cv_have_strtok_r_reentrant" = "xyes"
933 then
934         CFLAGS="$CFLAGS -D_REENTRANT=1"
935 fi
936
937 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
938
939 socket_needs_socket="no"
940 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
941 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
942
943 clock_gettime_needs_rt="no"
944 clock_gettime_needs_posix4="no"
945 have_clock_gettime="no"
946 AC_CHECK_FUNCS(clock_gettime, [have_clock_gettime="yes"])
947 if test "x$have_clock_gettime" = "xno"
948 then
949         AC_CHECK_LIB(rt, clock_gettime, [clock_gettime_needs_rt="yes"
950                                          have_clock_gettime="yes"])
951 fi
952 if test "x$have_clock_gettime" = "xno"
953 then
954         AC_CHECK_LIB(posix4, clock_gettime, [clock_gettime_needs_posix4="yes"
955                                              have_clock_gettime="yes"])
956 fi
957 if test "x$have_clock_gettime" = "xyes"
958 then
959         AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
960 fi
961
962 nanosleep_needs_rt="no"
963 nanosleep_needs_posix4="no"
964 AC_CHECK_FUNCS(nanosleep,
965     [],
966     AC_CHECK_LIB(rt, nanosleep,
967         [nanosleep_needs_rt="yes"],
968         AC_CHECK_LIB(posix4, nanosleep,
969             [nanosleep_needs_posix4="yes"],
970             AC_MSG_ERROR(cannot find nanosleep))))
971
972 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes")
973 AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes")
974
975 AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
976 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
977 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
978 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
979 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
980 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
981 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
982 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
983 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
984 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
985 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
986 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
987
988 # Check for strptime {{{
989 if test "x$GCC" = "xyes"
990 then
991         SAVE_CFLAGS="$CFLAGS"
992         CFLAGS="$CFLAGS -Wall -Wextra -Werror"
993 fi
994
995 AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"])
996 if test "x$have_strptime" = "xyes"
997 then
998         AC_CACHE_CHECK([whether strptime is exported by default],
999                        [c_cv_have_strptime_default],
1000                        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1001 [[[
1002 #include <time.h>
1003 ]]],
1004 [[[
1005  struct tm stm;
1006  (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
1007 ]]]
1008                        )],
1009                        [c_cv_have_strptime_default="yes"],
1010                        [c_cv_have_strptime_default="no"]))
1011 fi
1012 if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"
1013 then
1014         AC_CACHE_CHECK([whether strptime needs standards mode],
1015                        [c_cv_have_strptime_standards],
1016                        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1017 [[[
1018 #ifndef _ISOC99_SOURCE
1019 # define _ISOC99_SOURCE 1
1020 #endif
1021 #ifndef _POSIX_C_SOURCE
1022 # define _POSIX_C_SOURCE 200112L
1023 #endif
1024 #ifndef _XOPEN_SOURCE
1025 # define _XOPEN_SOURCE 500
1026 #endif
1027 #include <time.h>
1028 ]]],
1029 [[[
1030  struct tm stm;
1031  (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
1032 ]]]
1033                        )],
1034                        [c_cv_have_strptime_standards="yes"],
1035                        [c_cv_have_strptime_standards="no"]))
1036
1037         if test "x$c_cv_have_strptime_standards" = "xyes"
1038         then
1039                 AC_DEFINE([STRPTIME_NEEDS_STANDARDS], 1, [Set to true if strptime is only exported in X/Open mode (GNU libc).])
1040         else
1041                 have_strptime="no"
1042         fi
1043 fi
1044
1045 if test "x$GCC" = "xyes"
1046 then
1047         CFLAGS="$SAVE_CFLAGS"
1048 fi
1049 # }}} Check for strptime
1050
1051 # Check for timegm {{{
1052
1053 # These checks need -Werror because implicit function declarations are only a
1054 # warning ...
1055 SAVE_CFLAGS="$CFLAGS"
1056 CFLAGS="$CFLAGS -Werror"
1057
1058 AC_CACHE_CHECK([for timegm],
1059   [c_cv_have_timegm],
1060   AC_LINK_IFELSE(
1061     [AC_LANG_PROGRAM(
1062 [[[
1063 #if STRPTIME_NEEDS_STANDARDS
1064 # ifndef _ISOC99_SOURCE
1065 #  define _ISOC99_SOURCE 1
1066 # endif
1067 # ifndef _POSIX_C_SOURCE
1068 #  define _POSIX_C_SOURCE 200112L
1069 # endif
1070 # ifndef _XOPEN_SOURCE
1071 #  define _XOPEN_SOURCE 500
1072 # endif
1073 #endif
1074 #include <time.h>
1075 ]]],
1076 [[[
1077  time_t t = timegm(&(struct tm){0});
1078  if (t == ((time_t) -1)) {
1079    return 1;
1080  }
1081 ]]]
1082     )],
1083     [c_cv_have_timegm="yes"],
1084     [c_cv_have_timegm="no"]
1085   )
1086 )
1087
1088 if test "x$c_cv_have_timegm" != "xyes"
1089 then
1090   AC_CACHE_CHECK([for timegm with _BSD_SOURCE],
1091     [c_cv_have_timegm_bsd],
1092     AC_LINK_IFELSE(
1093       [AC_LANG_PROGRAM(
1094 [[[
1095 #if STRPTIME_NEEDS_STANDARDS
1096 # ifndef _ISOC99_SOURCE
1097 #  define _ISOC99_SOURCE 1
1098 # endif
1099 # ifndef _POSIX_C_SOURCE
1100 #  define _POSIX_C_SOURCE 200112L
1101 # endif
1102 # ifndef _XOPEN_SOURCE
1103 #  define _XOPEN_SOURCE 500
1104 # endif
1105 #endif
1106 #ifndef _BSD_SOURCE
1107 # define _BSD_SOURCE 1
1108 #endif
1109 #include <time.h>
1110 ]]],
1111 [[[
1112  time_t t = timegm(&(struct tm){0});
1113  if (t == ((time_t) -1)) {
1114    return 1;
1115  }
1116 ]]]
1117       )],
1118       [c_cv_have_timegm_bsd="yes"
1119        c_cv_have_timegm="yes"],
1120       [c_cv_have_timegm_bsd="no"]
1121     )
1122   )
1123 fi
1124
1125 if test "x$c_cv_have_timegm" = "xyes"
1126 then
1127   AC_DEFINE(HAVE_TIMEGM, 1, [Define if the timegm(3) function is available.])
1128   if test "x$c_cv_have_timegm_bsd" = "xyes"
1129   then
1130     AC_DEFINE(TIMEGM_NEEDS_BSD, 1, [Set to true if timegm is only exported in BSD mode.])
1131   fi
1132 fi
1133
1134 CFLAGS="$SAVE_CFLAGS"
1135 # }}} Check for timegm
1136
1137 AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
1138 if test "x$have_swapctl" = "xyes"; then
1139         AC_CACHE_CHECK([whether swapctl takes two arguments],
1140                 [c_cv_have_swapctl_two_args],
1141                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1142 [[[
1143 #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
1144 #  undef _FILE_OFFSET_BITS
1145 #  undef _LARGEFILE64_SOURCE
1146 #endif
1147 #include <sys/stat.h>
1148 #include <sys/param.h>
1149 #include <sys/swap.h>
1150 #include <unistd.h>
1151 ]]],
1152 [[[
1153 int num = swapctl(0, NULL);
1154 ]]]
1155                         )],
1156                         [c_cv_have_swapctl_two_args="yes"],
1157                         [c_cv_have_swapctl_two_args="no"]
1158                 )
1159         )
1160         AC_CACHE_CHECK([whether swapctl takes three arguments],
1161                 [c_cv_have_swapctl_three_args],
1162                 AC_COMPILE_IFELSE(
1163                         [AC_LANG_PROGRAM(
1164 [[[
1165 #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
1166 #  undef _FILE_OFFSET_BITS
1167 #  undef _LARGEFILE64_SOURCE
1168 #endif
1169 #include <sys/stat.h>
1170 #include <sys/param.h>
1171 #include <sys/swap.h>
1172 #include <unistd.h>
1173 ]]],
1174 [[[
1175 int num = swapctl(0, NULL, 0);
1176 ]]]
1177                         )],
1178                         [c_cv_have_swapctl_three_args="yes"],
1179                         [c_cv_have_swapctl_three_args="no"]
1180                 )
1181         )
1182 fi
1183 # Check for different versions of `swapctl' here..
1184 if test "x$have_swapctl" = "xyes"; then
1185         if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
1186                 AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1,
1187                           [Define if the function swapctl exists and takes two arguments.])
1188         fi
1189         if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
1190                 AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1,
1191                           [Define if the function swapctl exists and takes three arguments.])
1192         fi
1193 fi
1194
1195 # Check for NAN
1196 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
1197 [
1198  if test "x$withval" = "xno"; then
1199          nan_type="none"
1200  else if test "x$withval" = "xyes"; then
1201          nan_type="zero"
1202  else
1203          nan_type="$withval"
1204  fi; fi
1205 ],
1206 [nan_type="none"])
1207 if test "x$nan_type" = "xnone"; then
1208   AC_CACHE_CHECK([whether NAN is defined by default],
1209     [c_cv_have_nan_default],
1210     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1211 [[[
1212 #include <stdlib.h>
1213 #include <math.h>
1214 static double foo = NAN;
1215 ]]],
1216 [[[
1217        if (isnan (foo))
1218         return 0;
1219        else
1220         return 1;
1221 ]]]
1222       )],
1223       [c_cv_have_nan_default="yes"],
1224       [c_cv_have_nan_default="no"]
1225     )
1226   )
1227   if test "x$c_cv_have_nan_default" = "xyes"
1228   then
1229     nan_type="default"
1230   fi
1231 fi
1232 if test "x$nan_type" = "xnone"; then
1233   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
1234     [c_cv_have_nan_isoc],
1235     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1236 [[[
1237 #include <stdlib.h>
1238 #define __USE_ISOC99 1
1239 #include <math.h>
1240 static double foo = NAN;
1241 ]]],
1242 [[[
1243        if (isnan (foo))
1244         return 0;
1245        else
1246         return 1;
1247 ]]]
1248       )],
1249       [c_cv_have_nan_isoc="yes"],
1250       [c_cv_have_nan_isoc="no"]
1251     )
1252   )
1253   if test "x$c_cv_have_nan_isoc" = "xyes"
1254   then
1255     nan_type="isoc99"
1256   fi
1257 fi
1258 if test "x$nan_type" = "xnone"; then
1259   SAVE_LDFLAGS=$LDFLAGS
1260   LDFLAGS="$LDFLAGS -lm"
1261   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
1262     [c_cv_have_nan_zero],
1263     AC_RUN_IFELSE([AC_LANG_PROGRAM(
1264 [[[
1265 #include <stdlib.h>
1266 #include <math.h>
1267 #ifdef NAN
1268 # undef NAN
1269 #endif
1270 #define NAN (0.0 / 0.0)
1271 #ifndef isnan
1272 # define isnan(f) ((f) != (f))
1273 #endif
1274 static double foo = NAN;
1275 ]]],
1276 [[[
1277        if (isnan (foo))
1278         return 0;
1279        else
1280         return 1;
1281 ]]]
1282       )],
1283       [c_cv_have_nan_zero="yes"],
1284       [c_cv_have_nan_zero="no"]
1285     )
1286   )
1287   LDFLAGS=$SAVE_LDFLAGS
1288   if test "x$c_cv_have_nan_zero" = "xyes"
1289   then
1290     nan_type="zero"
1291   fi
1292 fi
1293
1294 if test "x$nan_type" = "xdefault"; then
1295   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
1296     [Define if NAN is defined by default and can initialize static variables.])
1297 else if test "x$nan_type" = "xisoc99"; then
1298   AC_DEFINE(NAN_STATIC_ISOC, 1,
1299     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
1300 else if test "x$nan_type" = "xzero"; then
1301   AC_DEFINE(NAN_ZERO_ZERO, 1,
1302     [Define if NAN can be defined as (0.0 / 0.0)])
1303 else
1304   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
1305 fi; fi; fi
1306
1307 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
1308 [
1309  if test "x$withval" = "xnothing"; then
1310         fp_layout_type="nothing"
1311  else if test "x$withval" = "xendianflip"; then
1312         fp_layout_type="endianflip"
1313  else if test "x$withval" = "xintswap"; then
1314         fp_layout_type="intswap"
1315  else
1316         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
1317 fi; fi; fi
1318 ],
1319 [fp_layout_type="unknown"])
1320
1321 if test "x$fp_layout_type" = "xunknown"; then
1322   AC_CACHE_CHECK([if doubles are stored in x86 representation],
1323     [c_cv_fp_layout_need_nothing],
1324     AC_RUN_IFELSE([AC_LANG_PROGRAM(
1325 [[[
1326 #include <stdlib.h>
1327 #include <stdio.h>
1328 #include <string.h>
1329 #if HAVE_STDINT_H
1330 # include <stdint.h>
1331 #endif
1332 #if HAVE_INTTYPES_H
1333 # include <inttypes.h>
1334 #endif
1335 #if HAVE_STDBOOL_H
1336 # include <stdbool.h>
1337 #endif
1338 ]]],
1339 [[[
1340         uint64_t i0;
1341         uint64_t i1;
1342         uint8_t c[8];
1343         double d;
1344
1345         d = 8.642135e130;
1346         memcpy ((void *) &i0, (void *) &d, 8);
1347
1348         i1 = i0;
1349         memcpy ((void *) c, (void *) &i1, 8);
1350
1351         if ((c[0] == 0x2f) && (c[1] == 0x25)
1352                         && (c[2] == 0xc0) && (c[3] == 0xc7)
1353                         && (c[4] == 0x43) && (c[5] == 0x2b)
1354                         && (c[6] == 0x1f) && (c[7] == 0x5b))
1355                 return (0);
1356         else
1357                 return (1);
1358 ]]]
1359       )],
1360       [c_cv_fp_layout_need_nothing="yes"],
1361       [c_cv_fp_layout_need_nothing="no"]
1362     )
1363   )
1364   if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
1365     fp_layout_type="nothing"
1366   fi
1367 fi
1368 if test "x$fp_layout_type" = "xunknown"; then
1369   AC_CACHE_CHECK([if endianflip converts to x86 representation],
1370     [c_cv_fp_layout_need_endianflip],
1371     AC_RUN_IFELSE([AC_LANG_PROGRAM(
1372 [[[
1373 #include <stdlib.h>
1374 #include <stdio.h>
1375 #include <string.h>
1376 #if HAVE_STDINT_H
1377 # include <stdint.h>
1378 #endif
1379 #if HAVE_INTTYPES_H
1380 # include <inttypes.h>
1381 #endif
1382 #if HAVE_STDBOOL_H
1383 # include <stdbool.h>
1384 #endif
1385 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
1386                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
1387                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
1388                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
1389                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
1390                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
1391                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
1392                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
1393 ]]],
1394 [[[
1395         uint64_t i0;
1396         uint64_t i1;
1397         uint8_t c[8];
1398         double d;
1399
1400         d = 8.642135e130;
1401         memcpy ((void *) &i0, (void *) &d, 8);
1402
1403         i1 = endianflip (i0);
1404         memcpy ((void *) c, (void *) &i1, 8);
1405
1406         if ((c[0] == 0x2f) && (c[1] == 0x25)
1407                         && (c[2] == 0xc0) && (c[3] == 0xc7)
1408                         && (c[4] == 0x43) && (c[5] == 0x2b)
1409                         && (c[6] == 0x1f) && (c[7] == 0x5b))
1410                 return (0);
1411         else
1412                 return (1);
1413 ]]]
1414       )],
1415       [c_cv_fp_layout_need_endianflip="yes"],
1416       [c_cv_fp_layout_need_endianflip="no"]
1417     )
1418   )
1419   if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
1420     fp_layout_type="endianflip"
1421   fi
1422 fi
1423 if test "x$fp_layout_type" = "xunknown"; then
1424   AC_CACHE_CHECK([if intswap converts to x86 representation],
1425     [c_cv_fp_layout_need_intswap],
1426     AC_RUN_IFELSE([AC_LANG_PROGRAM(
1427 [[[
1428 #include <stdlib.h>
1429 #include <stdio.h>
1430 #include <string.h>
1431 #if HAVE_STDINT_H
1432 # include <stdint.h>
1433 #endif
1434 #if HAVE_INTTYPES_H
1435 # include <inttypes.h>
1436 #endif
1437 #if HAVE_STDBOOL_H
1438 # include <stdbool.h>
1439 #endif
1440 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
1441                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
1442 ]]],
1443 [[[
1444         uint64_t i0;
1445         uint64_t i1;
1446         uint8_t c[8];
1447         double d;
1448
1449         d = 8.642135e130;
1450         memcpy ((void *) &i0, (void *) &d, 8);
1451
1452         i1 = intswap (i0);
1453         memcpy ((void *) c, (void *) &i1, 8);
1454
1455         if ((c[0] == 0x2f) && (c[1] == 0x25)
1456                         && (c[2] == 0xc0) && (c[3] == 0xc7)
1457                         && (c[4] == 0x43) && (c[5] == 0x2b)
1458                         && (c[6] == 0x1f) && (c[7] == 0x5b))
1459                 return (0);
1460         else
1461                 return (1);
1462 ]]]
1463       )],
1464       [c_cv_fp_layout_need_intswap="yes"],
1465       [c_cv_fp_layout_need_intswap="no"]
1466     )
1467   )
1468   if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
1469     fp_layout_type="intswap"
1470   fi
1471 fi
1472
1473 if test "x$fp_layout_type" = "xnothing"; then
1474   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
1475   [Define if doubles are stored in x86 representation.])
1476 else if test "x$fp_layout_type" = "xendianflip"; then
1477   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
1478   [Define if endianflip is needed to convert to x86 representation.])
1479 else if test "x$fp_layout_type" = "xintswap"; then
1480   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
1481   [Define if intswap is needed to convert to x86 representation.])
1482 else
1483   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
1484 fi; fi; fi
1485
1486 # --with-useragent {{{
1487 AC_ARG_WITH(useragent, [AS_HELP_STRING([--with-useragent@<:@=AGENT@:>@], [User agent to use on http requests])],
1488 [
1489     if test "x$withval" != "xno" && test "x$withval" != "xyes"
1490     then
1491         AC_DEFINE_UNQUOTED(COLLECTD_USERAGENT, ["$withval"], [User agent for http requests])
1492     fi
1493 ])
1494
1495 # }}}
1496
1497 # --with-data-max-name-len {{{
1498 AC_ARG_WITH(data-max-name-len, [AS_HELP_STRING([--with-data-max-name-len@<:@=VALUE@:>@], [Maximum length of data buffers])],
1499 [
1500     if test "x$withval" != "x" && test $withval -gt 0
1501     then
1502         AC_DEFINE_UNQUOTED(DATA_MAX_NAME_LEN, [$withval], [Maximum length of data buffers])
1503     else
1504         AC_MSG_ERROR([DATA_MAX_NAME_LEN must be a positive integer -- $withval given])
1505     fi
1506 ],
1507 [   AC_DEFINE(DATA_MAX_NAME_LEN, 128, [Maximum length of data buffers])]
1508 )
1509 # }}}
1510
1511 have_getfsstat="no"
1512 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
1513 have_getvfsstat="no"
1514 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
1515 have_listmntent="no"
1516 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
1517 have_getmntent_r="no"
1518 AC_CHECK_FUNCS(getmntent_r, [have_getmntent_r="yes"])
1519
1520 have_getmntent="no"
1521 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
1522 if test "x$have_getmntent" = "xno"; then
1523         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
1524 fi
1525 if test "x$have_getmntent" = "xno"; then
1526         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
1527 fi
1528 if test "x$have_getmntent" = "xno"; then
1529         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
1530 fi
1531
1532 if test "x$have_getmntent" = "xc"; then
1533         AC_CACHE_CHECK([whether getmntent takes one argument],
1534                 [c_cv_have_one_getmntent],
1535                 AC_COMPILE_IFELSE(
1536                         [AC_LANG_PROGRAM(
1537 [[[
1538 #include "$srcdir/src/utils_mount.h"
1539 ]]],
1540 [[[
1541 FILE *fh;
1542 struct mntent *me;
1543 fh = setmntent ("/etc/mtab", "r");
1544 me = getmntent (fh);
1545 return(me->mnt_passno);
1546 ]]]
1547                         )],
1548                         [c_cv_have_one_getmntent="yes"],
1549                         [c_cv_have_one_getmntent="no"]
1550                 )
1551         )
1552         AC_CACHE_CHECK([whether getmntent takes two arguments],
1553                 [c_cv_have_two_getmntent],
1554                 AC_COMPILE_IFELSE(
1555                         [AC_LANG_PROGRAM(
1556 [[[
1557 #include "$srcdir/src/utils_mount.h"
1558 ]]],
1559 [[[
1560                                  FILE *fh;
1561                                  struct mnttab mt;
1562                                  int status;
1563                                  fh = fopen ("/etc/mnttab", "r");
1564                                  status = getmntent (fh, &mt);
1565                                  return(status);
1566 ]]]
1567                         )],
1568                         [c_cv_have_two_getmntent="yes"],
1569                         [c_cv_have_two_getmntent="no"]
1570                 )
1571         )
1572 fi
1573
1574 # Check for different versions of `getmntent' here..
1575
1576 if test "x$have_getmntent" = "xc"; then
1577         if test "x$c_cv_have_one_getmntent" = "xyes"; then
1578                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
1579                           [Define if the function getmntent exists and takes one argument.])
1580         fi
1581         if test "x$c_cv_have_two_getmntent" = "xyes"; then
1582                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
1583                           [Define if the function getmntent exists and takes two arguments.])
1584         fi
1585 fi
1586 if test "x$have_getmntent" = "xsun"; then
1587         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
1588                   [Define if the function getmntent exists. It is the version from libsun.])
1589 fi
1590 if test "x$have_getmntent" = "xseq"; then
1591         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
1592                   [Define if the function getmntent exists. It is the version from libseq.])
1593 fi
1594 if test "x$have_getmntent" = "xgen"; then
1595         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
1596                   [Define if the function getmntent exists. It is the version from libgen.])
1597 fi
1598
1599 # Check for htonll
1600 AC_CACHE_CHECK([if have htonll defined],
1601                   [c_cv_have_htonll],
1602                   AC_LINK_IFELSE([AC_LANG_PROGRAM(
1603 [[[
1604 #include <sys/types.h>
1605 #include <netinet/in.h>
1606 #if HAVE_INTTYPES_H
1607 # include <inttypes.h>
1608 #endif
1609 ]]],
1610 [[[
1611           return htonll(0);
1612 ]]]
1613     )],
1614     [c_cv_have_htonll="yes"],
1615     [c_cv_have_htonll="no"]
1616   )
1617 )
1618 if test "x$c_cv_have_htonll" = "xyes"
1619 then
1620     AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
1621 fi
1622
1623 # Check for structures
1624 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
1625         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
1626         [],
1627         [
1628         #include <sys/types.h>
1629         #include <sys/socket.h>
1630         #include <net/if.h>
1631         ])
1632 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
1633         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
1634         [],
1635         [
1636         #include <sys/types.h>
1637         #include <sys/socket.h>
1638         #include <linux/if.h>
1639         #include <linux/netdevice.h>
1640         ])
1641 AC_CHECK_MEMBERS([struct inet_diag_req.id, struct inet_diag_req.idiag_states],
1642         [AC_DEFINE(HAVE_STRUCT_LINUX_INET_DIAG_REQ, 1, [Define if struct inet_diag_req exists and is usable.])],
1643         [],
1644         [
1645         #include <linux/inet_diag.h>
1646         ])
1647
1648
1649 AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [],
1650         [],
1651         [
1652         #include <netinet/in.h>
1653         #include <net/if.h>
1654         ])
1655
1656 AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
1657         [
1658                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
1659                         [Define if struct kinfo_proc exists in the FreeBSD variant.])
1660                 have_struct_kinfo_proc_freebsd="yes"
1661         ],
1662         [
1663                 have_struct_kinfo_proc_freebsd="no"
1664         ],
1665         [
1666 #include <kvm.h>
1667 #include <sys/param.h>
1668 #include <sys/sysctl.h>
1669 #include <sys/user.h>
1670         ])
1671
1672 AC_CHECK_MEMBERS([struct kinfo_proc.p_pid, struct kinfo_proc.p_vm_rssize],
1673         [
1674                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
1675                         [Define if struct kinfo_proc exists in the OpenBSD variant.])
1676                 have_struct_kinfo_proc_openbsd="yes"
1677         ],
1678         [
1679                 have_struct_kinfo_proc_openbsd="no"
1680         ],
1681         [
1682 #include <sys/param.h>
1683 #include <sys/sysctl.h>
1684 #include <kvm.h>
1685         ])
1686
1687
1688 AC_CHECK_MEMBERS([struct kinfo_proc2.p_pid, struct kinfo_proc2.p_uru_maxrss],
1689         [
1690                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC2_NETBSD, 1,
1691                         [Define if struct kinfo_proc2 exists in the NetBSD variant.])
1692                 have_struct_kinfo_proc2_netbsd="yes"
1693         ],
1694         [
1695                 have_struct_kinfo_proc2_netbsd="no"
1696         ],
1697         [
1698 #include <sys/param.h>
1699 #include <sys/sysctl.h>
1700 #include <kvm.h>
1701         ])
1702
1703
1704
1705 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
1706 [#define _BSD_SOURCE
1707 #define _DEFAULT_SOURCE
1708 #if HAVE_STDINT_H
1709 # include <stdint.h>
1710 #endif
1711 #if HAVE_SYS_TYPES_H
1712 # include <sys/types.h>
1713 #endif
1714 #if HAVE_NETINET_IN_SYSTM_H
1715 # include <netinet/in_systm.h>
1716 #endif
1717 #if HAVE_NETINET_IN_H
1718 # include <netinet/in.h>
1719 #endif
1720 #if HAVE_NETINET_IP_H
1721 # include <netinet/ip.h>
1722 #endif
1723 #if HAVE_NETINET_UDP_H
1724 # include <netinet/udp.h>
1725 #endif
1726 ])
1727 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
1728 [#define _BSD_SOURCE
1729 #define _DEFAULT_SOURCE
1730 #if HAVE_STDINT_H
1731 # include <stdint.h>
1732 #endif
1733 #if HAVE_SYS_TYPES_H
1734 # include <sys/types.h>
1735 #endif
1736 #if HAVE_NETINET_IN_SYSTM_H
1737 # include <netinet/in_systm.h>
1738 #endif
1739 #if HAVE_NETINET_IN_H
1740 # include <netinet/in.h>
1741 #endif
1742 #if HAVE_NETINET_IP_H
1743 # include <netinet/ip.h>
1744 #endif
1745 #if HAVE_NETINET_UDP_H
1746 # include <netinet/udp.h>
1747 #endif
1748 ])
1749
1750 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
1751         [],
1752         [],
1753         [
1754 #if HAVE_KSTAT_H
1755 # include <kstat.h>
1756 #endif
1757         ])
1758
1759 # check for pthread_setname_np
1760 SAVE_LDFLAGS="$LDFLAGS"
1761 LDFLAGS="$LDFLAGS -lpthread"
1762
1763 AC_MSG_CHECKING([for pthread_setname_np])
1764         have_pthread_setname_np="no"
1765         AC_LINK_IFELSE([AC_LANG_PROGRAM(
1766 [[
1767 #define _GNU_SOURCE
1768 #include <pthread.h>
1769 ]],
1770 [[
1771         pthread_setname_np((pthread_t) {0}, "conftest");
1772 ]]
1773         )], [
1774                 have_pthread_setname_np="yes"
1775                 AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [pthread_setname_np() is available.])
1776         ])
1777
1778 AC_MSG_RESULT([$have_pthread_setname_np])
1779
1780 # check for pthread_set_name_np(3) (FreeBSD)
1781 AC_MSG_CHECKING([for pthread_set_name_np])
1782         have_pthread_set_name_np="no"
1783         AC_LINK_IFELSE([AC_LANG_PROGRAM(
1784 [[
1785 #include <pthread_np.h>
1786 ]],
1787 [[
1788         pthread_set_name_np((pthread_t) {0}, "conftest");
1789 ]]
1790         )], [
1791                 have_pthread_set_name_np="yes"
1792                 AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP, 1, [pthread_set_name_np() is available.])
1793         ])
1794 AC_MSG_RESULT([$have_pthread_set_name_np])
1795
1796 LDFLAGS="$SAVE_LDFLAGS"
1797
1798 #
1799 # Checks for libraries begin here
1800 #
1801
1802 with_libresolv="yes"
1803 AC_CHECK_LIB(resolv, res_search,
1804 [
1805         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
1806 ],
1807 [with_libresolv="no"])
1808 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
1809
1810 dnl Check for HAL (hardware abstraction library)
1811 with_libhal="no"
1812 PKG_CHECK_MODULES([HAL], [hal],
1813   [
1814     SAVE_LIBS="$LIBS"
1815     LIBS="$HAL_LIBS $LIBS"
1816     AC_CHECK_LIB([hal], [libhal_device_property_exists],
1817       [
1818         SAVE_CPPFLAGS="$CPPFLAGS"
1819         CPPFLAGS="$HAL_CFLAGS $CPPFLAGS"
1820         AC_CHECK_HEADERS([libhal.h],
1821         [
1822           with_libhal="yes"
1823           BUILD_WITH_LIBHAL_CFLAGS="$HAL_CFLAGS"
1824           BUILD_WITH_LIBHAL_LIBS="$HAL_LIBS"
1825         ])
1826         CPPFLAGS="$SAVE_CPPFLAGS"
1827       ],
1828       [ : ]
1829     )
1830     LIBS="$SAVE_LIBS"
1831   ],
1832   [ : ]
1833 )
1834 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
1835 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
1836
1837
1838 SAVE_LIBS="$LIBS"
1839 AC_CHECK_LIB([pthread],
1840   [pthread_create],
1841   [],
1842   [AC_MSG_ERROR([Symbol 'pthread_create' not found in libpthread"])],
1843   []
1844 )
1845 PTHREAD_LIBS="$LIBS"
1846 LIBS="$SAVE_LIBS"
1847
1848 AC_CHECK_HEADERS([pthread.h],
1849   [],
1850   [AC_MSG_ERROR([pthread.h not found])]
1851 )
1852 AC_SUBST([PTHREAD_LIBS])
1853
1854 m4_divert_once([HELP_WITH], [
1855 collectd additional packages:])
1856
1857 if test "x$ac_system" = "xAIX"
1858 then
1859         with_perfstat="yes"
1860         with_procinfo="yes"
1861 else
1862         with_perfstat="no (AIX only)"
1863         with_procinfo="no (AIX only)"
1864 fi
1865
1866 if test "x$with_perfstat" = "xyes"
1867 then
1868         AC_CHECK_LIB(perfstat, perfstat_reset, [with_perfstat="yes"], [with_perfstat="no (perfstat not found)"], [])
1869 #       AC_CHECK_HEADERS(sys/protosw.h libperfstat.h,, [with_perfstat="no (perfstat not found)"])
1870 fi
1871 if test "x$with_perfstat" = "xyes"
1872 then
1873          AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
1874          # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
1875          AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled], [], [], [[#include <libperfstat.h]])
1876          if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"
1877          then
1878                 AC_DEFINE(PERFSTAT_SUPPORTS_DONATION, 1, [Define to 1 if your version of the 'perfstat' library supports donation])
1879          fi
1880 fi
1881 AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")
1882
1883 # Processes plugin under AIX.
1884 if test "x$with_procinfo" = "xyes"
1885 then
1886         AC_CHECK_HEADERS(procinfo.h,, [with_procinfo="no (procinfo.h not found)"])
1887 fi
1888 if test "x$with_procinfo" = "xyes"
1889 then
1890          AC_DEFINE(HAVE_PROCINFO_H, 1, [Define to 1 if you have the procinfo.h])
1891 fi
1892
1893 if test "x$ac_system" = "xSolaris"
1894 then
1895         with_kstat="yes"
1896         with_devinfo="yes"
1897 else
1898         with_kstat="no (Solaris only)"
1899         with_devinfo="no (Solaris only)"
1900 fi
1901
1902 if test "x$with_kstat" = "xyes"
1903 then
1904         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
1905 fi
1906 if test "x$with_kstat" = "xyes"
1907 then
1908         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
1909         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
1910 fi
1911 if test "x$with_kstat" = "xyes"
1912 then
1913         AC_DEFINE(HAVE_LIBKSTAT, 1,
1914                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1915 fi
1916 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1917 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1918
1919 with_libiokit="no"
1920 if test "x$ac_system" = "xDarwin"
1921 then
1922         with_libiokit="yes"
1923 else
1924         with_libiokit="no"
1925 fi
1926 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1927
1928 with_libkvm="no"
1929 AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
1930 if test "x$with_kvm_getprocs" = "xyes"
1931 then
1932         AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
1933                   [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
1934         with_libkvm="yes"
1935 fi
1936 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
1937
1938 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
1939 if test "x$with_kvm_getswapinfo" = "xyes"
1940 then
1941         AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
1942                   [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
1943         with_libkvm="yes"
1944 fi
1945 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
1946
1947 AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
1948 if test "x$with_kvm_nlist" = "xyes"
1949 then
1950         AC_CHECK_HEADERS(bsd/nlist.h nlist.h)
1951         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1952                   [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
1953         with_libkvm="yes"
1954 fi
1955 AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
1956
1957 AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
1958 if test "x$with_kvm_openfiles" = "xyes"
1959 then
1960         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1961                   [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
1962         with_libkvm="yes"
1963 fi
1964 AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
1965
1966 # --with-libaquaero5 {{{
1967 AC_ARG_WITH(libaquaero5, [AS_HELP_STRING([--with-libaquaero5@<:@=PREFIX@:>@], [Path to aquatools-ng source code.])],
1968 [
1969  if test "x$withval" = "xyes"
1970  then
1971          with_libaquaero5="yes"
1972  else if test "x$withval" = "xno"
1973  then
1974          with_libaquaero5="no"
1975  else
1976          with_libaquaero5="yes"
1977          LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS -I$withval/src"
1978          LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS -L$withval/obj"
1979  fi; fi
1980 ],
1981 [with_libaquaero5="yes"])
1982
1983 SAVE_CPPFLAGS="$CPPFLAGS"
1984 SAVE_LDFLAGS="$LDFLAGS"
1985
1986 CPPFLAGS="$CPPFLAGS $LIBAQUAERO5_CFLAGS"
1987 LDFLAGS="$LDFLAGS $LIBAQUAERO5_LDFLAGS"
1988
1989 if test "x$with_libaquaero5" = "xyes"
1990 then
1991         if test "x$LIBAQUAERO5_CFLAGS" != "x"
1992         then
1993                 AC_MSG_NOTICE([libaquaero5 CPPFLAGS: $LIBAQUAERO5_CFLAGS])
1994         fi
1995         AC_CHECK_HEADERS(libaquaero5.h,
1996         [with_libaquaero5="yes"],
1997         [with_libaquaero5="no (libaquaero5.h not found)"])
1998 fi
1999 if test "x$with_libaquaero5" = "xyes"
2000 then
2001         if test "x$LIBAQUAERO5_LDFLAGS" != "x"
2002         then
2003                 AC_MSG_NOTICE([libaquaero5 LDFLAGS: $LIBAQUAERO5_LDFLAGS])
2004         fi
2005         AC_CHECK_LIB(aquaero5, libaquaero5_poll,
2006         [with_libaquaero5="yes"],
2007         [with_libaquaero5="no (symbol 'libaquaero5_poll' not found)"])
2008 fi
2009
2010 CPPFLAGS="$SAVE_CPPFLAGS"
2011 LDFLAGS="$SAVE_LDFLAGS"
2012
2013 if test "x$with_libaquaero5" = "xyes"
2014 then
2015         BUILD_WITH_LIBAQUAERO5_CFLAGS="$LIBAQUAERO5_CFLAGS"
2016         BUILD_WITH_LIBAQUAERO5_LDFLAGS="$LIBAQUAERO5_LDFLAGS"
2017         AC_SUBST(BUILD_WITH_LIBAQUAERO5_CFLAGS)
2018         AC_SUBST(BUILD_WITH_LIBAQUAERO5_LDFLAGS)
2019 fi
2020 AM_CONDITIONAL(BUILD_WITH_LIBAQUAERO5, test "x$with_libaquaero5" = "xyes")
2021 # }}}
2022
2023 # --with-libhiredis {{{
2024 AC_ARG_WITH(libhiredis, [AS_HELP_STRING([--with-libhiredis@<:@=PREFIX@:>@],
2025       [Path to libhiredis.])],
2026 [
2027  if test "x$withval" = "xyes"
2028  then
2029          with_libhiredis="yes"
2030  else if test "x$withval" = "xno"
2031  then
2032          with_libhiredis="no"
2033  else
2034          with_libhiredis="yes"
2035          LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS -I$withval/include"
2036          LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS -L$withval/lib"
2037  fi; fi
2038 ],
2039 [with_libhiredis="yes"])
2040
2041 SAVE_CPPFLAGS="$CPPFLAGS"
2042 SAVE_LDFLAGS="$LDFLAGS"
2043
2044 CPPFLAGS="$CPPFLAGS $LIBHIREDIS_CPPFLAGS"
2045 LDFLAGS="$LDFLAGS $LIBHIREDIS_LDFLAGS"
2046
2047 if test "x$with_libhiredis" = "xyes"
2048 then
2049         if test "x$LIBHIREDIS_CPPFLAGS" != "x"
2050         then
2051                 AC_MSG_NOTICE([libhiredis CPPFLAGS: $LIBHIREDIS_CPPFLAGS])
2052         fi
2053         AC_CHECK_HEADERS(hiredis/hiredis.h,
2054         [with_libhiredis="yes"],
2055         [with_libhiredis="no (hiredis.h not found)"])
2056 fi
2057 if test "x$with_libhiredis" = "xyes"
2058 then
2059         if test "x$LIBHIREDIS_LDFLAGS" != "x"
2060         then
2061                 AC_MSG_NOTICE([libhiredis LDFLAGS: $LIBHIREDIS_LDFLAGS])
2062         fi
2063         AC_CHECK_LIB(hiredis, redisCommand,
2064         [with_libhiredis="yes"],
2065         [with_libhiredis="no (symbol 'redisCommand' not found)"])
2066
2067 fi
2068
2069 CPPFLAGS="$SAVE_CPPFLAGS"
2070 LDFLAGS="$SAVE_LDFLAGS"
2071
2072 if test "x$with_libhiredis" = "xyes"
2073 then
2074         BUILD_WITH_LIBHIREDIS_CPPFLAGS="$LIBHIREDIS_CPPFLAGS"
2075         BUILD_WITH_LIBHIREDIS_LDFLAGS="$LIBHIREDIS_LDFLAGS"
2076         AC_SUBST(BUILD_WITH_LIBHIREDIS_CPPFLAGS)
2077         AC_SUBST(BUILD_WITH_LIBHIREDIS_LDFLAGS)
2078 fi
2079 AM_CONDITIONAL(BUILD_WITH_LIBHIREDIS, test "x$with_libhiredis" = "xyes")
2080 # }}}
2081
2082 # --with-libcurl {{{
2083 with_curl_config="curl-config"
2084 with_curl_cflags=""
2085 with_curl_libs=""
2086 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
2087 [
2088         if test "x$withval" = "xno"
2089         then
2090                 with_libcurl="no"
2091         else if test "x$withval" = "xyes"
2092         then
2093                 with_libcurl="yes"
2094         else
2095                 if test -f "$withval" && test -x "$withval"
2096                 then
2097                         with_curl_config="$withval"
2098                         with_libcurl="yes"
2099                 else if test -x "$withval/bin/curl-config"
2100                 then
2101                         with_curl_config="$withval/bin/curl-config"
2102                         with_libcurl="yes"
2103                 fi; fi
2104                 with_libcurl="yes"
2105         fi; fi
2106 ],
2107 [
2108         with_libcurl="yes"
2109 ])
2110 if test "x$with_libcurl" = "xyes"
2111 then
2112         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
2113         curl_config_status=$?
2114
2115         if test $curl_config_status -ne 0
2116         then
2117                 with_libcurl="no ($with_curl_config failed)"
2118         else
2119                 SAVE_CPPFLAGS="$CPPFLAGS"
2120                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
2121
2122                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
2123
2124                 CPPFLAGS="$SAVE_CPPFLAGS"
2125         fi
2126 fi
2127 if test "x$with_libcurl" = "xyes"
2128 then
2129         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
2130         curl_config_status=$?
2131
2132         if test $curl_config_status -ne 0
2133         then
2134                 with_libcurl="no ($with_curl_config failed)"
2135         else
2136                 AC_CHECK_LIB(curl, curl_easy_init,
2137                  [with_libcurl="yes"],
2138                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
2139                  [$with_curl_libs])
2140                 AC_CHECK_DECL(CURLOPT_USERNAME,
2141                  [have_curlopt_username="yes"],
2142                  [have_curlopt_username="no"],
2143                  [[#include <curl/curl.h>]])
2144                 AC_CHECK_DECL(CURLOPT_TIMEOUT_MS,
2145                  [have_curlopt_timeout="yes"],
2146                  [have_curlopt_timeout="no"],
2147                  [[#include <curl/curl.h>]])
2148         fi
2149 fi
2150 if test "x$with_libcurl" = "xyes"
2151 then
2152         SAVE_CPPFLAGS="$CPPFLAGS"
2153         SAVE_LDFLAGS="$LDFLAGS"
2154         CPPFLAGS="$CPPFLAGS $with_curl_cflags"
2155         LDFLAGS="$LDFLAGS $with_curl_libs"
2156         AC_CACHE_CHECK([for CURLINFO_APPCONNECT_TIME],
2157                 [c_cv_have_curlinfo_appconnect_time],
2158                 AC_LINK_IFELSE([AC_LANG_PROGRAM(
2159 [[
2160 #include <curl/curl.h>
2161 ]],
2162 [[
2163 int val = CURLINFO_APPCONNECT_TIME;
2164 return val;
2165 ]]
2166                         )],
2167                         [c_cv_have_curlinfo_appconnect_time="yes"],
2168                         [c_cv_have_curlinfo_appconnect_time="no"]
2169                 )
2170         )
2171         CPPFLAGS="$SAVE_CPPFLAGS"
2172         LDFLAGS="$SAVE_LDFLAGS"
2173 fi
2174 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
2175 if test "x$c_cv_have_curlinfo_appconnect_time" = "xyes"
2176 then
2177         AC_DEFINE(HAVE_CURLINFO_APPCONNECT_TIME, 1, [Define if curl.h defines CURLINFO_APPCONNECT_TIME.])
2178 fi
2179
2180 if test "x$with_libcurl" = "xyes"
2181 then
2182         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
2183         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
2184         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
2185         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
2186
2187         if test "x$have_curlopt_username" = "xyes"
2188         then
2189                 AC_DEFINE(HAVE_CURLOPT_USERNAME, 1, [Define if libcurl supports CURLOPT_USERNAME option.])
2190         fi
2191
2192         if test "x$have_curlopt_timeout" = "xyes"
2193         then
2194                 AC_DEFINE(HAVE_CURLOPT_TIMEOUT_MS, 1, [Define if libcurl supports CURLOPT_TIMEOUT_MS option.])
2195         fi
2196 fi
2197 # }}}
2198
2199 # --with-libdbi {{{
2200 with_libdbi_cppflags=""
2201 with_libdbi_ldflags=""
2202 AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
2203 [
2204         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2205         then
2206                 with_libdbi_cppflags="-I$withval/include"
2207                 with_libdbi_ldflags="-L$withval/lib"
2208                 with_libdbi="yes"
2209         else
2210                 with_libdbi="$withval"
2211         fi
2212 ],
2213 [
2214         with_libdbi="yes"
2215 ])
2216 if test "x$with_libdbi" = "xyes"
2217 then
2218         SAVE_CPPFLAGS="$CPPFLAGS"
2219         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
2220
2221         AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
2222
2223         CPPFLAGS="$SAVE_CPPFLAGS"
2224 fi
2225 if test "x$with_libdbi" = "xyes"
2226 then
2227         SAVE_CPPFLAGS="$CPPFLAGS"
2228         SAVE_LDFLAGS="$LDFLAGS"
2229         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
2230         LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
2231
2232         AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
2233
2234         CPPFLAGS="$SAVE_CPPFLAGS"
2235         LDFLAGS="$SAVE_LDFLAGS"
2236 fi
2237 if test "x$with_libdbi" = "xyes"
2238 then
2239         BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
2240         BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
2241         BUILD_WITH_LIBDBI_LIBS="-ldbi"
2242         AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
2243         AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
2244         AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
2245 fi
2246 AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
2247 # }}}
2248
2249 # --with-libesmtp {{{
2250 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
2251 [
2252         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2253         then
2254                 LDFLAGS="$LDFLAGS -L$withval/lib"
2255                 CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
2256                 with_libesmtp="yes"
2257         else
2258                 with_libesmtp="$withval"
2259         fi
2260 ],
2261 [
2262         with_libesmtp="yes"
2263 ])
2264 if test "x$with_libesmtp" = "xyes"
2265 then
2266         AC_CHECK_LIB(esmtp, smtp_create_session,
2267         [
2268                 AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
2269         ], [with_libesmtp="no (libesmtp not found)"])
2270 fi
2271 if test "x$with_libesmtp" = "xyes"
2272 then
2273         AC_CHECK_HEADERS(libesmtp.h,
2274         [
2275                 AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
2276         ], [with_libesmtp="no (libesmtp.h not found)"])
2277 fi
2278 if test "x$with_libesmtp" = "xyes"
2279 then
2280         collect_libesmtp=1
2281 else
2282         collect_libesmtp=0
2283 fi
2284 AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
2285         [Wether or not to use the esmtp library])
2286 AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
2287 # }}}
2288
2289 # --with-libganglia {{{
2290 AC_ARG_WITH(libganglia, [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
2291 [
2292  if test -f "$withval" && test -x "$withval"
2293  then
2294          with_libganglia_config="$withval"
2295          with_libganglia="yes"
2296  else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"
2297  then
2298          with_libganglia_config="$withval/bin/ganglia-config"
2299          with_libganglia="yes"
2300  else if test -d "$withval"
2301  then
2302          GANGLIA_CPPFLAGS="-I$withval/include"
2303          GANGLIA_LDFLAGS="-L$withval/lib"
2304          with_libganglia="yes"
2305  else
2306          with_libganglia="$withval"
2307  fi; fi; fi
2308 ],
2309 [
2310  with_libganglia="yes"
2311 ])
2312
2313 if test "x$with_libganglia" = "xyes"
2314 then
2315         if test "x$with_libganglia_config" != "x"
2316         then
2317                 if test "x$GANGLIA_CPPFLAGS" = "x"
2318                 then
2319                         GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
2320                 fi
2321
2322                 if test "x$GANGLIA_LDFLAGS" = "x"
2323                 then
2324                         GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
2325                 fi
2326
2327                 if test "x$GANGLIA_LIBS" = "x"
2328                 then
2329                         GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
2330                 fi
2331         else
2332                 GANGLIA_LIBS="-lganglia"
2333         fi
2334 fi
2335
2336 SAVE_CPPFLAGS="$CPPFLAGS"
2337 SAVE_LDFLAGS="$LDFLAGS"
2338 CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
2339 LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
2340
2341 if test "x$with_libganglia" = "xyes"
2342 then
2343         AC_CHECK_HEADERS(gm_protocol.h,
2344         [
2345                 AC_DEFINE(HAVE_GM_PROTOCOL_H, 1,
2346                           [Define to 1 if you have the <gm_protocol.h> header file.])
2347         ], [with_libganglia="no (gm_protocol.h not found)"])
2348 fi
2349
2350 if test "x$with_libganglia" = "xyes"
2351 then
2352         AC_CHECK_LIB(ganglia, xdr_Ganglia_value_msg,
2353         [
2354                 AC_DEFINE(HAVE_LIBGANGLIA, 1,
2355                           [Define to 1 if you have the ganglia library (-lganglia).])
2356         ], [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"])
2357 fi
2358
2359 CPPFLAGS="$SAVE_CPPFLAGS"
2360 LDFLAGS="$SAVE_LDFLAGS"
2361
2362 AC_SUBST(GANGLIA_CPPFLAGS)
2363 AC_SUBST(GANGLIA_LDFLAGS)
2364 AC_SUBST(GANGLIA_LIBS)
2365 AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
2366 # }}}
2367
2368 # --with-libgcrypt {{{
2369 GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
2370 GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
2371 GCRYPT_LIBS="$GCRYPT_LIBS"
2372 AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
2373 [
2374  if test -f "$withval" && test -x "$withval"
2375  then
2376          with_libgcrypt_config="$withval"
2377          with_libgcrypt="yes"
2378  else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
2379  then
2380          with_libgcrypt_config="$withval/bin/gcrypt-config"
2381          with_libgcrypt="yes"
2382  else if test -d "$withval"
2383  then
2384          GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
2385          GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
2386          with_libgcrypt="yes"
2387  else
2388          with_libgcrypt_config="gcrypt-config"
2389          with_libgcrypt="$withval"
2390  fi; fi; fi
2391 ],
2392 [
2393  with_libgcrypt_config="libgcrypt-config"
2394  with_libgcrypt="yes"
2395 ])
2396
2397 if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
2398 then
2399         if test "x$GCRYPT_CPPFLAGS" = "x"
2400         then
2401                 GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
2402         fi
2403
2404         if test "x$GCRYPT_LIBS" = "x"
2405         then
2406                 GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
2407         fi
2408 fi
2409
2410 SAVE_CPPFLAGS="$CPPFLAGS"
2411 SAVE_LDFLAGS="$LDFLAGS"
2412 SAVE_LIBS="$LIBS"
2413 CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
2414 LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
2415 LIBS="$LIBS $GCRYPT_LIBS"
2416
2417 if test "x$with_libgcrypt" = "xyes"
2418 then
2419         if test "x$GCRYPT_CPPFLAGS" != "x"
2420         then
2421                 AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
2422         fi
2423         AC_CHECK_HEADERS(gcrypt.h,
2424                 [with_libgcrypt="yes"],
2425                 [with_libgcrypt="no (gcrypt.h not found)"])
2426 fi
2427
2428 if test "x$with_libgcrypt" = "xyes"
2429 then
2430         AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
2431                 [with_libgcrypt="yes"],
2432                 [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
2433 fi
2434
2435 CPPFLAGS="$SAVE_CPPFLAGS"
2436 LDFLAGS="$SAVE_LDFLAGS"
2437 LIBS="$SAVE_LIBS"
2438
2439 if test "x$with_libgcrypt" = "xyes"
2440 then
2441         AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to 1 if you have the gcrypt library (-lgcrypt).])
2442 fi
2443
2444 AC_SUBST(GCRYPT_CPPFLAGS)
2445 AC_SUBST(GCRYPT_LDFLAGS)
2446 AC_SUBST(GCRYPT_LIBS)
2447 AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
2448 # }}}
2449
2450 # --with-libgps {{{
2451 with_libgps_cflags=""
2452 with_libgps_ldflags=""
2453 AC_ARG_WITH(libgps, [AS_HELP_STRING([--with-libgps@<:@=PREFIX@:>@], [Path to libgps.])],
2454 [
2455         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2456         then
2457                 with_libgps_cflags="-I$withval/include"
2458                 with_libgps_ldflags="-L$withval/lib"
2459                 with_libgps="yes"
2460         else
2461                 with_libgps="$withval"
2462         fi
2463 ],
2464 [
2465         with_libgps="yes"
2466 ])
2467 if test "x$with_libgps" = "xyes"
2468 then
2469         SAVE_CFLAGS="$CFLAGS"
2470         CFLAGS="$CFLAGS $with_libgps_cflags"
2471
2472         AC_CHECK_HEADERS(gps.h, [with_libgps="yes"], [with_libgps="no (gps.h not found)"])
2473
2474         CFLAGS="$SAVE_CFLAGS"
2475 fi
2476 if test "x$with_libgps" = "xyes"
2477 then
2478         SAVE_CFLAGS="$CFLAGS"
2479         SAVE_LDFLAGS="$LDFLAGS"
2480         CFLAGS="$CFLAGS $with_libgps_cflags"
2481         LDFLAGS="$LDFLAGS $with_libgps_ldflags"
2482
2483         AC_CHECK_LIB(gps, gps_open, [with_libgps="yes"], [with_libgps="no (symbol gps_open not found)"])
2484
2485         CFLAGS="$SAVE_CFLAGS"
2486         LDFLAGS="$SAVE_LDFLAGS"
2487 fi
2488 if test "x$with_libgps" = "xyes"
2489 then
2490         BUILD_WITH_LIBGPS_CFLAGS="$with_libgps_cflags"
2491         BUILD_WITH_LIBGPS_LDFLAGS="$with_libgps_ldflags"
2492         BUILD_WITH_LIBGPS_LIBS="-lgps"
2493         AC_SUBST(BUILD_WITH_LIBGPS_CFLAGS)
2494         AC_SUBST(BUILD_WITH_LIBGPS_LDFLAGS)
2495         AC_SUBST(BUILD_WITH_LIBGPS_LIBS)
2496 fi
2497 AM_CONDITIONAL(BUILD_WITH_LIBGPS, test "x$with_libgps" = "xyes")
2498 # }}}
2499
2500 # --with-libgrpc++ {{{
2501 with_libgrpcpp_cppflags=""
2502 with_libgrpcpp_ldflags=""
2503 AC_ARG_WITH([libgrpc++], [AS_HELP_STRING([--with-libgrpc++@<:@=PREFIX@:>@], [Path to libgrpc++.])],
2504   [
2505     with_grpcpp="$withval"
2506     if test "x$withval" != "xno" && test "x$withval" != "xyes"
2507     then
2508       with_libgrpcpp_cppflags="-I$withval/include"
2509       with_libgrpcpp_ldflags="-L$withval/lib"
2510       with_libgrpcpp="yes"
2511     fi
2512     if test "x$withval" = "xno"
2513     then
2514       with_libgrpcpp="no (disabled on command line)"
2515     fi
2516   ],
2517   [withval="yes"]
2518 )
2519 if test "x$withval" = "xyes"
2520 then
2521 PKG_CHECK_MODULES([GRPCPP], [grpc++],
2522   [with_libgrpcpp="yes"],
2523   [with_libgrpcpp="no (pkg-config could not find libgrpc++)"]
2524 )
2525 fi
2526
2527 if test "x$withval" != "xno"
2528 then
2529   AC_MSG_CHECKING([whether $CXX accepts -std=c++11])
2530   if test_cxx_flags -std=c++11; then
2531     AC_MSG_RESULT([yes])
2532   else
2533     AC_MSG_RESULT([no])
2534     with_libgrpcpp="no (requires C++11 support)"
2535   fi
2536 fi
2537
2538 if test "x$with_libgrpcpp" = "xyes"
2539 then
2540   AC_LANG_PUSH(C++)
2541   SAVE_CPPFLAGS="$CPPFLAGS"
2542   CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS"
2543   AC_CHECK_HEADERS([grpc++/grpc++.h], [],
2544     [with_libgrpcpp="no (<grpc++/grpc++.h> not found)"]
2545   )
2546   CPPFLAGS="$SAVE_CPPFLAGS"
2547   AC_LANG_POP(C++)
2548 fi
2549 if test "x$with_libgrpcpp" = "xyes"
2550 then
2551   AC_LANG_PUSH(C++)
2552   SAVE_CPPFLAGS="$CPPFLAGS"
2553   SAVE_LDFLAGS="$LDFLAGS"
2554   SAVE_LIBS="$LIBS"
2555   CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS $CPPFLAGS"
2556   LDFLAGS="$with_libgrpcpp_ldflags"
2557   if test "x$GRPCPP_LIBS" = "x"
2558   then
2559     LIBS="-lgrpc++"
2560   else
2561     LIBS="$GRPCPP_LIBS"
2562   fi
2563   AC_LINK_IFELSE(
2564     [AC_LANG_PROGRAM(
2565       [[#include <grpc++/grpc++.h>]],
2566       [[grpc::ServerBuilder sb;]]
2567     )],
2568     [
2569       with_libgrpcpp="yes"
2570       if test "x$GRPCPP_LIBS" = "x"
2571       then
2572         GRPCPP_LIBS="-lgrpc++"
2573       fi
2574     ],
2575     [with_libgrpcpp="no (libgrpc++ not found)"]
2576   )
2577   CPPFLAGS="$SAVE_CPPFLAGS"
2578   LDFLAGS="$SAVE_LDFLAGS"
2579   LIBS="$SAVE_LIBS"
2580   AC_LANG_POP(C++)
2581 fi
2582 BUILD_WITH_LIBGRPCPP_CPPFLAGS="-std=c++11 $with_libgrpcpp_cppflags $GRPCPP_CFLAGS"
2583 BUILD_WITH_LIBGRPCPP_LDFLAGS="$with_libgrpcpp_ldflags"
2584 BUILD_WITH_LIBGRPCPP_LIBS="$GRPCPP_LIBS"
2585 AC_SUBST([BUILD_WITH_LIBGRPCPP_CPPFLAGS])
2586 AC_SUBST([BUILD_WITH_LIBGRPCPP_LDFLAGS])
2587 AC_SUBST([BUILD_WITH_LIBGRPCPP_LIBS])
2588 # }}}
2589
2590 # --with-libiptc {{{
2591 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
2592 [
2593         if test "x$withval" = "xyes"
2594         then
2595                 with_libiptc="pkgconfig"
2596         else if test "x$withval" = "xno"
2597         then
2598                 with_libiptc="no"
2599         else
2600                 with_libiptc="yes"
2601                 with_libiptc_cflags="-I$withval/include"
2602                 with_libiptc_libs="-L$withval/lib"
2603         fi; fi
2604 ],
2605 [
2606         if test "x$ac_system" = "xLinux"
2607         then
2608                 with_libiptc="pkgconfig"
2609         else
2610                 with_libiptc="no (Linux only)"
2611         fi
2612 ])
2613
2614 if test "x$with_libiptc" = "xpkgconfig"
2615 then
2616         $PKG_CONFIG --exists 'libiptc' 2>/dev/null
2617         if test $? -ne 0
2618         then
2619                 with_libiptc="no (pkg-config doesn't know libiptc)"
2620         fi
2621 fi
2622 if test "x$with_libiptc" = "xpkgconfig"
2623 then
2624         with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
2625         if test $? -ne 0
2626         then
2627                 with_libiptc="no ($PKG_CONFIG failed)"
2628         fi
2629         with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
2630         if test $? -ne 0
2631         then
2632                 with_libiptc="no ($PKG_CONFIG failed)"
2633         fi
2634 fi
2635
2636 SAVE_CPPFLAGS="$CPPFLAGS"
2637 CPPFLAGS="$CPPFLAGS $with_libiptc_cflags"
2638
2639 # check whether the header file for libiptc is available.
2640 if test "x$with_libiptc" = "xpkgconfig"
2641 then
2642         AC_CHECK_HEADERS(libiptc/libiptc.h libiptc/libip6tc.h, ,
2643                         [with_libiptc="no (header file missing)"])
2644 fi
2645 # If the header file is available, check for the required type declaractions.
2646 # They may be missing in old versions of libiptc. In that case, they will be
2647 # declared in the iptables plugin.
2648 if test "x$with_libiptc" = "xpkgconfig"
2649 then
2650         AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
2651 fi
2652 # Check for the iptc_init symbol in the library.
2653 # This could be in iptc or ip4tc
2654 if test "x$with_libiptc" = "xpkgconfig"
2655 then
2656         SAVE_LIBS="$LIBS"
2657         AC_SEARCH_LIBS(iptc_init, [iptc ip4tc],
2658                         [with_libiptc="pkgconfig"],
2659                         [with_libiptc="no"],
2660                         [$with_libiptc_libs])
2661         LIBS="$SAVE_LIBS"
2662 fi
2663 if test "x$with_libiptc" = "xpkgconfig"
2664 then
2665         with_libiptc="yes"
2666 fi
2667
2668 CPPFLAGS="$SAVE_CPPFLAGS"
2669
2670 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
2671 if test "x$with_libiptc" = "xyes"
2672 then
2673         BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
2674         BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
2675         AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
2676         AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
2677 fi
2678 # }}}
2679
2680 # --with-libdpdk {{{
2681 AC_ARG_VAR([LIBDPDK_CPPFLAGS], [Preprocessor flags for libdpdk])
2682 AC_ARG_VAR([LIBDPDK_CFLAGS], [Compiler flags for libdpdk])
2683 AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
2684 AC_ARG_VAR([LIBDPDK_LIBS], [Libraries to link for libdpdk])
2685
2686 AC_ARG_WITH([libdpdk],
2687   [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])],
2688   [with_libdpdk="$withval"],
2689   [with_libdpdk="yes"]
2690 )
2691
2692 if test "x$with_libdpdk" != "xno"; then
2693   PKG_CHECK_MODULES([DPDK], [libdpdk], [],
2694                     [AC_MSG_NOTICE([no DPDK pkg-config, using defaults])])
2695   if test "x$LIBDPDK_CPPFLAGS" = "x"; then
2696     LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
2697   fi
2698   if test "x$LIBDPDK_CFLAGS" = "x"; then
2699       LIBDPDK_CFLAGS="$DPDK_CFLAGS"
2700       LIBDPDK_CPPFLAGS="$LIBDPDK_CPPFLAGS $DPDK_CFLAGS"
2701   fi
2702   if test "x$LIBDPDK_LIBS" = "x"; then
2703       if test "x$DPDK_LIBS" != "x"; then
2704           LIBDPDK_LIBS="$DPDK_LIBS"
2705       else
2706           LIBDPDK_LIBS="-ldpdk"
2707       fi
2708   fi
2709   SAVE_CPPFLAGS="$CPPFLAGS"
2710   CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
2711   SAVE_CFLAGS="$CFLAGS"
2712   CFLAGS="$LIBDPDK_CFLAGS $CFLAGS"
2713   AC_CHECK_HEADERS([rte_config.h],
2714     [
2715       with_libdpdk="yes"
2716       AC_PREPROC_IFELSE(
2717         [
2718           AC_LANG_SOURCE(
2719             [[
2720               #include <rte_version.h>
2721               #if RTE_VERSION < RTE_VERSION_NUM(16,7,0,0)
2722               #error "required DPDK >= 16.07"
2723               #endif
2724             ]]
2725           )
2726         ],
2727         [dpdk_keepalive="yes"],
2728         [dpdk_keepalive="no (DPDK version < 16.07)"]
2729       )
2730     ],
2731     [with_libdpdk="no (rte_config.h not found)"]
2732   )
2733   CPPFLAGS="$SAVE_CPPFLAGS"
2734   CFLAGS="$SAVE_CFLAGS"
2735 fi
2736
2737 if test "x$with_libdpdk" = "xyes"; then
2738   SAVE_LDFLAGS="$LDFLAGS"
2739   LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
2740   AC_CHECK_LIB([dpdk], [rte_eal_init],
2741     [with_libdpdk="yes"],
2742     [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
2743   )
2744   LDFLAGS="$SAVE_LDFLAGS"
2745 fi
2746
2747 # }}}
2748
2749 # --with-java {{{
2750 with_java_home="$JAVA_HOME"
2751 if test "x$with_java_home" = "x"
2752 then
2753         with_java_home="/usr/lib/jvm"
2754 fi
2755 JAVAC="$JAVAC"
2756 JAR="$JAR"
2757 AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
2758 [
2759         if test "x$withval" = "xno"
2760         then
2761                 with_java="no"
2762         else if test "x$withval" = "xyes"
2763         then
2764                 with_java="yes"
2765         else
2766                 with_java_home="$withval"
2767                 with_java="yes"
2768         fi; fi
2769 ],
2770 [with_java="yes"])
2771 if test "x$with_java" = "xyes"
2772 then
2773         if test -d "$with_java_home"
2774         then
2775                 AC_MSG_CHECKING([for jni.h])
2776                 TMPVAR=`find -L "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2777                 if test "x$TMPVAR" != "x"
2778                 then
2779                         AC_MSG_RESULT([found in $TMPVAR])
2780                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
2781                 else
2782                         AC_MSG_RESULT([not found])
2783                 fi
2784
2785                 AC_MSG_CHECKING([for jni_md.h])
2786                 TMPVAR=`find -L "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2787                 if test "x$TMPVAR" != "x"
2788                 then
2789                         AC_MSG_RESULT([found in $TMPVAR])
2790                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPVAR"
2791                 else
2792                         AC_MSG_RESULT([not found])
2793                 fi
2794
2795                 AC_MSG_CHECKING([for libjvm.so])
2796                 TMPVAR=`find -L "$with_java_home" -type f \( -name libjvm.so -o -name libjvm.dylib \) -exec 'dirname' '{}' ';' 2>/dev/null | LC_ALL=C sort | head -n 1`
2797                 if test "x$TMPVAR" != "x"
2798                 then
2799                         AC_MSG_RESULT([found in $TMPVAR])
2800                         JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPVAR -Wl,-rpath -Wl,$TMPVAR"
2801                 else
2802                         AC_MSG_RESULT([not found])
2803                 fi
2804
2805                 if test "x$JAVAC" = "x"
2806                 then
2807                         AC_MSG_CHECKING([for javac])
2808                         TMPVAR=`find -L "$with_java_home" -name javac -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
2809                         if test "x$TMPVAR" != "x"
2810                         then
2811                                 JAVAC="$TMPVAR"
2812                                 AC_MSG_RESULT([$JAVAC])
2813                         else
2814                                 AC_MSG_RESULT([not found])
2815                         fi
2816                 fi
2817                 if test "x$JAR" = "x"
2818                 then
2819                         AC_MSG_CHECKING([for jar])
2820                         TMPVAR=`find -L "$with_java_home" -name jar -type f 2>/dev/null | LC_ALL=C sort | head -n 1`
2821                         if test "x$TMPVAR" != "x"
2822                         then
2823                                 JAR="$TMPVAR"
2824                                 AC_MSG_RESULT([$JAR])
2825                         else
2826                                 AC_MSG_RESULT([not found])
2827                         fi
2828                 fi
2829         else if test "x$with_java_home" != "x"
2830         then
2831                 AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
2832         fi; fi
2833 fi
2834
2835 if test "x$JAVA_CPPFLAGS" != "x"
2836 then
2837         AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
2838 fi
2839 if test "x$JAVA_CFLAGS" != "x"
2840 then
2841         AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
2842 fi
2843 if test "x$JAVA_LDFLAGS" != "x"
2844 then
2845         AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
2846 fi
2847 if test "x$JAVA_LIBS" != "x"
2848 then
2849         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
2850 fi
2851 if test "x$JAVAC" = "x"
2852 then
2853         with_javac_path="$PATH"
2854         if test "x$with_java_home" != "x"
2855         then
2856                 with_javac_path="$with_java_home:with_javac_path"
2857                 if test -d "$with_java_home/bin"
2858                 then
2859                         with_javac_path="$with_java_home/bin:with_javac_path"
2860                 fi
2861         fi
2862
2863         AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
2864 fi
2865 if test "x$JAVAC" = "x"
2866 then
2867         with_java="no (javac not found)"
2868 fi
2869 if test "x$JAR" = "x"
2870 then
2871         with_jar_path="$PATH"
2872         if test "x$with_java_home" != "x"
2873         then
2874                 with_jar_path="$with_java_home:$with_jar_path"
2875                 if test -d "$with_java_home/bin"
2876                 then
2877                         with_jar_path="$with_java_home/bin:$with_jar_path"
2878                 fi
2879         fi
2880
2881         AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
2882 fi
2883 if test "x$JAR" = "x"
2884 then
2885         with_java="no (jar not found)"
2886 fi
2887
2888 SAVE_CPPFLAGS="$CPPFLAGS"
2889 SAVE_CFLAGS="$CFLAGS"
2890 SAVE_LDFLAGS="$LDFLAGS"
2891 SAVE_LIBS="$LIBS"
2892 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
2893 CFLAGS="$CFLAGS $JAVA_CFLAGS"
2894 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
2895 LIBS="$LIBS $JAVA_LIBS"
2896
2897 if test "x$with_java" = "xyes"
2898 then
2899         AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
2900 fi
2901 if test "x$with_java" = "xyes"
2902 then
2903         AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
2904         [with_java="yes"],
2905         [with_java="no (Symbol 'JNI_CreateJavaVM' not found)"],
2906         [$JAVA_LIBS $PTHREAD_LIBS])
2907 fi
2908 if test "x$with_java" = "xyes"
2909 then
2910         JAVA_LIBS="$JAVA_LIBS -ljvm"
2911         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
2912 fi
2913
2914 CPPFLAGS="$SAVE_CPPFLAGS"
2915 CFLAGS="$SAVE_CFLAGS"
2916 LDFLAGS="$SAVE_LDFLAGS"
2917 LIBS="$SAVE_LIBS"
2918
2919 AC_SUBST(JAVA_CPPFLAGS)
2920 AC_SUBST(JAVA_CFLAGS)
2921 AC_SUBST(JAVA_LDFLAGS)
2922 AC_SUBST(JAVA_LIBS)
2923 AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
2924 # }}}
2925
2926 # --with-libldap {{{
2927 AC_ARG_WITH(libldap, [AS_HELP_STRING([--with-libldap@<:@=PREFIX@:>@], [Path to libldap.])],
2928 [
2929  if test "x$withval" = "xyes"
2930  then
2931          with_libldap="yes"
2932  else if test "x$withval" = "xno"
2933  then
2934          with_libldap="no"
2935  else
2936          with_libldap="yes"
2937          LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS -I$withval/include"
2938          LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS -L$withval/lib"
2939  fi; fi
2940 ],
2941 [with_libldap="yes"])
2942
2943 SAVE_CPPFLAGS="$CPPFLAGS"
2944 SAVE_LDFLAGS="$LDFLAGS"
2945
2946 CPPFLAGS="$CPPFLAGS $LIBLDAP_CPPFLAGS"
2947 LDFLAGS="$LDFLAGS $LIBLDAP_LDFLAGS"
2948
2949 if test "x$with_libldap" = "xyes"
2950 then
2951         if test "x$LIBLDAP_CPPFLAGS" != "x"
2952         then
2953                 AC_MSG_NOTICE([libldap CPPFLAGS: $LIBLDAP_CPPFLAGS])
2954         fi
2955         AC_CHECK_HEADERS(ldap.h,
2956         [with_libldap="yes"],
2957         [with_libldap="no ('ldap.h' not found)"])
2958 fi
2959 if test "x$with_libldap" = "xyes"
2960 then
2961         if test "x$LIBLDAP_LDFLAGS" != "x"
2962         then
2963                 AC_MSG_NOTICE([libldap LDFLAGS: $LIBLDAP_LDFLAGS])
2964         fi
2965         AC_CHECK_LIB(ldap, ldap_initialize,
2966         [with_libldap="yes"],
2967         [with_libldap="no (symbol 'ldap_initialize' not found)"])
2968
2969 fi
2970
2971 CPPFLAGS="$SAVE_CPPFLAGS"
2972 LDFLAGS="$SAVE_LDFLAGS"
2973
2974 if test "x$with_libldap" = "xyes"
2975 then
2976         BUILD_WITH_LIBLDAP_CPPFLAGS="$LIBLDAP_CPPFLAGS"
2977         BUILD_WITH_LIBLDAP_LDFLAGS="$LIBLDAP_LDFLAGS"
2978         AC_SUBST(BUILD_WITH_LIBLDAP_CPPFLAGS)
2979         AC_SUBST(BUILD_WITH_LIBLDAP_LDFLAGS)
2980 fi
2981 AM_CONDITIONAL(BUILD_WITH_LIBLDAP, test "x$with_libldap" = "xyes")
2982 # }}}
2983
2984 # --with-liblua {{{
2985 AC_ARG_VAR([LIBLUA_PKG_CONFIG_NAME], [Name of liblua used by pkg-config])
2986 if test "x$LIBLUA_PKG_CONFIG_NAME" != "x"
2987 then
2988   PKG_CHECK_MODULES([LUA], [$LIBLUA_PKG_CONFIG_NAME],
2989     [with_liblua="yes"],
2990     [with_liblua="no"]
2991   )
2992 else
2993   PKG_CHECK_MODULES([LUA], [lua],
2994     [with_liblua="yes"],
2995     [
2996       PKG_CHECK_MODULES([LUA], [lua-5.3],
2997         [with_liblua="yes"],
2998         [
2999           PKG_CHECK_MODULES([LUA], [lua5.3],
3000             [with_liblua="yes"],
3001             [
3002               PKG_CHECK_MODULES([LUA], [lua-5.2],
3003                 [with_liblua="yes"],
3004                 [
3005                   PKG_CHECK_MODULES([LUA], [lua5.2],
3006                     [with_liblua="yes"],
3007                     [
3008                       PKG_CHECK_MODULES([LUA], [lua-5.1],
3009                         [with_liblua="yes"],
3010                         [
3011                           PKG_CHECK_MODULES([LUA], [lua5.1],
3012                             [with_liblua="yes"],
3013                             [with_liblua="no (pkg-config cannot find liblua)"]
3014                           )
3015                         ]
3016                       )
3017                     ]
3018                   )
3019                 ]
3020               )
3021             ]
3022           )
3023         ]
3024       )
3025     ]
3026   )
3027 fi
3028
3029 if test "x$with_liblua" = "xyes"
3030 then
3031   SAVE_CPPFLAGS="$CPPFLAGS"
3032   CPPFLAGS="$CPPFLAGS $LUA_CFLAGS"
3033
3034   AC_CHECK_HEADERS([lua.h lauxlib.h lualib.h],
3035     [with_liblua="yes"],
3036     [with_liblua="no (header not found)"]
3037   )
3038
3039   CPPFLAGS="$SAVE_CPPFLAGS"
3040 fi
3041
3042 if test "x$with_liblua" = "xyes"
3043 then
3044   SAVE_LIBS="$LIBS"
3045   LIBS="$LIBS $LUA_LIBS"
3046
3047   AC_CHECK_FUNC([lua_settop],
3048     [with_liblua="yes"],
3049     [with_liblua="no (symbol 'lua_settop' not found)"]
3050   )
3051
3052   LIBS="$SAVE_LIBS"
3053 fi
3054
3055 if test "x$with_liblua" = "xyes"
3056 then
3057     BUILD_WITH_LIBLUA_CFLAGS="$LUA_CFLAGS"
3058     BUILD_WITH_LIBLUA_LIBS="$LUA_LIBS"
3059 fi
3060 AC_SUBST(BUILD_WITH_LIBLUA_CFLAGS)
3061 AC_SUBST(BUILD_WITH_LIBLUA_LIBS)
3062 # }}}
3063
3064 # --with-liblvm2app {{{
3065 with_liblvm2app_cppflags=""
3066 with_liblvm2app_ldflags=""
3067 AC_ARG_WITH(liblvm2app, [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
3068 [
3069         if test "x$withval" = "xno"
3070         then
3071                 with_liblvm2app="no"
3072         else
3073                 with_liblvm2app="yes"
3074                 if test "x$withval" != "xyes"
3075                 then
3076                         with_liblvm2app_cppflags="-I$withval/include"
3077                         with_liblvm2app_ldflags="-L$withval/lib"
3078                 fi
3079         fi
3080 ],
3081 [
3082         if test "x$ac_system" = "xLinux"
3083         then
3084                 with_liblvm2app="yes"
3085         else
3086                 with_liblvm2app="no (Linux only library)"
3087         fi
3088 ])
3089 if test "x$with_liblvm2app" = "xyes"
3090 then
3091         SAVE_CPPFLAGS="$CPPFLAGS"
3092         CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
3093
3094         AC_CHECK_HEADERS(lvm2app.h, [with_liblvm2app="yes"], [with_liblvm2app="no (lvm2app.h not found)"])
3095
3096         CPPFLAGS="$SAVE_CPPFLAGS"
3097 fi
3098
3099 if test "x$with_liblvm2app" = "xyes"
3100 then
3101         SAVE_CPPFLAGS="$CPPFLAGS"
3102         SAVE_LDFLAGS="$LDFLAGS"
3103         CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
3104         LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
3105
3106         AC_CHECK_LIB(lvm2app, lvm_lv_get_property, [with_liblvm2app="yes"], [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"])
3107
3108         CPPFLAGS="$SAVE_CPPFLAGS"
3109         LDFLAGS="$SAVE_LDFLAGS"
3110 fi
3111 if test "x$with_liblvm2app" = "xyes"
3112 then
3113         BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
3114         BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
3115         BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
3116         AC_SUBST(BUILD_WITH_LIBLVM2APP_CPPFLAGS)
3117         AC_SUBST(BUILD_WITH_LIBLVM2APP_LDFLAGS)
3118         AC_SUBST(BUILD_WITH_LIBLVM2APP_LIBS)
3119         AC_DEFINE(HAVE_LIBLVM2APP, 1, [Define if liblvm2app is present and usable.])
3120 fi
3121 AM_CONDITIONAL(BUILD_WITH_LIBLVM2APP, test "x$with_liblvm2app" = "xyes")
3122 # }}}
3123
3124 # --with-libmemcached {{{
3125 with_libmemcached_cppflags=""
3126 with_libmemcached_ldflags=""
3127 AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
3128 [
3129         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3130         then
3131                 with_libmemcached_cppflags="-I$withval/include"
3132                 with_libmemcached_ldflags="-L$withval/lib"
3133                 with_libmemcached="yes"
3134         else
3135                 with_libmemcached="$withval"
3136         fi
3137 ],
3138 [
3139         with_libmemcached="yes"
3140 ])
3141 if test "x$with_libmemcached" = "xyes"
3142 then
3143         SAVE_CPPFLAGS="$CPPFLAGS"
3144         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
3145
3146         AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
3147
3148         CPPFLAGS="$SAVE_CPPFLAGS"
3149 fi
3150 if test "x$with_libmemcached" = "xyes"
3151 then
3152         SAVE_CPPFLAGS="$CPPFLAGS"
3153         SAVE_LDFLAGS="$LDFLAGS"
3154         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
3155         LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
3156
3157         AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
3158
3159         CPPFLAGS="$SAVE_CPPFLAGS"
3160         LDFLAGS="$SAVE_LDFLAGS"
3161 fi
3162 if test "x$with_libmemcached" = "xyes"
3163 then
3164         BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
3165         BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
3166         BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
3167         AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
3168         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
3169         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
3170         AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
3171 fi
3172 AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
3173 # }}}
3174
3175 # --with-libmicrohttpd {{{
3176 with_libmicrohttpd_cppflags=""
3177 with_libmicrohttpd_ldflags=""
3178 AC_ARG_WITH([libmicrohttpd], [AS_HELP_STRING([--with-libmicrohttpd@<:@=PREFIX@:>@], [Path to libmicrohttpd.])],
3179   [
3180     if test "x$withval" != "xno" && test "x$withval" != "xyes"
3181     then
3182       with_libmicrohttpd_cppflags="-I$withval/include"
3183       with_libmicrohttpd_ldflags="-L$withval/lib"
3184       with_libmicrohttpd="yes"
3185     fi
3186     if test "x$withval" = "xno"
3187     then
3188       with_libmicrohttpd="no (disabled on command line)"
3189     fi
3190   ],
3191   [withval="yes"]
3192 )
3193 if test "x$withval" = "xyes"
3194 then
3195 PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd],
3196   [with_libmicrohttpd="yes"],
3197   [with_libmicrohttpd="no (pkg-config could not find libmicrohttpd)"]
3198 )
3199 fi
3200
3201 if test "x$MICROHTTPD_LIBS" = "x"
3202 then
3203   MICROHTTPD_LIBS="-lmicrohttpd"
3204 fi
3205
3206 SAVE_CPPFLAGS="$CPPFLAGS"
3207 SAVE_LDFLAGS="$LDFLAGS"
3208 SAVE_LIBS="$LIBS"
3209 CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
3210 LDFLAGS="$with_libmicrohttpd_ldflags $LDFLAGS"
3211 LIBS="$LIBS $MICROHTTPD_LIBS"
3212
3213 if test "x$with_libmicrohttpd" = "xyes"
3214 then
3215   AC_CHECK_HEADERS([microhttpd.h],
3216                    [with_libmicrohttpd="yes"],
3217                    [with_libmicrohttpd="no (<microhttpd.h> not found)"])
3218 fi
3219
3220 if test "x$with_libmicrohttpd" = "xyes"
3221 then
3222   AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
3223                [with_libmicrohttpd="yes"],
3224                [with_libmicrohttpd="no (libmicrohttpd not found)"])
3225 fi
3226
3227 CPPFLAGS="$SAVE_CPPFLAGS"
3228 LDFLAGS="$SAVE_LDFLAGS"
3229 LIBS="$SAVE_LIBS"
3230
3231 BUILD_WITH_LIBMICROHTTPD_CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
3232 BUILD_WITH_LIBMICROHTTPD_LDFLAGS="$with_libmicrohttpd_ldflags"
3233 BUILD_WITH_LIBMICROHTTPD_LIBS="$MICROHTTPD_LIBS"
3234 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_CPPFLAGS])
3235 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LDFLAGS])
3236 AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LIBS])
3237 # }}}
3238
3239 # --with-libmodbus {{{
3240 with_libmodbus_config=""
3241 with_libmodbus_cflags=""
3242 with_libmodbus_libs=""
3243 AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
3244 [
3245         if test "x$withval" = "xno"
3246         then
3247                 with_libmodbus="no"
3248         else if test "x$withval" = "xyes"
3249         then
3250                 with_libmodbus="use_pkgconfig"
3251         else if test -d "$with_libmodbus/lib"
3252         then
3253                 AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
3254                 with_libmodbus_cflags="-I$withval/include"
3255                 with_libmodbus_libs="-L$withval/lib -lmodbus"
3256                 with_libmodbus="yes"
3257         fi; fi; fi
3258 ],
3259 [with_libmodbus="use_pkgconfig"])
3260
3261 # configure using pkg-config
3262 if test "x$with_libmodbus" = "xuse_pkgconfig"
3263 then
3264         AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
3265         $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
3266         if test $? -ne 0
3267         then
3268                 with_libmodbus="no (pkg-config doesn't know libmodbus)"
3269         fi
3270 fi
3271 if test "x$with_libmodbus" = "xuse_pkgconfig"
3272 then
3273         with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
3274         if test $? -ne 0
3275         then
3276                 with_libmodbus="no ($PKG_CONFIG failed)"
3277         fi
3278         with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
3279         if test $? -ne 0
3280         then
3281                 with_libmodbus="no ($PKG_CONFIG failed)"
3282         fi
3283 fi
3284 if test "x$with_libmodbus" = "xuse_pkgconfig"
3285 then
3286         with_libmodbus="yes"
3287 fi
3288
3289 # with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do
3290 # the actual checks.
3291 if test "x$with_libmodbus" = "xyes"
3292 then
3293         SAVE_CPPFLAGS="$CPPFLAGS"
3294         CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
3295
3296         AC_CHECK_HEADERS(modbus.h, [], [with_libmodbus="no (modbus.h not found)"])
3297
3298         CPPFLAGS="$SAVE_CPPFLAGS"
3299 fi
3300 if test "x$with_libmodbus" = "xyes"
3301 then
3302         SAVE_CPPFLAGS="$CPPFLAGS"
3303         SAVE_LDFLAGS="$LDFLAGS"
3304
3305         CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
3306         LDFLAGS="$LDFLAGS $with_libmodbus_libs"
3307
3308         AC_CHECK_LIB(modbus, modbus_connect,
3309                      [with_libmodbus="yes"],
3310                      [with_libmodbus="no (symbol modbus_connect not found)"])
3311
3312         CPPFLAGS="$SAVE_CPPFLAGS"
3313         LDFLAGS="$SAVE_LDFLAGS"
3314 fi
3315 if test "x$with_libmodbus" = "xyes"
3316 then
3317         BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
3318         BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
3319         AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS)
3320         AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS)
3321 fi
3322 # }}}
3323
3324 # --with-libmongoc {{{
3325 AC_ARG_WITH(libmongoc, [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
3326 [
3327  if test "x$withval" = "xyes"
3328  then
3329          with_libmongoc="yes"
3330  else if test "x$withval" = "xno"
3331  then
3332          with_libmongoc="no"
3333  else
3334          with_libmongoc="yes"
3335          LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include"
3336          LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib"
3337  fi; fi
3338 ],
3339 [with_libmongoc="yes"])
3340
3341 SAVE_CPPFLAGS="$CPPFLAGS"
3342 SAVE_LDFLAGS="$LDFLAGS"
3343
3344 CPPFLAGS="$CPPFLAGS $LIBMONGOC_CPPFLAGS"
3345 LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
3346
3347 if test "x$with_libmongoc" = "xyes"
3348 then
3349         if test "x$LIBMONGOC_CPPFLAGS" != "x"
3350         then
3351                 AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CPPFLAGS])
3352         fi
3353         AC_CHECK_HEADERS(mongo.h,
3354         [with_libmongoc="yes"],
3355         [with_libmongoc="no ('mongo.h' not found)"],
3356 [#if HAVE_STDINT_H
3357 # define MONGO_HAVE_STDINT 1
3358 #else
3359 # define MONGO_USE_LONG_LONG_INT 1
3360 #endif
3361 ])
3362 fi
3363 if test "x$with_libmongoc" = "xyes"
3364 then
3365         if test "x$LIBMONGOC_LDFLAGS" != "x"
3366         then
3367                 AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
3368         fi
3369         AC_CHECK_LIB(mongoc, mongo_run_command,
3370         [with_libmongoc="yes"],
3371         [with_libmongoc="no (symbol 'mongo_run_command' not found)"])
3372 fi
3373
3374 CPPFLAGS="$SAVE_CPPFLAGS"
3375 LDFLAGS="$SAVE_LDFLAGS"
3376
3377 if test "x$with_libmongoc" = "xyes"
3378 then
3379         BUILD_WITH_LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS"
3380         BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
3381         AC_SUBST(BUILD_WITH_LIBMONGOC_CPPFLAGS)
3382         AC_SUBST(BUILD_WITH_LIBMONGOC_LDFLAGS)
3383 fi
3384 AM_CONDITIONAL(BUILD_WITH_LIBMONGOC, test "x$with_libmongoc" = "xyes")
3385 # }}}
3386
3387 # --with-libmosquitto {{{
3388 with_libmosquitto_cppflags=""
3389 with_libmosquitto_ldflags=""
3390 AC_ARG_WITH(libmosquitto, [AS_HELP_STRING([--with-libmosquitto@<:@=PREFIX@:>@], [Path to libmosquitto.])],
3391 [
3392         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3393         then
3394                 with_libmosquitto_cppflags="-I$withval/include"
3395                 with_libmosquitto_ldflags="-L$withval/lib"
3396                 with_libmosquitto="yes"
3397         else
3398                 with_libmosquitto="$withval"
3399         fi
3400 ],
3401 [
3402         with_libmosquitto="yes"
3403 ])
3404 if test "x$with_libmosquitto" = "xyes"
3405 then
3406         SAVE_CPPFLAGS="$CPPFLAGS"
3407         CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
3408
3409         AC_CHECK_HEADERS(mosquitto.h, [with_libmosquitto="yes"], [with_libmosquitto="no (mosquitto.h not found)"])
3410
3411         CPPFLAGS="$SAVE_CPPFLAGS"
3412 fi
3413 if test "x$with_libmosquitto" = "xyes"
3414 then
3415         SAVE_LDFLAGS="$LDFLAGS"
3416         SAVE_CPPFLAGS="$CPPFLAGS"
3417         LDFLAGS="$LDFLAGS $with_libmosquitto_ldflags"
3418         CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
3419
3420         AC_CHECK_LIB(mosquitto, mosquitto_connect, [with_libmosquitto="yes"], [with_libmosquitto="no (libmosquitto not found)"])
3421
3422         LDFLAGS="$SAVE_LDFLAGS"
3423         CPPFLAGS="$SAVE_CPPFLAGS"
3424 fi
3425 if test "x$with_libmosquitto" = "xyes"
3426 then
3427         BUILD_WITH_LIBMOSQUITTO_CPPFLAGS="$with_libmosquitto_cppflags"
3428         BUILD_WITH_LIBMOSQUITTO_LDFLAGS="$with_libmosquitto_ldflags"
3429         BUILD_WITH_LIBMOSQUITTO_LIBS="-lmosquitto"
3430         AC_SUBST(BUILD_WITH_LIBMOSQUITTO_CPPFLAGS)
3431         AC_SUBST(BUILD_WITH_LIBMOSQUITTO_LDFLAGS)
3432         AC_SUBST(BUILD_WITH_LIBMOSQUITTO_LIBS)
3433 fi
3434 # }}}
3435
3436 # --with-libmysql {{{
3437 with_mysql_config="mysql_config"
3438 with_mysql_cflags=""
3439 with_mysql_libs=""
3440 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
3441 [
3442         if test "x$withval" = "xno"
3443         then
3444                 with_libmysql="no"
3445         else if test "x$withval" = "xyes"
3446         then
3447                 with_libmysql="yes"
3448         else
3449                 if test -f "$withval" && test -x "$withval";
3450                 then
3451                         with_mysql_config="$withval"
3452                 else if test -x "$withval/bin/mysql_config"
3453                 then
3454                         with_mysql_config="$withval/bin/mysql_config"
3455                 fi; fi
3456                 with_libmysql="yes"
3457         fi; fi
3458 ],
3459 [
3460         with_libmysql="yes"
3461 ])
3462 if test "x$with_libmysql" = "xyes"
3463 then
3464         with_mysql_cflags=`$with_mysql_config --include 2>/dev/null`
3465         mysql_config_status=$?
3466
3467         if test $mysql_config_status -ne 0
3468         then
3469                 with_libmysql="no ($with_mysql_config failed)"
3470         else
3471                 SAVE_CPPFLAGS="$CPPFLAGS"
3472                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
3473
3474                 have_mysql_h="no"
3475                 have_mysql_mysql_h="no"
3476                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
3477
3478                 if test "x$have_mysql_h" = "xno"
3479                 then
3480                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
3481                 fi
3482
3483                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
3484                 then
3485                         with_libmysql="no (mysql.h not found)"
3486                 fi
3487
3488                 CPPFLAGS="$SAVE_CPPFLAGS"
3489         fi
3490 fi
3491 if test "x$with_libmysql" = "xyes"
3492 then
3493         with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
3494         mysql_config_status=$?
3495
3496         if test $mysql_config_status -ne 0
3497         then
3498                 with_libmysql="no ($with_mysql_config failed)"
3499         else
3500                 SAVE_CPPFLAGS="$CPPFLAGS"
3501                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
3502                 SAVE_LIBS="$LIBS"
3503                 LIBS="$with_mysql_libs"
3504                 AC_SEARCH_LIBS([mysql_get_server_version],
3505                  [],
3506                  [with_libmysql="yes"],
3507                  [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
3508                  [])
3509                 CPPFLAGS="$SAVE_CPPFLAGS"
3510                 LIBS="$SAVE_LIBS"
3511         fi
3512 fi
3513 if test "x$with_libmysql" = "xyes"
3514 then
3515         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
3516         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
3517         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
3518         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
3519 fi
3520 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
3521 # }}}
3522
3523 # --with-libmnl {{{
3524 with_libmnl_cflags=""
3525 with_libmnl_libs=""
3526 AC_ARG_WITH(libmnl, [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
3527 [
3528  echo "libmnl: withval = $withval"
3529  if test "x$withval" = "xyes"
3530  then
3531          with_libmnl="yes"
3532  else if test "x$withval" = "xno"
3533  then
3534          with_libmnl="no"
3535  else
3536          if test -d "$withval/include"
3537          then
3538                  with_libmnl_cflags="-I$withval/include"
3539                  with_libmnl_libs="-L$withval/lib -lmnl"
3540                  with_libmnl="yes"
3541          else
3542                  AC_MSG_ERROR("no such directory: $withval/include")
3543          fi
3544  fi; fi
3545 ],
3546 [
3547  if test "x$ac_system" = "xLinux"
3548  then
3549          with_libmnl="yes"
3550  else
3551          with_libmnl="no (Linux only library)"
3552  fi
3553 ])
3554 if test "x$with_libmnl" = "xyes"
3555 then
3556         if $PKG_CONFIG --exists libmnl 2>/dev/null; then
3557           with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
3558           with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
3559         fi
3560
3561         AC_CHECK_HEADERS(libmnl.h libmnl/libmnl.h,
3562         [
3563          with_libmnl="yes"
3564          break
3565         ], [],
3566 [#include <stdio.h>
3567 #include <sys/types.h>
3568 #include <asm/types.h>
3569 #include <sys/socket.h>
3570 #include <linux/netlink.h>
3571 #include <linux/rtnetlink.h>])
3572         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
3573 [#include <stdio.h>
3574 #include <sys/types.h>
3575 #include <asm/types.h>
3576 #include <sys/socket.h>])
3577
3578         AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3579 [[
3580 #include <stdio.h>
3581 #include <sys/types.h>
3582 #include <asm/types.h>
3583 #include <sys/socket.h>
3584 #include <linux/netlink.h>
3585 #include <linux/rtnetlink.h>
3586 ]],
3587 [[
3588 int retval = TCA_STATS2;
3589 return (retval);
3590 ]]
3591         )],
3592         [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])])
3593
3594         AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
3595 [[
3596 #include <stdio.h>
3597 #include <sys/types.h>
3598 #include <asm/types.h>
3599 #include <sys/socket.h>
3600 #include <linux/netlink.h>
3601 #include <linux/rtnetlink.h>
3602 ]],
3603 [[
3604 int retval = TCA_STATS;
3605 return (retval);
3606 ]]
3607         )],
3608         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])])
3609 fi
3610 if test "x$with_libmnl" = "xyes"
3611 then
3612         AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
3613         [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
3614         [],
3615         [
3616         #include <linux/if_link.h>
3617         ])
3618 fi
3619 if test "x$with_libmnl" = "xyes"
3620 then
3621         AC_CHECK_LIB(mnl, mnl_nlmsg_get_payload,
3622                      [with_libmnl="yes"],
3623                      [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
3624                      [$with_libmnl_libs])
3625 fi
3626 if test "x$with_libmnl" = "xyes"
3627 then
3628         AC_DEFINE(HAVE_LIBMNL, 1, [Define if libmnl is present and usable.])
3629         BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
3630         BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
3631         AC_SUBST(BUILD_WITH_LIBMNL_CFLAGS)
3632         AC_SUBST(BUILD_WITH_LIBMNL_LIBS)
3633 fi
3634 AM_CONDITIONAL(BUILD_WITH_LIBMNL, test "x$with_libmnl" = "xyes")
3635 # }}}
3636
3637 # --with-libnetapp {{{
3638 AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
3639 AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
3640 AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
3641 LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS"
3642 LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS"
3643 LIBNETAPP_LIBS="$LIBNETAPP_LIBS"
3644 AC_ARG_WITH(libnetapp, [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
3645 [
3646  if test -d "$withval"
3647  then
3648          LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
3649          LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
3650          with_libnetapp="yes"
3651  else
3652          with_libnetapp="$withval"
3653  fi
3654 ],
3655 [
3656  with_libnetapp="yes"
3657 ])
3658
3659 SAVE_CPPFLAGS="$CPPFLAGS"
3660 SAVE_LDFLAGS="$LDFLAGS"
3661 CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
3662 LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
3663
3664 if test "x$with_libnetapp" = "xyes"
3665 then
3666         if test "x$LIBNETAPP_CPPFLAGS" != "x"
3667         then
3668                 AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
3669         fi
3670         AC_CHECK_HEADERS(netapp_api.h,
3671                 [with_libnetapp="yes"],
3672                 [with_libnetapp="no (netapp_api.h not found)"])
3673 fi
3674
3675 if test "x$with_libnetapp" = "xyes"
3676 then
3677         if test "x$LIBNETAPP_LDFLAGS" != "x"
3678         then
3679                 AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
3680         fi
3681
3682         if test "x$LIBNETAPP_LIBS" = "x"
3683         then
3684                 LIBNETAPP_LIBS="$PTHREAD_LIBS -lxml -ladt -lssl -lm -lcrypto -lz"
3685         fi
3686         AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
3687
3688         AC_CHECK_LIB(netapp, na_server_invoke_elem,
3689                 [with_libnetapp="yes"],
3690                 [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
3691                 [$LIBNETAPP_LIBS])
3692         LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
3693 fi
3694
3695 CPPFLAGS="$SAVE_CPPFLAGS"
3696 LDFLAGS="$SAVE_LDFLAGS"
3697
3698 if test "x$with_libnetapp" = "xyes"
3699 then
3700         AC_DEFINE(HAVE_LIBNETAPP, 1, [Define to 1 if you have the netapp library (-lnetapp).])
3701 fi
3702
3703 AC_SUBST(LIBNETAPP_CPPFLAGS)
3704 AC_SUBST(LIBNETAPP_LDFLAGS)
3705 AC_SUBST(LIBNETAPP_LIBS)
3706 AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
3707 # }}}
3708
3709 # --with-libnetsnmp {{{
3710 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
3711 [
3712         if test "x$withval" = "xno"
3713         then
3714                 with_libnetsnmp="no"
3715         else if test "x$withval" = "xyes"
3716         then
3717                 with_libnetsnmp="yes"
3718         else
3719                 with_libnetsnmp_cppflags="-I$withval/include"
3720                 with_libnetsnmp_ldflags="-I$withval/lib"
3721                 with_libnetsnmp="yes"
3722         fi; fi
3723 ],
3724 [with_libnetsnmp="yes"])
3725 if test "x$with_libnetsnmp" = "xyes"
3726 then
3727         SAVE_CPPFLAGS="$CPPFLAGS"
3728         CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
3729
3730         AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
3731
3732         CPPFLAGS="$SAVE_CPPFLAGS"
3733 fi
3734 if test "x$with_libnetsnmp" = "xyes"
3735 then
3736         SAVE_LDFLAGS="$LDFLAGS"
3737         LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
3738
3739         AC_CHECK_LIB(netsnmp, init_snmp,
3740                 [with_libnetsnmp="yes"],
3741                 [with_libnetsnmp="no (libnetsnmp not found)"],
3742                 [$with_snmp_libs])
3743
3744         LDFLAGS="$SAVE_LDFLAGS"
3745 fi
3746 if test "x$with_libnetsnmp" = "xyes"
3747 then
3748         BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
3749         BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
3750         BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
3751 fi
3752 AC_SUBST(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
3753 AC_SUBST(BUILD_WITH_LIBNETSNMP_LDFLAGS)
3754 AC_SUBST(BUILD_WITH_LIBNETSNMP_LIBS)
3755 # }}}
3756
3757 # --with-liboconfig {{{
3758 with_own_liboconfig="no"
3759 liboconfig_LDFLAGS="$LDFLAGS"
3760 liboconfig_CPPFLAGS="$CPPFLAGS"
3761 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
3762 [
3763         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3764         then
3765                 if test -d "$withval/lib"
3766                 then
3767                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
3768                 fi
3769                 if test -d "$withval/include"
3770                 then
3771                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
3772                 fi
3773         fi
3774         if test "x$withval" = "xno"
3775         then
3776                 AC_MSG_ERROR("liboconfig is required")
3777         fi
3778 ],
3779 [
3780         with_liboconfig="yes"
3781 ])
3782
3783 save_LDFLAGS="$LDFLAGS"
3784 save_CPPFLAGS="$CPPFLAGS"
3785 LDFLAGS="$liboconfig_LDFLAGS"
3786 CPPFLAGS="$liboconfig_CPPFLAGS"
3787 AC_CHECK_LIB(oconfig, oconfig_parse_file,
3788 [
3789         with_liboconfig="yes"
3790         with_own_liboconfig="no"
3791 ],
3792 [
3793         with_liboconfig="yes"
3794         with_own_liboconfig="yes"
3795         LDFLAGS="$save_LDFLAGS"
3796         CPPFLAGS="$save_CPPFLAGS"
3797 ])
3798
3799 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
3800 if test "x$with_own_liboconfig" = "xyes"
3801 then
3802         with_liboconfig="yes (shipped version)"
3803 fi
3804 # }}}
3805
3806 # --with-liboping {{{
3807 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
3808 [
3809  if test "x$withval" = "xyes"
3810  then
3811          with_liboping="yes"
3812  else if test "x$withval" = "xno"
3813  then
3814          with_liboping="no"
3815  else
3816          with_liboping="yes"
3817          LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
3818          LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
3819  fi; fi
3820 ],
3821 [with_liboping="yes"])
3822
3823 SAVE_CPPFLAGS="$CPPFLAGS"
3824 SAVE_LDFLAGS="$LDFLAGS"
3825
3826 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
3827 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
3828
3829 if test "x$with_liboping" = "xyes"
3830 then
3831         if test "x$LIBOPING_CPPFLAGS" != "x"
3832         then
3833                 AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
3834         fi
3835         AC_CHECK_HEADERS(oping.h,
3836         [with_liboping="yes"],
3837         [with_liboping="no (oping.h not found)"])
3838 fi
3839 if test "x$with_liboping" = "xyes"
3840 then
3841         if test "x$LIBOPING_LDFLAGS" != "x"
3842         then
3843                 AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
3844         fi
3845         AC_CHECK_LIB(oping, ping_construct,
3846         [with_liboping="yes"],
3847         [with_liboping="no (symbol 'ping_construct' not found)"])
3848 fi
3849
3850 CPPFLAGS="$SAVE_CPPFLAGS"
3851 LDFLAGS="$SAVE_LDFLAGS"
3852
3853 if test "x$with_liboping" = "xyes"
3854 then
3855         BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
3856         BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
3857         AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
3858         AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
3859 fi
3860 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
3861 # }}}
3862
3863 # --with-oracle {{{
3864 with_oracle_cppflags=""
3865 with_oracle_libs=""
3866 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
3867 [
3868         if test "x$withval" = "xyes"
3869         then
3870                 if test "x$ORACLE_HOME" = "x"
3871                 then
3872                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
3873                 fi
3874                 with_oracle="yes"
3875         else if test "x$withval" = "xno"
3876         then
3877                 with_oracle="no"
3878         else
3879                 with_oracle="yes"
3880                 ORACLE_HOME="$withval"
3881         fi; fi
3882 ],
3883 [
3884         if test "x$ORACLE_HOME" = "x"
3885         then
3886                 with_oracle="no (ORACLE_HOME is not set)"
3887         else
3888                 with_oracle="yes"
3889         fi
3890 ])
3891 if test "x$ORACLE_HOME" != "x"
3892 then
3893         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
3894
3895         if test -e "$ORACLE_HOME/lib/ldflags"
3896         then
3897                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
3898         fi
3899         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
3900         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
3901 fi
3902 if test "x$with_oracle" = "xyes"
3903 then
3904         SAVE_CPPFLAGS="$CPPFLAGS"
3905         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
3906
3907         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
3908
3909         CPPFLAGS="$SAVE_CPPFLAGS"
3910 fi
3911 if test "x$with_oracle" = "xyes"
3912 then
3913         SAVE_CPPFLAGS="$CPPFLAGS"
3914         SAVE_LIBS="$LIBS"
3915         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
3916         LIBS="$LIBS $with_oracle_libs"
3917
3918         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
3919
3920         CPPFLAGS="$SAVE_CPPFLAGS"
3921         LIBS="$SAVE_LIBS"
3922 fi
3923 if test "x$with_oracle" = "xyes"
3924 then
3925         BUILD_WITH_ORACLE_CPPFLAGS="$with_oracle_cppflags"
3926         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
3927         AC_SUBST(BUILD_WITH_ORACLE_CPPFLAGS)
3928         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
3929 fi
3930 # }}}
3931
3932 # --with-libowcapi {{{
3933 with_libowcapi_cppflags=""
3934 with_libowcapi_ldflags=""
3935 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
3936 [
3937         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3938         then
3939                 with_libowcapi_cppflags="-I$withval/include"
3940                 with_libowcapi_ldflags="-L$withval/lib"
3941                 with_libowcapi="yes"
3942         else
3943                 with_libowcapi="$withval"
3944         fi
3945 ],
3946 [
3947         with_libowcapi="yes"
3948 ])
3949 if test "x$with_libowcapi" = "xyes"
3950 then
3951         SAVE_CPPFLAGS="$CPPFLAGS"
3952         CPPFLAGS="$CPPFLAGS $with_libowcapi_cppflags"
3953
3954         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
3955
3956         CPPFLAGS="$SAVE_CPPFLAGS"
3957 fi
3958 if test "x$with_libowcapi" = "xyes"
3959 then
3960         SAVE_LDFLAGS="$LDFLAGS"
3961         SAVE_CPPFLAGS="$CPPFLAGS"
3962         LDFLAGS="$LDFLAGS $with_libowcapi_ldflags"
3963         CPPFLAGS="$with_libowcapi_cppflags"
3964
3965         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
3966
3967         LDFLAGS="$SAVE_LDFLAGS"
3968         CPPFLAGS="$SAVE_CPPFLAGS"
3969 fi
3970 if test "x$with_libowcapi" = "xyes"
3971 then
3972         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
3973         BUILD_WITH_LIBOWCAPI_LDFLAGS="$with_libowcapi_ldflags"
3974         BUILD_WITH_LIBOWCAPI_LIBS="-lowcapi"
3975         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
3976         AC_SUBST(BUILD_WITH_LIBOWCAPI_LDFLAGS)
3977         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
3978 fi
3979 # }}}
3980
3981 # --with-libpcap {{{
3982 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
3983 [
3984         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3985         then
3986                 LDFLAGS="$LDFLAGS -L$withval/lib"
3987                 CPPFLAGS="$CPPFLAGS -I$withval/include"
3988                 with_libpcap="yes"
3989         else
3990                 with_libpcap="$withval"
3991         fi
3992 ],
3993 [
3994         with_libpcap="yes"
3995 ])
3996 if test "x$with_libpcap" = "xyes"
3997 then
3998         AC_CHECK_LIB(pcap, pcap_open_live,
3999         [
4000                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
4001         ],