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