Code

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