Code

collectd.conf(5): Document the per-plugin interval configuration.
[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(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 AM_CONDITIONAL(HAVE_PROTOC_C, test "x$have_protoc_c" = "xyes")
54 AC_MSG_CHECKING([for kernel type ($host_os)])
55 case $host_os in
56         *linux*)
57         AC_DEFINE([KERNEL_LINUX], 1, [True if program is to be compiled for a Linux kernel])
58         ac_system="Linux"
59         ;;
60         *solaris*)
61         AC_DEFINE([KERNEL_SOLARIS], 1, [True if program is to be compiled for a Solaris kernel])
62         ac_system="Solaris"
63         ;;
64         *darwin*)
65         ac_system="Darwin"
66         ;;
67         *openbsd*)
68         ac_system="OpenBSD"
69         ;;
70         *aix*)
71         AC_DEFINE([KERNEL_AIX], 1, [True if program is to be compiled for a AIX kernel])
72         ac_system="AIX"
73         ;;
74         *)
75         ac_system="unknown"
76 esac
77 AC_MSG_RESULT([$ac_system])
79 if test "x$ac_system" = "xLinux"
80 then
81         AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
82         if test -z "$KERNEL_DIR"
83         then
84                 KERNEL_DIR="/lib/modules/`uname -r`/source"
85         fi
87         KERNEL_CFLAGS="-I$KERNEL_DIR/include"
88         AC_SUBST(KERNEL_CFLAGS)
89 fi
91 if test "x$ac_system" = "xSolaris"
92 then
93         AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Define to enforce POSIX thread semantics under Solaris.])
94 fi
95 if test "x$ac_system" = "xAIX"
96 then
97         AC_DEFINE(_THREAD_SAFE_ERRNO, 1, [Define to use the thread-safe version of errno under AIX.])
98 fi
100 # Where to install .pc files.
101 pkgconfigdir="${libdir}/pkgconfig"
102 AC_SUBST(pkgconfigdir)
104 # Check for standards compliance mode
105 AC_ARG_ENABLE(standards,
106               AS_HELP_STRING([--enable-standards], [Enable standards compliance mode]),
107               [enable_standards="$enableval"],
108               [enable_standards="no"])
109 if test "x$enable_standards" = "xyes"
110 then
111         AC_DEFINE(_ISOC99_SOURCE,        1, [Define to enforce ISO C99 compliance.])
112         AC_DEFINE(_POSIX_C_SOURCE, 200809L, [Define to enforce POSIX.1-2008 compliance.])
113         AC_DEFINE(_XOPEN_SOURCE,       700, [Define to enforce X/Open 7 (XSI) compliance.])
114         AC_DEFINE(_REENTRANT,            1, [Define to enable reentrancy interfaces.])
115         if test "x$GCC" = "xyes"
116         then
117                 CFLAGS="$CFLAGS -std=c99"
118         fi
119 fi
120 AM_CONDITIONAL(BUILD_FEATURE_STANDARDS, test "x$enable_standards" = "xyes")
123 # Checks for header files.
125 AC_HEADER_STDC
126 AC_HEADER_SYS_WAIT
127 AC_HEADER_DIRENT
128 AC_HEADER_STDBOOL
130 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)
132 # For ping library
133 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
134 [#if HAVE_STDINT_H
135 # include <stdint.h>
136 #endif
137 #if HAVE_SYS_TYPES_H
138 # include <sys/types.h>
139 #endif
140 ])
141 AC_CHECK_HEADERS(netinet/in.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 #if HAVE_NETINET_IN_SYSTM_H
149 # include <netinet/in_systm.h>
150 #endif
151 ])
152 AC_CHECK_HEADERS(netinet/ip.h, [], [],
153 [#if HAVE_STDINT_H
154 # include <stdint.h>
155 #endif
156 #if HAVE_SYS_TYPES_H
157 # include <sys/types.h>
158 #endif
159 #if HAVE_NETINET_IN_SYSTM_H
160 # include <netinet/in_systm.h>
161 #endif
162 #if HAVE_NETINET_IN_H
163 # include <netinet/in.h>
164 #endif
165 ])
166 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
167 [#if HAVE_STDINT_H
168 # include <stdint.h>
169 #endif
170 #if HAVE_SYS_TYPES_H
171 # include <sys/types.h>
172 #endif
173 #if HAVE_NETINET_IN_SYSTM_H
174 # include <netinet/in_systm.h>
175 #endif
176 #if HAVE_NETINET_IN_H
177 # include <netinet/in.h>
178 #endif
179 #if HAVE_NETINET_IP_H
180 # include <netinet/ip.h>
181 #endif
182 ])
183 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
184 [#if HAVE_STDINT_H
185 # include <stdint.h>
186 #endif
187 #if HAVE_SYS_TYPES_H
188 # include <sys/types.h>
189 #endif
190 #if HAVE_NETINET_IN_SYSTM_H
191 # include <netinet/in_systm.h>
192 #endif
193 #if HAVE_NETINET_IN_H
194 # include <netinet/in.h>
195 #endif
196 #if HAVE_NETINET_IP_H
197 # include <netinet/ip.h>
198 #endif
199 ])
200 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
201 [#if HAVE_STDINT_H
202 # include <stdint.h>
203 #endif
204 #if HAVE_SYS_TYPES_H
205 # include <sys/types.h>
206 #endif
207 #if HAVE_NETINET_IN_SYSTM_H
208 # include <netinet/in_systm.h>
209 #endif
210 #if HAVE_NETINET_IN_H
211 # include <netinet/in.h>
212 #endif
213 ])
214 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
215 [#if HAVE_STDINT_H
216 # include <stdint.h>
217 #endif
218 #if HAVE_SYS_TYPES_H
219 # include <sys/types.h>
220 #endif
221 #if HAVE_NETINET_IN_SYSTM_H
222 # include <netinet/in_systm.h>
223 #endif
224 #if HAVE_NETINET_IN_H
225 # include <netinet/in.h>
226 #endif
227 #if HAVE_NETINET_IP6_H
228 # include <netinet/ip6.h>
229 #endif
230 ])
231 AC_CHECK_HEADERS(netinet/tcp.h, [], [],
232 [#if HAVE_STDINT_H
233 # include <stdint.h>
234 #endif
235 #if HAVE_SYS_TYPES_H
236 # include <sys/types.h>
237 #endif
238 #if HAVE_NETINET_IN_SYSTM_H
239 # include <netinet/in_systm.h>
240 #endif
241 #if HAVE_NETINET_IN_H
242 # include <netinet/in.h>
243 #endif
244 #if HAVE_NETINET_IP_H
245 # include <netinet/ip.h>
246 #endif
247 ])
248 AC_CHECK_HEADERS(netinet/udp.h, [], [],
249 [#if HAVE_STDINT_H
250 # include <stdint.h>
251 #endif
252 #if HAVE_SYS_TYPES_H
253 # include <sys/types.h>
254 #endif
255 #if HAVE_NETINET_IN_SYSTM_H
256 # include <netinet/in_systm.h>
257 #endif
258 #if HAVE_NETINET_IN_H
259 # include <netinet/in.h>
260 #endif
261 #if HAVE_NETINET_IP_H
262 # include <netinet/ip.h>
263 #endif
264 ])
266 # For cpu modules
267 AC_CHECK_HEADERS(sys/dkstat.h)
268 if test "x$ac_system" = "xDarwin"
269 then
270         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)
271         AC_CHECK_HEADERS(CoreFoundation/CoreFoundation.h IOKit/IOKitLib.h IOKit/IOTypes.h IOKit/ps/IOPSKeys.h IOKit/IOBSD.h IOKit/storage/IOBlockStorageDriver.h)
272 fi
273 AC_CHECK_HEADERS(sys/sysctl.h, [], [],
275 #if HAVE_SYS_TYPES_H
276 #  include <sys/types.h>
277 #endif
278 #if HAVE_SYS_PARAM_H
279 # include <sys/param.h>
280 #endif
281 ])
283 AC_MSG_CHECKING([for sysctl kern.cp_times])
284 if test -x /sbin/sysctl
285 then
286         /sbin/sysctl kern.cp_times 2>/dev/null
287         if test $? -eq 0
288         then
289                 AC_MSG_RESULT([yes])
290                 AC_DEFINE(HAVE_SYSCTL_KERN_CP_TIMES, 1,
291                 [Define if sysctl supports kern.cp_times])
292         else
293                 AC_MSG_RESULT([no])
294         fi
295 else
296         AC_MSG_RESULT([no])
297 fi
299 # For hddtemp module
300 AC_CHECK_HEADERS(linux/major.h libgen.h)
302 # For the battery plugin
303 AC_CHECK_HEADERS(IOKit/ps/IOPowerSources.h, [], [],
305 #if HAVE_IOKIT_IOKITLIB_H
306 #  include <IOKit/IOKitLib.h>
307 #endif
308 #if HAVE_IOKIT_IOTYPES_H
309 #  include <IOKit/IOTypes.h>
310 #endif
311 ])
313 # For the swap module
314 have_linux_wireless_h="no"
315 if test "x$ac_system" = "xLinux"
316 then
317   AC_CHECK_HEADERS(linux/wireless.h,
318                    [have_linux_wireless_h="yes"],
319                    [have_linux_wireless_h="no"],
321 #include <dirent.h>
322 #include <sys/ioctl.h>
323 #include <sys/socket.h>
324 ])
325 fi
327 # For the swap module
328 have_sys_swap_h="yes"
329 AC_CHECK_HEADERS(sys/swap.h vm/anon.h, [], [have_sys_swap_h="no"],
331 #undef _FILE_OFFSET_BITS
332 #undef _LARGEFILE64_SOURCE
333 #if HAVE_SYS_TYPES_H
334 #  include <sys/types.h>
335 #endif
336 #if HAVE_SYS_PARAM_H
337 # include <sys/param.h>
338 #endif
339 ])
341 if test "x$have_sys_swap_h$ac_system" = "xnoSolaris"
342 then
343         hint_64=""
344         if test "x$GCC" = "xyes"
345         then
346                 hint_64="CFLAGS='-m64'"
347         else
348                 hint_64="CFLAGS='-xarch=v9'"
349         fi
350         AC_MSG_NOTICE([Solaris detected and sys/swap.h not usable. Try building a 64-bit binary ($hint_64 ./configure).])
351 fi
353 # For load module
354 # For the processes plugin
355 # For users module
356 AC_CHECK_HEADERS(sys/loadavg.h linux/config.h utmp.h utmpx.h)
358 # For interface plugin
359 AC_CHECK_HEADERS(ifaddrs.h)
360 AC_CHECK_HEADERS(net/if.h, [], [],
362 #if HAVE_SYS_TYPES_H
363 #  include <sys/types.h>
364 #endif
365 #if HAVE_SYS_SOCKET_H
366 #  include <sys/socket.h>
367 #endif
368 ])
369 AC_CHECK_HEADERS(linux/if.h, [], [],
371 #if HAVE_SYS_TYPES_H
372 #  include <sys/types.h>
373 #endif
374 #if HAVE_SYS_SOCKET_H
375 #  include <sys/socket.h>
376 #endif
377 ])
378 AC_CHECK_HEADERS(linux/netdevice.h, [], [],
380 #if HAVE_SYS_TYPES_H
381 #  include <sys/types.h>
382 #endif
383 #if HAVE_SYS_SOCKET_H
384 #  include <sys/socket.h>
385 #endif
386 #if HAVE_LINUX_IF_H
387 # include <linux/if.h>
388 #endif
389 ])
391 # For ipvs module
392 have_net_ip_vs_h="no"
393 have_ip_vs_h="no"
394 if test "x$ac_system" = "xLinux"
395 then
396         SAVE_CFLAGS="$CFLAGS"
397         CFLAGS="$CFLAGS $KERNEL_CFLAGS"
399         AC_CHECK_HEADERS(net/ip_vs.h, [have_net_ip_vs_h="yes"])
400         AC_CHECK_HEADERS(ip_vs.h, [have_ip_vs_h="yes"])
402         CFLAGS="$SAVE_CFLAGS"
403 fi
405 # For quota module
406 AC_CHECK_HEADERS(sys/ucred.h, [], [],
408 #if HAVE_SYS_TYPES_H
409 #  include <sys/types.h>
410 #endif
411 #if HAVE_SYS_PARAM_H
412 # include <sys/param.h>
413 #endif
414 ])
416 # For mount interface
417 AC_CHECK_HEADERS(sys/mount.h, [], [],
419 #if HAVE_SYS_TYPES_H
420 #  include <sys/types.h>
421 #endif
422 #if HAVE_SYS_PARAM_H
423 # include <sys/param.h>
424 #endif
425 ])
427 # For the email plugin
428 AC_CHECK_HEADERS(linux/un.h, [], [],
430 #if HAVE_SYS_SOCKET_H
431 #       include <sys/socket.h>
432 #endif
433 ])
435 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)
437 # For the dns plugin
438 AC_CHECK_HEADERS(arpa/nameser.h)
439 AC_CHECK_HEADERS(arpa/nameser_compat.h, [], [],
441 #if HAVE_ARPA_NAMESER_H
442 # include <arpa/nameser.h>
443 #endif
444 ])
446 AC_CHECK_HEADERS(net/if_arp.h, [], [],
447 [#if HAVE_SYS_SOCKET_H
448 # include <sys/socket.h>
449 #endif
450 ])
451 AC_CHECK_HEADERS(net/ppp_defs.h)
452 AC_CHECK_HEADERS(net/if_ppp.h, [], [],
453 [#if HAVE_NET_PPP_DEFS_H
454 # include <net/ppp_defs.h>
455 #endif
456 ])
457 AC_CHECK_HEADERS(netinet/if_ether.h, [], [],
458 [#if HAVE_STDINT_H
459 # include <stdint.h>
460 #endif
461 #if HAVE_SYS_TYPES_H
462 # include <sys/types.h>
463 #endif
464 #if HAVE_SYS_SOCKET_H
465 # include <sys/socket.h>
466 #endif
467 #if HAVE_NET_IF_H
468 # include <net/if.h>
469 #endif
470 #if HAVE_NETINET_IN_H
471 # include <netinet/in.h>
472 #endif
473 ])
475 # For the multimeter plugin
476 have_termios_h="no"
477 AC_CHECK_HEADERS(termios.h, [have_termios_h="yes"])
480 # Checks for typedefs, structures, and compiler characteristics.
482 AC_C_CONST
483 AC_TYPE_PID_T
484 AC_TYPE_SIZE_T
485 AC_TYPE_UID_T
486 AC_HEADER_TIME
489 # Checks for library functions.
491 AC_PROG_GCC_TRADITIONAL
492 AC_CHECK_FUNCS(gettimeofday select strdup strtol getaddrinfo getnameinfo strchr memcpy strstr strcmp strncmp strncpy strlen strncasecmp strcasecmp openlog closelog sysconf setenv if_indextoname)
494 AC_FUNC_STRERROR_R
496 SAVE_CFLAGS="$CFLAGS"
497 # Emulate behavior of src/Makefile.am
498 if test "x$GCC" = "xyes"
499 then
500         CFLAGS="$CFLAGS -Wall -Werror"
501 fi
503 AC_CACHE_CHECK([for strtok_r],
504   [c_cv_have_strtok_r_default],
505   AC_LINK_IFELSE(
506     AC_LANG_PROGRAM(
507     [[[[
508 #include <stdlib.h>
509 #include <stdio.h>
510 #include <string.h>
511     ]]]],
512     [[[[
513       char buffer[] = "foo,bar,baz";
514       char *token;
515       char *dummy;
516       char *saveptr;
518       dummy = buffer;
519       saveptr = NULL;
520       while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
521       {
522         dummy = NULL;
523         printf ("token = %s;\n", token);
524       }
525     ]]]]),
526     [c_cv_have_strtok_r_default="yes"],
527     [c_cv_have_strtok_r_default="no"]
528   )
531 if test "x$c_cv_have_strtok_r_default" = "xno"
532 then
533   CFLAGS="$CFLAGS -D_REENTRANT=1"
535   AC_CACHE_CHECK([if strtok_r needs _REENTRANT],
536     [c_cv_have_strtok_r_reentrant],
537     AC_LINK_IFELSE(
538       AC_LANG_PROGRAM(
539       [[[[
540 #include <stdlib.h>
541 #include <stdio.h>
542 #include <string.h>
543       ]]]],
544       [[[[
545         char buffer[] = "foo,bar,baz";
546         char *token;
547         char *dummy;
548         char *saveptr;
550         dummy = buffer;
551         saveptr = NULL;
552         while ((token = strtok_r (dummy, ",", &saveptr)) != NULL)
553         {
554           dummy = NULL;
555           printf ("token = %s;\n", token);
556         }
557       ]]]]),
558       [c_cv_have_strtok_r_reentrant="yes"],
559       [AC_MSG_FAILURE([strtok_r isn't available. Please file a bugreport!])]
560     )
561   )
562 fi
564 CFLAGS="$SAVE_CFLAGS"
565 if test "x$c_cv_have_strtok_r_reentrant" = "xyes"
566 then
567         CFLAGS="$CFLAGS -D_REENTRANT=1"
568 fi
570 AC_CHECK_FUNCS(getpwnam_r getgrnam_r setgroups regcomp regerror regexec regfree)
572 socket_needs_socket="no"
573 AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [socket_needs_socket="yes"], AC_MSG_ERROR(cannot find socket)))
574 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
576 clock_gettime_needs_rt="no"
577 clock_gettime_needs_posix4="no"
578 have_clock_gettime="no"
579 AC_CHECK_FUNCS(clock_gettime, [have_clock_gettime="yes"])
580 if test "x$have_clock_gettime" = "xno"
581 then
582         AC_CHECK_LIB(rt, clock_gettime, [clock_gettime_needs_rt="yes"
583                                          have_clock_gettime="yes"])
584 fi
585 if test "x$have_clock_gettime" = "xno"
586 then
587         AC_CHECK_LIB(posix4, clock_gettime, [clock_gettime_needs_posix4="yes"
588                                              have_clock_gettime="yes"])
589 fi
590 if test "x$have_clock_gettime" = "xyes"
591 then
592         AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if the clock_gettime(2) function is available.])
593 else
594         AC_MSG_WARN(cannot find clock_gettime)
595 fi
597 nanosleep_needs_rt="no"
598 nanosleep_needs_posix4="no"
599 AC_CHECK_FUNCS(nanosleep,
600     [],
601     AC_CHECK_LIB(rt, nanosleep,
602         [nanosleep_needs_rt="yes"],
603         AC_CHECK_LIB(posix4, nanosleep,
604             [nanosleep_needs_posix4="yes"],
605             AC_MSG_ERROR(cannot find nanosleep))))
607 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$clock_gettime_needs_rt" = "xyes" || test "x$nanosleep_needs_rt" = "xyes")
608 AM_CONDITIONAL(BUILD_WITH_LIBPOSIX4, test "x$clock_gettime_needs_posix4" = "xyes" || test "x$nanosleep_needs_posix4" = "xyes")
610 AC_CHECK_FUNCS(sysctl, [have_sysctl="yes"], [have_sysctl="no"])
611 AC_CHECK_FUNCS(sysctlbyname, [have_sysctlbyname="yes"], [have_sysctlbyname="no"])
612 AC_CHECK_FUNCS(host_statistics, [have_host_statistics="yes"], [have_host_statistics="no"])
613 AC_CHECK_FUNCS(processor_info, [have_processor_info="yes"], [have_processor_info="no"])
614 AC_CHECK_FUNCS(thread_info, [have_thread_info="yes"], [have_thread_info="no"])
615 AC_CHECK_FUNCS(statfs, [have_statfs="yes"], [have_statfs="no"])
616 AC_CHECK_FUNCS(statvfs, [have_statvfs="yes"], [have_statvfs="no"])
617 AC_CHECK_FUNCS(getifaddrs, [have_getifaddrs="yes"], [have_getifaddrs="no"])
618 AC_CHECK_FUNCS(getloadavg, [have_getloadavg="yes"], [have_getloadavg="no"])
619 AC_CHECK_FUNCS(syslog, [have_syslog="yes"], [have_syslog="no"])
620 AC_CHECK_FUNCS(getutent, [have_getutent="yes"], [have_getutent="no"])
621 AC_CHECK_FUNCS(getutxent, [have_getutxent="yes"], [have_getutxent="no"])
623 # Check for strptime {{{
624 if test "x$GCC" = "xyes"
625 then
626         SAVE_CFLAGS="$CFLAGS"
627         CFLAGS="$CFLAGS -Wall -Wextra -Werror"
628 fi
630 AC_CHECK_FUNCS(strptime, [have_strptime="yes"], [have_strptime="no"])
631 if test "x$have_strptime" = "xyes"
632 then
633         AC_CACHE_CHECK([whether strptime is exported by default],
634                        [c_cv_have_strptime_default],
635                        AC_COMPILE_IFELSE(
636 AC_LANG_PROGRAM(
637 [[
638 AC_INCLUDES_DEFAULT
639 #include <time.h>
640 ]],
641 [[
642  struct tm stm;
643  (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
644 ]]),
645                        [c_cv_have_strptime_default="yes"],
646                        [c_cv_have_strptime_default="no"]))
647 fi
648 if test "x$have_strptime" = "xyes" && test "x$c_cv_have_strptime_default" = "xno"
649 then
650         AC_CACHE_CHECK([whether strptime needs standards mode],
651                        [c_cv_have_strptime_standards],
652                        AC_COMPILE_IFELSE(
653 AC_LANG_PROGRAM(
654 [[
655 #ifndef _ISOC99_SOURCE
656 # define _ISOC99_SOURCE 1
657 #endif
658 #ifndef _POSIX_C_SOURCE
659 # define _POSIX_C_SOURCE 200112L
660 #endif
661 #ifndef _XOPEN_SOURCE
662 # define _XOPEN_SOURCE 500
663 #endif
664 AC_INCLUDES_DEFAULT
665 #include <time.h>
666 ]],
667 [[
668  struct tm stm;
669  (void) strptime ("2010-12-30%13:42:42", "%Y-%m-%dT%T", &stm);
670 ]]),
671                        [c_cv_have_strptime_standards="yes"],
672                        [c_cv_have_strptime_standards="no"]))
674         if test "x$c_cv_have_strptime_standards" = "xyes"
675         then
676                 AC_DEFINE([STRPTIME_NEEDS_STANDARDS], 1, [Set to true if strptime is only exported in X/Open mode (GNU libc).])
677         else
678                 have_strptime="no"
679         fi
680 fi
682 if test "x$GCC" = "xyes"
683 then
684         CFLAGS="$SAVE_CFLAGS"
685 fi
687 # }}} Check for strptime
689 AC_CHECK_FUNCS(swapctl, [have_swapctl="yes"], [have_swapctl="no"])
690 if test "x$have_swapctl" = "xyes"; then
691         AC_CACHE_CHECK([whether swapctl takes two arguments],
692                 [c_cv_have_swapctl_two_args],
693                 AC_COMPILE_IFELSE(
694                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
695 #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
696 #  undef _FILE_OFFSET_BITS
697 #  undef _LARGEFILE64_SOURCE
698 #endif
699 #include <sys/stat.h>
700 #include <sys/swap.h>]],
701                                 [[
702                                 int num = swapctl(0, NULL);
703                                 ]]
704                         ),
705                         [c_cv_have_swapctl_two_args="yes"],
706                         [c_cv_have_swapctl_two_args="no"]
707                 )
708         )
709         AC_CACHE_CHECK([whether swapctl takes three arguments],
710                 [c_cv_have_swapctl_three_args],
711                 AC_COMPILE_IFELSE(
712                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
713 #if HAVE_SYS_SWAP_H && !defined(_LP64) && _FILE_OFFSET_BITS == 64
714 #  undef _FILE_OFFSET_BITS
715 #  undef _LARGEFILE64_SOURCE
716 #endif
717 #include <sys/stat.h>
718 #include <sys/swap.h>]],
719                                 [[
720                                 int num = swapctl(0, NULL,0);
721                                 ]]
722                         ),
723                         [c_cv_have_swapctl_three_args="yes"],
724                         [c_cv_have_swapctl_three_args="no"]
725                 )
726         )
727 fi
728 # Check for different versions of `swapctl' here..
729 if test "x$have_swapctl" = "xyes"; then
730         if test "x$c_cv_have_swapctl_two_args" = "xyes"; then
731                 AC_DEFINE(HAVE_SWAPCTL_TWO_ARGS, 1,
732                           [Define if the function swapctl exists and takes two arguments.])
733         fi
734         if test "x$c_cv_have_swapctl_three_args" = "xyes"; then
735                 AC_DEFINE(HAVE_SWAPCTL_THREE_ARGS, 1,
736                           [Define if the function swapctl exists and takes three arguments.])
737         fi
738 fi
740 # Check for NAN
741 AC_ARG_WITH(nan-emulation, [AS_HELP_STRING([--with-nan-emulation], [use emulated NAN. For crosscompiling only.])],
743  if test "x$withval" = "xno"; then
744          nan_type="none"
745  else if test "x$withval" = "xyes"; then
746          nan_type="zero"
747  else
748          nan_type="$withval"
749  fi; fi
750 ],
751 [nan_type="none"])
752 if test "x$nan_type" = "xnone"; then
753   AC_CACHE_CHECK([whether NAN is defined by default],
754     [c_cv_have_nan_default],
755     AC_COMPILE_IFELSE(
756       AC_LANG_PROGRAM(
757       [[
758 #include <stdlib.h>
759 #include <math.h>
760 static double foo = NAN;
761       ]],
762       [[
763        if (isnan (foo))
764         return 0;
765        else
766         return 1;
767       ]]),
768       [c_cv_have_nan_default="yes"],
769       [c_cv_have_nan_default="no"]
770     )
771   )
772   if test "x$c_cv_have_nan_default" = "xyes"
773   then
774     nan_type="default"
775   fi
776 fi
777 if test "x$nan_type" = "xnone"; then
778   AC_CACHE_CHECK([whether NAN is defined by __USE_ISOC99],
779     [c_cv_have_nan_isoc],
780     AC_COMPILE_IFELSE(
781       AC_LANG_PROGRAM(
782       [[
783 #include <stdlib.h>
784 #define __USE_ISOC99 1
785 #include <math.h>
786 static double foo = NAN;
787       ]],
788       [[
789        if (isnan (foo))
790         return 0;
791        else
792         return 1;
793       ]]),
794       [c_cv_have_nan_isoc="yes"],
795       [c_cv_have_nan_isoc="no"]
796     )
797   )
798   if test "x$c_cv_have_nan_isoc" = "xyes"
799   then
800     nan_type="isoc99"
801   fi
802 fi
803 if test "x$nan_type" = "xnone"; then
804   SAVE_LDFLAGS=$LDFLAGS
805   LDFLAGS="$LDFLAGS -lm"
806   AC_CACHE_CHECK([whether NAN can be defined by 0/0],
807     [c_cv_have_nan_zero],
808     AC_RUN_IFELSE(
809       AC_LANG_PROGRAM(
810       [[
811 #include <stdlib.h>
812 #include <math.h>
813 #ifdef NAN
814 # undef NAN
815 #endif
816 #define NAN (0.0 / 0.0)
817 #ifndef isnan
818 # define isnan(f) ((f) != (f))
819 #endif
820 static double foo = NAN;
821       ]],
822       [[
823        if (isnan (foo))
824         return 0;
825        else
826         return 1;
827       ]]),
828       [c_cv_have_nan_zero="yes"],
829       [c_cv_have_nan_zero="no"]
830     )
831   )
832   LDFLAGS=$SAVE_LDFLAGS
833   if test "x$c_cv_have_nan_zero" = "xyes"
834   then
835     nan_type="zero"
836   fi
837 fi
839 if test "x$nan_type" = "xdefault"; then
840   AC_DEFINE(NAN_STATIC_DEFAULT, 1,
841     [Define if NAN is defined by default and can initialize static variables.])
842 else if test "x$nan_type" = "xisoc99"; then
843   AC_DEFINE(NAN_STATIC_ISOC, 1,
844     [Define if NAN is defined by __USE_ISOC99 and can initialize static variables.])
845 else if test "x$nan_type" = "xzero"; then
846   AC_DEFINE(NAN_ZERO_ZERO, 1,
847     [Define if NAN can be defined as (0.0 / 0.0)])
848 else
849   AC_MSG_ERROR([Didn't find out how to statically initialize variables to NAN. Sorry.])
850 fi; fi; fi
852 AC_ARG_WITH(fp-layout, [AS_HELP_STRING([--with-fp-layout], [set the memory layout of doubles. For crosscompiling only.])],
854  if test "x$withval" = "xnothing"; then
855         fp_layout_type="nothing"
856  else if test "x$withval" = "xendianflip"; then
857         fp_layout_type="endianflip"
858  else if test "x$withval" = "xintswap"; then
859         fp_layout_type="intswap"
860  else
861         AC_MSG_ERROR([Invalid argument for --with-fp-layout. Valid arguments are: nothing, endianflip, intswap]);
862 fi; fi; fi
863 ],
864 [fp_layout_type="unknown"])
866 if test "x$fp_layout_type" = "xunknown"; then
867   AC_CACHE_CHECK([if doubles are stored in x86 representation],
868     [c_cv_fp_layout_need_nothing],
869     AC_RUN_IFELSE(
870       AC_LANG_PROGRAM(
871       [[[[
872 #include <stdlib.h>
873 #include <stdio.h>
874 #include <string.h>
875 #if HAVE_STDINT_H
876 # include <stdint.h>
877 #endif
878 #if HAVE_INTTYPES_H
879 # include <inttypes.h>
880 #endif
881 #if HAVE_STDBOOL_H
882 # include <stdbool.h>
883 #endif
884       ]]]],
885       [[[[
886         uint64_t i0;
887         uint64_t i1;
888         uint8_t c[8];
889         double d;
891         d = 8.642135e130; 
892         memcpy ((void *) &i0, (void *) &d, 8);
894         i1 = i0;
895         memcpy ((void *) c, (void *) &i1, 8);
897         if ((c[0] == 0x2f) && (c[1] == 0x25)
898                         && (c[2] == 0xc0) && (c[3] == 0xc7)
899                         && (c[4] == 0x43) && (c[5] == 0x2b)
900                         && (c[6] == 0x1f) && (c[7] == 0x5b))
901                 return (0);
902         else
903                 return (1);
904       ]]]]),
905       [c_cv_fp_layout_need_nothing="yes"],
906       [c_cv_fp_layout_need_nothing="no"]
907     )
908   )
909   if test "x$c_cv_fp_layout_need_nothing" = "xyes"; then
910     fp_layout_type="nothing"
911   fi
912 fi
913 if test "x$fp_layout_type" = "xunknown"; then
914   AC_CACHE_CHECK([if endianflip converts to x86 representation],
915     [c_cv_fp_layout_need_endianflip],
916     AC_RUN_IFELSE(
917       AC_LANG_PROGRAM(
918       [[[[
919 #include <stdlib.h>
920 #include <stdio.h>
921 #include <string.h>
922 #if HAVE_STDINT_H
923 # include <stdint.h>
924 #endif
925 #if HAVE_INTTYPES_H
926 # include <inttypes.h>
927 #endif
928 #if HAVE_STDBOOL_H
929 # include <stdbool.h>
930 #endif
931 #define endianflip(A) ((((uint64_t)(A) & 0xff00000000000000LL) >> 56) | \
932                        (((uint64_t)(A) & 0x00ff000000000000LL) >> 40) | \
933                        (((uint64_t)(A) & 0x0000ff0000000000LL) >> 24) | \
934                        (((uint64_t)(A) & 0x000000ff00000000LL) >> 8)  | \
935                        (((uint64_t)(A) & 0x00000000ff000000LL) << 8)  | \
936                        (((uint64_t)(A) & 0x0000000000ff0000LL) << 24) | \
937                        (((uint64_t)(A) & 0x000000000000ff00LL) << 40) | \
938                        (((uint64_t)(A) & 0x00000000000000ffLL) << 56))
939       ]]]],
940       [[[[
941         uint64_t i0;
942         uint64_t i1;
943         uint8_t c[8];
944         double d;
946         d = 8.642135e130; 
947         memcpy ((void *) &i0, (void *) &d, 8);
949         i1 = endianflip (i0);
950         memcpy ((void *) c, (void *) &i1, 8);
952         if ((c[0] == 0x2f) && (c[1] == 0x25)
953                         && (c[2] == 0xc0) && (c[3] == 0xc7)
954                         && (c[4] == 0x43) && (c[5] == 0x2b)
955                         && (c[6] == 0x1f) && (c[7] == 0x5b))
956                 return (0);
957         else
958                 return (1);
959       ]]]]),
960       [c_cv_fp_layout_need_endianflip="yes"],
961       [c_cv_fp_layout_need_endianflip="no"]
962     )
963   )
964   if test "x$c_cv_fp_layout_need_endianflip" = "xyes"; then
965     fp_layout_type="endianflip"
966   fi
967 fi
968 if test "x$fp_layout_type" = "xunknown"; then
969   AC_CACHE_CHECK([if intswap converts to x86 representation],
970     [c_cv_fp_layout_need_intswap],
971     AC_RUN_IFELSE(
972       AC_LANG_PROGRAM(
973       [[[[
974 #include <stdlib.h>
975 #include <stdio.h>
976 #include <string.h>
977 #if HAVE_STDINT_H
978 # include <stdint.h>
979 #endif
980 #if HAVE_INTTYPES_H
981 # include <inttypes.h>
982 #endif
983 #if HAVE_STDBOOL_H
984 # include <stdbool.h>
985 #endif
986 #define intswap(A)    ((((uint64_t)(A) & 0xffffffff00000000LL) >> 32) | \
987                        (((uint64_t)(A) & 0x00000000ffffffffLL) << 32))
988       ]]]],
989       [[[[
990         uint64_t i0;
991         uint64_t i1;
992         uint8_t c[8];
993         double d;
995         d = 8.642135e130; 
996         memcpy ((void *) &i0, (void *) &d, 8);
998         i1 = intswap (i0);
999         memcpy ((void *) c, (void *) &i1, 8);
1001         if ((c[0] == 0x2f) && (c[1] == 0x25)
1002                         && (c[2] == 0xc0) && (c[3] == 0xc7)
1003                         && (c[4] == 0x43) && (c[5] == 0x2b)
1004                         && (c[6] == 0x1f) && (c[7] == 0x5b))
1005                 return (0);
1006         else
1007                 return (1);
1008       ]]]]),
1009       [c_cv_fp_layout_need_intswap="yes"],
1010       [c_cv_fp_layout_need_intswap="no"]
1011     )
1012   )
1013   if test "x$c_cv_fp_layout_need_intswap" = "xyes"; then
1014     fp_layout_type="intswap"
1015   fi
1016 fi
1018 if test "x$fp_layout_type" = "xnothing"; then
1019   AC_DEFINE(FP_LAYOUT_NEED_NOTHING, 1,
1020   [Define if doubles are stored in x86 representation.])
1021 else if test "x$fp_layout_type" = "xendianflip"; then
1022   AC_DEFINE(FP_LAYOUT_NEED_ENDIANFLIP, 1,
1023   [Define if endianflip is needed to convert to x86 representation.])
1024 else if test "x$fp_layout_type" = "xintswap"; then
1025   AC_DEFINE(FP_LAYOUT_NEED_INTSWAP, 1,
1026   [Define if intswap is needed to convert to x86 representation.])
1027 else
1028   AC_MSG_ERROR([Didn't find out how doubles are stored in memory. Sorry.])
1029 fi; fi; fi
1031 have_getfsstat="no"
1032 AC_CHECK_FUNCS(getfsstat, [have_getfsstat="yes"])
1033 have_getvfsstat="no"
1034 AC_CHECK_FUNCS(getvfsstat, [have_getvfsstat="yes"])
1035 have_listmntent="no"
1036 AC_CHECK_FUNCS(listmntent, [have_listmntent="yes"])
1038 have_getmntent="no"
1039 AC_CHECK_FUNCS(getmntent, [have_getmntent="c"])
1040 if test "x$have_getmntent" = "xno"; then
1041         AC_CHECK_LIB(sun, getmntent, [have_getmntent="sun"])
1042 fi
1043 if test "x$have_getmntent" = "xno"; then
1044         AC_CHECK_LIB(seq, getmntent, [have_getmntent="seq"])
1045 fi
1046 if test "x$have_getmntent" = "xno"; then
1047         AC_CHECK_LIB(gen, getmntent, [have_getmntent="gen"])
1048 fi
1050 if test "x$have_getmntent" = "xc"; then
1051         AC_CACHE_CHECK([whether getmntent takes one argument],
1052                 [c_cv_have_one_getmntent],
1053                 AC_COMPILE_IFELSE(
1054                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
1055 #include "$srcdir/src/utils_mount.h"]],
1056                                 [[
1057                                  FILE *fh;
1058                                  struct mntent *me;
1059                                  fh = setmntent ("/etc/mtab", "r");
1060                                  me = getmntent (fh);
1061                                 ]]
1062                         ),
1063                         [c_cv_have_one_getmntent="yes"],
1064                         [c_cv_have_one_getmntent="no"]
1065                 )
1066         )
1067         AC_CACHE_CHECK([whether getmntent takes two arguments],
1068                 [c_cv_have_two_getmntent],
1069                 AC_COMPILE_IFELSE(
1070                         AC_LANG_PROGRAM([[AC_INCLUDES_DEFAULT
1071 #include "$srcdir/src/utils_mount.h"]],
1072                                 [[
1073                                  FILE *fh;
1074                                  struct mnttab mt;
1075                                  int status;
1076                                  fh = fopen ("/etc/mnttab", "r");
1077                                  status = getmntent (fh, &mt);
1078                                 ]]
1079                         ),
1080                         [c_cv_have_two_getmntent="yes"],
1081                         [c_cv_have_two_getmntent="no"]
1082                 )
1083         )
1084 fi
1086 # Check for different versions of `getmntent' here..
1088 if test "x$have_getmntent" = "xc"; then
1089         if test "x$c_cv_have_one_getmntent" = "xyes"; then
1090                 AC_DEFINE(HAVE_ONE_GETMNTENT, 1,
1091                           [Define if the function getmntent exists and takes one argument.])
1092         fi
1093         if test "x$c_cv_have_two_getmntent" = "xyes"; then
1094                 AC_DEFINE(HAVE_TWO_GETMNTENT, 1,
1095                           [Define if the function getmntent exists and takes two arguments.])
1096         fi
1097 fi
1098 if test "x$have_getmntent" = "xsun"; then
1099         AC_DEFINE(HAVE_SUN_GETMNTENT, 1,
1100                   [Define if the function getmntent exists. It's the version from libsun.])
1101 fi
1102 if test "x$have_getmntent" = "xseq"; then
1103         AC_DEFINE(HAVE_SEQ_GETMNTENT, 1,
1104                   [Define if the function getmntent exists. It's the version from libseq.])
1105 fi
1106 if test "x$have_getmntent" = "xgen"; then
1107         AC_DEFINE(HAVE_GEN_GETMNTENT, 1,
1108                   [Define if the function getmntent exists. It's the version from libgen.])
1109 fi
1111 # Check for htonll
1112 AC_MSG_CHECKING([if have htonll defined])
1114     have_htonll="no"
1115     AC_LINK_IFELSE([
1116        AC_LANG_PROGRAM([
1117 #include <sys/types.h>
1118 #include <netinet/in.h>
1119 #if HAVE_INTTYPES_H
1120 # include <inttypes.h>
1121 #endif
1122        ], [
1123           return htonll(0);
1124        ])
1125     ], [
1126       have_htonll="yes"
1127       AC_DEFINE(HAVE_HTONLL, 1, [Define if the function htonll exists.])
1128     ])
1129  
1130 AC_MSG_RESULT([$have_htonll])
1132 # Check for structures
1133 AC_CHECK_MEMBERS([struct if_data.ifi_ibytes, struct if_data.ifi_opackets, struct if_data.ifi_ierrors],
1134         [AC_DEFINE(HAVE_STRUCT_IF_DATA, 1, [Define if struct if_data exists and is usable.])],
1135         [],
1136         [
1137         #include <sys/types.h>
1138         #include <sys/socket.h>
1139         #include <net/if.h>
1140         ])
1141 AC_CHECK_MEMBERS([struct net_device_stats.rx_bytes, struct net_device_stats.tx_packets, struct net_device_stats.rx_errors],
1142         [AC_DEFINE(HAVE_STRUCT_NET_DEVICE_STATS, 1, [Define if struct net_device_stats exists and is usable.])],
1143         [],
1144         [
1145         #include <sys/types.h>
1146         #include <sys/socket.h>
1147         #include <linux/if.h>
1148         #include <linux/netdevice.h>
1149         ])
1151 AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [],
1152         [],
1153         [
1154         #include <netinet/in.h>
1155         #include <net/if.h>
1156         ])
1158 AC_CHECK_MEMBERS([struct kinfo_proc.ki_pid, struct kinfo_proc.ki_rssize, struct kinfo_proc.ki_rusage],
1159         [
1160                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_FREEBSD, 1,
1161                         [Define if struct kinfo_proc exists in the FreeBSD variant.])
1162                 have_struct_kinfo_proc_freebsd="yes"
1163         ],
1164         [
1165                 have_struct_kinfo_proc_freebsd="no"
1166         ],
1167         [
1168 #include <kvm.h>
1169 #include <sys/param.h>
1170 #include <sys/sysctl.h>
1171 #include <sys/user.h>
1172         ])
1174 AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc],
1175         [
1176                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
1177                         [Define if struct kinfo_proc exists in the OpenBSD variant.])
1178                 have_struct_kinfo_proc_openbsd="yes"
1179         ],
1180         [
1181                 have_struct_kinfo_proc_openbsd="no"
1182         ],
1183         [
1184 #include <sys/param.h>
1185 #include <sys/sysctl.h>
1186 #include <kvm.h>
1187         ])
1189 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
1190 [#define _BSD_SOURCE
1191 #if HAVE_STDINT_H
1192 # include <stdint.h>
1193 #endif
1194 #if HAVE_SYS_TYPES_H
1195 # include <sys/types.h>
1196 #endif
1197 #if HAVE_NETINET_IN_SYSTM_H
1198 # include <netinet/in_systm.h>
1199 #endif
1200 #if HAVE_NETINET_IN_H
1201 # include <netinet/in.h>
1202 #endif
1203 #if HAVE_NETINET_IP_H
1204 # include <netinet/ip.h>
1205 #endif
1206 #if HAVE_NETINET_UDP_H
1207 # include <netinet/udp.h>
1208 #endif
1209 ])
1210 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
1211 [#define _BSD_SOURCE
1212 #if HAVE_STDINT_H
1213 # include <stdint.h>
1214 #endif
1215 #if HAVE_SYS_TYPES_H
1216 # include <sys/types.h>
1217 #endif
1218 #if HAVE_NETINET_IN_SYSTM_H
1219 # include <netinet/in_systm.h>
1220 #endif
1221 #if HAVE_NETINET_IN_H
1222 # include <netinet/in.h>
1223 #endif
1224 #if HAVE_NETINET_IP_H
1225 # include <netinet/ip.h>
1226 #endif
1227 #if HAVE_NETINET_UDP_H
1228 # include <netinet/udp.h>
1229 #endif
1230 ])
1232 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
1233         [],
1234         [],
1235         [
1236 #if HAVE_KSTAT_H
1237 # include <kstat.h>
1238 #endif
1239         ])
1242 # Checks for libraries begin here
1244 with_libresolv="yes"
1245 AC_CHECK_LIB(resolv, res_search,
1247         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
1248 ],
1249 [with_libresolv="no"])
1250 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
1252 dnl Check for HAL (hardware abstraction library)
1253 with_libhal="yes"
1254 AC_CHECK_LIB(hal,libhal_device_property_exists,
1255              [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
1256              [with_libhal="no"])
1257 if test "x$with_libhal" = "xyes"; then
1258         if test "x$PKG_CONFIG" != "x"; then
1259                 BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
1260                 BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
1261                 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
1262                 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
1263         fi
1264 fi
1266 m4_divert_once([HELP_WITH], [
1267 collectd additional packages:])
1269 AM_CONDITIONAL([BUILD_AIX],[test "x$x$ac_system" = "xAIX"]) 
1271 if test "x$ac_system" = "xAIX"
1272 then
1273         with_perfstat="yes"
1274         with_procinfo="yes"
1275 else
1276         with_perfstat="no (AIX only)"
1277         with_procinfo="no (AIX only)"
1278 fi
1280 if test "x$with_perfstat" = "xyes"
1281 then
1282         AC_CHECK_LIB(perfstat, perfstat_reset, [with_perfstat="yes"], [with_perfstat="no (perfstat not found)"], [])
1283 #       AC_CHECK_HEADERS(sys/protosw.h libperfstat.h,, [with_perfstat="no (perfstat not found)"])
1284 fi
1285 if test "x$with_perfstat" = "xyes"
1286 then
1287          AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
1288          # struct members pertaining to donation have been added to libperfstat somewhere between AIX5.3ML5 and AIX5.3ML9
1289          AC_CHECK_MEMBER([perfstat_partition_type_t.b.donate_enabled], [], [], [[#include <libperfstat.h]])
1290          if test "x$av_cv_member_perfstat_partition_type_t_b_donate_enabled" = "xyes"
1291          then
1292                 AC_DEFINE(PERFSTAT_SUPPORTS_DONATION, 1, [Define to 1 if your version of the 'perfstat' library supports donation])
1293          fi
1294 fi
1295 AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")
1297 # Processes plugin under AIX.
1298 if test "x$with_procinfo" = "xyes"
1299 then
1300         AC_CHECK_HEADERS(procinfo.h,, [with_procinfo="no (procinfo.h not found)"])
1301 fi
1302 if test "x$with_procinfo" = "xyes"
1303 then
1304          AC_DEFINE(HAVE_PROCINFO_H, 1, [Define to 1 if you have the procinfo.h])
1305 fi
1307 if test "x$ac_system" = "xSolaris"
1308 then
1309         with_kstat="yes"
1310         with_devinfo="yes"
1311 else
1312         with_kstat="no (Solaris only)"
1313         with_devinfo="no (Solaris only)"
1314 fi
1316 if test "x$with_kstat" = "xyes"
1317 then
1318         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
1319 fi
1320 if test "x$with_kstat" = "xyes"
1321 then
1322         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
1323         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
1324 fi
1325 if test "x$with_kstat" = "xyes"
1326 then
1327         AC_DEFINE(HAVE_LIBKSTAT, 1,
1328                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1329 fi
1330 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1331 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1333 with_libiokit="no"
1334 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1336         with_libiokit="yes"
1337 ], 
1339         with_libiokit="no"
1340 ])
1341 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1343 with_libkvm="no"
1344 AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
1345 if test "x$with_kvm_getprocs" = "xyes"
1346 then
1347         AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
1348                   [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
1349         with_libkvm="yes"
1350 fi
1351 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
1353 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
1354 if test "x$with_kvm_getswapinfo" = "xyes"
1355 then
1356         AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
1357                   [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
1358         with_libkvm="yes"
1359 fi
1360 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
1362 AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
1363 if test "x$with_kvm_nlist" = "xyes"
1364 then
1365         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1366                   [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
1367         with_libkvm="yes"
1368 fi
1369 AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
1371 AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
1372 if test "x$with_kvm_openfiles" = "xyes"
1373 then
1374         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1375                   [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
1376         with_libkvm="yes"
1377 fi
1378 AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
1380 # --with-libcredis {{{
1381 AC_ARG_WITH(libcredis, [AS_HELP_STRING([--with-libcredis@<:@=PREFIX@:>@], [Path to libcredis.])],
1383  if test "x$withval" = "xyes"
1384  then
1385          with_libcredis="yes"
1386  else if test "x$withval" = "xno"
1387  then
1388          with_libcredis="no"
1389  else
1390          with_libcredis="yes"
1391          LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS -I$withval/include"
1392          LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS -L$withval/lib"
1393  fi; fi
1394 ],
1395 [with_libcredis="yes"])
1397 SAVE_CPPFLAGS="$CPPFLAGS"
1398 SAVE_LDFLAGS="$LDFLAGS"
1400 CPPFLAGS="$CPPFLAGS $LIBCREDIS_CPPFLAGS"
1401 LDFLAGS="$LDFLAGS $LIBCREDIS_LDFLAGS"
1403 if test "x$with_libcredis" = "xyes"
1404 then
1405         if test "x$LIBCREDIS_CPPFLAGS" != "x"
1406         then
1407                 AC_MSG_NOTICE([libcredis CPPFLAGS: $LIBCREDIS_CPPFLAGS])
1408         fi
1409         AC_CHECK_HEADERS(credis.h,
1410         [with_libcredis="yes"],
1411         [with_libcredis="no (credis.h not found)"])
1412 fi
1413 if test "x$with_libcredis" = "xyes"
1414 then
1415         if test "x$LIBCREDIS_LDFLAGS" != "x"
1416         then
1417                 AC_MSG_NOTICE([libcredis LDFLAGS: $LIBCREDIS_LDFLAGS])
1418         fi
1419         AC_CHECK_LIB(credis, credis_info,
1420         [with_libcredis="yes"],
1421         [with_libcredis="no (symbol 'credis_info' not found)"])
1423 fi
1425 CPPFLAGS="$SAVE_CPPFLAGS"
1426 LDFLAGS="$SAVE_LDFLAGS"
1428 if test "x$with_libcredis" = "xyes"
1429 then
1430         BUILD_WITH_LIBCREDIS_CPPFLAGS="$LIBCREDIS_CPPFLAGS"
1431         BUILD_WITH_LIBCREDIS_LDFLAGS="$LIBCREDIS_LDFLAGS"
1432         AC_SUBST(BUILD_WITH_LIBCREDIS_CPPFLAGS)
1433         AC_SUBST(BUILD_WITH_LIBCREDIS_LDFLAGS)
1434 fi
1435 AM_CONDITIONAL(BUILD_WITH_LIBCREDIS, test "x$with_libcredis" = "xyes")
1436 # }}}
1438 # --with-libcurl {{{
1439 with_curl_config="curl-config"
1440 with_curl_cflags=""
1441 with_curl_libs=""
1442 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
1444         if test "x$withval" = "xno"
1445         then
1446                 with_libcurl="no"
1447         else if test "x$withval" = "xyes"
1448         then
1449                 with_libcurl="yes"
1450         else
1451                 if test -f "$withval" && test -x "$withval"
1452                 then
1453                         with_curl_config="$withval"
1454                         with_libcurl="yes"
1455                 else if test -x "$withval/bin/curl-config"
1456                 then
1457                         with_curl_config="$withval/bin/curl-config"
1458                         with_libcurl="yes"
1459                 fi; fi
1460                 with_libcurl="yes"
1461         fi; fi
1462 ],
1464         with_libcurl="yes"
1465 ])
1466 if test "x$with_libcurl" = "xyes"
1467 then
1468         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1469         curl_config_status=$?
1471         if test $curl_config_status -ne 0
1472         then
1473                 with_libcurl="no ($with_curl_config failed)"
1474         else
1475                 SAVE_CPPFLAGS="$CPPFLAGS"
1476                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1478                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1480                 CPPFLAGS="$SAVE_CPPFLAGS"
1481         fi
1482 fi
1483 if test "x$with_libcurl" = "xyes"
1484 then
1485         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1486         curl_config_status=$?
1488         if test $curl_config_status -ne 0
1489         then
1490                 with_libcurl="no ($with_curl_config failed)"
1491         else
1492                 AC_CHECK_LIB(curl, curl_easy_init,
1493                  [with_libcurl="yes"],
1494                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1495                  [$with_curl_libs])
1496         fi
1497 fi
1498 if test "x$with_libcurl" = "xyes"
1499 then
1500         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1501         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1502         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1503         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1504 fi
1505 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1506 # }}}
1508 # --with-libdbi {{{
1509 with_libdbi_cppflags=""
1510 with_libdbi_ldflags=""
1511 AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
1513         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1514         then
1515                 with_libdbi_cppflags="-I$withval/include"
1516                 with_libdbi_ldflags="-L$withval/lib"
1517                 with_libdbi="yes"
1518         else
1519                 with_libdbi="$withval"
1520         fi
1521 ],
1523         with_libdbi="yes"
1524 ])
1525 if test "x$with_libdbi" = "xyes"
1526 then
1527         SAVE_CPPFLAGS="$CPPFLAGS"
1528         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1530         AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
1532         CPPFLAGS="$SAVE_CPPFLAGS"
1533 fi
1534 if test "x$with_libdbi" = "xyes"
1535 then
1536         SAVE_CPPFLAGS="$CPPFLAGS"
1537         SAVE_LDFLAGS="$LDFLAGS"
1538         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1539         LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
1541         AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
1543         CPPFLAGS="$SAVE_CPPFLAGS"
1544         LDFLAGS="$SAVE_LDFLAGS"
1545 fi
1546 if test "x$with_libdbi" = "xyes"
1547 then
1548         BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
1549         BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
1550         BUILD_WITH_LIBDBI_LIBS="-ldbi"
1551         AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
1552         AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
1553         AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
1554 fi
1555 AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
1556 # }}}
1558 # --with-libesmtp {{{
1559 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
1561         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1562         then
1563                 LDFLAGS="$LDFLAGS -L$withval/lib"
1564                 CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
1565                 with_libesmtp="yes"
1566         else
1567                 with_libesmtp="$withval"
1568         fi
1569 ],
1571         with_libesmtp="yes"
1572 ])
1573 if test "x$with_libesmtp" = "xyes"
1574 then
1575         AC_CHECK_LIB(esmtp, smtp_create_session,
1576         [
1577                 AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
1578         ], [with_libesmtp="no (libesmtp not found)"])
1579 fi
1580 if test "x$with_libesmtp" = "xyes"
1581 then
1582         AC_CHECK_HEADERS(libesmtp.h,
1583         [
1584                 AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
1585         ], [with_libesmtp="no (libesmtp.h not found)"])
1586 fi
1587 if test "x$with_libesmtp" = "xyes"
1588 then
1589         collect_libesmtp=1
1590 else
1591         collect_libesmtp=0
1592 fi
1593 AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
1594         [Wether or not to use the esmtp library])
1595 AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
1596 # }}}
1598 # --with-libganglia {{{
1599 AC_ARG_WITH(libganglia, [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
1601  if test -f "$withval" && test -x "$withval"
1602  then
1603          with_libganglia_config="$withval"
1604          with_libganglia="yes"
1605  else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"
1606  then
1607          with_libganglia_config="$withval/bin/ganglia-config"
1608          with_libganglia="yes"
1609  else if test -d "$withval"
1610  then
1611          GANGLIA_CPPFLAGS="-I$withval/include"
1612          GANGLIA_LDFLAGS="-L$withval/lib"
1613          with_libganglia="yes"
1614  else
1615          with_libganglia_config="ganglia-config"
1616          with_libganglia="$withval"
1617  fi; fi; fi
1618 ],
1620  with_libganglia_config="ganglia-config"
1621  with_libganglia="yes"
1622 ])
1624 if test "x$with_libganglia" = "xyes" && test "x$with_libganglia_config" != "x"
1625 then
1626         if test "x$GANGLIA_CPPFLAGS" = "x"
1627         then
1628                 GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
1629         fi
1631         if test "x$GANGLIA_LDFLAGS" = "x"
1632         then
1633                 GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
1634         fi
1636         if test "x$GANGLIA_LIBS" = "x"
1637         then
1638                 GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
1639         fi
1640 fi
1642 SAVE_CPPFLAGS="$CPPFLAGS"
1643 SAVE_LDFLAGS="$LDFLAGS"
1644 CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
1645 LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
1647 if test "x$with_libganglia" = "xyes"
1648 then
1649         AC_CHECK_HEADERS(gm_protocol.h,
1650         [
1651                 AC_DEFINE(HAVE_GM_PROTOCOL_H, 1,
1652                           [Define to 1 if you have the <gm_protocol.h> header file.])
1653         ], [with_libganglia="no (gm_protocol.h not found)"])
1654 fi
1656 if test "x$with_libganglia" = "xyes"
1657 then
1658         AC_CHECK_LIB(ganglia, xdr_Ganglia_value_msg,
1659         [
1660                 AC_DEFINE(HAVE_LIBGANGLIA, 1,
1661                           [Define to 1 if you have the ganglia library (-lganglia).])
1662         ], [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"])
1663 fi
1665 CPPFLAGS="$SAVE_CPPFLAGS"
1666 LDFLAGS="$SAVE_LDFLAGS"
1668 AC_SUBST(GANGLIA_CPPFLAGS)
1669 AC_SUBST(GANGLIA_LDFLAGS)
1670 AC_SUBST(GANGLIA_LIBS)
1671 AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
1672 # }}}
1674 # --with-libgcrypt {{{
1675 GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
1676 GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
1677 GCRYPT_LIBS="$GCRYPT_LIBS"
1678 AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
1680  if test -f "$withval" && test -x "$withval"
1681  then
1682          with_libgcrypt_config="$withval"
1683          with_libgcrypt="yes"
1684  else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
1685  then
1686          with_libgcrypt_config="$withval/bin/gcrypt-config"
1687          with_libgcrypt="yes"
1688  else if test -d "$withval"
1689  then
1690          GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
1691          GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
1692          with_libgcrypt="yes"
1693  else
1694          with_libgcrypt_config="gcrypt-config"
1695          with_libgcrypt="$withval"
1696  fi; fi; fi
1697 ],
1699  with_libgcrypt_config="libgcrypt-config"
1700  with_libgcrypt="yes"
1701 ])
1703 if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
1704 then
1705         if test "x$GCRYPT_CPPFLAGS" = "x"
1706         then
1707                 GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
1708         fi
1710         if test "x$GCRYPT_LDFLAGS" = "x"
1711         then
1712                 gcrypt_exec_prefix=`"$with_libgcrypt_config" --exec-prefix 2>/dev/null`
1713                 GCRYPT_LDFLAGS="-L$gcrypt_exec_prefix/lib"
1714         fi
1716         if test "x$GCRYPT_LIBS" = "x"
1717         then
1718                 GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
1719         fi
1720 fi
1722 SAVE_CPPFLAGS="$CPPFLAGS"
1723 SAVE_LDFLAGS="$LDFLAGS"
1724 CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
1725 LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
1727 if test "x$with_libgcrypt" = "xyes"
1728 then
1729         if test "x$GCRYPT_CPPFLAGS" != "x"
1730         then
1731                 AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
1732         fi
1733         AC_CHECK_HEADERS(gcrypt.h,
1734                 [with_libgcrypt="yes"],
1735                 [with_libgcrypt="no (gcrypt.h not found)"])
1736 fi
1738 if test "x$with_libgcrypt" = "xyes"
1739 then
1740         if test "x$GCRYPT_LDFLAGS" != "x"
1741         then
1742                 AC_MSG_NOTICE([gcrypt LDFLAGS: $GCRYPT_LDFLAGS])
1743         fi
1744         AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
1745                 [with_libgcrypt="yes"],
1746                 [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
1748         if test "$with_libgcrypt" != "no"; then
1749                 AM_PATH_LIBGCRYPT(1:1.2.0,,with_libgcrypt="no (version 1.2.0+ required)")
1750         fi
1751 fi
1753 CPPFLAGS="$SAVE_CPPFLAGS"
1754 LDFLAGS="$SAVE_LDFLAGS"
1756 if test "x$with_libgcrypt" = "xyes"
1757 then
1758         AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to 1 if you have the gcrypt library (-lgcrypt).])
1759 fi
1761 AC_SUBST(GCRYPT_CPPFLAGS)
1762 AC_SUBST(GCRYPT_LDFLAGS)
1763 AC_SUBST(GCRYPT_LIBS)
1764 AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
1765 # }}}
1767 # --with-libiptc {{{
1768 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1770         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1771         then
1772                 LIBIPTC_CPPFLAGS="$LIBIPTC_CPPFLAGS -I$withval/include"
1773                 LIBIPTC_LDFLAGS="$LIBIPTC_LDFLAGS -L$withval/lib"
1774                 with_libiptc="yes"
1775         else
1776                 with_libiptc="$withval"
1777         fi
1778 ],
1780         if test "x$ac_system" = "xLinux"
1781         then
1782                 with_libiptc="yes"
1783         else
1784                 with_libiptc="no (Linux only)"
1785         fi
1786 ])
1787 SAVE_CPPFLAGS="$CPPFLAGS"
1788 SAVE_LDFLAGS="$LDFLAGS"
1789 CPPFLAGS="$CPPFLAGS $LIBIPTC_CPPFLAGS"
1790 LDFLAGS="$LDFLAGS $LIBIPTC_LDFLAGS"
1791 # check whether the header file for libiptc is available.
1792 if test "x$with_libiptc" = "xyes"
1793 then
1794         AC_CHECK_HEADERS(libiptc/libiptc.h,
1795                          [with_libiptc="yes"],
1796                          [with_libiptc="no (libiptc/libiptc.h not found)"])
1797 fi
1798 if test "x$with_libiptc" = "xyes"
1799 then
1800         AC_CHECK_HEADERS(libiptc/libip6tc.h,
1801                          [with_libiptc="yes"],
1802                          [with_libiptc="no (libiptc/libip6tc.h not found)"])
1803 fi
1804 # If the header file is available, check for the required type declaractions.
1805 # They may be missing in old versions of libiptc. In that case, they will be
1806 # declared in the iptables plugin.
1807 if test "x$with_libiptc" = "xyes"
1808 then
1809         AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [],
1810         [
1811 #include <libiptc/libiptc.h>
1812 #include <libiptc/libip6tc.h>
1813         ])
1814 fi
1815 # Check for the iptc_init symbol in the library.
1816 if test "x$with_libiptc" = "xyes"
1817 then
1818         AC_CHECK_LIB(iptc, iptc_init,
1819                      [with_libiptc="yes"],
1820                      [with_libiptc="no (symbol 'iptc_init' not found)"])
1821 fi
1822 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1823 if test "x$with_libiptc" = "xyes"
1824 then
1825         BUILD_WITH_LIBIPTC_CPPFLAGS="$LIBIPTC_CPPFLAGS"
1826         BUILD_WITH_LIBIPTC_LDFLAGS="$LIBIPTC_LDFLAGS"
1827         AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
1828         AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
1829 fi
1830 CPPFLAGS="$SAVE_CPPFLAGS"
1831 LDFLAGS="$SAVE_LDFLAGS"
1832 # }}}
1834 # --with-java {{{
1835 with_java_home="$JAVA_HOME"
1836 with_java_vmtype="client"
1837 with_java_cflags=""
1838 with_java_libs=""
1839 JAVAC="$JAVAC"
1840 JAR="$JAR"
1841 AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
1843         if test "x$withval" = "xno"
1844         then
1845                 with_java="no"
1846         else if test "x$withval" = "xyes"
1847         then
1848                 with_java="yes"
1849         else
1850                 with_java_home="$withval"
1851                 with_java="yes"
1852         fi; fi
1853 ],
1854 [with_java="yes"])
1855 if test "x$with_java" = "xyes"
1856 then
1857         if test -d "$with_java_home"
1858         then
1859                 AC_MSG_CHECKING([for jni.h])
1860                 TMPDIR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
1861                 if test "x$TMPDIR" != "x"
1862                 then
1863                         AC_MSG_RESULT([found in $TMPDIR])
1864                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
1865                 else
1866                         AC_MSG_RESULT([not found])
1867                 fi
1869                 AC_MSG_CHECKING([for jni_md.h])
1870                 TMPDIR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
1871                 if test "x$TMPDIR" != "x"
1872                 then
1873                         AC_MSG_RESULT([found in $TMPDIR])
1874                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
1875                 else
1876                         AC_MSG_RESULT([not found])
1877                 fi
1879                 AC_MSG_CHECKING([for libjvm.so])
1880                 TMPDIR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
1881                 if test "x$TMPDIR" != "x"
1882                 then
1883                         AC_MSG_RESULT([found in $TMPDIR])
1884                         JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPDIR -Wl,-rpath -Wl,$TMPDIR"
1885                 else
1886                         AC_MSG_RESULT([not found])
1887                 fi
1889                 if test "x$JAVAC" = "x"
1890                 then
1891                         AC_MSG_CHECKING([for javac])
1892                         TMPDIR=`find "$with_java_home" -name javac -type f | head -n 1`
1893                         if test "x$TMPDIR" != "x"
1894                         then
1895                                 JAVAC="$TMPDIR"
1896                                 AC_MSG_RESULT([$JAVAC])
1897                         else
1898                                 AC_MSG_RESULT([not found])
1899                         fi
1900                 fi
1901                 if test "x$JAR" = "x"
1902                 then
1903                         AC_MSG_CHECKING([for jar])
1904                         TMPDIR=`find "$with_java_home" -name jar -type f | head -n 1`
1905                         if test "x$TMPDIR" != "x"
1906                         then
1907                                 JAR="$TMPDIR"
1908                                 AC_MSG_RESULT([$JAR])
1909                         else
1910                                 AC_MSG_RESULT([not found])
1911                         fi
1912                 fi
1913         else if test "x$with_java_home" != "x"
1914         then
1915                 AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
1916         fi; fi
1917 fi
1919 if test "x$JAVA_CPPFLAGS" != "x"
1920 then
1921         AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
1922 fi
1923 if test "x$JAVA_CFLAGS" != "x"
1924 then
1925         AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
1926 fi
1927 if test "x$JAVA_LDFLAGS" != "x"
1928 then
1929         AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
1930 fi
1931 if test "x$JAVAC" = "x"
1932 then
1933         with_javac_path="$PATH"
1934         if test "x$with_java_home" != "x"
1935         then
1936                 with_javac_path="$with_java_home:with_javac_path"
1937                 if test -d "$with_java_home/bin"
1938                 then
1939                         with_javac_path="$with_java_home/bin:with_javac_path"
1940                 fi
1941         fi
1943         AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
1944 fi
1945 if test "x$JAVAC" = "x"
1946 then
1947         with_java="no (javac not found)"
1948 fi
1949 if test "x$JAR" = "x"
1950 then
1951         with_jar_path="$PATH"
1952         if test "x$with_java_home" != "x"
1953         then
1954                 with_jar_path="$with_java_home:$with_jar_path"
1955                 if test -d "$with_java_home/bin"
1956                 then
1957                         with_jar_path="$with_java_home/bin:$with_jar_path"
1958                 fi
1959         fi
1961         AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
1962 fi
1963 if test "x$JAR" = "x"
1964 then
1965         with_java="no (jar not found)"
1966 fi
1968 SAVE_CPPFLAGS="$CPPFLAGS"
1969 SAVE_CFLAGS="$CFLAGS"
1970 SAVE_LDFLAGS="$LDFLAGS"
1971 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
1972 CFLAGS="$CFLAGS $JAVA_CFLAGS"
1973 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
1975 if test "x$with_java" = "xyes"
1976 then
1977         AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
1978 fi
1979 if test "x$with_java" = "xyes"
1980 then
1981         AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
1982         [with_java="yes"],
1983         [with_java="no (libjvm not found)"],
1984         [$JAVA_LIBS])
1985 fi
1986 if test "x$with_java" = "xyes"
1987 then
1988         JAVA_LIBS="$JAVA_LIBS -ljvm"
1989         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
1990 fi
1992 CPPFLAGS="$SAVE_CPPFLAGS"
1993 CFLAGS="$SAVE_CFLAGS"
1994 LDFLAGS="$SAVE_LDFLAGS"
1996 AC_SUBST(JAVA_CPPFLAGS)
1997 AC_SUBST(JAVA_CFLAGS)
1998 AC_SUBST(JAVA_LDFLAGS)
1999 AC_SUBST(JAVA_LIBS)
2000 AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
2001 # }}}
2003 # --with-libmemcached {{{
2004 with_libmemcached_cppflags=""
2005 with_libmemcached_ldflags=""
2006 AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
2008         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2009         then
2010                 with_libmemcached_cppflags="-I$withval/include"
2011                 with_libmemcached_ldflags="-L$withval/lib"
2012                 with_libmemcached="yes"
2013         else
2014                 with_libmemcached="$withval"
2015         fi
2016 ],
2018         with_libmemcached="yes"
2019 ])
2020 if test "x$with_libmemcached" = "xyes"
2021 then
2022         SAVE_CPPFLAGS="$CPPFLAGS"
2023         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
2025         AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
2027         CPPFLAGS="$SAVE_CPPFLAGS"
2028 fi
2029 if test "x$with_libmemcached" = "xyes"
2030 then
2031         SAVE_CPPFLAGS="$CPPFLAGS"
2032         SAVE_LDFLAGS="$LDFLAGS"
2033         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
2034         LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
2036         AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
2038         CPPFLAGS="$SAVE_CPPFLAGS"
2039         LDFLAGS="$SAVE_LDFLAGS"
2040 fi
2041 if test "x$with_libmemcached" = "xyes"
2042 then
2043         BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
2044         BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
2045         BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
2046         AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
2047         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
2048         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
2049         AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
2050 fi
2051 AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
2052 # }}}
2054 # --with-libmodbus {{{
2055 with_libmodbus_config=""
2056 with_libmodbus_cflags=""
2057 with_libmodbus_libs=""
2058 AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
2060         if test "x$withval" = "xno"
2061         then
2062                 with_libmodbus="no"
2063         else if test "x$withval" = "xyes"
2064         then
2065                 with_libmodbus="use_pkgconfig"
2066         else if test -d "$with_libmodbus/lib"
2067         then
2068                 AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
2069                 with_libmodbus_cflags="-I$withval/include"
2070                 with_libmodbus_libs="-L$withval/lib -lmodbus"
2071                 with_libmodbus="yes"
2072         fi; fi; fi
2073 ],
2074 [with_libmodbus="use_pkgconfig"])
2076 # configure using pkg-config
2077 if test "x$with_libmodbus" = "xuse_pkgconfig"
2078 then
2079         if test "x$PKG_CONFIG" = "x"
2080         then
2081                 with_libmodbus="no (Don't have pkg-config)"
2082         fi
2083 fi
2084 if test "x$with_libmodbus" = "xuse_pkgconfig"
2085 then
2086         AC_MSG_NOTICE([Checking for modbus using $PKG_CONFIG])
2087         $PKG_CONFIG --exists 'modbus' 2>/dev/null
2088         if test $? -ne 0
2089         then
2090                 with_libmodbus="no (pkg-config doesn't know modbus)"
2091         fi
2092 fi
2093 if test "x$with_libmodbus" = "xuse_pkgconfig"
2094 then
2095         with_libmodbus_cflags="`$PKG_CONFIG --cflags 'modbus'`"
2096         if test $? -ne 0
2097         then
2098                 with_libmodbus="no ($PKG_CONFIG failed)"
2099         fi
2100         with_libmodbus_libs="`$PKG_CONFIG --libs 'modbus'`"
2101         if test $? -ne 0
2102         then
2103                 with_libmodbus="no ($PKG_CONFIG failed)"
2104         fi
2105 fi
2106 if test "x$with_libmodbus" = "xuse_pkgconfig"
2107 then
2108         with_libmodbus="yes"
2109 fi
2111 # with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do
2112 # the actual checks.
2113 if test "x$with_libmodbus" = "xyes"
2114 then
2115         SAVE_CPPFLAGS="$CPPFLAGS"
2116         CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
2118         AC_CHECK_HEADERS(modbus/modbus.h, [], [with_libmodbus="no (modbus/modbus.h not found)"])
2120         CPPFLAGS="$SAVE_CPPFLAGS"
2121 fi
2122 if test "x$with_libmodbus" = "xyes"
2123 then
2124         SAVE_CPPFLAGS="$CPPFLAGS"
2125         SAVE_LDFLAGS="$LDFLAGS"
2127         CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
2128         LDFLAGS="$LDFLAGS $with_libmodbus_libs"
2130         AC_CHECK_LIB(modbus, modbus_connect,
2131                      [with_libmodbus="yes"],
2132                      [with_libmodbus="no (symbol modbus_connect not found)"])
2134         CPPFLAGS="$SAVE_CPPFLAGS"
2135         LDFLAGS="$SAVE_LDFLAGS"
2136 fi
2137 if test "x$with_libmodbus" = "xyes"
2138 then
2139         BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
2140         BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
2141         AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS)
2142         AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS)
2143 fi
2144 # }}}
2146 # --with-libmysql {{{
2147 with_mysql_config="mysql_config"
2148 with_mysql_cflags=""
2149 with_mysql_libs=""
2150 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
2152         if test "x$withval" = "xno"
2153         then
2154                 with_libmysql="no"
2155         else if test "x$withval" = "xyes"
2156         then
2157                 with_libmysql="yes"
2158         else
2159                 if test -f "$withval" && test -x "$withval";
2160                 then
2161                         with_mysql_config="$withval"
2162                 else if test -x "$withval/bin/mysql_config"
2163                 then
2164                         with_mysql_config="$withval/bin/mysql_config"
2165                 fi; fi
2166                 with_libmysql="yes"
2167         fi; fi
2168 ],
2170         with_libmysql="yes"
2171 ])
2172 if test "x$with_libmysql" = "xyes"
2173 then
2174         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
2175         mysql_config_status=$?
2177         if test $mysql_config_status -ne 0
2178         then
2179                 with_libmysql="no ($with_mysql_config failed)"
2180         else
2181                 SAVE_CPPFLAGS="$CPPFLAGS"
2182                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
2184                 have_mysql_h="no"
2185                 have_mysql_mysql_h="no"
2186                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
2188                 if test "x$have_mysql_h" = "xno"
2189                 then
2190                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
2191                 fi
2193                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
2194                 then
2195                         with_libmysql="no (mysql.h not found)"
2196                 fi
2198                 CPPFLAGS="$SAVE_CPPFLAGS"
2199         fi
2200 fi
2201 if test "x$with_libmysql" = "xyes"
2202 then
2203         with_mysql_libs=`$with_mysql_config --libs 2>/dev/null`
2204         mysql_config_status=$?
2206         if test $mysql_config_status -ne 0
2207         then
2208                 with_libmysql="no ($with_mysql_config failed)"
2209         else
2210                 AC_CHECK_LIB(mysqlclient, mysql_init,
2211                  [with_libmysql="yes"],
2212                  [with_libmysql="no (symbol 'mysql_init' not found)"],
2213                  [$with_mysql_libs])
2215                 AC_CHECK_LIB(mysqlclient, mysql_get_server_version,
2216                  [with_libmysql="yes"],
2217                  [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
2218                  [$with_mysql_libs])
2219         fi
2220 fi
2221 if test "x$with_libmysql" = "xyes"
2222 then
2223         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
2224         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
2225         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
2226         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
2227 fi
2228 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
2229 # }}}
2231 # --with-libnetlink {{{
2232 with_libnetlink_cflags=""
2233 with_libnetlink_libs="-lnetlink"
2234 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
2236  echo "libnetlink: withval = $withval"
2237  if test "x$withval" = "xyes"
2238  then
2239          with_libnetlink="yes"
2240  else if test "x$withval" = "xno"
2241  then
2242          with_libnetlink="no"
2243  else
2244          if test -d "$withval/include"
2245          then
2246                  with_libnetlink_cflags="-I$withval/include"
2247                  with_libnetlink_libs="-L$withval/lib -lnetlink"
2248                  with_libnetlink="yes"
2249          else
2250                  AC_MSG_ERROR("no such directory: $withval/include")
2251          fi
2252  fi; fi
2253 ],
2255  if test "x$ac_system" = "xLinux"
2256  then
2257          with_libnetlink="yes"
2258  else
2259          with_libnetlink="no (Linux only library)"
2260  fi
2261 ])
2262 if test "x$with_libnetlink" = "xyes"
2263 then
2264         SAVE_CFLAGS="$CFLAGS"
2265         CFLAGS="$CFLAGS $with_libnetlink_cflags"
2267         with_libnetlink="no (libnetlink.h not found)"
2269         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
2270         [
2271          with_libnetlink="yes"
2272          break
2273         ], [],
2274 [#include <stdio.h>
2275 #include <sys/types.h>
2276 #include <asm/types.h>
2277 #include <sys/socket.h>
2278 #include <linux/netlink.h>
2279 #include <linux/rtnetlink.h>])
2280         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
2281 [#include <stdio.h>
2282 #include <sys/types.h>
2283 #include <asm/types.h>
2284 #include <sys/socket.h>])
2286         AC_COMPILE_IFELSE(
2287 [#include <stdio.h>
2288 #include <sys/types.h>
2289 #include <asm/types.h>
2290 #include <sys/socket.h>
2291 #include <linux/netlink.h>
2292 #include <linux/rtnetlink.h>
2294 int main (void)
2296         int retval = TCA_STATS2;
2297         return (retval);
2298 }],
2299         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
2300         []);
2302         AC_COMPILE_IFELSE(
2303 [#include <stdio.h>
2304 #include <sys/types.h>
2305 #include <asm/types.h>
2306 #include <sys/socket.h>
2307 #include <linux/netlink.h>
2308 #include <linux/rtnetlink.h>
2310 int main (void)
2312         int retval = TCA_STATS;
2313         return (retval);
2314 }],
2315         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
2316         []);
2318         CFLAGS="$SAVE_CFLAGS"
2319 fi
2320 if test "x$with_libnetlink" = "xyes"
2321 then
2322         AC_CHECK_LIB(netlink, rtnl_open,
2323                      [with_libnetlink="yes"],
2324                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
2325                      [$with_libnetlink_libs])
2326 fi
2327 if test "x$with_libnetlink" = "xyes"
2328 then
2329         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
2330         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
2331         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
2332         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
2333 fi
2334 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
2335 # }}}
2337 # --with-libnetapp {{{
2338 AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
2339 AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
2340 AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
2341 LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS"
2342 LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS"
2343 LIBNETAPP_LIBS="$LIBNETAPP_LIBS"
2344 AC_ARG_WITH(libnetapp, [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
2346  if test -d "$withval"
2347  then
2348          LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
2349          LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
2350          with_libnetapp="yes"
2351  else
2352          with_libnetapp="$withval"
2353  fi
2354 ],
2356  with_libnetapp="yes"
2357 ])
2359 SAVE_CPPFLAGS="$CPPFLAGS"
2360 SAVE_LDFLAGS="$LDFLAGS"
2361 CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
2362 LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
2364 if test "x$with_libnetapp" = "xyes"
2365 then
2366         if test "x$LIBNETAPP_CPPFLAGS" != "x"
2367         then
2368                 AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
2369         fi
2370         AC_CHECK_HEADERS(netapp_api.h,
2371                 [with_libnetapp="yes"],
2372                 [with_libnetapp="no (netapp_api.h not found)"])
2373 fi
2375 if test "x$with_libnetapp" = "xyes"
2376 then
2377         if test "x$LIBNETAPP_LDFLAGS" != "x"
2378         then
2379                 AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
2380         fi
2382         if test "x$LIBNETAPP_LIBS" = "x"
2383         then
2384                 LIBNETAPP_LIBS="-lpthread -lxml -ladt -lssl -lm -lcrypto -lz"
2385         fi
2386         AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
2388         AC_CHECK_LIB(netapp, na_server_invoke_elem,
2389                 [with_libnetapp="yes"],
2390                 [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
2391                 [$LIBNETAPP_LIBS])
2392         LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
2393 fi
2395 CPPFLAGS="$SAVE_CPPFLAGS"
2396 LDFLAGS="$SAVE_LDFLAGS"
2398 if test "x$with_libnetapp" = "xyes"
2399 then
2400         AC_DEFINE(HAVE_LIBNETAPP, 1, [Define to 1 if you have the netapp library (-lnetapp).])
2401 fi
2403 AC_SUBST(LIBNETAPP_CPPFLAGS)
2404 AC_SUBST(LIBNETAPP_LDFLAGS)
2405 AC_SUBST(LIBNETAPP_LIBS)
2406 AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
2407 # }}}
2409 # --with-libnetsnmp {{{
2410 with_snmp_config="net-snmp-config"
2411 with_snmp_cflags=""
2412 with_snmp_libs=""
2413 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
2415         if test "x$withval" = "xno"
2416         then
2417                 with_libnetsnmp="no"
2418         else if test "x$withval" = "xyes"
2419         then
2420                 with_libnetsnmp="yes"
2421         else
2422                 if test -x "$withval"
2423                 then
2424                         with_snmp_config="$withval"
2425                         with_libnetsnmp="yes"
2426                 else
2427                         with_snmp_config="$withval/bin/net-snmp-config"
2428                         with_libnetsnmp="yes"
2429                 fi
2430         fi; fi
2431 ],
2432 [with_libnetsnmp="yes"])
2433 if test "x$with_libnetsnmp" = "xyes"
2434 then
2435         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
2436         snmp_config_status=$?
2438         if test $snmp_config_status -ne 0
2439         then
2440                 with_libnetsnmp="no ($with_snmp_config failed)"
2441         else
2442                 SAVE_CPPFLAGS="$CPPFLAGS"
2443                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
2444                 
2445                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
2447                 CPPFLAGS="$SAVE_CPPFLAGS"
2448         fi
2449 fi
2450 if test "x$with_libnetsnmp" = "xyes"
2451 then
2452         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
2453         snmp_config_status=$?
2455         if test $snmp_config_status -ne 0
2456         then
2457                 with_libnetsnmp="no ($with_snmp_config failed)"
2458         else
2459                 AC_CHECK_LIB(netsnmp, init_snmp,
2460                 [with_libnetsnmp="yes"],
2461                 [with_libnetsnmp="no (libnetsnmp not found)"],
2462                 [$with_snmp_libs])
2463         fi
2464 fi
2465 if test "x$with_libnetsnmp" = "xyes"
2466 then
2467         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
2468         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
2469         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
2470         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
2471 fi
2472 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
2473 # }}}
2475 # --with-liboconfig {{{
2476 with_own_liboconfig="no"
2477 liboconfig_LDFLAGS="$LDFLAGS"
2478 liboconfig_CPPFLAGS="$CPPFLAGS"
2479 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
2481         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2482         then
2483                 if test -d "$withval/lib"
2484                 then
2485                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
2486                 fi
2487                 if test -d "$withval/include"
2488                 then
2489                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
2490                 fi
2491         fi
2492         if test "x$withval" = "xno"
2493         then
2494                 AC_MSG_ERROR("liboconfig is required")
2495         fi
2496 ],
2498         with_liboconfig="yes"
2499 ])
2501 save_LDFLAGS="$LDFLAGS"
2502 save_CPPFLAGS="$CPPFLAGS"
2503 LDFLAGS="$liboconfig_LDFLAGS"
2504 CPPFLAGS="$liboconfig_CPPFLAGS"
2505 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
2507         with_liboconfig="yes"
2508         with_own_liboconfig="no"
2509 ],
2511         with_liboconfig="yes"
2512         with_own_liboconfig="yes"
2513         LDFLAGS="$save_LDFLAGS"
2514         CPPFLAGS="$save_CPPFLAGS"
2515 ])
2517 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
2518 if test "x$with_own_liboconfig" = "xyes"
2519 then
2520         with_liboconfig="yes (shipped version)"
2521 fi
2522 # }}}
2524 # --with-liboping {{{
2525 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
2527  if test "x$withval" = "xyes"
2528  then
2529          with_liboping="yes"
2530  else if test "x$withval" = "xno"
2531  then
2532          with_liboping="no"
2533  else
2534          with_liboping="yes"
2535          LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
2536          LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
2537  fi; fi
2538 ],
2539 [with_liboping="yes"])
2541 SAVE_CPPFLAGS="$CPPFLAGS"
2542 SAVE_LDFLAGS="$LDFLAGS"
2544 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
2545 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
2547 if test "x$with_liboping" = "xyes"
2548 then
2549         if test "x$LIBOPING_CPPFLAGS" != "x"
2550         then
2551                 AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
2552         fi
2553         AC_CHECK_HEADERS(oping.h,
2554         [with_liboping="yes"],
2555         [with_liboping="no (oping.h not found)"])
2556 fi
2557 if test "x$with_liboping" = "xyes"
2558 then
2559         if test "x$LIBOPING_LDFLAGS" != "x"
2560         then
2561                 AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
2562         fi
2563         AC_CHECK_LIB(oping, ping_construct,
2564         [with_liboping="yes"],
2565         [with_liboping="no (symbol 'ping_construct' not found)"])
2566 fi
2568 CPPFLAGS="$SAVE_CPPFLAGS"
2569 LDFLAGS="$SAVE_LDFLAGS"
2571 if test "x$with_liboping" = "xyes"
2572 then
2573         BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
2574         BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
2575         AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
2576         AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
2577 fi
2578 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
2579 # }}}
2581 # --with-oracle {{{
2582 with_oracle_cppflags=""
2583 with_oracle_libs=""
2584 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
2586         if test "x$withval" = "xyes"
2587         then
2588                 if test "x$ORACLE_HOME" = "x"
2589                 then
2590                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
2591                 fi
2592                 with_oracle="yes"
2593         else if test "x$withval" = "xno"
2594         then
2595                 with_oracle="no"
2596         else
2597                 with_oracle="yes"
2598                 ORACLE_HOME="$withval"
2599         fi; fi
2600 ],
2602         if test "x$ORACLE_HOME" = "x"
2603         then
2604                 with_oracle="no (ORACLE_HOME is not set)"
2605         else
2606                 with_oracle="yes"
2607         fi
2608 ])
2609 if test "x$ORACLE_HOME" != "x"
2610 then
2611         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
2613         if test -e "$ORACLE_HOME/lib/ldflags"
2614         then
2615                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
2616         fi
2617         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
2618         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
2619 fi
2620 if test "x$with_oracle" = "xyes"
2621 then
2622         SAVE_CPPFLAGS="$CPPFLAGS"
2623         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
2625         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
2627         CPPFLAGS="$SAVE_CPPFLAGS"
2628 fi
2629 if test "x$with_oracle" = "xyes"
2630 then
2631         SAVE_CPPFLAGS="$CPPFLAGS"
2632         SAVE_LDFLAGS="$LDFLAGS"
2633         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
2634         LDFLAGS="$LDFLAGS $with_oracle_libs"
2636         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
2638         CPPFLAGS="$SAVE_CPPFLAGS"
2639         LDFLAGS="$SAVE_LDFLAGS"
2640 fi
2641 if test "x$with_oracle" = "xyes"
2642 then
2643         BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
2644         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
2645         AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
2646         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
2647 fi
2648 # }}}
2650 # --with-libowcapi {{{
2651 with_libowcapi_cppflags=""
2652 with_libowcapi_libs="-lowcapi"
2653 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
2655         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2656         then
2657                 with_libowcapi_cppflags="-I$withval/include"
2658                 with_libowcapi_libs="-L$withval/lib -lowcapi"
2659                 with_libowcapi="yes"
2660         else
2661                 with_libowcapi="$withval"
2662         fi
2663 ],
2665         with_libowcapi="yes"
2666 ])
2667 if test "x$with_libowcapi" = "xyes"
2668 then
2669         SAVE_CPPFLAGS="$CPPFLAGS"
2670         CPPFLAGS="$with_libowcapi_cppflags"
2671         
2672         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
2674         CPPFLAGS="$SAVE_CPPFLAGS"
2675 fi
2676 if test "x$with_libowcapi" = "xyes"
2677 then
2678         SAVE_LDFLAGS="$LDFLAGS"
2679         SAVE_CPPFLAGS="$CPPFLAGS"
2680         LDFLAGS="$with_libowcapi_libs"
2681         CPPFLAGS="$with_libowcapi_cppflags"
2682         
2683         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
2685         LDFLAGS="$SAVE_LDFLAGS"
2686         CPPFLAGS="$SAVE_CPPFLAGS"
2687 fi
2688 if test "x$with_libowcapi" = "xyes"
2689 then
2690         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
2691         BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
2692         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
2693         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
2694 fi
2695 # }}}
2697 # --with-libpcap {{{
2698 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
2700         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2701         then
2702                 LDFLAGS="$LDFLAGS -L$withval/lib"
2703                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2704                 with_libpcap="yes"
2705         else
2706                 with_libpcap="$withval"
2707         fi
2708 ],
2710         with_libpcap="yes"
2711 ])
2712 if test "x$with_libpcap" = "xyes"
2713 then
2714         AC_CHECK_LIB(pcap, pcap_open_live,
2715         [
2716                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
2717         ], [with_libpcap="no (libpcap not found)"])
2718 fi
2719 if test "x$with_libpcap" = "xyes"
2720 then
2721         AC_CHECK_HEADERS(pcap.h,,
2722                          [with_libpcap="no (pcap.h not found)"])
2723 fi
2724 if test "x$with_libpcap" = "xyes"
2725 then
2726         AC_CHECK_HEADERS(pcap-bpf.h,,
2727                          [with_libpcap="no (pcap-bpf.h not found)"])
2728 fi
2729 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
2730 # }}}
2732 # --with-libperl {{{
2733 perl_interpreter="perl"
2734 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
2736         if test -x "$withval"
2737         then
2738                 perl_interpreter="$withval"
2739                 with_libperl="yes"
2740         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
2741         then
2742                 LDFLAGS="$LDFLAGS -L$withval/lib"
2743                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2744                 perl_interpreter="$withval/bin/perl"
2745                 with_libperl="yes"
2746         else
2747                 with_libperl="$withval"
2748         fi; fi
2749 ],
2751         with_libperl="yes"
2752 ])
2754 AC_MSG_CHECKING([for perl])
2755 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
2756 if test -x "$perl_interpreter"
2757 then
2758         AC_MSG_RESULT([yes ($perl_interpreter)])
2759 else
2760         perl_interpreter=""
2761         AC_MSG_RESULT([no])
2762 fi
2764 AC_SUBST(PERL, "$perl_interpreter")
2766 if test "x$with_libperl" = "xyes" \
2767         && test -n "$perl_interpreter"
2768 then
2769   SAVE_CFLAGS="$CFLAGS"
2770   SAVE_LDFLAGS="$LDFLAGS"
2771 dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
2772   PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
2773   PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
2774   CFLAGS="$CFLAGS $PERL_CFLAGS"
2775   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2777   AC_CACHE_CHECK([for libperl],
2778     [c_cv_have_libperl],
2779     AC_LINK_IFELSE(
2780       AC_LANG_PROGRAM(
2781       [[
2782 #define PERL_NO_GET_CONTEXT
2783 #include <EXTERN.h>
2784 #include <perl.h>
2785 #include <XSUB.h>
2786       ]],
2787       [[
2788        dTHX;
2789        load_module (PERL_LOADMOD_NOIMPORT,
2790                          newSVpv ("Collectd::Plugin::FooBar", 24),
2791                          Nullsv);
2792       ]]),
2793       [c_cv_have_libperl="yes"],
2794       [c_cv_have_libperl="no"]
2795     )
2796   )
2798   if test "x$c_cv_have_libperl" = "xyes"
2799   then
2800           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
2801           AC_SUBST(PERL_CFLAGS)
2802           AC_SUBST(PERL_LDFLAGS)
2803   else
2804           with_libperl="no"
2805   fi
2807   CFLAGS="$SAVE_CFLAGS"
2808   LDFLAGS="$SAVE_LDFLAGS"
2809 else if test -z "$perl_interpreter"; then
2810   with_libperl="no (no perl interpreter found)"
2811   c_cv_have_libperl="no"
2812 fi; fi
2813 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
2815 if test "x$with_libperl" = "xyes"
2816 then
2817         SAVE_CFLAGS="$CFLAGS"
2818         SAVE_LDFLAGS="$LDFLAGS"
2819         CFLAGS="$CFLAGS $PERL_CFLAGS"
2820         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2822         AC_CACHE_CHECK([if perl supports ithreads],
2823                 [c_cv_have_perl_ithreads],
2824                 AC_LINK_IFELSE(
2825                         AC_LANG_PROGRAM(
2826                         [[
2827 #include <EXTERN.h>
2828 #include <perl.h>
2829 #include <XSUB.h>
2831 #if !defined(USE_ITHREADS)
2832 # error "Perl does not support ithreads!"
2833 #endif /* !defined(USE_ITHREADS) */
2834                         ]],
2835                         [[ ]]),
2836                         [c_cv_have_perl_ithreads="yes"],
2837                         [c_cv_have_perl_ithreads="no"]
2838                 )
2839         )
2841         if test "x$c_cv_have_perl_ithreads" = "xyes"
2842         then
2843                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
2844         fi
2846         CFLAGS="$SAVE_CFLAGS"
2847         LDFLAGS="$SAVE_LDFLAGS"
2848 fi
2850 if test "x$with_libperl" = "xyes"
2851 then
2852         SAVE_CFLAGS="$CFLAGS"
2853         SAVE_LDFLAGS="$LDFLAGS"
2854         # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
2855         # (see issues #41 and #42)
2856         CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
2857         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2859         AC_CACHE_CHECK([for broken Perl_load_module()],
2860                 [c_cv_have_broken_perl_load_module],
2861                 AC_LINK_IFELSE(
2862                         AC_LANG_PROGRAM(
2863                         [[
2864 #define PERL_NO_GET_CONTEXT
2865 #include <EXTERN.h>
2866 #include <perl.h>
2867 #include <XSUB.h>
2868                         ]],
2869                         [[
2870                          dTHX;
2871                          load_module (PERL_LOADMOD_NOIMPORT,
2872                              newSVpv ("Collectd::Plugin::FooBar", 24),
2873                              Nullsv);
2874                         ]]),
2875                         [c_cv_have_broken_perl_load_module="no"],
2876                         [c_cv_have_broken_perl_load_module="yes"]
2877                 )
2878         )
2880         CFLAGS="$SAVE_CFLAGS"
2881         LDFLAGS="$SAVE_LDFLAGS"
2882 fi
2883 AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
2884                 test "x$c_cv_have_broken_perl_load_module" = "xyes")
2886 if test "x$with_libperl" = "xyes"
2887 then
2888         SAVE_CFLAGS="$CFLAGS"
2889         SAVE_LDFLAGS="$LDFLAGS"
2890         CFLAGS="$CFLAGS $PERL_CFLAGS"
2891         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2893         AC_CHECK_MEMBER(
2894                 [struct mgvtbl.svt_local],
2895                 [have_struct_mgvtbl_svt_local="yes"],
2896                 [have_struct_mgvtbl_svt_local="no"],
2897                 [
2898 #include <EXTERN.h>
2899 #include <perl.h>
2900 #include <XSUB.h>
2901                 ])
2903         if test "x$have_struct_mgvtbl_svt_local" = "xyes"
2904         then
2905                 AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
2906                                   [Define if Perl's struct mgvtbl has member svt_local.])
2907         fi
2909         CFLAGS="$SAVE_CFLAGS"
2910         LDFLAGS="$SAVE_LDFLAGS"
2911 fi
2912 # }}}
2914 # --with-libpq {{{
2915 with_pg_config="pg_config"
2916 with_libpq_includedir=""
2917 with_libpq_libdir=""
2918 with_libpq_cppflags=""
2919 with_libpq_ldflags=""
2920 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
2921         [Path to libpq.])],
2923         if test "x$withval" = "xno"
2924         then
2925                 with_libpq="no"
2926         else if test "x$withval" = "xyes"
2927         then
2928                 with_libpq="yes"
2929         else
2930                 if test -f "$withval" && test -x "$withval";
2931                 then
2932                         with_pg_config="$withval"
2933                 else if test -x "$withval/bin/pg_config"
2934                 then
2935                         with_pg_config="$withval/bin/pg_config"
2936                 fi; fi
2937                 with_libpq="yes"
2938         fi; fi
2939 ],
2941         with_libpq="yes"
2942 ])
2943 if test "x$with_libpq" = "xyes"
2944 then
2945         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
2946         pg_config_status=$?
2948         if test $pg_config_status -eq 0
2949         then
2950                 if test -n "$with_libpq_includedir"; then
2951                         for dir in $with_libpq_includedir; do
2952                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
2953                         done
2954                 fi
2955         else
2956                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2957         fi
2959         SAVE_CPPFLAGS="$CPPFLAGS"
2960         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
2962         AC_CHECK_HEADERS(libpq-fe.h, [],
2963                 [with_libpq="no (libpq-fe.h not found)"], [])
2965         CPPFLAGS="$SAVE_CPPFLAGS"
2966 fi
2967 if test "x$with_libpq" = "xyes"
2968 then
2969         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
2970         pg_config_status=$?
2972         if test $pg_config_status -eq 0
2973         then
2974                 if test -n "$with_libpq_libdir"; then
2975                         for dir in $with_libpq_libdir; do
2976                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
2977                         done
2978                 fi
2979         else
2980                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2981         fi
2983         SAVE_LDFLAGS="$LDFLAGS"
2984         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
2986         AC_CHECK_LIB(pq, PQconnectdb,
2987                 [with_libpq="yes"],
2988                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
2990         AC_CHECK_LIB(pq, PQserverVersion,
2991                 [with_libpq="yes"],
2992                 [with_libpq="no (symbol 'PQserverVersion' not found)"])
2994         LDFLAGS="$SAVE_LDFLAGS"
2995 fi
2996 if test "x$with_libpq" = "xyes"
2997 then
2998         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
2999         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
3000         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
3001         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
3002 fi
3003 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
3004 # }}}
3006 # --with-libpthread {{{
3007 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
3008 [       if test "x$withval" != "xno" \
3009                 && test "x$withval" != "xyes"
3010         then
3011                 LDFLAGS="$LDFLAGS -L$withval/lib"
3012                 CPPFLAGS="$CPPFLAGS -I$withval/include"
3013                 with_libpthread="yes"
3014         else
3015                 if test "x$withval" = "xno"
3016                 then
3017                         with_libpthread="no (disabled)"
3018                 fi
3019         fi
3020 ], [with_libpthread="yes"])
3021 if test "x$with_libpthread" = "xyes"
3022 then
3023         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
3024 fi
3026 if test "x$with_libpthread" = "xyes"
3027 then
3028         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
3029 fi
3030 if test "x$with_libpthread" = "xyes"
3031 then
3032         collect_pthread=1
3033 else
3034         collect_pthread=0
3035 fi
3036 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
3037         [Wether or not to use pthread (POSIX threads) library])
3038 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
3039 # }}}
3041 # --with-python {{{
3042 with_python_prog=""
3043 with_python_path="$PATH"
3044 AC_ARG_WITH(python, [AS_HELP_STRING([--with-python@<:@=PREFIX@:>@], [Path to the python interpreter.])],
3046  if test "x$withval" = "xyes" || test "x$withval" = "xno"
3047  then
3048          with_python="$withval"
3049  else if test -x "$withval"
3050  then
3051          with_python_prog="$withval"
3052          with_python_path="`dirname \"$withval\"`$PATH_SEPARATOR$with_python_path"
3053          with_python="yes"
3054  else if test -d "$withval"
3055  then
3056          with_python_path="$withval$PATH_SEPARATOR$with_python_path"
3057          with_python="yes"
3058  else
3059          AC_MSG_WARN([Argument not recognized: $withval])
3060  fi; fi; fi
3061 ], [with_python="yes"])
3063 SAVE_PATH="$PATH"
3064 SAVE_CPPFLAGS="$CPPFLAGS"
3065 SAVE_LDFLAGS="$LDFLAGS"
3066 SAVE_LIBS="$LIBS"
3068 PATH="$with_python_path"
3070 if test "x$with_python" = "xyes" && test "x$with_python_prog" = "x"
3071 then
3072         AC_MSG_CHECKING([for python])
3073         with_python_prog="`which python 2>/dev/null`"
3074         if test "x$with_python_prog" = "x"
3075         then
3076                 AC_MSG_RESULT([not found])
3077                 with_python="no (interpreter not found)"
3078         else
3079                 AC_MSG_RESULT([$with_python_prog])
3080         fi
3081 fi
3083 if test "x$with_python" = "xyes"
3084 then
3085         AC_MSG_CHECKING([for Python CPPFLAGS])
3086         python_include_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_python_inc())" | "$with_python_prog" 2>&1`
3087         python_config_status=$?
3089         if test "$python_config_status" -ne 0 || test "x$python_include_path" = "x"
3090         then
3091                 AC_MSG_RESULT([failed with status $python_config_status (output: $python_include_path)])
3092                 with_python="no"
3093         else
3094                 AC_MSG_RESULT([$python_include_path])
3095         fi
3096 fi
3098 if test "x$with_python" = "xyes"
3099 then
3100         CPPFLAGS="-I$python_include_path $CPPFLAGS"
3101         AC_CHECK_HEADERS(Python.h,
3102                          [with_python="yes"],
3103                          [with_python="no ('Python.h' not found)"])
3104 fi
3106 if test "x$with_python" = "xyes"
3107 then
3108         AC_MSG_CHECKING([for Python LDFLAGS])
3109         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`
3110         python_config_status=$?
3112         if test "$python_config_status" -ne 0 || test "x$python_library_path" = "x"
3113         then
3114                 AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_path)])
3115                 with_python="no"
3116         else
3117                 AC_MSG_RESULT([$python_library_path])
3118         fi
3119 fi
3121 if test "x$with_python" = "xyes"
3122 then
3123         AC_MSG_CHECKING([for Python LIBS])
3124         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`
3125         python_config_status=$?
3127         if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
3128         then
3129                 AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_flags)])
3130                 with_python="no"
3131         else
3132                 AC_MSG_RESULT([$python_library_flags])
3133         fi
3134 fi
3136 if test "x$with_python" = "xyes"
3137 then
3138         LDFLAGS="-L$python_library_path $LDFLAGS"
3139         LIBS="$python_library_flags $LIBS"
3141         AC_CHECK_FUNC(PyObject_CallFunction,
3142                       [with_python="yes"],
3143                       [with_python="no (Symbol 'PyObject_CallFunction' not found)"])
3144 fi
3146 PATH="$SAVE_PATH"
3147 CPPFLAGS="$SAVE_CPPFLAGS"
3148 LDFLAGS="$SAVE_LDFLAGS"
3149 LIBS="$SAVE_LIBS"
3151 if test "x$with_python" = "xyes"
3152 then
3153         BUILD_WITH_PYTHON_CPPFLAGS="-I$python_include_path"
3154         BUILD_WITH_PYTHON_LDFLAGS="-L$python_library_path"
3155         BUILD_WITH_PYTHON_LIBS="$python_library_flags"
3156         AC_SUBST(BUILD_WITH_PYTHON_CPPFLAGS)
3157         AC_SUBST(BUILD_WITH_PYTHON_LDFLAGS)
3158         AC_SUBST(BUILD_WITH_PYTHON_LIBS)
3159 fi
3160 # }}} --with-python
3162 # --with-librabbitmq {{{
3163 with_librabbitmq_cppflags=""
3164 with_librabbitmq_ldflags=""
3165 AC_ARG_WITH(librabbitmq, [AS_HELP_STRING([--with-librabbitmq@<:@=PREFIX@:>@], [Path to librabbitmq.])],
3167         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3168         then
3169                 with_librabbitmq_cppflags="-I$withval/include"
3170                 with_librabbitmq_ldflags="-L$withval/lib"
3171                 with_librabbitmq="yes"
3172         else
3173                 with_librabbitmq="$withval"
3174         fi
3175 ],
3177         with_librabbitmq="yes"
3178 ])
3179 if test "x$with_librabbitmq" = "xyes"
3180 then
3181         SAVE_CPPFLAGS="$CPPFLAGS"
3182         CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
3184         AC_CHECK_HEADERS(amqp.h, [with_librabbitmq="yes"], [with_librabbitmq="no (amqp.h not found)"])
3186         CPPFLAGS="$SAVE_CPPFLAGS"
3187 fi
3188 if test "x$with_librabbitmq" = "xyes"
3189 then
3190         SAVE_CPPFLAGS="$CPPFLAGS"
3191         SAVE_LDFLAGS="$LDFLAGS"
3192         CPPFLAGS="$CPPFLAGS $with_librabbitmq_cppflags"
3193         LDFLAGS="$LDFLAGS $with_librabbitmq_ldflags"
3195         AC_CHECK_LIB(rabbitmq, amqp_basic_publish, [with_librabbitmq="yes"], [with_librabbitmq="no (Symbol 'amqp_basic_publish' not found)"])
3197         CPPFLAGS="$SAVE_CPPFLAGS"
3198         LDFLAGS="$SAVE_LDFLAGS"
3199 fi
3200 if test "x$with_librabbitmq" = "xyes"
3201 then
3202         BUILD_WITH_LIBRABBITMQ_CPPFLAGS="$with_librabbitmq_cppflags"
3203         BUILD_WITH_LIBRABBITMQ_LDFLAGS="$with_librabbitmq_ldflags"
3204         BUILD_WITH_LIBRABBITMQ_LIBS="-lrabbitmq"
3205         AC_SUBST(BUILD_WITH_LIBRABBITMQ_CPPFLAGS)
3206         AC_SUBST(BUILD_WITH_LIBRABBITMQ_LDFLAGS)
3207         AC_SUBST(BUILD_WITH_LIBRABBITMQ_LIBS)
3208         AC_DEFINE(HAVE_LIBRABBITMQ, 1, [Define if librabbitmq is present and usable.])
3209 fi
3210 AM_CONDITIONAL(BUILD_WITH_LIBRABBITMQ, test "x$with_librabbitmq" = "xyes")
3211 # }}}
3213 # --with-librouteros {{{
3214 AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
3216  if test "x$withval" = "xyes"
3217  then
3218          with_librouteros="yes"
3219  else if test "x$withval" = "xno"
3220  then
3221          with_librouteros="no"
3222  else
3223          with_librouteros="yes"
3224          LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS -I$withval/include"
3225          LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS -L$withval/lib"
3226  fi; fi
3227 ],
3228 [with_librouteros="yes"])
3230 SAVE_CPPFLAGS="$CPPFLAGS"
3231 SAVE_LDFLAGS="$LDFLAGS"
3233 CPPFLAGS="$CPPFLAGS $LIBROUTEROS_CPPFLAGS"
3234 LDFLAGS="$LDFLAGS $LIBROUTEROS_LDFLAGS"
3236 if test "x$with_librouteros" = "xyes"
3237 then
3238         if test "x$LIBROUTEROS_CPPFLAGS" != "x"
3239         then
3240                 AC_MSG_NOTICE([librouteros CPPFLAGS: $LIBROUTEROS_CPPFLAGS])
3241         fi
3242         AC_CHECK_HEADERS(routeros_api.h,
3243         [with_librouteros="yes"],
3244         [with_librouteros="no (routeros_api.h not found)"])
3245 fi
3246 if test "x$with_librouteros" = "xyes"
3247 then
3248         if test "x$LIBROUTEROS_LDFLAGS" != "x"
3249         then
3250                 AC_MSG_NOTICE([librouteros LDFLAGS: $LIBROUTEROS_LDFLAGS])
3251         fi
3252         AC_CHECK_LIB(routeros, ros_interface,
3253         [with_librouteros="yes"],
3254         [with_librouteros="no (symbol 'ros_interface' not found)"])
3255 fi
3257 CPPFLAGS="$SAVE_CPPFLAGS"
3258 LDFLAGS="$SAVE_LDFLAGS"
3260 if test "x$with_librouteros" = "xyes"
3261 then
3262         BUILD_WITH_LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS"
3263         BUILD_WITH_LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS"
3264         AC_SUBST(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
3265         AC_SUBST(BUILD_WITH_LIBROUTEROS_LDFLAGS)
3266 fi
3267 AM_CONDITIONAL(BUILD_WITH_LIBROUTEROS, test "x$with_librouteros" = "xyes")
3268 # }}}
3270 # --with-librrd {{{
3271 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
3272 librrd_cflags=""
3273 librrd_ldflags=""
3274 librrd_threadsafe="yes"
3275 librrd_rrdc_update="no"
3276 AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
3277 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
3278         then
3279                 librrd_cflags="-I$withval/include"
3280                 librrd_ldflags="-L$withval/lib"
3281                 with_librrd="yes"
3282         else
3283                 with_librrd="$withval"
3284         fi
3285 ], [with_librrd="yes"])
3286 if test "x$with_librrd" = "xyes"
3287 then
3288         SAVE_CPPFLAGS="$CPPFLAGS"
3289         SAVE_LDFLAGS="$LDFLAGS"
3291         CPPFLAGS="$CPPFLAGS $librrd_cflags"
3292         LDFLAGS="$LDFLAGS $librrd_ldflags"
3294         AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
3296         CPPFLAGS="$SAVE_CPPFLAGS"
3297         LDFLAGS="$SAVE_LDFLAGS"
3298 fi
3299 if test "x$with_librrd" = "xyes"
3300 then
3301         SAVE_CPPFLAGS="$CPPFLAGS"
3302         SAVE_LDFLAGS="$LDFLAGS"
3304         CPPFLAGS="$CPPFLAGS $librrd_cflags"
3305         LDFLAGS="$LDFLAGS $librrd_ldflags"
3307         AC_CHECK_LIB(rrd_th, rrd_update_r,
3308         [with_librrd="yes"
3309          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
3310         ],
3311         [librrd_threadsafe="no"
3312          AC_CHECK_LIB(rrd, rrd_update,
3313          [with_librrd="yes"
3314           librrd_ldflags="$librrd_ldflags -lrrd -lm"
3315          ],
3316          [with_librrd="no (symbol 'rrd_update' not found)"],
3317          [-lm])
3318         ],
3319         [-lm])
3321         if test "x$librrd_threadsafe" = "xyes"
3322         then
3323                 AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
3324         else
3325                 AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
3326         fi
3328         CPPFLAGS="$SAVE_CPPFLAGS"
3329         LDFLAGS="$SAVE_LDFLAGS"
3330 fi
3331 if test "x$with_librrd" = "xyes"
3332 then
3333         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
3334         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
3335         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
3336         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
3337 fi
3338 if test "x$librrd_threadsafe" = "xyes"
3339 then
3340         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
3341 fi
3342 # }}}
3344 # --with-libsensors {{{
3345 with_sensors_cflags=""
3346 with_sensors_ldflags=""
3347 AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
3349         if test "x$withval" = "xno"
3350         then
3351                 with_libsensors="no"
3352         else
3353                 with_libsensors="yes"
3354                 if test "x$withval" != "xyes"
3355                 then
3356                         with_sensors_cflags="-I$withval/include"
3357                         with_sensors_ldflags="-L$withval/lib"
3358                         with_libsensors="yes"
3359                 fi
3360         fi
3361 ],
3363         if test "x$ac_system" = "xLinux"
3364         then
3365                 with_libsensors="yes"
3366         else
3367                 with_libsensors="no (Linux only library)"
3368         fi
3369 ])
3370 if test "x$with_libsensors" = "xyes"
3371 then
3372         SAVE_CPPFLAGS="$CPPFLAGS"
3373         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
3375 #       AC_CHECK_HEADERS(sensors/sensors.h,
3376 #       [
3377 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
3378 #       ],
3379 #       [with_libsensors="no (sensors/sensors.h not found)"])
3380         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
3382         CPPFLAGS="$SAVE_CPPFLAGS"
3383 fi
3384 if test "x$with_libsensors" = "xyes"
3385 then
3386         SAVE_CPPFLAGS="$CPPFLAGS"
3387         SAVE_LDFLAGS="$LDFLAGS"
3388         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
3389         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
3391         AC_CHECK_LIB(sensors, sensors_init,
3392         [
3393                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
3394         ],
3395         [with_libsensors="no (libsensors not found)"])
3397         CPPFLAGS="$SAVE_CPPFLAGS"
3398         LDFLAGS="$SAVE_LDFLAGS"
3399 fi
3400 if test "x$with_libsensors" = "xyes"
3401 then
3402         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
3403         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
3404         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
3405         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
3406 fi
3407 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
3408 # }}}
3410 # --with-libstatgrab {{{
3411 with_libstatgrab_cflags=""
3412 with_libstatgrab_ldflags=""
3413 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
3415  if test "x$withval" != "xno" \
3416    && test "x$withval" != "xyes"
3417  then
3418    with_libstatgrab_cflags="-I$withval/include"
3419    with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
3420    with_libstatgrab="yes"
3421    with_libstatgrab_pkg_config="no"
3422  else
3423    with_libstatgrab="$withval"
3424    with_libstatgrab_pkg_config="yes"
3425  fi
3426  ],
3428  with_libstatgrab="yes"
3429  with_libstatgrab_pkg_config="yes"
3430 ])
3432 if test "x$with_libstatgrab" = "xyes" \
3433   && test "x$with_libstatgrab_pkg_config" = "xyes"
3434 then
3435   if test "x$PKG_CONFIG" != "x"
3436   then
3437     AC_MSG_CHECKING([pkg-config for libstatgrab])
3438     temp_result="found"
3439     $PKG_CONFIG --exists libstatgrab 2>/dev/null
3440     if test "$?" != "0"
3441     then
3442       with_libstatgrab_pkg_config="no"
3443       with_libstatgrab="no (pkg-config doesn't know libstatgrab)"
3444       temp_result="not found"
3445     fi
3446     AC_MSG_RESULT([$temp_result])
3447   else
3448     AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
3449     with_libstatgrab_pkg_config="no"
3450     with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
3451   fi
3452 fi
3454 if test "x$with_libstatgrab" = "xyes" \
3455   && test "x$with_libstatgrab_pkg_config" = "xyes" \
3456   && test "x$with_libstatgrab_cflags" = "x"
3457 then
3458   AC_MSG_CHECKING([for libstatgrab CFLAGS])
3459   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
3460   if test "$?" = "0"
3461   then
3462     with_libstatgrab_cflags="$temp_result"
3463   else
3464     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
3465     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
3466   fi
3467   AC_MSG_RESULT([$temp_result])
3468 fi
3470 if test "x$with_libstatgrab" = "xyes" \
3471   && test "x$with_libstatgrab_pkg_config" = "xyes" \
3472   && test "x$with_libstatgrab_ldflags" = "x"
3473 then
3474   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
3475   temp_result="`$PKG_CONFIG --libs libstatgrab`"
3476   if test "$?" = "0"
3477   then
3478     with_libstatgrab_ldflags="$temp_result"
3479   else
3480     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
3481     temp_result="$PKG_CONFIG --libs libstatgrab failed"
3482   fi
3483   AC_MSG_RESULT([$temp_result])
3484 fi
3486 if test "x$with_libstatgrab" = "xyes"
3487 then
3488   SAVE_CPPFLAGS="$CPPFLAGS"
3489   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
3491   AC_CHECK_HEADERS(statgrab.h,
3492                    [with_libstatgrab="yes"],
3493                    [with_libstatgrab="no (statgrab.h not found)"])
3495   CPPFLAGS="$SAVE_CPPFLAGS"
3496 fi
3498 if test "x$with_libstatgrab" = "xyes"
3499 then
3500   SAVE_CFLAGS="$CFLAGS"
3501   SAVE_LDFLAGS="$LDFLAGS"
3503   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
3504   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
3506   AC_CHECK_LIB(statgrab, sg_init,
3507                [with_libstatgrab="yes"],
3508                [with_libstatgrab="no (symbol sg_init not found)"])
3510   CFLAGS="$SAVE_CFLAGS"
3511   LDFLAGS="$SAVE_LDFLAGS"
3512 fi
3514 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
3515 if test "x$with_libstatgrab" = "xyes"
3516 then
3517   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
3518   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
3519   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
3520   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
3521   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
3522 fi
3523 # }}}
3525 # --with-libtokyotyrant {{{
3526 with_libtokyotyrant_cppflags=""
3527 with_libtokyotyrant_ldflags=""
3528 with_libtokyotyrant_libs=""
3529 AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
3531   if test "x$withval" = "xno"
3532   then
3533     with_libtokyotyrant="no"
3534   else if test "x$withval" = "xyes"
3535   then
3536     with_libtokyotyrant="yes"
3537   else
3538     with_libtokyotyrant_cppflags="-I$withval/include"
3539     with_libtokyotyrant_ldflags="-L$withval/include"
3540     with_libtokyotyrant_libs="-ltokyotyrant"
3541     with_libtokyotyrant="yes"
3542   fi; fi
3543 ],
3545   with_libtokyotyrant="yes"
3546 ])
3548 if test "x$with_libtokyotyrant" = "xyes"
3549 then
3550   if $PKG_CONFIG --exists tokyotyrant
3551   then
3552     with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
3553     with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `pkg-config --libs-only-L tokyotyrant`"
3554     with_libtokyotyrant_libs="$with_libtokyotyrant_libs `pkg-config --libs-only-l tokyotyrant`"
3555   fi
3556 fi
3558 SAVE_CPPFLAGS="$CPPFLAGS"
3559 SAVE_LDFLAGS="$LDFLAGS"
3560 CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
3561 LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
3563 if test "x$with_libtokyotyrant" = "xyes"
3564 then
3565   AC_CHECK_HEADERS(tcrdb.h,
3566   [
3567           AC_DEFINE(HAVE_TCRDB_H, 1,
3568                     [Define to 1 if you have the <tcrdb.h> header file.])
3569   ], [with_libtokyotyrant="no (tcrdb.h not found)"])
3570 fi
3572 if test "x$with_libtokyotyrant" = "xyes"
3573 then
3574   AC_CHECK_LIB(tokyotyrant, tcrdbrnum,
3575   [
3576           AC_DEFINE(HAVE_LIBTOKYOTYRANT, 1,
3577                     [Define to 1 if you have the tokyotyrant library (-ltokyotyrant).])
3578   ],
3579   [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
3580   [$with_libtokyotyrant_libs])
3581 fi
3583 CPPFLAGS="$SAVE_CPPFLAGS"
3584 LDFLAGS="$SAVE_LDFLAGS"
3586 if test "x$with_libtokyotyrant" = "xyes"
3587 then 
3588   BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
3589   BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
3590   BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
3591   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
3592   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
3593   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS)
3594 fi
3595 AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes")
3596 # }}}
3598 # --with-libupsclient {{{
3599 with_libupsclient_config=""
3600 with_libupsclient_cflags=""
3601 with_libupsclient_libs=""
3602 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
3604         if test "x$withval" = "xno"
3605         then
3606                 with_libupsclient="no"
3607         else if test "x$withval" = "xyes"
3608         then
3609                 with_libupsclient="use_pkgconfig"
3610         else
3611                 if test -x "$withval"
3612                 then
3613                         with_libupsclient_config="$withval"
3614                         with_libupsclient="use_libupsclient_config"
3615                 else if test -x "$withval/bin/libupsclient-config"
3616                 then
3617                         with_libupsclient_config="$withval/bin/libupsclient-config"
3618                         with_libupsclient="use_libupsclient_config"
3619                 else
3620                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
3621                         with_libupsclient_cflags="-I$withval/include"
3622                         with_libupsclient_libs="-L$withval/lib -lupsclient"
3623                         with_libupsclient="yes"
3624                 fi; fi
3625         fi; fi
3626 ],
3627 [with_libupsclient="use_pkgconfig"])
3629 # configure using libupsclient-config
3630 if test "x$with_libupsclient" = "xuse_libupsclient_config"
3631 then
3632         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
3633         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
3634         if test $? -ne 0
3635         then
3636                 with_libupsclient="no ($with_libupsclient_config failed)"
3637         fi
3638         with_libupsclient_libs="`$with_libupsclient_config --libs`"
3639         if test $? -ne 0
3640         then
3641                 with_libupsclient="no ($with_libupsclient_config failed)"
3642         fi
3643 fi
3644 if test "x$with_libupsclient" = "xuse_libupsclient_config"
3645 then
3646         with_libupsclient="yes"
3647 fi
3649 # configure using pkg-config
3650 if test "x$with_libupsclient" = "xuse_pkgconfig"
3651 then
3652         if test "x$PKG_CONFIG" = "x"
3653         then
3654                 with_libupsclient="no (Don't have pkg-config)"
3655         fi
3656 fi
3657 if test "x$with_libupsclient" = "xuse_pkgconfig"
3658 then
3659         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
3660         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
3661         if test $? -ne 0
3662         then
3663                 with_libupsclient="no (pkg-config doesn't know libupsclient)"
3664         fi
3665 fi
3666 if test "x$with_libupsclient" = "xuse_pkgconfig"
3667 then
3668         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
3669         if test $? -ne 0
3670         then
3671                 with_libupsclient="no ($PKG_CONFIG failed)"
3672         fi
3673         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
3674         if test $? -ne 0
3675         then
3676                 with_libupsclient="no ($PKG_CONFIG failed)"
3677         fi
3678 fi
3679 if test "x$with_libupsclient" = "xuse_pkgconfig"
3680 then
3681         with_libupsclient="yes"
3682 fi
3684 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
3685 # the actual checks.
3686 if test "x$with_libupsclient" = "xyes"
3687 then
3688         SAVE_CPPFLAGS="$CPPFLAGS"
3689         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3691         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
3693         CPPFLAGS="$SAVE_CPPFLAGS"
3694 fi
3695 if test "x$with_libupsclient" = "xyes"
3696 then
3697         SAVE_CPPFLAGS="$CPPFLAGS"
3698         SAVE_LDFLAGS="$LDFLAGS"
3700         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3701         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
3703         AC_CHECK_LIB(upsclient, upscli_connect,
3704                      [with_libupsclient="yes"],
3705                      [with_libupsclient="no (symbol upscli_connect not found)"])
3707         CPPFLAGS="$SAVE_CPPFLAGS"
3708         LDFLAGS="$SAVE_LDFLAGS"
3709 fi
3710 if test "x$with_libupsclient" = "xyes"
3711 then
3712         SAVE_CPPFLAGS="$CPPFLAGS"
3713         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3715         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
3716 [#include <stdlib.h>
3717 #include <stdio.h>
3718 #include <upsclient.h>])
3720         CPPFLAGS="$SAVE_CPPFLAGS"
3721 fi
3722 if test "x$with_libupsclient" = "xyes"
3723 then
3724         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
3725         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
3726         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
3727         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
3728 fi
3729 # }}}
3731 # --with-libxmms {{{
3732 with_xmms_config="xmms-config"
3733 with_xmms_cflags=""
3734 with_xmms_libs=""
3735 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
3737         if test "x$withval" != "xno" \
3738                 && test "x$withval" != "xyes"
3739         then
3740                 if test -f "$withval" && test -x "$withval";
3741                 then
3742                         with_xmms_config="$withval"
3743                 else if test -x "$withval/bin/xmms-config"
3744                 then
3745                         with_xmms_config="$withval/bin/xmms-config"
3746                 fi; fi
3747                 with_libxmms="yes"
3748         else if test "x$withval" = "xno"
3749         then
3750                 with_libxmms="no"
3751         else
3752                 with_libxmms="yes"
3753         fi; fi
3754 ],
3756         with_libxmms="yes"
3757 ])
3758 if test "x$with_libxmms" = "xyes"
3759 then
3760         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
3761         xmms_config_status=$?
3763         if test $xmms_config_status -ne 0
3764         then
3765                 with_libxmms="no"
3766         fi
3767 fi
3768 if test "x$with_libxmms" = "xyes"
3769 then
3770         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
3771         xmms_config_status=$?
3773         if test $xmms_config_status -ne 0
3774         then
3775                 with_libxmms="no"
3776         fi
3777 fi
3778 if test "x$with_libxmms" = "xyes"
3779 then
3780         AC_CHECK_LIB(xmms, xmms_remote_get_info,
3781         [
3782                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
3783                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
3784                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
3785                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
3786         ],
3787         [
3788                 with_libxmms="no"
3789         ],
3790         [$with_xmms_libs])
3791 fi
3792 with_libxmms_numeric=0
3793 if test "x$with_libxmms" = "xyes"
3794 then
3795         with_libxmms_numeric=1
3796 fi
3797 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
3798 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
3799 # }}}
3801 # --with-libyajl {{{
3802 with_libyajl_cppflags=""
3803 with_libyajl_ldflags=""
3804 AC_ARG_WITH(libyajl, [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
3806         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3807         then
3808                 with_libyajl_cppflags="-I$withval/include"
3809                 with_libyajl_ldflags="-L$withval/lib"
3810                 with_libyajl="yes"
3811         else
3812                 with_libyajl="$withval"
3813         fi
3814 ],
3816         with_libyajl="yes"
3817 ])
3818 if test "x$with_libyajl" = "xyes"
3819 then
3820         SAVE_CPPFLAGS="$CPPFLAGS"
3821         CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
3823         AC_CHECK_HEADERS(yajl/yajl_parse.h, [with_libyajl="yes"], [with_libyajl="no (yajl/yajl_parse.h not found)"])
3824         AC_CHECK_HEADERS(yajl/yajl_version.h)
3826         CPPFLAGS="$SAVE_CPPFLAGS"
3827 fi
3828 if test "x$with_libyajl" = "xyes"
3829 then
3830         SAVE_CPPFLAGS="$CPPFLAGS"
3831         SAVE_LDFLAGS="$LDFLAGS"
3832         CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
3833         LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
3835         AC_CHECK_LIB(yajl, yajl_alloc, [with_libyajl="yes"], [with_libyajl="no (Symbol 'yajl_alloc' not found)"])
3837         CPPFLAGS="$SAVE_CPPFLAGS"
3838         LDFLAGS="$SAVE_LDFLAGS"
3839 fi
3840 if test "x$with_libyajl" = "xyes"
3841 then
3842         BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
3843         BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
3844         BUILD_WITH_LIBYAJL_LIBS="-lyajl"
3845         AC_SUBST(BUILD_WITH_LIBYAJL_CPPFLAGS)
3846         AC_SUBST(BUILD_WITH_LIBYAJL_LDFLAGS)
3847         AC_SUBST(BUILD_WITH_LIBYAJL_LIBS)
3848         AC_DEFINE(HAVE_LIBYAJL, 1, [Define if libyajl is present and usable.])
3849 fi
3850 AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
3851 # }}}
3853 # --with-libvarnish {{{
3854 with_libvarnish_cppflags=""
3855 with_libvarnish_cflags=""
3856 with_libvarnish_libs=""
3857 AC_ARG_WITH(libvarnish, [AS_HELP_STRING([--with-libvarnish@<:@=PREFIX@:>@], [Path to libvarnish.])],
3859         if test "x$withval" = "xno"
3860         then
3861                 with_libvarnish="no"
3862         else if test "x$withval" = "xyes"
3863         then
3864                 with_libvarnish="use_pkgconfig"
3865         else if test -d "$with_libvarnish/lib"
3866         then
3867                 AC_MSG_NOTICE([Not checking for libvarnish: Manually configured])
3868                 with_libvarnish_cflags="-I$withval/include"
3869                 with_libvarnish_libs="-L$withval/lib -lvarnish -lvarnishcompat -lvarnishapi"
3870                 with_libvarnish="yes"
3871         fi; fi; fi
3872 ],
3873 [with_libvarnish="use_pkgconfig"])
3875 # configure using pkg-config
3876 if test "x$with_libvarnish" = "xuse_pkgconfig"
3877 then
3878         if test "x$PKG_CONFIG" = "x"
3879         then
3880                 with_libvarnish="no (Don't have pkg-config)"
3881         fi
3882 fi
3883 if test "x$with_libvarnish" = "xuse_pkgconfig"
3884 then
3885         AC_MSG_NOTICE([Checking for varnishapi using $PKG_CONFIG])
3886         $PKG_CONFIG --exists 'varnishapi' 2>/dev/null
3887         if test $? -ne 0
3888         then
3889                 with_libvarnish="no (pkg-config doesn't know varnishapi)"
3890         fi
3891 fi
3892 if test "x$with_libvarnish" = "xuse_pkgconfig"
3893 then
3894         with_libvarnish_cflags="`$PKG_CONFIG --cflags 'varnishapi'`"
3895         if test $? -ne 0
3896         then
3897                 with_libvarnish="no ($PKG_CONFIG failed)"
3898         fi
3899         with_libvarnish_libs="`$PKG_CONFIG --libs 'varnishapi'`"
3900         if test $? -ne 0
3901         then
3902                 with_libvarnish="no ($PKG_CONFIG failed)"
3903         fi
3904 fi
3905 if test "x$with_libvarnish" = "xuse_pkgconfig"
3906 then
3907         with_libvarnish="yes"
3908 fi
3910 # with_libvarnish_cflags and with_libvarnish_libs are set up now, let's do
3911 # the actual checks.
3912 if test "x$with_libvarnish" = "xyes"
3913 then
3914         SAVE_CPPFLAGS="$CPPFLAGS"
3915         CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
3916         AC_CHECK_HEADERS(varnish/varnishapi.h, [], [with_libvarnish="no (varnish/varnishapi.h not found)"])
3918         CPPFLAGS="$SAVE_CPPFLAGS"
3919 fi
3920 if test "x$with_libvarnish" = "xyes"
3921 then
3922         SAVE_CPPFLAGS="$CPPFLAGS"
3923         #SAVE_LDFLAGS="$LDFLAGS"
3925         CPPFLAGS="$CPPFLAGS $with_libvarnish_cflags"
3926         #LDFLAGS="$LDFLAGS $with_libvarnish_libs"
3928         AC_CHECK_LIB(varnishapi, VSL_OpenStats,
3929                      [with_libvarnish="yes"],
3930                      [with_libvarnish="no (symbol VSL_OpenStats not found)"],
3931                      [$with_libvarnish_libs])
3933         CPPFLAGS="$SAVE_CPPFLAGS"
3934         #LDFLAGS="$SAVE_LDFLAGS"
3935 fi
3936 if test "x$with_libvarnish" = "xyes"
3937 then
3938         BUILD_WITH_LIBVARNISH_CFLAGS="$with_libvarnish_cflags"
3939         BUILD_WITH_LIBVARNISH_LIBS="$with_libvarnish_libs"
3940         AC_SUBST(BUILD_WITH_LIBVARNISH_CFLAGS)
3941         AC_SUBST(BUILD_WITH_LIBVARNISH_LIBS)
3942 fi
3943 # }}}
3945 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
3946 with_libxml2="no (pkg-config isn't available)"
3947 with_libxml2_cflags=""
3948 with_libxml2_ldflags=""
3949 with_libvirt="no (pkg-config isn't available)"
3950 with_libvirt_cflags=""
3951 with_libvirt_ldflags=""
3952 if test "x$PKG_CONFIG" != "x"
3953 then
3954         pkg-config --exists 'libxml-2.0' 2>/dev/null
3955         if test "$?" = "0"
3956         then
3957                 with_libxml2="yes"
3958         else
3959                 with_libxml2="no (pkg-config doesn't know libxml-2.0)"
3960         fi
3962         pkg-config --exists libvirt 2>/dev/null
3963         if test "$?" = "0"
3964         then
3965                 with_libvirt="yes"
3966         else
3967                 with_libvirt="no (pkg-config doesn't know libvirt)"
3968         fi
3969 fi
3970 if test "x$with_libxml2" = "xyes"
3971 then
3972         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
3973         if test $? -ne 0
3974         then
3975                 with_libxml2="no"
3976         fi
3977         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
3978         if test $? -ne 0
3979         then
3980                 with_libxml2="no"
3981         fi
3982 fi
3983 if test "x$with_libxml2" = "xyes"
3984 then
3985         SAVE_CPPFLAGS="$CPPFLAGS"
3986         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
3988         AC_CHECK_HEADERS(libxml/parser.h, [],
3989                       [with_libxml2="no (libxml/parser.h not found)"])
3991         CPPFLAGS="$SAVE_CPPFLAGS"
3992 fi
3993 if test "x$with_libxml2" = "xyes"
3994 then
3995         SAVE_CFLAGS="$CFLAGS"
3996         SAVE_LDFLAGS="$LDFLAGS"
3998         CFLAGS="$CFLAGS $with_libxml2_cflags"
3999         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
4001         AC_CHECK_LIB(xml2, xmlXPathEval,
4002                      [with_libxml2="yes"],
4003                      [with_libxml2="no (symbol xmlXPathEval not found)"])
4005         CFLAGS="$SAVE_CFLAGS"
4006         LDFLAGS="$SAVE_LDFLAGS"
4007 fi
4008 dnl Add the right compiler flags and libraries.
4009 if test "x$with_libxml2" = "xyes"; then
4010         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
4011         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
4012         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
4013         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
4014 fi
4015 if test "x$with_libvirt" = "xyes"
4016 then
4017         with_libvirt_cflags="`pkg-config --cflags libvirt`"
4018         if test $? -ne 0
4019         then
4020                 with_libvirt="no"
4021         fi
4022         with_libvirt_ldflags="`pkg-config --libs libvirt`"
4023         if test $? -ne 0
4024         then
4025                 with_libvirt="no"
4026         fi
4027 fi
4028 if test "x$with_libvirt" = "xyes"
4029 then
4030         SAVE_CPPFLAGS="$CPPFLAGS"
4031         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
4033         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
4034                       [with_libvirt="no (libvirt/libvirt.h not found)"])
4036         CPPFLAGS="$SAVE_CPPFLAGS"
4037 fi
4038 if test "x$with_libvirt" = "xyes"
4039 then
4040         SAVE_CFLAGS="$CFLAGS"
4041         SAVE_LDFLAGS="$LDFLAGS"
4043         CFLAGS="$CFLAGS $with_libvirt_cflags"
4044         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
4046         AC_CHECK_LIB(virt, virDomainBlockStats,
4047                      [with_libvirt="yes"],
4048                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
4050         CFLAGS="$SAVE_CFLAGS"
4051         LDFLAGS="$SAVE_LDFLAGS"
4052 fi
4053 dnl Add the right compiler flags and libraries.
4054 if test "x$with_libvirt" = "xyes"; then
4055         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
4056         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
4057         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
4058         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
4059 fi
4060 # }}}
4062 # $PKG_CONFIG --exists OpenIPMIpthread {{{
4063 with_libopenipmipthread="yes"
4064 with_libopenipmipthread_cflags=""
4065 with_libopenipmipthread_libs=""
4067 AC_MSG_CHECKING([for pkg-config])
4068 temp_result="no"
4069 if test "x$PKG_CONFIG" = "x"
4070 then
4071         with_libopenipmipthread="no"
4072         temp_result="no"
4073 else
4074         temp_result="$PKG_CONFIG"
4075 fi
4076 AC_MSG_RESULT([$temp_result])
4078 if test "x$with_libopenipmipthread" = "xyes"
4079 then
4080         AC_MSG_CHECKING([for libOpenIPMIpthread])
4081         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
4082         if test "$?" != "0"
4083         then
4084                 with_libopenipmipthread="no (pkg-config doesn't know OpenIPMIpthread)"
4085         fi
4086         AC_MSG_RESULT([$with_libopenipmipthread])
4087 fi
4089 if test "x$with_libopenipmipthread" = "xyes"
4090 then
4091         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
4092         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
4093         if test "$?" = "0"
4094         then
4095                 with_libopenipmipthread_cflags="$temp_result"
4096         else
4097                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
4098                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
4099         fi
4100         AC_MSG_RESULT([$temp_result])
4101 fi
4103 if test "x$with_libopenipmipthread" = "xyes"
4104 then
4105         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
4106         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
4107         if test "$?" = "0"
4108         then
4109                 with_libopenipmipthread_ldflags="$temp_result"
4110         else
4111                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
4112                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
4113         fi
4114         AC_MSG_RESULT([$temp_result])
4115 fi
4117 if test "x$with_libopenipmipthread" = "xyes"
4118 then
4119         SAVE_CPPFLAGS="$CPPFLAGS"
4120         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
4122         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
4123                          [with_libopenipmipthread="yes"],
4124                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
4125 [#include <OpenIPMI/ipmiif.h>
4126 #include <OpenIPMI/ipmi_err.h>
4127 #include <OpenIPMI/ipmi_posix.h>
4128 #include <OpenIPMI/ipmi_conn.h>
4129 ])
4131         CPPFLAGS="$SAVE_CPPFLAGS"
4132 fi
4134 if test "x$with_libopenipmipthread" = "xyes"
4135 then
4136         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
4137         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
4138         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
4139         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
4140 fi
4141 # }}}
4143 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
4144                 [with_libnotify="yes"],
4145                 [if test "x$LIBNOTIFY_PKG_ERRORS" = "x"; then
4146                          with_libnotify="no"
4147                  else
4148                          with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"
4149                  fi])
4151 # Check for enabled/disabled features
4154 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
4155 # ------------------------------------------------------------
4156 dnl
4157 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
4158 dnl
4159 AC_DEFUN(
4160         [AC_COLLECTD],
4161         [
4162         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
4163         m4_if(
4164                 [$2],
4165                 [enable],
4166                 [dnl
4167                 m4_define([EnDis],[disabled])dnl
4168                 m4_define([YesNo],[no])dnl
4169                 ],dnl
4170                 [m4_if(
4171                         [$2],
4172                         [disable],
4173                         [dnl
4174                         m4_define([EnDis],[enabled])dnl
4175                         m4_define([YesNo],[yes])dnl
4176                         ],
4177                         [dnl
4178                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
4179                         ]dnl
4180                 )]dnl
4181         )dnl
4182         m4_if([$3], [feature], [],
4183                 [m4_if(
4184                         [$3], [module], [],
4185                         [dnl
4186                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
4187                         ]dnl
4188                 )]dnl
4189         )dnl
4190         AC_ARG_ENABLE(
4191                 [$1],
4192                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
4193                 [],
4194                 enable_$1='[YesNo]'dnl
4195         )# AC_ARG_ENABLE
4196 if test "x$enable_$1" = "xno"
4197 then
4198         collectd_$1=0
4199 else
4200         if test "x$enable_$1" = "xyes"
4201         then
4202                 collectd_$1=1
4203         else
4204                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
4205                 collectd_$1=1
4206                 enable_$1='yes'
4207         fi
4208 fi
4209         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
4210         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
4211         ]dnl
4212 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
4214 # AC_PLUGIN(name, default, info)
4215 # ------------------------------------------------------------
4216 dnl
4217 AC_DEFUN(
4218   [AC_PLUGIN],
4219   [
4220     enable_plugin="no"
4221     force="no"
4222     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
4223     [
4224      if test "x$enableval" = "xyes"
4225      then
4226              enable_plugin="yes"
4227      else if test "x$enableval" = "xforce"
4228      then
4229              enable_plugin="yes"
4230              force="yes"
4231      else
4232              enable_plugin="no (disabled on command line)"
4233      fi; fi
4234     ],
4235     [
4236          if test "x$enable_all_plugins" = "xauto"
4237          then
4238              if test "x$2" = "xyes"
4239              then
4240                      enable_plugin="yes"
4241              else
4242                      enable_plugin="no"
4243              fi
4244          else
4245              enable_plugin="$enable_all_plugins"
4246          fi
4247     ])
4248     if test "x$enable_plugin" = "xyes"
4249     then
4250             if test "x$2" = "xyes" || test "x$force" = "xyes"
4251             then
4252                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
4253                     if test "x$2" != "xyes"
4254                     then
4255                             dependency_warning="yes"
4256                     fi
4257             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
4258                     dependency_error="yes"
4259                     enable_plugin="no (dependency error)"
4260             fi
4261     fi
4262     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
4263     enable_$1="$enable_plugin"
4264   ]
4265 )# AC_PLUGIN(name, default, info)
4267 m4_divert_once([HELP_ENABLE], [
4268 collectd features:])
4269 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
4270 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
4271 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
4272 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
4274 dependency_warning="no"
4275 dependency_error="no"
4277 plugin_ascent="no"
4278 plugin_battery="no"
4279 plugin_bind="no"
4280 plugin_conntrack="no"
4281 plugin_contextswitch="no"
4282 plugin_cpu="no"
4283 plugin_cpufreq="no"
4284 plugin_curl_json="no"
4285 plugin_curl_xml="no"
4286 plugin_df="no"
4287 plugin_disk="no"
4288 plugin_entropy="no"
4289 plugin_interface="no"
4290 plugin_ipmi="no"
4291 plugin_ipvs="no"
4292 plugin_irq="no"
4293 plugin_libvirt="no"
4294 plugin_load="no"
4295 plugin_memory="no"
4296 plugin_multimeter="no"
4297 plugin_nfs="no"
4298 plugin_fscache="no"
4299 plugin_perl="no"
4300 plugin_processes="no"
4301 plugin_protocols="no"
4302 plugin_serial="no"
4303 plugin_swap="no"
4304 plugin_tape="no"
4305 plugin_tcpconns="no"
4306 plugin_ted="no"
4307 plugin_thermal="no"
4308 plugin_users="no"
4309 plugin_uptime="no"
4310 plugin_vmem="no"
4311 plugin_vserver="no"
4312 plugin_wireless="no"
4313 plugin_zfs_arc="no"
4315 # Linux
4316 if test "x$ac_system" = "xLinux"
4317 then
4318         plugin_battery="yes"
4319         plugin_conntrack="yes"
4320         plugin_contextswitch="yes"
4321         plugin_cpu="yes"
4322         plugin_cpufreq="yes"
4323         plugin_disk="yes"
4324         plugin_entropy="yes"
4325         plugin_interface="yes"
4326         plugin_irq="yes"
4327         plugin_load="yes"
4328         plugin_memory="yes"
4329         plugin_nfs="yes"
4330         plugin_fscache="yes"
4331         plugin_processes="yes"
4332         plugin_protocols="yes"
4333         plugin_serial="yes"
4334         plugin_swap="yes"
4335         plugin_tcpconns="yes"
4336         plugin_thermal="yes"
4337         plugin_uptime="yes"
4338         plugin_vmem="yes"
4339         plugin_vserver="yes"
4340         plugin_wireless="yes"
4342         if test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
4343         then
4344                 plugin_ipvs="yes"
4345         fi
4346 fi
4348 if test "x$ac_system" = "xOpenBSD"
4349 then
4350         plugin_tcpconns="yes"
4351 fi
4353 # Mac OS X devices
4354 if test "x$with_libiokit" = "xyes"
4355 then
4356         plugin_battery="yes"
4357         plugin_disk="yes"
4358 fi
4360 # AIX
4362 if test "x$ac_system" = "xAIX"
4363 then
4364         plugin_tcpconns="yes"
4365 fi
4367 if test "x$with_perfstat" = "xyes"
4368 then
4369         plugin_cpu="yes"
4370         plugin_disk="yes"
4371         plugin_memory="yes"
4372         plugin_swap="yes"
4373         plugin_interface="yes"
4374         plugin_load="yes"
4375 fi
4377 if test "x$with_procinfo" = "xyes"
4378 then
4379         plugin_processes="yes"
4380 fi
4382 # Solaris
4383 if test "x$with_kstat" = "xyes"
4384 then
4385         plugin_uptime="yes"
4386         plugin_zfs_arc="yes"
4387 fi
4389 if test "x$with_devinfo$with_kstat" = "xyesyes"
4390 then
4391         plugin_cpu="yes"
4392         plugin_disk="yes"
4393         plugin_interface="yes"
4394         plugin_memory="yes"
4395         plugin_tape="yes"
4396 fi
4398 # libstatgrab
4399 if test "x$with_libstatgrab" = "xyes"
4400 then
4401         plugin_cpu="yes"
4402         plugin_disk="yes"
4403         plugin_interface="yes"
4404         plugin_load="yes"
4405         plugin_memory="yes"
4406         plugin_swap="yes"
4407         plugin_users="yes"
4408 fi
4410 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
4411 then
4412         plugin_ascent="yes"
4413         if test "x$have_strptime" = "xyes"
4414         then
4415                 plugin_bind="yes"
4416         fi
4417 fi
4419 if test "x$with_libopenipmipthread" = "xyes"
4420 then
4421         plugin_ipmi="yes"
4422 fi
4424 if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"
4425 then
4426         plugin_curl_json="yes"
4427 fi
4429 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
4430 then
4431         plugin_curl_xml="yes"
4432 fi
4434 if test "x$have_processor_info" = "xyes"
4435 then
4436         plugin_cpu="yes"
4437 fi
4438 if test "x$have_sysctl" = "xyes"
4439 then
4440         plugin_cpu="yes"
4441         plugin_memory="yes"
4442         plugin_uptime="yes"
4443         if test "x$ac_system" = "xDarwin"
4444         then
4445                 plugin_swap="yes"
4446         fi
4447 fi
4448 if test "x$have_sysctlbyname" = "xyes"
4449 then
4450         plugin_contextswitch="yes"
4451         plugin_cpu="yes"
4452         plugin_memory="yes"
4453         plugin_tcpconns="yes"
4454 fi
4456 # Df plugin: Check if we know how to determine mount points first.
4457 #if test "x$have_listmntent" = "xyes"; then
4458 #       plugin_df="yes"
4459 #fi
4460 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
4461 then
4462         plugin_df="yes"
4463 fi
4464 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
4465 then
4466         plugin_df="yes"
4467 fi
4468 #if test "x$have_getmntent" = "xseq"
4469 #then
4470 #       plugin_df="yes"
4471 #fi
4472 if test "x$c_cv_have_one_getmntent" = "xyes"
4473 then
4474         plugin_df="yes"
4475 fi
4477 # Df plugin: Check if we have either `statfs' or `statvfs' second.
4478 if test "x$plugin_df" = "xyes"
4479 then
4480         plugin_df="no"
4481         if test "x$have_statfs" = "xyes"
4482         then
4483                 plugin_df="yes"
4484         fi
4485         if test "x$have_statvfs" = "xyes"
4486         then
4487                 plugin_df="yes"
4488         fi
4489 fi
4491 if test "x$have_getifaddrs" = "xyes"
4492 then
4493         plugin_interface="yes"
4494 fi
4496 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
4497 then
4498         plugin_libvirt="yes"
4499 fi
4501 if test "x$have_getloadavg" = "xyes"
4502 then
4503         plugin_load="yes"
4504 fi
4506 if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
4507 then
4508         plugin_perl="yes"
4509 fi
4511 # Mac OS X memory interface
4512 if test "x$have_host_statistics" = "xyes"
4513 then
4514         plugin_memory="yes"
4515 fi
4517 if test "x$have_termios_h" = "xyes"
4518 then
4519         plugin_multimeter="yes"
4520         plugin_ted="yes"
4521 fi
4523 if test "x$have_thread_info" = "xyes"
4524 then
4525         plugin_processes="yes"
4526 fi
4528 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
4529 then
4530         plugin_processes="yes"
4531 fi
4533 if test "x$with_kvm_getswapinfo" = "xyes"
4534 then
4535         plugin_swap="yes"
4536 fi
4538 if test "x$have_swapctl" = "xyes" && test "x$c_cv_have_swapctl_two_args" = "xyes"
4539 then
4540         plugin_swap="yes"
4541 fi
4543 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
4544 then
4545         plugin_tcpconns="yes"
4546 fi
4548 if test "x$have_getutent" = "xyes"
4549 then
4550         plugin_users="yes"
4551 fi
4552 if test "x$have_getutxent" = "xyes"
4553 then
4554         plugin_users="yes"
4555 fi
4557 m4_divert_once([HELP_ENABLE], [
4558 collectd plugins:])
4560 AC_ARG_ENABLE([all-plugins],
4561                 AC_HELP_STRING([--enable-all-plugins],
4562                                 [enable all plugins (auto by def)]),
4563                 [
4564                  if test "x$enableval" = "xyes"
4565                  then
4566                          enable_all_plugins="yes"
4567                  else if test "x$enableval" = "xauto"
4568                  then
4569                          enable_all_plugins="auto"
4570                  else
4571                          enable_all_plugins="no"
4572                  fi; fi
4573                 ],
4574                 [enable_all_plugins="auto"])
4576 m4_divert_once([HELP_ENABLE], [])
4578 AC_PLUGIN([amqp],        [$with_librabbitmq],  [AMQP output plugin])
4579 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
4580 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
4581 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
4582 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
4583 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
4584 AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
4585 AC_PLUGIN([conntrack],   [$plugin_conntrack],  [nf_conntrack statistics])
4586 AC_PLUGIN([contextswitch], [$plugin_contextswitch], [context switch statistics])
4587 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
4588 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
4589 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
4590 AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
4591 AC_PLUGIN([curl_json],   [$plugin_curl_json],    [CouchDB statistics])
4592 AC_PLUGIN([curl_xml],   [$plugin_curl_xml],    [CURL generic xml statistics])
4593 AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
4594 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
4595 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
4596 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
4597 AC_PLUGIN([email],       [yes],                [EMail statistics])
4598 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
4599 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
4600 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
4601 AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
4602 AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
4603 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
4604 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
4605 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
4606 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
4607 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
4608 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
4609 AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
4610 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
4611 AC_PLUGIN([load],        [$plugin_load],       [System load])
4612 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
4613 AC_PLUGIN([lpar],        [$with_perfstat],     [AIX logical partitions statistics])
4614 AC_PLUGIN([madwifi],     [$have_linux_wireless_h], [Madwifi wireless statistics])
4615 AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
4616 AC_PLUGIN([match_hashed], [yes],               [The hashed match])
4617 AC_PLUGIN([match_regex], [yes],                [The regex match])
4618 AC_PLUGIN([match_timediff], [yes],             [The timediff match])
4619 AC_PLUGIN([match_value], [yes],                [The value match])
4620 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
4621 AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
4622 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
4623 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
4624 AC_PLUGIN([modbus],      [$with_libmodbus],    [Modbus plugin])
4625 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
4626 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
4627 AC_PLUGIN([netapp],      [$with_libnetapp],    [NetApp plugin])
4628 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
4629 AC_PLUGIN([network],     [yes],                [Network communication plugin])
4630 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
4631 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
4632 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
4633 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
4634 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
4635 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
4636 AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
4637 AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
4638 AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
4639 AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
4640 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
4641 # FIXME: Check for libevent, too.
4642 AC_PLUGIN([pinba],       [$have_protoc_c],     [Pinba statistics])
4643 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
4644 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
4645 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
4646 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
4647 AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
4648 AC_PLUGIN([python],      [$with_python],       [Embed a Python interpreter])
4649 AC_PLUGIN([redis],       [$with_libcredis],    [Redis plugin])
4650 AC_PLUGIN([routeros],    [$with_librouteros],  [RouterOS plugin])
4651 AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
4652 AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
4653 AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
4654 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
4655 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
4656 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
4657 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
4658 AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
4659 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
4660 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
4661 AC_PLUGIN([target_notification], [yes],        [The notification target])
4662 AC_PLUGIN([target_replace], [yes],             [The replace target])
4663 AC_PLUGIN([target_scale],[yes],                [The scale target])
4664 AC_PLUGIN([target_set],  [yes],                [The set target])
4665 AC_PLUGIN([target_v5upgrade], [yes],           [The v5upgrade target])
4666 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
4667 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
4668 AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
4669 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
4670 AC_PLUGIN([threshold],   [yes],                [Threshold checking plugin])
4671 AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant],  [TokyoTyrant database statistics])
4672 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
4673 AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
4674 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
4675 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
4676 AC_PLUGIN([varnish],     [$with_libvarnish],   [Varnish cache statistics])
4677 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
4678 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
4679 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
4680 AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
4681 AC_PLUGIN([write_redis], [$with_libcredis],    [Redis output plugin])
4682 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
4683 AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
4685 dnl Default configuration file
4686 # Load either syslog or logfile
4687 LOAD_PLUGIN_SYSLOG=""
4688 LOAD_PLUGIN_LOGFILE=""
4690 AC_MSG_CHECKING([which default log plugin to load])
4691 default_log_plugin="none"
4692 if test "x$enable_syslog" = "xyes"
4693 then
4694         default_log_plugin="syslog"
4695 else
4696         LOAD_PLUGIN_SYSLOG="##"
4697 fi
4699 if test "x$enable_logfile" = "xyes"
4700 then
4701         if test "x$default_log_plugin" = "xnone"
4702         then
4703                 default_log_plugin="logfile"
4704         else
4705                 LOAD_PLUGIN_LOGFILE="#"
4706         fi
4707 else
4708         LOAD_PLUGIN_LOGFILE="##"
4709 fi
4710 AC_MSG_RESULT([$default_log_plugin])
4712 AC_SUBST(LOAD_PLUGIN_SYSLOG)
4713 AC_SUBST(LOAD_PLUGIN_LOGFILE)
4715 DEFAULT_LOG_LEVEL="info"
4716 if test "x$enable_debug" = "xyes"
4717 then
4718         DEFAULT_LOG_LEVEL="debug"
4719 fi
4720 AC_SUBST(DEFAULT_LOG_LEVEL)
4722 # Load only one of rrdtool, network, csv in the default config.
4723 LOAD_PLUGIN_RRDTOOL=""
4724 LOAD_PLUGIN_NETWORK=""
4725 LOAD_PLUGIN_CSV=""
4727 AC_MSG_CHECKING([which default write plugin to load])
4728 default_write_plugin="none"
4729 if test "x$enable_rrdtool" = "xyes"
4730 then
4731         default_write_plugin="rrdtool"
4732 else
4733         LOAD_PLUGIN_RRDTOOL="##"
4734 fi
4736 if test "x$enable_network" = "xyes"
4737 then
4738         if test "x$default_write_plugin" = "xnone"
4739         then
4740                 default_write_plugin="network"
4741         else
4742                 LOAD_PLUGIN_NETWORK="#"
4743         fi
4744 else
4745         LOAD_PLUGIN_NETWORK="##"
4746 fi
4748 if test "x$enable_csv" = "xyes"
4749 then
4750         if test "x$default_write_plugin" = "xnone"
4751         then
4752                 default_write_plugin="csv"
4753         else
4754                 LOAD_PLUGIN_CSV="#"
4755         fi
4756 else
4757         LOAD_PLUGIN_CSV="##"
4758 fi
4759 AC_MSG_RESULT([$default_write_plugin])
4761 AC_SUBST(LOAD_PLUGIN_RRDTOOL)
4762 AC_SUBST(LOAD_PLUGIN_NETWORK)
4763 AC_SUBST(LOAD_PLUGIN_CSV)
4765 dnl ip_vs.h
4766 if test "x$ac_system" = "xLinux" \
4767         && test "x$have_net_ip_vs_h$have_ip_vs_h" = "xnono"
4768 then
4769         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
4770 fi
4772 dnl Perl bindings
4773 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
4775         if test "x$withval" != "xno" && test "x$withval" != "xyes"
4776         then
4777                 PERL_BINDINGS_OPTIONS="$withval"
4778                 with_perl_bindings="yes"
4779         else
4780                 PERL_BINDINGS_OPTIONS=""
4781                 with_perl_bindings="$withval"
4782         fi
4783 ],
4785         PERL_BINDINGS_OPTIONS=""
4786         if test -n "$perl_interpreter"
4787         then
4788                 with_perl_bindings="yes"
4789         else
4790                 with_perl_bindings="no (no perl interpreter found)"
4791         fi
4792 ])
4793 if test "x$with_perl_bindings" = "xyes"
4794 then
4795         PERL_BINDINGS="perl"
4796 else
4797         PERL_BINDINGS=""
4798 fi
4799 AC_SUBST(PERL_BINDINGS)
4800 AC_SUBST(PERL_BINDINGS_OPTIONS)
4802 dnl libcollectdclient
4803 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
4804 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
4805 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
4807 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
4809 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
4811 AC_SUBST(LCC_VERSION_MAJOR)
4812 AC_SUBST(LCC_VERSION_MINOR)
4813 AC_SUBST(LCC_VERSION_PATCH)
4814 AC_SUBST(LCC_VERSION_EXTRA)
4815 AC_SUBST(LCC_VERSION_STRING)
4817 AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
4819 AC_OUTPUT(Makefile src/Makefile src/collectd.conf src/libcollectdclient/Makefile src/libcollectdclient/libcollectdclient.pc src/liboconfig/Makefile bindings/Makefile bindings/java/Makefile)
4821 if test "x$with_librrd" = "xyes" \
4822         && test "x$librrd_threadsafe" != "xyes"
4823 then
4824         with_librrd="yes (warning: librrd is not thread-safe)"
4825 fi
4827 if test "x$with_libperl" = "xyes"
4828 then
4829         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
4830 else
4831         enable_perl="no (needs libperl)"
4832 fi
4834 if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"
4835 then
4836         enable_perl="no (libperl doesn't support ithreads)"
4837 fi
4839 if test "x$with_perl_bindings" = "xyes" \
4840         && test "x$PERL_BINDINGS_OPTIONS" != "x"
4841 then
4842         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
4843 fi
4845 cat <<EOF;
4847 Configuration:
4848   Libraries:
4849     libcurl . . . . . . . $with_libcurl
4850     libdbi  . . . . . . . $with_libdbi
4851     libcredis . . . . . . $with_libcredis
4852     libesmtp  . . . . . . $with_libesmtp
4853     libganglia  . . . . . $with_libganglia
4854     libgcrypt . . . . . . $with_libgcrypt
4855     libiokit  . . . . . . $with_libiokit
4856     libiptc . . . . . . . $with_libiptc
4857     libjvm  . . . . . . . $with_java
4858     libkstat  . . . . . . $with_kstat
4859     libkvm  . . . . . . . $with_libkvm
4860     libmemcached  . . . . $with_libmemcached
4861     libmodbus . . . . . . $with_libmodbus
4862     libmysql  . . . . . . $with_libmysql
4863     libnetapp . . . . . . $with_libnetapp
4864     libnetlink  . . . . . $with_libnetlink
4865     libnetsnmp  . . . . . $with_libnetsnmp
4866     libnotify . . . . . . $with_libnotify
4867     liboconfig  . . . . . $with_liboconfig
4868     libopenipmi . . . . . $with_libopenipmipthread
4869     liboping  . . . . . . $with_liboping
4870     libpcap . . . . . . . $with_libpcap
4871     libperfstat . . . . . $with_perfstat
4872     libperl . . . . . . . $with_libperl
4873     libpq . . . . . . . . $with_libpq
4874     libpthread  . . . . . $with_libpthread
4875     librabbitmq . . . . . $with_librabbitmq
4876     librouteros . . . . . $with_librouteros
4877     librrd  . . . . . . . $with_librrd
4878     libsensors  . . . . . $with_libsensors
4879     libstatgrab . . . . . $with_libstatgrab
4880     libtokyotyrant  . . . $with_libtokyotyrant
4881     libupsclient  . . . . $with_libupsclient
4882     libvarnish  . . . . . $with_libvarnish
4883     libvirt . . . . . . . $with_libvirt
4884     libxml2 . . . . . . . $with_libxml2
4885     libxmms . . . . . . . $with_libxmms
4886     libyajl . . . . . . . $with_libyajl
4887     libevent  . . . . . . $with_libevent
4888     protobuf-c  . . . . . $have_protoc_c
4889     oracle  . . . . . . . $with_oracle
4890     python  . . . . . . . $with_python
4892   Features:
4893     daemon mode . . . . . $enable_daemon
4894     debug . . . . . . . . $enable_debug
4896   Bindings:
4897     perl  . . . . . . . . $with_perl_bindings
4899   Modules:
4900     amqp    . . . . . . . $enable_amqp
4901     apache  . . . . . . . $enable_apache
4902     apcups  . . . . . . . $enable_apcups
4903     apple_sensors . . . . $enable_apple_sensors
4904     ascent  . . . . . . . $enable_ascent
4905     battery . . . . . . . $enable_battery
4906     bind  . . . . . . . . $enable_bind
4907     conntrack . . . . . . $enable_conntrack
4908     contextswitch . . . . $enable_contextswitch
4909     cpu . . . . . . . . . $enable_cpu
4910     cpufreq . . . . . . . $enable_cpufreq
4911     csv . . . . . . . . . $enable_csv
4912     curl  . . . . . . . . $enable_curl
4913     curl_json . . . . . . $enable_curl_json
4914     curl_xml  . . . . . . $enable_curl_xml
4915     dbi . . . . . . . . . $enable_dbi
4916     df  . . . . . . . . . $enable_df
4917     disk  . . . . . . . . $enable_disk
4918     dns . . . . . . . . . $enable_dns
4919     email . . . . . . . . $enable_email
4920     entropy . . . . . . . $enable_entropy
4921     exec  . . . . . . . . $enable_exec
4922     filecount . . . . . . $enable_filecount
4923     fscache . . . . . . . $enable_fscache
4924     gmond . . . . . . . . $enable_gmond
4925     hddtemp . . . . . . . $enable_hddtemp
4926     interface . . . . . . $enable_interface
4927     ipmi  . . . . . . . . $enable_ipmi
4928     iptables  . . . . . . $enable_iptables
4929     ipvs  . . . . . . . . $enable_ipvs
4930     irq . . . . . . . . . $enable_irq
4931     java  . . . . . . . . $enable_java
4932     libvirt . . . . . . . $enable_libvirt
4933     load  . . . . . . . . $enable_load
4934     logfile . . . . . . . $enable_logfile
4935     lpar... . . . . . . . $enable_lpar
4936     madwifi . . . . . . . $enable_madwifi
4937     match_empty_counter . $enable_match_empty_counter
4938     match_hashed  . . . . $enable_match_hashed
4939     match_regex . . . . . $enable_match_regex
4940     match_timediff  . . . $enable_match_timediff
4941     match_value . . . . . $enable_match_value
4942     mbmon . . . . . . . . $enable_mbmon
4943     memcachec . . . . . . $enable_memcachec
4944     memcached . . . . . . $enable_memcached
4945     memory  . . . . . . . $enable_memory
4946     modbus  . . . . . . . $enable_modbus
4947     multimeter  . . . . . $enable_multimeter
4948     mysql . . . . . . . . $enable_mysql
4949     netapp  . . . . . . . $enable_netapp
4950     netlink . . . . . . . $enable_netlink
4951     network . . . . . . . $enable_network
4952     nfs . . . . . . . . . $enable_nfs
4953     nginx . . . . . . . . $enable_nginx
4954     notify_desktop  . . . $enable_notify_desktop
4955     notify_email  . . . . $enable_notify_email
4956     ntpd  . . . . . . . . $enable_ntpd
4957     nut . . . . . . . . . $enable_nut
4958     olsrd . . . . . . . . $enable_olsrd
4959     onewire . . . . . . . $enable_onewire
4960     openvpn . . . . . . . $enable_openvpn
4961     oracle  . . . . . . . $enable_oracle
4962     perl  . . . . . . . . $enable_perl
4963     pinba . . . . . . . . $enable_pinba
4964     ping  . . . . . . . . $enable_ping
4965     postgresql  . . . . . $enable_postgresql
4966     powerdns  . . . . . . $enable_powerdns
4967     processes . . . . . . $enable_processes
4968     protocols . . . . . . $enable_protocols
4969     python  . . . . . . . $enable_python
4970     redis . . . . . . . . $enable_redis
4971     routeros  . . . . . . $enable_routeros
4972     rrdcached . . . . . . $enable_rrdcached
4973     rrdtool . . . . . . . $enable_rrdtool
4974     sensors . . . . . . . $enable_sensors
4975     serial  . . . . . . . $enable_serial
4976     snmp  . . . . . . . . $enable_snmp
4977     swap  . . . . . . . . $enable_swap
4978     syslog  . . . . . . . $enable_syslog
4979     table . . . . . . . . $enable_table
4980     tail  . . . . . . . . $enable_tail
4981     tape  . . . . . . . . $enable_tape
4982     target_notification . $enable_target_notification
4983     target_replace  . . . $enable_target_replace
4984     target_scale  . . . . $enable_target_scale
4985     target_set  . . . . . $enable_target_set
4986     target_v5upgrade  . . $enable_target_v5upgrade
4987     tcpconns  . . . . . . $enable_tcpconns
4988     teamspeak2  . . . . . $enable_teamspeak2
4989     ted . . . . . . . . . $enable_ted
4990     thermal . . . . . . . $enable_thermal
4991     threshold . . . . . . $enable_threshold
4992     tokyotyrant . . . . . $enable_tokyotyrant
4993     unixsock  . . . . . . $enable_unixsock
4994     uptime  . . . . . . . $enable_uptime
4995     users . . . . . . . . $enable_users
4996     uuid  . . . . . . . . $enable_uuid
4997     varnish . . . . . . . $enable_varnish
4998     vmem  . . . . . . . . $enable_vmem
4999     vserver . . . . . . . $enable_vserver
5000     wireless  . . . . . . $enable_wireless
5001     write_http  . . . . . $enable_write_http
5002     write_redis . . . . . $enable_write_redis
5003     xmms  . . . . . . . . $enable_xmms
5004     zfs_arc . . . . . . . $enable_zfs_arc
5006 EOF
5008 if test "x$dependency_error" = "xyes"; then
5009         AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
5010 fi
5012 if test "x$dependency_warning" = "xyes"; then
5013         AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
5014 fi
5016 # vim: set fdm=marker :