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