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