Merge branch 'ff/snmp' into collectd-4.10
[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 AC_INCLUDES_DEFAULT
1047 #include <kvm.h>
1048 #include <sys/param.h>
1049 #include <sys/sysctl.h>
1050 #include <sys/user.h>
1051         ])
1052
1053 AC_CHECK_MEMBERS([struct kinfo_proc.kp_proc, struct kinfo_proc.kp_eproc],
1054         [
1055                 AC_DEFINE(HAVE_STRUCT_KINFO_PROC_OPENBSD, 1,
1056                         [Define if struct kinfo_proc exists in the OpenBSD variant.])
1057                 have_struct_kinfo_proc_openbsd="yes"
1058         ],
1059         [
1060                 have_struct_kinfo_proc_openbsd="no"
1061         ],
1062         [
1063 AC_INCLUDES_DEFAULT
1064 #include <sys/param.h>
1065 #include <sys/sysctl.h>
1066 #include <kvm.h>
1067         ])
1068
1069 AC_CHECK_MEMBERS([struct udphdr.uh_dport, struct udphdr.uh_sport], [], [],
1070 [#define _BSD_SOURCE
1071 #if HAVE_STDINT_H
1072 # include <stdint.h>
1073 #endif
1074 #if HAVE_SYS_TYPES_H
1075 # include <sys/types.h>
1076 #endif
1077 #if HAVE_NETINET_IN_SYSTM_H
1078 # include <netinet/in_systm.h>
1079 #endif
1080 #if HAVE_NETINET_IN_H
1081 # include <netinet/in.h>
1082 #endif
1083 #if HAVE_NETINET_IP_H
1084 # include <netinet/ip.h>
1085 #endif
1086 #if HAVE_NETINET_UDP_H
1087 # include <netinet/udp.h>
1088 #endif
1089 ])
1090 AC_CHECK_MEMBERS([struct udphdr.dest, struct udphdr.source], [], [],
1091 [#define _BSD_SOURCE
1092 #if HAVE_STDINT_H
1093 # include <stdint.h>
1094 #endif
1095 #if HAVE_SYS_TYPES_H
1096 # include <sys/types.h>
1097 #endif
1098 #if HAVE_NETINET_IN_SYSTM_H
1099 # include <netinet/in_systm.h>
1100 #endif
1101 #if HAVE_NETINET_IN_H
1102 # include <netinet/in.h>
1103 #endif
1104 #if HAVE_NETINET_IP_H
1105 # include <netinet/ip.h>
1106 #endif
1107 #if HAVE_NETINET_UDP_H
1108 # include <netinet/udp.h>
1109 #endif
1110 ])
1111
1112 AC_CHECK_MEMBERS([kstat_io_t.nwritten, kstat_io_t.writes, kstat_io_t.nwrites, kstat_io_t.wtime],
1113         [],
1114         [],
1115         [
1116 #if HAVE_KSTAT_H
1117 # include <kstat.h>
1118 #endif
1119         ])
1120
1121 #
1122 # Checks for libraries begin here
1123 #
1124 with_libresolv="yes"
1125 AC_CHECK_LIB(resolv, res_search,
1126 [
1127         AC_DEFINE(HAVE_LIBRESOLV, 1, [Define to 1 if you have the 'resolv' library (-lresolv).])
1128 ],
1129 [with_libresolv="no"])
1130 AM_CONDITIONAL(BUILD_WITH_LIBRESOLV, test "x$with_libresolv" = "xyes")
1131
1132 dnl Check for HAL (hardware abstraction library)
1133 with_libhal="yes"
1134 AC_CHECK_LIB(hal,libhal_device_property_exists,
1135              [AC_DEFINE(HAVE_LIBHAL, 1, [Define to 1 if you have 'hal' library])],
1136              [with_libhal="no"])
1137 if test "x$with_libhal" = "xyes"; then
1138         if test "x$PKG_CONFIG" != "x"; then
1139                 BUILD_WITH_LIBHAL_CFLAGS="`pkg-config --cflags hal`"
1140                 BUILD_WITH_LIBHAL_LIBS="`pkg-config --libs hal`"
1141                 AC_SUBST(BUILD_WITH_LIBHAL_CFLAGS)
1142                 AC_SUBST(BUILD_WITH_LIBHAL_LIBS)
1143         fi
1144 fi
1145
1146 m4_divert_once([HELP_WITH], [
1147 collectd additional packages:])
1148
1149 AM_CONDITIONAL([BUILD_AIX],[test "x$x$ac_system" = "xAIX"]) 
1150
1151 if test "x$ac_system" = "xAIX"
1152 then
1153         with_perfstat="yes"
1154         with_procinfo="yes"
1155 else
1156         with_perfstat="no (AIX only)"
1157         with_procinfo="no (AIX only)"
1158 fi
1159
1160 if test "x$with_perfstat" = "xyes"
1161 then
1162         AC_CHECK_LIB(perfstat, perfstat_reset, [with_perfstat="yes"], [with_perfstat="no (perfstat not found)"], [])
1163 #       AC_CHECK_HEADERS(sys/protosw.h libperfstat.h,, [with_perfstat="no (perfstat not found)"])
1164 fi
1165 if test "x$with_perfstat" = "xyes"
1166 then
1167          AC_DEFINE(HAVE_PERFSTAT, 1, [Define to 1 if you have the 'perfstat' library (-lperfstat)])
1168 fi
1169 AM_CONDITIONAL(BUILD_WITH_PERFSTAT, test "x$with_perfstat" = "xyes")
1170
1171 # Processes plugin under AIX.
1172 if test "x$with_procinfo" = "xyes"
1173 then
1174         AC_CHECK_HEADERS(procinfo.h,, [with_procinfo="no (procinfo.h not found)"])
1175 fi
1176 if test "x$with_procinfo" = "xyes"
1177 then
1178          AC_DEFINE(HAVE_PROCINFO_H, 1, [Define to 1 if you have the procinfo.h])
1179 fi
1180
1181 if test "x$ac_system" = "xSolaris"
1182 then
1183         with_kstat="yes"
1184         with_devinfo="yes"
1185 else
1186         with_kstat="no (Solaris only)"
1187         with_devinfo="no (Solaris only)"
1188 fi
1189
1190 if test "x$with_kstat" = "xyes"
1191 then
1192         AC_CHECK_LIB(kstat, kstat_open, [with_kstat="yes"], [with_kstat="no (libkstat not found)"], [])
1193 fi
1194 if test "x$with_kstat" = "xyes"
1195 then
1196         AC_CHECK_LIB(devinfo, di_init, [with_devinfo="yes"], [with_devinfo="no (not found)"], [])
1197         AC_CHECK_HEADERS(kstat.h,, [with_kstat="no (kstat.h not found)"])
1198 fi
1199 if test "x$with_kstat" = "xyes"
1200 then
1201         AC_DEFINE(HAVE_LIBKSTAT, 1,
1202                   [Define to 1 if you have the 'kstat' library (-lkstat)])
1203 fi
1204 AM_CONDITIONAL(BUILD_WITH_LIBKSTAT, test "x$with_kstat" = "xyes")
1205 AM_CONDITIONAL(BUILD_WITH_LIBDEVINFO, test "x$with_devinfo" = "xyes")
1206
1207 with_libiokit="no"
1208 AC_CHECK_LIB(IOKit, IOServiceGetMatchingServices,
1209 [
1210         with_libiokit="yes"
1211 ], 
1212 [
1213         with_libiokit="no"
1214 ])
1215 AM_CONDITIONAL(BUILD_WITH_LIBIOKIT, test "x$with_libiokit" = "xyes")
1216
1217 with_libkvm="no"
1218 AC_CHECK_LIB(kvm, kvm_getprocs, [with_kvm_getprocs="yes"], [with_kvm_getprocs="no"])
1219 if test "x$with_kvm_getprocs" = "xyes"
1220 then
1221         AC_DEFINE(HAVE_LIBKVM_GETPROCS, 1,
1222                   [Define to 1 if you have the 'kvm' library with the 'kvm_getprocs' symbol (-lkvm)])
1223         with_libkvm="yes"
1224 fi
1225 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETPROCS, test "x$with_kvm_getprocs" = "xyes")
1226
1227 AC_CHECK_LIB(kvm, kvm_getswapinfo, [with_kvm_getswapinfo="yes"], [with_kvm_getswapinfo="no"])
1228 if test "x$with_kvm_getswapinfo" = "xyes"
1229 then
1230         AC_DEFINE(HAVE_LIBKVM_GETSWAPINFO, 1,
1231                   [Define to 1 if you have the 'kvm' library with the 'kvm_getswapinfo' symbol (-lkvm)])
1232         with_libkvm="yes"
1233 fi
1234 AM_CONDITIONAL(BUILD_WITH_LIBKVM_GETSWAPINFO, test "x$with_kvm_getswapinfo" = "xyes")
1235
1236 AC_CHECK_LIB(kvm, kvm_nlist, [with_kvm_nlist="yes"], [with_kvm_nlist="no"])
1237 if test "x$with_kvm_nlist" = "xyes"
1238 then
1239         AC_CHECK_HEADERS(bsd/nlist.h nlist.h)
1240         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1241                   [Define to 1 if you have the 'kvm' library with the 'kvm_nlist' symbol (-lkvm)])
1242         with_libkvm="yes"
1243 fi
1244 AM_CONDITIONAL(BUILD_WITH_LIBKVM_NLIST, test "x$with_kvm_nlist" = "xyes")
1245
1246 AC_CHECK_LIB(kvm, kvm_openfiles, [with_kvm_openfiles="yes"], [with_kvm_openfiles="no"])
1247 if test "x$with_kvm_openfiles" = "xyes"
1248 then
1249         AC_DEFINE(HAVE_LIBKVM_NLIST, 1,
1250                   [Define to 1 if you have the 'kvm' library with the 'kvm_openfiles' symbol (-lkvm)])
1251         with_libkvm="yes"
1252 fi
1253 AM_CONDITIONAL(BUILD_WITH_LIBKVM_OPENFILES, test "x$with_kvm_openfiles" = "xyes")
1254
1255 # --with-libcurl {{{
1256 with_curl_config="curl-config"
1257 with_curl_cflags=""
1258 with_curl_libs=""
1259 AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to libcurl.])],
1260 [
1261         if test "x$withval" = "xno"
1262         then
1263                 with_libcurl="no"
1264         else if test "x$withval" = "xyes"
1265         then
1266                 with_libcurl="yes"
1267         else
1268                 if test -f "$withval" && test -x "$withval"
1269                 then
1270                         with_curl_config="$withval"
1271                         with_libcurl="yes"
1272                 else if test -x "$withval/bin/curl-config"
1273                 then
1274                         with_curl_config="$withval/bin/curl-config"
1275                         with_libcurl="yes"
1276                 fi; fi
1277                 with_libcurl="yes"
1278         fi; fi
1279 ],
1280 [
1281         with_libcurl="yes"
1282 ])
1283 if test "x$with_libcurl" = "xyes"
1284 then
1285         with_curl_cflags=`$with_curl_config --cflags 2>/dev/null`
1286         curl_config_status=$?
1287
1288         if test $curl_config_status -ne 0
1289         then
1290                 with_libcurl="no ($with_curl_config failed)"
1291         else
1292                 SAVE_CPPFLAGS="$CPPFLAGS"
1293                 CPPFLAGS="$CPPFLAGS $with_curl_cflags"
1294
1295                 AC_CHECK_HEADERS(curl/curl.h, [], [with_libcurl="no (curl/curl.h not found)"], [])
1296
1297                 CPPFLAGS="$SAVE_CPPFLAGS"
1298         fi
1299 fi
1300 if test "x$with_libcurl" = "xyes"
1301 then
1302         with_curl_libs=`$with_curl_config --libs 2>/dev/null`
1303         curl_config_status=$?
1304
1305         if test $curl_config_status -ne 0
1306         then
1307                 with_libcurl="no ($with_curl_config failed)"
1308         else
1309                 AC_CHECK_LIB(curl, curl_easy_init,
1310                  [with_libcurl="yes"],
1311                  [with_libcurl="no (symbol 'curl_easy_init' not found)"],
1312                  [$with_curl_libs])
1313         fi
1314 fi
1315 if test "x$with_libcurl" = "xyes"
1316 then
1317         BUILD_WITH_LIBCURL_CFLAGS="$with_curl_cflags"
1318         BUILD_WITH_LIBCURL_LIBS="$with_curl_libs"
1319         AC_SUBST(BUILD_WITH_LIBCURL_CFLAGS)
1320         AC_SUBST(BUILD_WITH_LIBCURL_LIBS)
1321 fi
1322 AM_CONDITIONAL(BUILD_WITH_LIBCURL, test "x$with_libcurl" = "xyes")
1323 # }}}
1324
1325 # --with-libdbi {{{
1326 with_libdbi_cppflags=""
1327 with_libdbi_ldflags=""
1328 AC_ARG_WITH(libdbi, [AS_HELP_STRING([--with-libdbi@<:@=PREFIX@:>@], [Path to libdbi.])],
1329 [
1330         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1331         then
1332                 with_libdbi_cppflags="-I$withval/include"
1333                 with_libdbi_ldflags="-L$withval/lib"
1334                 with_libdbi="yes"
1335         else
1336                 with_libdbi="$withval"
1337         fi
1338 ],
1339 [
1340         with_libdbi="yes"
1341 ])
1342 if test "x$with_libdbi" = "xyes"
1343 then
1344         SAVE_CPPFLAGS="$CPPFLAGS"
1345         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1346
1347         AC_CHECK_HEADERS(dbi/dbi.h, [with_libdbi="yes"], [with_libdbi="no (dbi/dbi.h not found)"])
1348
1349         CPPFLAGS="$SAVE_CPPFLAGS"
1350 fi
1351 if test "x$with_libdbi" = "xyes"
1352 then
1353         SAVE_CPPFLAGS="$CPPFLAGS"
1354         SAVE_LDFLAGS="$LDFLAGS"
1355         CPPFLAGS="$CPPFLAGS $with_libdbi_cppflags"
1356         LDFLAGS="$LDFLAGS $with_libdbi_ldflags"
1357
1358         AC_CHECK_LIB(dbi, dbi_initialize, [with_libdbi="yes"], [with_libdbi="no (Symbol 'dbi_initialize' not found)"])
1359
1360         CPPFLAGS="$SAVE_CPPFLAGS"
1361         LDFLAGS="$SAVE_LDFLAGS"
1362 fi
1363 if test "x$with_libdbi" = "xyes"
1364 then
1365         BUILD_WITH_LIBDBI_CPPFLAGS="$with_libdbi_cppflags"
1366         BUILD_WITH_LIBDBI_LDFLAGS="$with_libdbi_ldflags"
1367         BUILD_WITH_LIBDBI_LIBS="-ldbi"
1368         AC_SUBST(BUILD_WITH_LIBDBI_CPPFLAGS)
1369         AC_SUBST(BUILD_WITH_LIBDBI_LDFLAGS)
1370         AC_SUBST(BUILD_WITH_LIBDBI_LIBS)
1371 fi
1372 AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
1373 # }}}
1374
1375 # --with-libesmtp {{{
1376 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
1377 [
1378         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1379         then
1380                 LDFLAGS="$LDFLAGS -L$withval/lib"
1381                 CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
1382                 with_libesmtp="yes"
1383         else
1384                 with_libesmtp="$withval"
1385         fi
1386 ],
1387 [
1388         with_libesmtp="yes"
1389 ])
1390 if test "x$with_libesmtp" = "xyes"
1391 then
1392         AC_CHECK_LIB(esmtp, smtp_create_session,
1393         [
1394                 AC_DEFINE(HAVE_LIBESMTP, 1, [Define to 1 if you have the esmtp library (-lesmtp).])
1395         ], [with_libesmtp="no (libesmtp not found)"])
1396 fi
1397 if test "x$with_libesmtp" = "xyes"
1398 then
1399         AC_CHECK_HEADERS(libesmtp.h,
1400         [
1401                 AC_DEFINE(HAVE_LIBESMTP_H, 1, [Define to 1 if you have the <libesmtp.h> header file.])
1402         ], [with_libesmtp="no (libesmtp.h not found)"])
1403 fi
1404 if test "x$with_libesmtp" = "xyes"
1405 then
1406         collect_libesmtp=1
1407 else
1408         collect_libesmtp=0
1409 fi
1410 AC_DEFINE_UNQUOTED(COLLECT_LIBESMTP, [$collect_libesmtp],
1411         [Wether or not to use the esmtp library])
1412 AM_CONDITIONAL(BUILD_WITH_LIBESMTP, test "x$with_libesmtp" = "xyes")
1413 # }}}
1414
1415 # --with-libganglia {{{
1416 AC_ARG_WITH(libganglia, [AS_HELP_STRING([--with-libganglia@<:@=PREFIX@:>@], [Path to libganglia.])],
1417 [
1418  if test -f "$withval" && test -x "$withval"
1419  then
1420          with_libganglia_config="$withval"
1421          with_libganglia="yes"
1422  else if test -f "$withval/bin/ganglia-config" && test -x "$withval/bin/ganglia-config"
1423  then
1424          with_libganglia_config="$withval/bin/ganglia-config"
1425          with_libganglia="yes"
1426  else if test -d "$withval"
1427  then
1428          GANGLIA_CPPFLAGS="-I$withval/include"
1429          GANGLIA_LDFLAGS="-L$withval/lib"
1430          with_libganglia="yes"
1431  else
1432          with_libganglia_config="ganglia-config"
1433          with_libganglia="$withval"
1434  fi; fi; fi
1435 ],
1436 [
1437  with_libganglia_config="ganglia-config"
1438  with_libganglia="yes"
1439 ])
1440
1441 if test "x$with_libganglia" = "xyes" && test "x$with_libganglia_config" != "x"
1442 then
1443         if test "x$GANGLIA_CPPFLAGS" = "x"
1444         then
1445                 GANGLIA_CPPFLAGS=`"$with_libganglia_config" --cflags 2>/dev/null`
1446         fi
1447
1448         if test "x$GANGLIA_LDFLAGS" = "x"
1449         then
1450                 GANGLIA_LDFLAGS=`"$with_libganglia_config" --ldflags 2>/dev/null`
1451         fi
1452
1453         if test "x$GANGLIA_LIBS" = "x"
1454         then
1455                 GANGLIA_LIBS=`"$with_libganglia_config" --libs 2>/dev/null`
1456         fi
1457 fi
1458
1459 SAVE_CPPFLAGS="$CPPFLAGS"
1460 SAVE_LDFLAGS="$LDFLAGS"
1461 CPPFLAGS="$CPPFLAGS $GANGLIA_CPPFLAGS"
1462 LDFLAGS="$LDFLAGS $GANGLIA_LDFLAGS"
1463
1464 if test "x$with_libganglia" = "xyes"
1465 then
1466         AC_CHECK_HEADERS(gm_protocol.h,
1467         [
1468                 AC_DEFINE(HAVE_GM_PROTOCOL_H, 1,
1469                           [Define to 1 if you have the <gm_protocol.h> header file.])
1470         ], [with_libganglia="no (gm_protocol.h not found)"])
1471 fi
1472
1473 if test "x$with_libganglia" = "xyes"
1474 then
1475         AC_CHECK_LIB(ganglia, xdr_Ganglia_value_msg,
1476         [
1477                 AC_DEFINE(HAVE_LIBGANGLIA, 1,
1478                           [Define to 1 if you have the ganglia library (-lganglia).])
1479         ], [with_libganglia="no (symbol xdr_Ganglia_value_msg not found)"])
1480 fi
1481
1482 CPPFLAGS="$SAVE_CPPFLAGS"
1483 LDFLAGS="$SAVE_LDFLAGS"
1484
1485 AC_SUBST(GANGLIA_CPPFLAGS)
1486 AC_SUBST(GANGLIA_LDFLAGS)
1487 AC_SUBST(GANGLIA_LIBS)
1488 AM_CONDITIONAL(BUILD_WITH_LIBGANGLIA, test "x$with_libganglia" = "xyes")
1489 # }}}
1490
1491 # --with-libgcrypt {{{
1492 GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS"
1493 GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS"
1494 GCRYPT_LIBS="$GCRYPT_LIBS"
1495 AC_ARG_WITH(libgcrypt, [AS_HELP_STRING([--with-libgcrypt@<:@=PREFIX@:>@], [Path to libgcrypt.])],
1496 [
1497  if test -f "$withval" && test -x "$withval"
1498  then
1499          with_libgcrypt_config="$withval"
1500          with_libgcrypt="yes"
1501  else if test -f "$withval/bin/gcrypt-config" && test -x "$withval/bin/gcrypt-config"
1502  then
1503          with_libgcrypt_config="$withval/bin/gcrypt-config"
1504          with_libgcrypt="yes"
1505  else if test -d "$withval"
1506  then
1507          GCRYPT_CPPFLAGS="$GCRYPT_CPPFLAGS -I$withval/include"
1508          GCRYPT_LDFLAGS="$GCRYPT_LDFLAGS -L$withval/lib"
1509          with_libgcrypt="yes"
1510  else
1511          with_libgcrypt_config="gcrypt-config"
1512          with_libgcrypt="$withval"
1513  fi; fi; fi
1514 ],
1515 [
1516  with_libgcrypt_config="libgcrypt-config"
1517  with_libgcrypt="yes"
1518 ])
1519
1520 if test "x$with_libgcrypt" = "xyes" && test "x$with_libgcrypt_config" != "x"
1521 then
1522         if test "x$GCRYPT_CPPFLAGS" = "x"
1523         then
1524                 GCRYPT_CPPFLAGS=`"$with_libgcrypt_config" --cflags 2>/dev/null`
1525         fi
1526
1527         if test "x$GCRYPT_LDFLAGS" = "x"
1528         then
1529                 gcrypt_exec_prefix=`"$with_libgcrypt_config" --exec-prefix 2>/dev/null`
1530                 GCRYPT_LDFLAGS="-L$gcrypt_exec_prefix/lib"
1531         fi
1532
1533         if test "x$GCRYPT_LIBS" = "x"
1534         then
1535                 GCRYPT_LIBS=`"$with_libgcrypt_config" --libs 2>/dev/null`
1536         fi
1537 fi
1538
1539 SAVE_CPPFLAGS="$CPPFLAGS"
1540 SAVE_LDFLAGS="$LDFLAGS"
1541 CPPFLAGS="$CPPFLAGS $GCRYPT_CPPFLAGS"
1542 LDFLAGS="$LDFLAGS $GCRYPT_LDFLAGS"
1543
1544 if test "x$with_libgcrypt" = "xyes"
1545 then
1546         if test "x$GCRYPT_CPPFLAGS" != "x"
1547         then
1548                 AC_MSG_NOTICE([gcrypt CPPFLAGS: $GCRYPT_CPPFLAGS])
1549         fi
1550         AC_CHECK_HEADERS(gcrypt.h,
1551                 [with_libgcrypt="yes"],
1552                 [with_libgcrypt="no (gcrypt.h not found)"])
1553 fi
1554
1555 if test "x$with_libgcrypt" = "xyes"
1556 then
1557         if test "x$GCRYPT_LDFLAGS" != "x"
1558         then
1559                 AC_MSG_NOTICE([gcrypt LDFLAGS: $GCRYPT_LDFLAGS])
1560         fi
1561         AC_CHECK_LIB(gcrypt, gcry_md_hash_buffer,
1562                 [with_libgcrypt="yes"],
1563                 [with_libgcrypt="no (symbol gcry_md_hash_buffer not found)"])
1564
1565         if test "$with_libgcrypt" != "no"; then
1566                 AM_PATH_LIBGCRYPT(1:1.2.0,,with_libgcrypt="no (version 1.2.0+ required)")
1567         fi
1568 fi
1569
1570 CPPFLAGS="$SAVE_CPPFLAGS"
1571 LDFLAGS="$SAVE_LDFLAGS"
1572
1573 if test "x$with_libgcrypt" = "xyes"
1574 then
1575         AC_DEFINE(HAVE_LIBGCRYPT, 1, [Define to 1 if you have the gcrypt library (-lgcrypt).])
1576 fi
1577
1578 AC_SUBST(GCRYPT_CPPFLAGS)
1579 AC_SUBST(GCRYPT_LDFLAGS)
1580 AC_SUBST(GCRYPT_LIBS)
1581 AM_CONDITIONAL(BUILD_WITH_LIBGCRYPT, test "x$with_libgcrypt" = "xyes")
1582 # }}}
1583
1584 # --with-libiptc {{{
1585 AC_ARG_WITH(libiptc, [AS_HELP_STRING([--with-libiptc@<:@=PREFIX@:>@], [Path to libiptc.])],
1586 [
1587         if test "x$withval" = "xshipped"
1588         then
1589                 with_libiptc="own"
1590         else if test "x$withval" = "xyes"
1591         then
1592                 with_libiptc="pkgconfig"
1593         else if test "x$withval" = "xno"
1594         then
1595                 with_libiptc="no"
1596         else
1597                 with_libiptc="yes"
1598                 with_libiptc_cflags="-I$withval/include"
1599                 with_libiptc_libs="-L$withval/lib"
1600         fi; fi; fi
1601 ],
1602 [
1603         if test "x$ac_system" = "xLinux"
1604         then
1605                 with_libiptc="pkgconfig"
1606         else
1607                 with_libiptc="no (Linux only)"
1608         fi
1609 ])
1610
1611 if test "x$with_libiptc" = "xpkgconfig" && test "x$PKG_CONFIG" = "x"
1612 then
1613         with_libiptc="no (Don't have pkg-config)"
1614 fi
1615
1616 if test "x$with_libiptc" = "xpkgconfig"
1617 then
1618         $PKG_CONFIG --exists 'libiptc' 2>/dev/null
1619         if test $? -ne 0
1620         then
1621                 with_libiptc="no (pkg-config doesn't know libiptc)"
1622         fi
1623 fi
1624 if test "x$with_libiptc" = "xpkgconfig"
1625 then
1626         with_libiptc_cflags="`$PKG_CONFIG --cflags 'libiptc'`"
1627         if test $? -ne 0
1628         then
1629                 with_libiptc="no ($PKG_CONFIG failed)"
1630         fi
1631         with_libiptc_libs="`$PKG_CONFIG --libs 'libiptc'`"
1632         if test $? -ne 0
1633         then
1634                 with_libiptc="no ($PKG_CONFIG failed)"
1635         fi
1636 fi
1637
1638 SAVE_CPPFLAGS="$CPPFLAGS"
1639 CPPFLAGS="$CPPFLAGS $with_libiptc_cflags"
1640
1641 # check whether the header file for libiptc is available.
1642 if test "x$with_libiptc" = "xpkgconfig"
1643 then
1644         AC_CHECK_HEADERS(libiptc/libiptc.h libiptc/libip6tc.h, ,
1645                         [with_libiptc="no (header file missing)"])
1646 fi
1647 # If the header file is available, check for the required type declaractions.
1648 # They may be missing in old versions of libiptc. In that case, they will be
1649 # declared in the iptables plugin.
1650 if test "x$with_libiptc" = "xpkgconfig"
1651 then
1652         AC_CHECK_TYPES([iptc_handle_t, ip6tc_handle_t], [], [])
1653 fi
1654 # Check for the iptc_init symbol in the library.
1655 # This could be in iptc or ip4tc
1656 if test "x$with_libiptc" = "xpkgconfig"
1657 then
1658         SAVE_LIBS="$LIBS"
1659         AC_SEARCH_LIBS(iptc_init, [iptc ip4tc],
1660                         [with_libiptc="pkgconfig"],
1661                         [with_libiptc="no"],
1662                         [$with_libiptc_libs])
1663         LIBS="$SAVE_LIBS"
1664 fi
1665 if test "x$with_libiptc" = "xpkgconfig"
1666 then
1667         with_libiptc="yes"
1668 fi
1669
1670 CPPFLAGS="$SAVE_CPPFLAGS"
1671
1672 if test "x$with_libiptc" = "xown"
1673 then
1674         with_libiptc_cflags=""
1675         with_libiptc_libs=""
1676 fi
1677 if test "x$with_libiptc" = "xown"
1678 then
1679         AC_CHECK_HEADERS(linux/netfilter_ipv4/ip_tables.h linux/netfilter_ipv6/ip6_tables.h linux/netfilter/x_tables.h, [],
1680         [
1681                 with_libiptc="no (Linux iptables headers not found)"
1682         ],
1683         [
1684 #include "$srcdir/src/owniptc/ipt_kernel_headers.h"
1685         ])
1686 fi
1687 AM_CONDITIONAL(BUILD_WITH_OWN_LIBIPTC, test "x$with_libiptc" = "xown")
1688 if test "x$with_libiptc" = "xown"
1689 then
1690         AC_DEFINE(OWN_LIBIPTC, 1, [Define to 1 if we use the shipped iptc library.])
1691         with_libiptc="yes"
1692 fi
1693
1694 AM_CONDITIONAL(BUILD_WITH_LIBIPTC, test "x$with_libiptc" = "xyes")
1695 if test "x$with_libiptc" = "xyes"
1696 then
1697         BUILD_WITH_LIBIPTC_CPPFLAGS="$with_libiptc_cflags"
1698         BUILD_WITH_LIBIPTC_LDFLAGS="$with_libiptc_libs"
1699         AC_SUBST(BUILD_WITH_LIBIPTC_CPPFLAGS)
1700         AC_SUBST(BUILD_WITH_LIBIPTC_LDFLAGS)
1701 fi
1702 # }}}
1703
1704 # --with-java {{{
1705 with_java_home="$JAVA_HOME"
1706 with_java_vmtype="client"
1707 with_java_cflags=""
1708 with_java_libs=""
1709 JAVAC="$JAVAC"
1710 JAR="$JAR"
1711 AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])],
1712 [
1713         if test "x$withval" = "xno"
1714         then
1715                 with_java="no"
1716         else if test "x$withval" = "xyes"
1717         then
1718                 with_java="yes"
1719         else
1720                 with_java_home="$withval"
1721                 with_java="yes"
1722         fi; fi
1723 ],
1724 [with_java="yes"])
1725 if test "x$with_java" = "xyes"
1726 then
1727         if test -d "$with_java_home"
1728         then
1729                 AC_MSG_CHECKING([for jni.h])
1730                 TMPDIR=`find "$with_java_home" -name jni.h -type f -exec 'dirname' '{}' ';' | head -n 1`
1731                 if test "x$TMPDIR" != "x"
1732                 then
1733                         AC_MSG_RESULT([found in $TMPDIR])
1734                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
1735                 else
1736                         AC_MSG_RESULT([not found])
1737                 fi
1738
1739                 AC_MSG_CHECKING([for jni_md.h])
1740                 TMPDIR=`find "$with_java_home" -name jni_md.h -type f -exec 'dirname' '{}' ';' | head -n 1`
1741                 if test "x$TMPDIR" != "x"
1742                 then
1743                         AC_MSG_RESULT([found in $TMPDIR])
1744                         JAVA_CPPFLAGS="$JAVA_CPPFLAGS -I$TMPDIR"
1745                 else
1746                         AC_MSG_RESULT([not found])
1747                 fi
1748
1749                 AC_MSG_CHECKING([for libjvm.so])
1750                 TMPDIR=`find "$with_java_home" -name libjvm.so -type f -exec 'dirname' '{}' ';' | head -n 1`
1751                 if test "x$TMPDIR" != "x"
1752                 then
1753                         AC_MSG_RESULT([found in $TMPDIR])
1754                         JAVA_LDFLAGS="$JAVA_LDFLAGS -L$TMPDIR -Wl,-rpath -Wl,$TMPDIR"
1755                 else
1756                         AC_MSG_RESULT([not found])
1757                 fi
1758
1759                 if test "x$JAVAC" = "x"
1760                 then
1761                         AC_MSG_CHECKING([for javac])
1762                         TMPDIR=`find "$with_java_home" -name javac -type f | head -n 1`
1763                         if test "x$TMPDIR" != "x"
1764                         then
1765                                 JAVAC="$TMPDIR"
1766                                 AC_MSG_RESULT([$JAVAC])
1767                         else
1768                                 AC_MSG_RESULT([not found])
1769                         fi
1770                 fi
1771                 if test "x$JAR" = "x"
1772                 then
1773                         AC_MSG_CHECKING([for jar])
1774                         TMPDIR=`find "$with_java_home" -name jar -type f | head -n 1`
1775                         if test "x$TMPDIR" != "x"
1776                         then
1777                                 JAR="$TMPDIR"
1778                                 AC_MSG_RESULT([$JAR])
1779                         else
1780                                 AC_MSG_RESULT([not found])
1781                         fi
1782                 fi
1783         else if test "x$with_java_home" != "x"
1784         then
1785                 AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home])
1786         fi; fi
1787 fi
1788
1789 if test "x$JAVA_CPPFLAGS" != "x"
1790 then
1791         AC_MSG_NOTICE([Building with JAVA_CPPFLAGS set to: $JAVA_CPPFLAGS])
1792 fi
1793 if test "x$JAVA_CFLAGS" != "x"
1794 then
1795         AC_MSG_NOTICE([Building with JAVA_CFLAGS set to: $JAVA_CFLAGS])
1796 fi
1797 if test "x$JAVA_LDFLAGS" != "x"
1798 then
1799         AC_MSG_NOTICE([Building with JAVA_LDFLAGS set to: $JAVA_LDFLAGS])
1800 fi
1801 if test "x$JAVAC" = "x"
1802 then
1803         with_javac_path="$PATH"
1804         if test "x$with_java_home" != "x"
1805         then
1806                 with_javac_path="$with_java_home:with_javac_path"
1807                 if test -d "$with_java_home/bin"
1808                 then
1809                         with_javac_path="$with_java_home/bin:with_javac_path"
1810                 fi
1811         fi
1812
1813         AC_PATH_PROG(JAVAC, javac, [], "$with_javac_path")
1814 fi
1815 if test "x$JAVAC" = "x"
1816 then
1817         with_java="no (javac not found)"
1818 fi
1819 if test "x$JAR" = "x"
1820 then
1821         with_jar_path="$PATH"
1822         if test "x$with_java_home" != "x"
1823         then
1824                 with_jar_path="$with_java_home:$with_jar_path"
1825                 if test -d "$with_java_home/bin"
1826                 then
1827                         with_jar_path="$with_java_home/bin:$with_jar_path"
1828                 fi
1829         fi
1830
1831         AC_PATH_PROG(JAR, jar, [], "$with_jar_path")
1832 fi
1833 if test "x$JAR" = "x"
1834 then
1835         with_java="no (jar not found)"
1836 fi
1837
1838 SAVE_CPPFLAGS="$CPPFLAGS"
1839 SAVE_CFLAGS="$CFLAGS"
1840 SAVE_LDFLAGS="$LDFLAGS"
1841 CPPFLAGS="$CPPFLAGS $JAVA_CPPFLAGS"
1842 CFLAGS="$CFLAGS $JAVA_CFLAGS"
1843 LDFLAGS="$LDFLAGS $JAVA_LDFLAGS"
1844
1845 if test "x$with_java" = "xyes"
1846 then
1847         AC_CHECK_HEADERS(jni.h, [], [with_java="no (jni.h not found)"])
1848 fi
1849 if test "x$with_java" = "xyes"
1850 then
1851         AC_CHECK_LIB(jvm, JNI_CreateJavaVM,
1852         [with_java="yes"],
1853         [with_java="no (libjvm not found)"],
1854         [$JAVA_LIBS])
1855 fi
1856 if test "x$with_java" = "xyes"
1857 then
1858         JAVA_LIBS="$JAVA_LIBS -ljvm"
1859         AC_MSG_NOTICE([Building with JAVA_LIBS set to: $JAVA_LIBS])
1860 fi
1861
1862 CPPFLAGS="$SAVE_CPPFLAGS"
1863 CFLAGS="$SAVE_CFLAGS"
1864 LDFLAGS="$SAVE_LDFLAGS"
1865
1866 AC_SUBST(JAVA_CPPFLAGS)
1867 AC_SUBST(JAVA_CFLAGS)
1868 AC_SUBST(JAVA_LDFLAGS)
1869 AC_SUBST(JAVA_LIBS)
1870 AM_CONDITIONAL(BUILD_WITH_JAVA, test "x$with_java" = "xyes")
1871 # }}}
1872
1873 # --with-libmemcached {{{
1874 with_libmemcached_cppflags=""
1875 with_libmemcached_ldflags=""
1876 AC_ARG_WITH(libmemcached, [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
1877 [
1878         if test "x$withval" != "xno" && test "x$withval" != "xyes"
1879         then
1880                 with_libmemcached_cppflags="-I$withval/include"
1881                 with_libmemcached_ldflags="-L$withval/lib"
1882                 with_libmemcached="yes"
1883         else
1884                 with_libmemcached="$withval"
1885         fi
1886 ],
1887 [
1888         with_libmemcached="yes"
1889 ])
1890 if test "x$with_libmemcached" = "xyes"
1891 then
1892         SAVE_CPPFLAGS="$CPPFLAGS"
1893         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
1894
1895         AC_CHECK_HEADERS(libmemcached/memcached.h, [with_libmemcached="yes"], [with_libmemcached="no (libmemcached/memcached.h not found)"])
1896
1897         CPPFLAGS="$SAVE_CPPFLAGS"
1898 fi
1899 if test "x$with_libmemcached" = "xyes"
1900 then
1901         SAVE_CPPFLAGS="$CPPFLAGS"
1902         SAVE_LDFLAGS="$LDFLAGS"
1903         CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
1904         LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
1905
1906         AC_CHECK_LIB(memcached, memcached_create, [with_libmemcached="yes"], [with_libmemcached="no (Symbol 'memcached_create' not found)"])
1907
1908         CPPFLAGS="$SAVE_CPPFLAGS"
1909         LDFLAGS="$SAVE_LDFLAGS"
1910 fi
1911 if test "x$with_libmemcached" = "xyes"
1912 then
1913         BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
1914         BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
1915         BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
1916         AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
1917         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
1918         AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
1919         AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
1920 fi
1921 AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
1922 # }}}
1923
1924 # --with-libmodbus {{{
1925 with_libmodbus_config=""
1926 with_libmodbus_cflags=""
1927 with_libmodbus_libs=""
1928 AC_ARG_WITH(libmodbus, [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
1929 [
1930         if test "x$withval" = "xno"
1931         then
1932                 with_libmodbus="no"
1933         else if test "x$withval" = "xyes"
1934         then
1935                 with_libmodbus="use_pkgconfig"
1936         else if test -d "$with_libmodbus/lib"
1937         then
1938                 AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
1939                 with_libmodbus_cflags="-I$withval/include"
1940                 with_libmodbus_libs="-L$withval/lib -lmodbus"
1941                 with_libmodbus="yes"
1942         fi; fi; fi
1943 ],
1944 [with_libmodbus="use_pkgconfig"])
1945
1946 # configure using pkg-config
1947 if test "x$with_libmodbus" = "xuse_pkgconfig"
1948 then
1949         if test "x$PKG_CONFIG" = "x"
1950         then
1951                 with_libmodbus="no (Don't have pkg-config)"
1952         fi
1953 fi
1954 if test "x$with_libmodbus" = "xuse_pkgconfig"
1955 then
1956         AC_MSG_NOTICE([Checking for modbus using $PKG_CONFIG])
1957         $PKG_CONFIG --exists 'modbus' 2>/dev/null
1958         if test $? -ne 0
1959         then
1960                 with_libmodbus="no (pkg-config doesn't know library)"
1961         fi
1962 fi
1963 if test "x$with_libmodbus" = "xuse_pkgconfig"
1964 then
1965         with_libmodbus_cflags="`$PKG_CONFIG --cflags 'modbus'`"
1966         if test $? -ne 0
1967         then
1968                 with_libmodbus="no ($PKG_CONFIG failed)"
1969         fi
1970         with_libmodbus_libs="`$PKG_CONFIG --libs 'modbus'`"
1971         if test $? -ne 0
1972         then
1973                 with_libmodbus="no ($PKG_CONFIG failed)"
1974         fi
1975 fi
1976 if test "x$with_libmodbus" = "xuse_pkgconfig"
1977 then
1978         with_libmodbus="yes"
1979 fi
1980
1981 # with_libmodbus_cflags and with_libmodbus_libs are set up now, let's do
1982 # the actual checks.
1983 if test "x$with_libmodbus" = "xyes"
1984 then
1985         SAVE_CPPFLAGS="$CPPFLAGS"
1986         CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
1987
1988         AC_CHECK_HEADERS(modbus/modbus.h, [], [with_libmodbus="no (modbus/modbus.h not found)"])
1989
1990         CPPFLAGS="$SAVE_CPPFLAGS"
1991 fi
1992 if test "x$with_libmodbus" = "xyes"
1993 then
1994         SAVE_CPPFLAGS="$CPPFLAGS"
1995         SAVE_LDFLAGS="$LDFLAGS"
1996
1997         CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
1998         LDFLAGS="$LDFLAGS $with_libmodbus_libs"
1999
2000         AC_CHECK_LIB(modbus, modbus_init_tcp,
2001                      [with_libmodbus="yes"],
2002                      [with_libmodbus="no (symbol modbus_init_tcp not found)"])
2003
2004         CPPFLAGS="$SAVE_CPPFLAGS"
2005         LDFLAGS="$SAVE_LDFLAGS"
2006 fi
2007 if test "x$with_libmodbus" = "xyes"
2008 then
2009         BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
2010         BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
2011         AC_SUBST(BUILD_WITH_LIBMODBUS_CFLAGS)
2012         AC_SUBST(BUILD_WITH_LIBMODBUS_LIBS)
2013 fi
2014 # }}}
2015
2016 # --with-libmysql {{{
2017 with_mysql_config="mysql_config"
2018 with_mysql_cflags=""
2019 with_mysql_libs=""
2020 AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
2021 [
2022         if test "x$withval" = "xno"
2023         then
2024                 with_libmysql="no"
2025         else if test "x$withval" = "xyes"
2026         then
2027                 with_libmysql="yes"
2028         else
2029                 if test -f "$withval" && test -x "$withval";
2030                 then
2031                         with_mysql_config="$withval"
2032                 else if test -x "$withval/bin/mysql_config"
2033                 then
2034                         with_mysql_config="$withval/bin/mysql_config"
2035                 fi; fi
2036                 with_libmysql="yes"
2037         fi; fi
2038 ],
2039 [
2040         with_libmysql="yes"
2041 ])
2042 if test "x$with_libmysql" = "xyes"
2043 then
2044         with_mysql_cflags=`$with_mysql_config --cflags 2>/dev/null`
2045         mysql_config_status=$?
2046
2047         if test $mysql_config_status -ne 0
2048         then
2049                 with_libmysql="no ($with_mysql_config failed)"
2050         else
2051                 SAVE_CPPFLAGS="$CPPFLAGS"
2052                 CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
2053
2054                 have_mysql_h="no"
2055                 have_mysql_mysql_h="no"
2056                 AC_CHECK_HEADERS(mysql.h, [have_mysql_h="yes"])
2057
2058                 if test "x$have_mysql_h" = "xno"
2059                 then
2060                         AC_CHECK_HEADERS(mysql/mysql.h, [have_mysql_mysql_h="yes"])
2061                 fi
2062
2063                 if test "x$have_mysql_h$have_mysql_mysql_h" = "xnono"
2064                 then
2065                         with_libmysql="no (mysql.h not found)"
2066                 fi
2067
2068                 CPPFLAGS="$SAVE_CPPFLAGS"
2069         fi
2070 fi
2071 if test "x$with_libmysql" = "xyes"
2072 then
2073         with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
2074         mysql_config_status=$?
2075
2076         if test $mysql_config_status -ne 0
2077         then
2078                 with_libmysql="no ($with_mysql_config failed)"
2079         else
2080                 AC_CHECK_LIB(mysqlclient, mysql_init,
2081                  [with_libmysql="yes"],
2082                  [with_libmysql="no (symbol 'mysql_init' not found)"],
2083                  [$with_mysql_libs])
2084
2085                 AC_CHECK_LIB(mysqlclient, mysql_get_server_version,
2086                  [with_libmysql="yes"],
2087                  [with_libmysql="no (symbol 'mysql_get_server_version' not found)"],
2088                  [$with_mysql_libs])
2089         fi
2090 fi
2091 if test "x$with_libmysql" = "xyes"
2092 then
2093         BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
2094         BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
2095         AC_SUBST(BUILD_WITH_LIBMYSQL_CFLAGS)
2096         AC_SUBST(BUILD_WITH_LIBMYSQL_LIBS)
2097 fi
2098 AM_CONDITIONAL(BUILD_WITH_LIBMYSQL, test "x$with_libmysql" = "xyes")
2099 # }}}
2100
2101 # --with-libnetlink {{{
2102 with_libnetlink_cflags=""
2103 with_libnetlink_libs="-lnetlink"
2104 AC_ARG_WITH(libnetlink, [AS_HELP_STRING([--with-libnetlink@<:@=PREFIX@:>@], [Path to libnetlink.])],
2105 [
2106  echo "libnetlink: withval = $withval"
2107  if test "x$withval" = "xyes"
2108  then
2109          with_libnetlink="yes"
2110  else if test "x$withval" = "xno"
2111  then
2112          with_libnetlink="no"
2113  else
2114          if test -d "$withval/include"
2115          then
2116                  with_libnetlink_cflags="-I$withval/include"
2117                  with_libnetlink_libs="-L$withval/lib -lnetlink"
2118                  with_libnetlink="yes"
2119          else
2120                  AC_MSG_ERROR("no such directory: $withval/include")
2121          fi
2122  fi; fi
2123 ],
2124 [
2125  if test "x$ac_system" = "xLinux"
2126  then
2127          with_libnetlink="yes"
2128  else
2129          with_libnetlink="no (Linux only library)"
2130  fi
2131 ])
2132 if test "x$with_libnetlink" = "xyes"
2133 then
2134         SAVE_CFLAGS="$CFLAGS"
2135         CFLAGS="$CFLAGS $with_libnetlink_cflags"
2136
2137         with_libnetlink="no (libnetlink.h not found)"
2138
2139         AC_CHECK_HEADERS(libnetlink.h iproute/libnetlink.h linux/libnetlink.h,
2140         [
2141          with_libnetlink="yes"
2142          break
2143         ], [],
2144 [#include <stdio.h>
2145 #include <sys/types.h>
2146 #include <asm/types.h>
2147 #include <sys/socket.h>
2148 #include <linux/netlink.h>
2149 #include <linux/rtnetlink.h>])
2150         AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
2151 [#include <stdio.h>
2152 #include <sys/types.h>
2153 #include <asm/types.h>
2154 #include <sys/socket.h>])
2155
2156         AC_COMPILE_IFELSE(
2157 [#include <stdio.h>
2158 #include <sys/types.h>
2159 #include <asm/types.h>
2160 #include <sys/socket.h>
2161 #include <linux/netlink.h>
2162 #include <linux/rtnetlink.h>
2163
2164 int main (void)
2165 {
2166         int retval = TCA_STATS2;
2167         return (retval);
2168 }],
2169         [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
2170         []);
2171
2172         AC_COMPILE_IFELSE(
2173 [#include <stdio.h>
2174 #include <sys/types.h>
2175 #include <asm/types.h>
2176 #include <sys/socket.h>
2177 #include <linux/netlink.h>
2178 #include <linux/rtnetlink.h>
2179
2180 int main (void)
2181 {
2182         int retval = TCA_STATS;
2183         return (retval);
2184 }],
2185         [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
2186         []);
2187
2188         CFLAGS="$SAVE_CFLAGS"
2189 fi
2190 if test "x$with_libnetlink" = "xyes"
2191 then
2192         AC_CHECK_LIB(netlink, rtnl_open,
2193                      [with_libnetlink="yes"],
2194                      [with_libnetlink="no (symbol 'rtnl_open' not found)"],
2195                      [$with_libnetlink_libs])
2196 fi
2197 if test "x$with_libnetlink" = "xyes"
2198 then
2199         SAVE_CFLAGS="$CFLAGS"
2200         CFLAGS="$CFLAGS $with_libnetlink_cflags"
2201
2202         AC_CACHE_CHECK(
2203                 [if function 'rtnl_dump_filter' expects five arguments],
2204                 [c_cv_rtnl_dump_filter_five_args],
2205                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
2206                                 [
2207 AC_INCLUDES_DEFAULT
2208 #include <asm/types.h>
2209 #include <sys/socket.h>
2210 #if HAVE_LIBNETLINK_H
2211 # include <libnetlink.h>
2212 #elif HAVE_IPROUTE_LIBNETLINK_H
2213 # include <iproute/libnetlink.h>
2214 #elif HAVE_LINUX_LIBNETLINK_H
2215 # include <linux/libnetlink.h>
2216 #endif
2217                                 ],
2218                                 [
2219 if (rtnl_dump_filter(NULL, NULL, NULL, NULL, NULL))
2220         return 1;
2221 return 0;
2222                                 ]
2223                         )],
2224                         [c_cv_rtnl_dump_filter_five_args="yes"],
2225                         [c_cv_rtnl_dump_filter_five_args="no"]
2226                 )
2227         )
2228
2229         AC_CACHE_CHECK(
2230                 [if function 'rtnl_dump_filter' expects three arguments],
2231                 [c_cv_rtnl_dump_filter_three_args],
2232                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
2233                                 [
2234 AC_INCLUDES_DEFAULT
2235 #include <asm/types.h>
2236 #include <sys/socket.h>
2237 #if HAVE_LIBNETLINK_H
2238 # include <libnetlink.h>
2239 #elif HAVE_IPROUTE_LIBNETLINK_H
2240 # include <iproute/libnetlink.h>
2241 #elif HAVE_LINUX_LIBNETLINK_H
2242 # include <linux/libnetlink.h>
2243 #endif
2244                                 ],
2245                                 [
2246 if (rtnl_dump_filter(NULL, NULL, NULL))
2247         return 1;
2248 return 0;
2249                                 ]
2250                         )],
2251                         [c_cv_rtnl_dump_filter_three_args="yes"],
2252                         [c_cv_rtnl_dump_filter_three_args="no"]
2253                 )
2254         )
2255
2256         CFLAGS="$SAVE_CFLAGS"
2257
2258         if test "x$c_cv_rtnl_dump_filter_five_args" = "xyes"
2259         then
2260                 AC_DEFINE(RTNL_DUMP_FILTER_FIVE_ARGS, 1,
2261                                 [Define to 1 if function 'rtnl_dump_filter' expects five arguments.])
2262         fi
2263         if test "x$c_cv_rtnl_dump_filter_three_args" = "xyes"
2264         then
2265                 AC_DEFINE(RTNL_DUMP_FILTER_THREE_ARGS, 1,
2266                                 [Define to 1 if function 'rtnl_dump_filter' expects three arguments.])
2267         fi
2268
2269         BUILD_WITH_LIBNETLINK_CFLAGS="$with_libnetlink_cflags"
2270         BUILD_WITH_LIBNETLINK_LIBS="$with_libnetlink_libs"
2271         AC_SUBST(BUILD_WITH_LIBNETLINK_CFLAGS)
2272         AC_SUBST(BUILD_WITH_LIBNETLINK_LIBS)
2273 fi
2274 AM_CONDITIONAL(BUILD_WITH_LIBNETLINK, test "x$with_libnetlink" = "xyes")
2275 # }}}
2276
2277 # --with-libnetapp {{{
2278 AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
2279 AC_ARG_VAR([LIBNETAPP_LDFLAGS],  [Linker flags required to build with libnetapp])
2280 AC_ARG_VAR([LIBNETAPP_LIBS],     [Other libraries required to link against libnetapp])
2281 LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS"
2282 LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS"
2283 LIBNETAPP_LIBS="$LIBNETAPP_LIBS"
2284 AC_ARG_WITH(libnetapp, [AS_HELP_STRING([--with-libnetapp@<:@=PREFIX@:>@], [Path to libnetapp.])],
2285 [
2286  if test -d "$withval"
2287  then
2288          LIBNETAPP_CPPFLAGS="$LIBNETAPP_CPPFLAGS -I$withval/include"
2289          LIBNETAPP_LDFLAGS="$LIBNETAPP_LDFLAGS -L$withval/lib"
2290          with_libnetapp="yes"
2291  else
2292          with_libnetapp="$withval"
2293  fi
2294 ],
2295 [
2296  with_libnetapp="yes"
2297 ])
2298
2299 SAVE_CPPFLAGS="$CPPFLAGS"
2300 SAVE_LDFLAGS="$LDFLAGS"
2301 CPPFLAGS="$CPPFLAGS $LIBNETAPP_CPPFLAGS"
2302 LDFLAGS="$LDFLAGS $LIBNETAPP_LDFLAGS"
2303
2304 if test "x$with_libnetapp" = "xyes"
2305 then
2306         if test "x$LIBNETAPP_CPPFLAGS" != "x"
2307         then
2308                 AC_MSG_NOTICE([netapp CPPFLAGS: $LIBNETAPP_CPPFLAGS])
2309         fi
2310         AC_CHECK_HEADERS(netapp_api.h,
2311                 [with_libnetapp="yes"],
2312                 [with_libnetapp="no (netapp_api.h not found)"])
2313 fi
2314
2315 if test "x$with_libnetapp" = "xyes"
2316 then
2317         if test "x$LIBNETAPP_LDFLAGS" != "x"
2318         then
2319                 AC_MSG_NOTICE([netapp LDFLAGS: $LIBNETAPP_LDFLAGS])
2320         fi
2321
2322         if test "x$LIBNETAPP_LIBS" = "x"
2323         then
2324                 LIBNETAPP_LIBS="-lpthread -lxml -ladt -lssl -lm -lcrypto -lz"
2325         fi
2326         AC_MSG_NOTICE([netapp LIBS: $LIBNETAPP_LIBS])
2327
2328         AC_CHECK_LIB(netapp, na_server_invoke_elem,
2329                 [with_libnetapp="yes"],
2330                 [with_libnetapp="no (symbol na_server_invoke_elem not found)"],
2331                 [$LIBNETAPP_LIBS])
2332         LIBNETAPP_LIBS="-lnetapp $LIBNETAPP_LIBS"
2333 fi
2334
2335 CPPFLAGS="$SAVE_CPPFLAGS"
2336 LDFLAGS="$SAVE_LDFLAGS"
2337
2338 if test "x$with_libnetapp" = "xyes"
2339 then
2340         AC_DEFINE(HAVE_LIBNETAPP, 1, [Define to 1 if you have the netapp library (-lnetapp).])
2341 fi
2342
2343 AC_SUBST(LIBNETAPP_CPPFLAGS)
2344 AC_SUBST(LIBNETAPP_LDFLAGS)
2345 AC_SUBST(LIBNETAPP_LIBS)
2346 AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
2347 # }}}
2348
2349 # --with-libnetsnmp {{{
2350 with_snmp_config="net-snmp-config"
2351 with_snmp_cflags=""
2352 with_snmp_libs=""
2353 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
2354 [
2355         if test "x$withval" = "xno"
2356         then
2357                 with_libnetsnmp="no"
2358         else if test "x$withval" = "xyes"
2359         then
2360                 with_libnetsnmp="yes"
2361         else
2362                 if test -x "$withval"
2363                 then
2364                         with_snmp_config="$withval"
2365                         with_libnetsnmp="yes"
2366                 else
2367                         with_snmp_config="$withval/bin/net-snmp-config"
2368                         with_libnetsnmp="yes"
2369                 fi
2370         fi; fi
2371 ],
2372 [with_libnetsnmp="yes"])
2373 if test "x$with_libnetsnmp" = "xyes"
2374 then
2375         with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
2376         snmp_config_status=$?
2377
2378         if test $snmp_config_status -ne 0
2379         then
2380                 with_libnetsnmp="no ($with_snmp_config failed)"
2381         else
2382                 SAVE_CPPFLAGS="$CPPFLAGS"
2383                 CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
2384                 
2385                 AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
2386
2387                 CPPFLAGS="$SAVE_CPPFLAGS"
2388         fi
2389 fi
2390 if test "x$with_libnetsnmp" = "xyes"
2391 then
2392         with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
2393         snmp_config_status=$?
2394
2395         if test $snmp_config_status -ne 0
2396         then
2397                 with_libnetsnmp="no ($with_snmp_config failed)"
2398         else
2399                 AC_CHECK_LIB(netsnmp, init_snmp,
2400                 [with_libnetsnmp="yes"],
2401                 [with_libnetsnmp="no (libnetsnmp not found)"],
2402                 [$with_snmp_libs])
2403         fi
2404 fi
2405 if test "x$with_libnetsnmp" = "xyes"
2406 then
2407         BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
2408         BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
2409         AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
2410         AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
2411 fi
2412 AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
2413 # }}}
2414
2415 # --with-liboconfig {{{
2416 with_own_liboconfig="no"
2417 liboconfig_LDFLAGS="$LDFLAGS"
2418 liboconfig_CPPFLAGS="$CPPFLAGS"
2419 AC_ARG_WITH(liboconfig, [AS_HELP_STRING([--with-liboconfig@<:@=PREFIX@:>@], [Path to liboconfig.])],
2420 [
2421         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2422         then
2423                 if test -d "$withval/lib"
2424                 then
2425                         liboconfig_LDFLAGS="$LDFLAGS -L$withval/lib"
2426                 fi
2427                 if test -d "$withval/include"
2428                 then
2429                         liboconfig_CPPFLAGS="$CPPFLAGS -I$withval/include"
2430                 fi
2431         fi
2432         if test "x$withval" = "xno"
2433         then
2434                 AC_MSG_ERROR("liboconfig is required")
2435         fi
2436 ],
2437 [
2438         with_liboconfig="yes"
2439 ])
2440
2441 save_LDFLAGS="$LDFLAGS"
2442 save_CPPFLAGS="$CPPFLAGS"
2443 LDFLAGS="$liboconfig_LDFLAGS"
2444 CPPFLAGS="$liboconfig_CPPFLAGS"
2445 AC_CHECK_LIB(oconfig, oconfig_parse_fh,
2446 [
2447         with_liboconfig="yes"
2448         with_own_liboconfig="no"
2449 ],
2450 [
2451         with_liboconfig="yes"
2452         with_own_liboconfig="yes"
2453         LDFLAGS="$save_LDFLAGS"
2454         CPPFLAGS="$save_CPPFLAGS"
2455 ])
2456
2457 AM_CONDITIONAL(BUILD_WITH_OWN_LIBOCONFIG, test "x$with_own_liboconfig" = "xyes")
2458 if test "x$with_own_liboconfig" = "xyes"
2459 then
2460         with_liboconfig="yes (shipped version)"
2461 fi
2462 # }}}
2463
2464 # --with-liboping {{{
2465 AC_ARG_WITH(liboping, [AS_HELP_STRING([--with-liboping@<:@=PREFIX@:>@], [Path to liboping.])],
2466 [
2467  if test "x$withval" = "xyes"
2468  then
2469          with_liboping="yes"
2470  else if test "x$withval" = "xno"
2471  then
2472          with_liboping="no"
2473  else
2474          with_liboping="yes"
2475          LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS -I$withval/include"
2476          LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS -L$withval/lib"
2477  fi; fi
2478 ],
2479 [with_liboping="yes"])
2480
2481 SAVE_CPPFLAGS="$CPPFLAGS"
2482 SAVE_LDFLAGS="$LDFLAGS"
2483
2484 CPPFLAGS="$CPPFLAGS $LIBOPING_CPPFLAGS"
2485 LDFLAGS="$LDFLAGS $LIBOPING_LDFLAGS"
2486
2487 if test "x$with_liboping" = "xyes"
2488 then
2489         if test "x$LIBOPING_CPPFLAGS" != "x"
2490         then
2491                 AC_MSG_NOTICE([liboping CPPFLAGS: $LIBOPING_CPPFLAGS])
2492         fi
2493         AC_CHECK_HEADERS(oping.h,
2494         [with_liboping="yes"],
2495         [with_liboping="no ('oping.h' not found)"])
2496 fi
2497 if test "x$with_liboping" = "xyes"
2498 then
2499         if test "x$LIBOPING_LDFLAGS" != "x"
2500         then
2501                 AC_MSG_NOTICE([liboping LDFLAGS: $LIBOPING_LDFLAGS])
2502         fi
2503         AC_CHECK_LIB(oping, ping_construct,
2504         [with_liboping="yes"],
2505         [with_liboping="no (symbol 'ping_construct' not found)"])
2506 fi
2507
2508 CPPFLAGS="$SAVE_CPPFLAGS"
2509 LDFLAGS="$SAVE_LDFLAGS"
2510
2511 if test "x$with_liboping" = "xyes"
2512 then
2513         BUILD_WITH_LIBOPING_CPPFLAGS="$LIBOPING_CPPFLAGS"
2514         BUILD_WITH_LIBOPING_LDFLAGS="$LIBOPING_LDFLAGS"
2515         AC_SUBST(BUILD_WITH_LIBOPING_CPPFLAGS)
2516         AC_SUBST(BUILD_WITH_LIBOPING_LDFLAGS)
2517 fi
2518 AM_CONDITIONAL(BUILD_WITH_LIBOPING, test "x$with_liboping" = "xyes")
2519 # }}}
2520
2521 # --with-oracle {{{
2522 with_oracle_cppflags=""
2523 with_oracle_libs=""
2524 AC_ARG_WITH(oracle, [AS_HELP_STRING([--with-oracle@<:@=ORACLE_HOME@:>@], [Path to Oracle.])],
2525 [
2526         if test "x$withval" = "xyes"
2527         then
2528                 if test "x$ORACLE_HOME" = "x"
2529                 then
2530                         AC_MSG_WARN([Use of the Oracle library has been forced, but the environment variable ORACLE_HOME is not set.])
2531                 fi
2532                 with_oracle="yes"
2533         else if test "x$withval" = "xno"
2534         then
2535                 with_oracle="no"
2536         else
2537                 with_oracle="yes"
2538                 ORACLE_HOME="$withval"
2539         fi; fi
2540 ],
2541 [
2542         if test "x$ORACLE_HOME" = "x"
2543         then
2544                 with_oracle="no (ORACLE_HOME is not set)"
2545         else
2546                 with_oracle="yes"
2547         fi
2548 ])
2549 if test "x$ORACLE_HOME" != "x"
2550 then
2551         with_oracle_cppflags="-I$ORACLE_HOME/rdbms/public"
2552
2553         if test -e "$ORACLE_HOME/lib/ldflags"
2554         then
2555                 with_oracle_libs=`cat "$ORACLE_HOME/lib/ldflags"`
2556         fi
2557         #with_oracle_libs="-L$ORACLE_HOME/lib $with_oracle_libs -lclntsh"
2558         with_oracle_libs="-L$ORACLE_HOME/lib -lclntsh"
2559 fi
2560 if test "x$with_oracle" = "xyes"
2561 then
2562         SAVE_CPPFLAGS="$CPPFLAGS"
2563         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
2564
2565         AC_CHECK_HEADERS(oci.h, [with_oracle="yes"], [with_oracle="no (oci.h not found)"])
2566
2567         CPPFLAGS="$SAVE_CPPFLAGS"
2568 fi
2569 if test "x$with_oracle" = "xyes"
2570 then
2571         SAVE_CPPFLAGS="$CPPFLAGS"
2572         SAVE_LDFLAGS="$LDFLAGS"
2573         CPPFLAGS="$CPPFLAGS $with_oracle_cppflags"
2574         LDFLAGS="$LDFLAGS $with_oracle_libs"
2575
2576         AC_CHECK_FUNC(OCIEnvCreate, [with_oracle="yes"], [with_oracle="no (Symbol 'OCIEnvCreate' not found)"])
2577
2578         CPPFLAGS="$SAVE_CPPFLAGS"
2579         LDFLAGS="$SAVE_LDFLAGS"
2580 fi
2581 if test "x$with_oracle" = "xyes"
2582 then
2583         BUILD_WITH_ORACLE_CFLAGS="$with_oracle_cppflags"
2584         BUILD_WITH_ORACLE_LIBS="$with_oracle_libs"
2585         AC_SUBST(BUILD_WITH_ORACLE_CFLAGS)
2586         AC_SUBST(BUILD_WITH_ORACLE_LIBS)
2587 fi
2588 # }}}
2589
2590 # --with-libowcapi {{{
2591 with_libowcapi_cppflags=""
2592 with_libowcapi_libs="-lowcapi"
2593 AC_ARG_WITH(libowcapi, [AS_HELP_STRING([--with-libowcapi@<:@=PREFIX@:>@], [Path to libowcapi.])],
2594 [
2595         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2596         then
2597                 with_libowcapi_cppflags="-I$withval/include"
2598                 with_libowcapi_libs="-L$withval/lib -lowcapi"
2599                 with_libowcapi="yes"
2600         else
2601                 with_libowcapi="$withval"
2602         fi
2603 ],
2604 [
2605         with_libowcapi="yes"
2606 ])
2607 if test "x$with_libowcapi" = "xyes"
2608 then
2609         SAVE_CPPFLAGS="$CPPFLAGS"
2610         CPPFLAGS="$with_libowcapi_cppflags"
2611         
2612         AC_CHECK_HEADERS(owcapi.h, [with_libowcapi="yes"], [with_libowcapi="no (owcapi.h not found)"])
2613
2614         CPPFLAGS="$SAVE_CPPFLAGS"
2615 fi
2616 if test "x$with_libowcapi" = "xyes"
2617 then
2618         SAVE_LDFLAGS="$LDFLAGS"
2619         SAVE_CPPFLAGS="$CPPFLAGS"
2620         LDFLAGS="$with_libowcapi_libs"
2621         CPPFLAGS="$with_libowcapi_cppflags"
2622         
2623         AC_CHECK_LIB(owcapi, OW_get, [with_libowcapi="yes"], [with_libowcapi="no (libowcapi not found)"])
2624
2625         LDFLAGS="$SAVE_LDFLAGS"
2626         CPPFLAGS="$SAVE_CPPFLAGS"
2627 fi
2628 if test "x$with_libowcapi" = "xyes"
2629 then
2630         BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
2631         BUILD_WITH_LIBOWCAPI_LIBS="$with_libowcapi_libs"
2632         AC_SUBST(BUILD_WITH_LIBOWCAPI_CPPFLAGS)
2633         AC_SUBST(BUILD_WITH_LIBOWCAPI_LIBS)
2634 fi
2635 # }}}
2636
2637 # --with-libpcap {{{
2638 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
2639 [
2640         if test "x$withval" != "xno" && test "x$withval" != "xyes"
2641         then
2642                 LDFLAGS="$LDFLAGS -L$withval/lib"
2643                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2644                 with_libpcap="yes"
2645         else
2646                 with_libpcap="$withval"
2647         fi
2648 ],
2649 [
2650         with_libpcap="yes"
2651 ])
2652 if test "x$with_libpcap" = "xyes"
2653 then
2654         AC_CHECK_LIB(pcap, pcap_open_live,
2655         [
2656                 AC_DEFINE(HAVE_LIBPCAP, 1, [Define to 1 if you have the pcap library (-lpcap).])
2657         ], [with_libpcap="no (libpcap not found)"])
2658 fi
2659 if test "x$with_libpcap" = "xyes"
2660 then
2661         AC_CHECK_HEADERS(pcap.h,,
2662                          [with_libpcap="no (pcap.h not found)"])
2663 fi
2664 if test "x$with_libpcap" = "xyes"
2665 then
2666         AC_CHECK_HEADERS(pcap-bpf.h)
2667 fi
2668 AM_CONDITIONAL(BUILD_WITH_LIBPCAP, test "x$with_libpcap" = "xyes")
2669 # }}}
2670
2671 # --with-libperl {{{
2672 perl_interpreter="perl"
2673 AC_ARG_WITH(libperl, [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
2674 [
2675         if test -f "$withval" && test -x "$withval"
2676         then
2677                 perl_interpreter="$withval"
2678                 with_libperl="yes"
2679         else if test "x$withval" != "xno" && test "x$withval" != "xyes"
2680         then
2681                 LDFLAGS="$LDFLAGS -L$withval/lib"
2682                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2683                 perl_interpreter="$withval/bin/perl"
2684                 with_libperl="yes"
2685         else
2686                 with_libperl="$withval"
2687         fi; fi
2688 ],
2689 [
2690         with_libperl="yes"
2691 ])
2692
2693 AC_MSG_CHECKING([for perl])
2694 perl_interpreter=`which "$perl_interpreter" 2> /dev/null`
2695 if test -x "$perl_interpreter"
2696 then
2697         AC_MSG_RESULT([yes ($perl_interpreter)])
2698 else
2699         perl_interpreter=""
2700         AC_MSG_RESULT([no])
2701 fi
2702
2703 AC_SUBST(PERL, "$perl_interpreter")
2704
2705 if test "x$with_libperl" = "xyes" \
2706         && test -n "$perl_interpreter"
2707 then
2708   SAVE_CFLAGS="$CFLAGS"
2709   SAVE_LDFLAGS="$LDFLAGS"
2710 dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
2711   PERL_CFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ccopts`
2712   PERL_LDFLAGS=`ARCHFLAGS="" $perl_interpreter -MExtUtils::Embed -e ldopts`
2713   CFLAGS="$CFLAGS $PERL_CFLAGS"
2714   LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2715
2716   AC_CACHE_CHECK([for libperl],
2717     [c_cv_have_libperl],
2718     AC_LINK_IFELSE(
2719       AC_LANG_PROGRAM(
2720       [[
2721 #define PERL_NO_GET_CONTEXT
2722 #include <EXTERN.h>
2723 #include <perl.h>
2724 #include <XSUB.h>
2725       ]],
2726       [[
2727        dTHX;
2728        load_module (PERL_LOADMOD_NOIMPORT,
2729                          newSVpv ("Collectd::Plugin::FooBar", 24),
2730                          Nullsv);
2731       ]]),
2732       [c_cv_have_libperl="yes"],
2733       [c_cv_have_libperl="no"]
2734     )
2735   )
2736
2737   if test "x$c_cv_have_libperl" = "xyes"
2738   then
2739           AC_DEFINE(HAVE_LIBPERL, 1, [Define if libperl is present and usable.])
2740           AC_SUBST(PERL_CFLAGS)
2741           AC_SUBST(PERL_LDFLAGS)
2742   else
2743           with_libperl="no"
2744   fi
2745
2746   CFLAGS="$SAVE_CFLAGS"
2747   LDFLAGS="$SAVE_LDFLAGS"
2748 else if test -z "$perl_interpreter"; then
2749   with_libperl="no (no perl interpreter found)"
2750   c_cv_have_libperl="no"
2751 fi; fi
2752 AM_CONDITIONAL(BUILD_WITH_LIBPERL, test "x$with_libperl" = "xyes")
2753
2754 if test "x$with_libperl" = "xyes"
2755 then
2756         SAVE_CFLAGS="$CFLAGS"
2757         SAVE_LDFLAGS="$LDFLAGS"
2758         CFLAGS="$CFLAGS $PERL_CFLAGS"
2759         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2760
2761         AC_CACHE_CHECK([if perl supports ithreads],
2762                 [c_cv_have_perl_ithreads],
2763                 AC_LINK_IFELSE(
2764                         AC_LANG_PROGRAM(
2765                         [[
2766 #include <EXTERN.h>
2767 #include <perl.h>
2768 #include <XSUB.h>
2769
2770 #if !defined(USE_ITHREADS)
2771 # error "Perl does not support ithreads!"
2772 #endif /* !defined(USE_ITHREADS) */
2773                         ]],
2774                         [[ ]]),
2775                         [c_cv_have_perl_ithreads="yes"],
2776                         [c_cv_have_perl_ithreads="no"]
2777                 )
2778         )
2779
2780         if test "x$c_cv_have_perl_ithreads" = "xyes"
2781         then
2782                 AC_DEFINE(HAVE_PERL_ITHREADS, 1, [Define if Perl supports ithreads.])
2783         fi
2784
2785         CFLAGS="$SAVE_CFLAGS"
2786         LDFLAGS="$SAVE_LDFLAGS"
2787 fi
2788
2789 if test "x$with_libperl" = "xyes"
2790 then
2791         SAVE_CFLAGS="$CFLAGS"
2792         SAVE_LDFLAGS="$LDFLAGS"
2793         # trigger an error if Perl_load_module*() uses __attribute__nonnull__(3)
2794         # (see issues #41 and #42)
2795         CFLAGS="$CFLAGS $PERL_CFLAGS -Wall -Werror"
2796         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2797
2798         AC_CACHE_CHECK([for broken Perl_load_module()],
2799                 [c_cv_have_broken_perl_load_module],
2800                 AC_LINK_IFELSE(
2801                         AC_LANG_PROGRAM(
2802                         [[
2803 #define PERL_NO_GET_CONTEXT
2804 #include <EXTERN.h>
2805 #include <perl.h>
2806 #include <XSUB.h>
2807                         ]],
2808                         [[
2809                          dTHX;
2810                          load_module (PERL_LOADMOD_NOIMPORT,
2811                              newSVpv ("Collectd::Plugin::FooBar", 24),
2812                              Nullsv);
2813                         ]]),
2814                         [c_cv_have_broken_perl_load_module="no"],
2815                         [c_cv_have_broken_perl_load_module="yes"]
2816                 )
2817         )
2818
2819         CFLAGS="$SAVE_CFLAGS"
2820         LDFLAGS="$SAVE_LDFLAGS"
2821 fi
2822 AM_CONDITIONAL(HAVE_BROKEN_PERL_LOAD_MODULE,
2823                 test "x$c_cv_have_broken_perl_load_module" = "xyes")
2824
2825 if test "x$with_libperl" = "xyes"
2826 then
2827         SAVE_CFLAGS="$CFLAGS"
2828         SAVE_LDFLAGS="$LDFLAGS"
2829         CFLAGS="$CFLAGS $PERL_CFLAGS"
2830         LDFLAGS="$LDFLAGS $PERL_LDFLAGS"
2831
2832         AC_CHECK_MEMBER(
2833                 [struct mgvtbl.svt_local],
2834                 [have_struct_mgvtbl_svt_local="yes"],
2835                 [have_struct_mgvtbl_svt_local="no"],
2836                 [
2837 #include <EXTERN.h>
2838 #include <perl.h>
2839 #include <XSUB.h>
2840                 ])
2841
2842         if test "x$have_struct_mgvtbl_svt_local" = "xyes"
2843         then
2844                 AC_DEFINE(HAVE_PERL_STRUCT_MGVTBL_SVT_LOCAL, 1,
2845                                   [Define if Perl's struct mgvtbl has member svt_local.])
2846         fi
2847
2848         CFLAGS="$SAVE_CFLAGS"
2849         LDFLAGS="$SAVE_LDFLAGS"
2850 fi
2851 # }}}
2852
2853 # --with-libpq {{{
2854 with_pg_config="pg_config"
2855 with_libpq_includedir=""
2856 with_libpq_libdir=""
2857 with_libpq_cppflags=""
2858 with_libpq_ldflags=""
2859 AC_ARG_WITH(libpq, [AS_HELP_STRING([--with-libpq@<:@=PREFIX@:>@],
2860         [Path to libpq.])],
2861 [
2862         if test "x$withval" = "xno"
2863         then
2864                 with_libpq="no"
2865         else if test "x$withval" = "xyes"
2866         then
2867                 with_libpq="yes"
2868         else
2869                 if test -f "$withval" && test -x "$withval";
2870                 then
2871                         with_pg_config="$withval"
2872                 else if test -x "$withval/bin/pg_config"
2873                 then
2874                         with_pg_config="$withval/bin/pg_config"
2875                 fi; fi
2876                 with_libpq="yes"
2877         fi; fi
2878 ],
2879 [
2880         with_libpq="yes"
2881 ])
2882 if test "x$with_libpq" = "xyes"
2883 then
2884         with_libpq_includedir=`$with_pg_config --includedir 2> /dev/null`
2885         pg_config_status=$?
2886
2887         if test $pg_config_status -eq 0
2888         then
2889                 if test -n "$with_libpq_includedir"; then
2890                         for dir in $with_libpq_includedir; do
2891                                 with_libpq_cppflags="$with_libpq_cppflags -I$dir"
2892                         done
2893                 fi
2894         else
2895                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2896         fi
2897
2898         SAVE_CPPFLAGS="$CPPFLAGS"
2899         CPPFLAGS="$CPPFLAGS $with_libpq_cppflags"
2900
2901         AC_CHECK_HEADERS(libpq-fe.h, [],
2902                 [with_libpq="no (libpq-fe.h not found)"], [])
2903
2904         CPPFLAGS="$SAVE_CPPFLAGS"
2905 fi
2906 if test "x$with_libpq" = "xyes"
2907 then
2908         with_libpq_libdir=`$with_pg_config --libdir 2> /dev/null`
2909         pg_config_status=$?
2910
2911         if test $pg_config_status -eq 0
2912         then
2913                 if test -n "$with_libpq_libdir"; then
2914                         for dir in $with_libpq_libdir; do
2915                                 with_libpq_ldflags="$with_libpq_ldflags -L$dir"
2916                         done
2917                 fi
2918         else
2919                 AC_MSG_WARN([$with_pg_config returned with status $pg_config_status])
2920         fi
2921
2922         SAVE_LDFLAGS="$LDFLAGS"
2923         LDFLAGS="$LDFLAGS $with_libpq_ldflags"
2924
2925         AC_CHECK_LIB(pq, PQconnectdb,
2926                 [with_libpq="yes"],
2927                 [with_libpq="no (symbol 'PQconnectdb' not found)"])
2928
2929         AC_CHECK_LIB(pq, PQserverVersion,
2930                 [with_libpq="yes"],
2931                 [with_libpq="no (symbol 'PQserverVersion' not found)"])
2932
2933         LDFLAGS="$SAVE_LDFLAGS"
2934 fi
2935 if test "x$with_libpq" = "xyes"
2936 then
2937         BUILD_WITH_LIBPQ_CPPFLAGS="$with_libpq_cppflags"
2938         BUILD_WITH_LIBPQ_LDFLAGS="$with_libpq_ldflags"
2939         AC_SUBST(BUILD_WITH_LIBPQ_CPPFLAGS)
2940         AC_SUBST(BUILD_WITH_LIBPQ_LDFLAGS)
2941 fi
2942 AM_CONDITIONAL(BUILD_WITH_LIBPQ, test "x$with_libpq" = "xyes")
2943 # }}}
2944
2945 # --with-libpthread {{{
2946 AC_ARG_WITH(libpthread, [AS_HELP_STRING([--with-libpthread=@<:@=PREFIX@:>@], [Path to libpthread.])],
2947 [       if test "x$withval" != "xno" \
2948                 && test "x$withval" != "xyes"
2949         then
2950                 LDFLAGS="$LDFLAGS -L$withval/lib"
2951                 CPPFLAGS="$CPPFLAGS -I$withval/include"
2952                 with_libpthread="yes"
2953         else
2954                 if test "x$withval" = "xno"
2955                 then
2956                         with_libpthread="no (disabled)"
2957                 fi
2958         fi
2959 ], [with_libpthread="yes"])
2960 if test "x$with_libpthread" = "xyes"
2961 then
2962         AC_CHECK_LIB(pthread, pthread_create, [with_libpthread="yes"], [with_libpthread="no (libpthread not found)"], [])
2963 fi
2964
2965 if test "x$with_libpthread" = "xyes"
2966 then
2967         AC_CHECK_HEADERS(pthread.h,, [with_libpthread="no (pthread.h not found)"])
2968 fi
2969 if test "x$with_libpthread" = "xyes"
2970 then
2971         collect_pthread=1
2972 else
2973         collect_pthread=0
2974 fi
2975 AC_DEFINE_UNQUOTED(HAVE_LIBPTHREAD, [$collect_pthread],
2976         [Wether or not to use pthread (POSIX threads) library])
2977 AM_CONDITIONAL(BUILD_WITH_LIBPTHREAD, test "x$with_libpthread" = "xyes")
2978 # }}}
2979
2980 # --with-python {{{
2981 with_python_prog=""
2982 with_python_path="$PATH"
2983 AC_ARG_WITH(python, [AS_HELP_STRING([--with-python@<:@=PREFIX@:>@], [Path to the python interpreter.])],
2984 [
2985  if test "x$withval" = "xyes" || test "x$withval" = "xno"
2986  then
2987          with_python="$withval"
2988  else if test -x "$withval"
2989  then
2990          with_python_prog="$withval"
2991          with_python_path="`dirname \"$withval\"`$PATH_SEPARATOR$with_python_path"
2992          with_python="yes"
2993  else if test -d "$withval"
2994  then
2995          with_python_path="$withval$PATH_SEPARATOR$with_python_path"
2996          with_python="yes"
2997  else
2998          AC_MSG_WARN([Argument not recognized: $withval])
2999  fi; fi; fi
3000 ], [with_python="yes"])
3001
3002 SAVE_PATH="$PATH"
3003 SAVE_CPPFLAGS="$CPPFLAGS"
3004 SAVE_LDFLAGS="$LDFLAGS"
3005 SAVE_LIBS="$LIBS"
3006
3007 PATH="$with_python_path"
3008
3009 if test "x$with_python" = "xyes" && test "x$with_python_prog" = "x"
3010 then
3011         AC_MSG_CHECKING([for python])
3012         with_python_prog="`which python 2>/dev/null`"
3013         if test "x$with_python_prog" = "x"
3014         then
3015                 AC_MSG_RESULT([not found])
3016                 with_python="no (interpreter not found)"
3017         else
3018                 AC_MSG_RESULT([$with_python_prog])
3019         fi
3020 fi
3021
3022 if test "x$with_python" = "xyes"
3023 then
3024         AC_MSG_CHECKING([for Python CPPFLAGS])
3025         python_include_path=`echo "import distutils.sysconfig;import sys;sys.stdout.write(distutils.sysconfig.get_python_inc())" | "$with_python_prog" 2>&1`
3026         python_config_status=$?
3027
3028         if test "$python_config_status" -ne 0 || test "x$python_include_path" = "x"
3029         then
3030                 AC_MSG_RESULT([failed with status $python_config_status (output: $python_include_path)])
3031                 with_python="no"
3032         else
3033                 AC_MSG_RESULT([$python_include_path])
3034         fi
3035 fi
3036
3037 if test "x$with_python" = "xyes"
3038 then
3039         CPPFLAGS="-I$python_include_path $CPPFLAGS"
3040         AC_CHECK_HEADERS(Python.h,
3041                          [with_python="yes"],
3042                          [with_python="no ('Python.h' not found)"])
3043 fi
3044
3045 if test "x$with_python" = "xyes"
3046 then
3047         AC_MSG_CHECKING([for Python LDFLAGS])
3048         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`
3049         python_config_status=$?
3050
3051         if test "$python_config_status" -ne 0 || test "x$python_library_path" = "x"
3052         then
3053                 AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_path)])
3054                 with_python="no"
3055         else
3056                 AC_MSG_RESULT([$python_library_path])
3057         fi
3058 fi
3059
3060 if test "x$with_python" = "xyes"
3061 then
3062         AC_MSG_CHECKING([for Python LIBS])
3063         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`
3064         python_config_status=$?
3065
3066         if test "$python_config_status" -ne 0 || test "x$python_library_flags" = "x"
3067         then
3068                 AC_MSG_RESULT([failed with status $python_config_status (output: $python_library_flags)])
3069                 with_python="no"
3070         else
3071                 AC_MSG_RESULT([$python_library_flags])
3072         fi
3073 fi
3074
3075 if test "x$with_python" = "xyes"
3076 then
3077         LDFLAGS="-L$python_library_path $LDFLAGS"
3078         LIBS="$python_library_flags $LIBS"
3079
3080         AC_CHECK_FUNC(PyObject_CallFunction,
3081                       [with_python="yes"],
3082                       [with_python="no (Symbol 'PyObject_CallFunction' not found)"])
3083 fi
3084
3085 PATH="$SAVE_PATH"
3086 CPPFLAGS="$SAVE_CPPFLAGS"
3087 LDFLAGS="$SAVE_LDFLAGS"
3088 LIBS="$SAVE_LIBS"
3089
3090 if test "x$with_python" = "xyes"
3091 then
3092         BUILD_WITH_PYTHON_CPPFLAGS="-I$python_include_path"
3093         BUILD_WITH_PYTHON_LDFLAGS="-L$python_library_path"
3094         BUILD_WITH_PYTHON_LIBS="$python_library_flags"
3095         AC_SUBST(BUILD_WITH_PYTHON_CPPFLAGS)
3096         AC_SUBST(BUILD_WITH_PYTHON_LDFLAGS)
3097         AC_SUBST(BUILD_WITH_PYTHON_LIBS)
3098 fi
3099 # }}} --with-python
3100
3101 # --with-librouteros {{{
3102 AC_ARG_WITH(librouteros, [AS_HELP_STRING([--with-librouteros@<:@=PREFIX@:>@], [Path to librouteros.])],
3103 [
3104  if test "x$withval" = "xyes"
3105  then
3106          with_librouteros="yes"
3107  else if test "x$withval" = "xno"
3108  then
3109          with_librouteros="no"
3110  else
3111          with_librouteros="yes"
3112          LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS -I$withval/include"
3113          LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS -L$withval/lib"
3114  fi; fi
3115 ],
3116 [with_librouteros="yes"])
3117
3118 SAVE_CPPFLAGS="$CPPFLAGS"
3119 SAVE_LDFLAGS="$LDFLAGS"
3120
3121 CPPFLAGS="$CPPFLAGS $LIBROUTEROS_CPPFLAGS"
3122 LDFLAGS="$LDFLAGS $LIBROUTEROS_LDFLAGS"
3123
3124 if test "x$with_librouteros" = "xyes"
3125 then
3126         if test "x$LIBROUTEROS_CPPFLAGS" != "x"
3127         then
3128                 AC_MSG_NOTICE([librouteros CPPFLAGS: $LIBROUTEROS_CPPFLAGS])
3129         fi
3130         AC_CHECK_HEADERS(routeros_api.h,
3131         [with_librouteros="yes"],
3132         [with_librouteros="no ('routeros_api.h' not found)"])
3133 fi
3134 if test "x$with_librouteros" = "xyes"
3135 then
3136         if test "x$LIBROUTEROS_LDFLAGS" != "x"
3137         then
3138                 AC_MSG_NOTICE([librouteros LDFLAGS: $LIBROUTEROS_LDFLAGS])
3139         fi
3140         AC_CHECK_LIB(routeros, ros_interface,
3141         [with_librouteros="yes"],
3142         [with_librouteros="no (symbol 'ros_interface' not found)"])
3143 fi
3144
3145 CPPFLAGS="$SAVE_CPPFLAGS"
3146 LDFLAGS="$SAVE_LDFLAGS"
3147
3148 if test "x$with_librouteros" = "xyes"
3149 then
3150         BUILD_WITH_LIBROUTEROS_CPPFLAGS="$LIBROUTEROS_CPPFLAGS"
3151         BUILD_WITH_LIBROUTEROS_LDFLAGS="$LIBROUTEROS_LDFLAGS"
3152         AC_SUBST(BUILD_WITH_LIBROUTEROS_CPPFLAGS)
3153         AC_SUBST(BUILD_WITH_LIBROUTEROS_LDFLAGS)
3154 fi
3155 AM_CONDITIONAL(BUILD_WITH_LIBROUTEROS, test "x$with_librouteros" = "xyes")
3156 # }}}
3157
3158 # --with-librrd {{{
3159 # AC_ARG_WITH (package, help-string, [action-if-given], [action-if-not-given])
3160 librrd_cflags=""
3161 librrd_ldflags=""
3162 librrd_threadsafe="yes"
3163 librrd_rrdc_update="no"
3164 AC_ARG_WITH(librrd, [AS_HELP_STRING([--with-librrd@<:@=PREFIX@:>@], [Path to rrdtool.])],
3165 [       if test "x$withval" != "xno" && test "x$withval" != "xyes"
3166         then
3167                 librrd_cflags="-I$withval/include"
3168                 librrd_ldflags="-L$withval/lib"
3169                 with_librrd="yes"
3170         else
3171                 with_librrd="$withval"
3172         fi
3173 ], [with_librrd="yes"])
3174 if test "x$with_librrd" = "xyes"
3175 then
3176         SAVE_CPPFLAGS="$CPPFLAGS"
3177         SAVE_LDFLAGS="$LDFLAGS"
3178
3179         CPPFLAGS="$CPPFLAGS $librrd_cflags"
3180         LDFLAGS="$LDFLAGS $librrd_ldflags"
3181
3182         AC_CHECK_HEADERS(rrd.h,, [with_librrd="no (rrd.h not found)"])
3183
3184         CPPFLAGS="$SAVE_CPPFLAGS"
3185         LDFLAGS="$SAVE_LDFLAGS"
3186 fi
3187 if test "x$with_librrd" = "xyes"
3188 then
3189         SAVE_CPPFLAGS="$CPPFLAGS"
3190         SAVE_LDFLAGS="$LDFLAGS"
3191
3192         CPPFLAGS="$CPPFLAGS $librrd_cflags"
3193         LDFLAGS="$LDFLAGS $librrd_ldflags"
3194
3195         AC_CHECK_LIB(rrd_th, rrd_update_r,
3196         [with_librrd="yes"
3197          librrd_ldflags="$librrd_ldflags -lrrd_th -lm"
3198         ],
3199         [librrd_threadsafe="no"
3200          AC_CHECK_LIB(rrd, rrd_update,
3201          [with_librrd="yes"
3202           librrd_ldflags="$librrd_ldflags -lrrd -lm"
3203          ],
3204          [with_librrd="no (symbol 'rrd_update' not found)"],
3205          [-lm])
3206         ],
3207         [-lm])
3208
3209         if test "x$librrd_threadsafe" = "xyes"
3210         then
3211                 AC_CHECK_LIB(rrd_th, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
3212         else
3213                 AC_CHECK_LIB(rrd, rrdc_update, [librrd_rrdc_update="yes"], [librrd_rrdc_update="no"])
3214         fi
3215
3216         CPPFLAGS="$SAVE_CPPFLAGS"
3217         LDFLAGS="$SAVE_LDFLAGS"
3218 fi
3219 if test "x$with_librrd" = "xyes"
3220 then
3221         BUILD_WITH_LIBRRD_CFLAGS="$librrd_cflags"
3222         BUILD_WITH_LIBRRD_LDFLAGS="$librrd_ldflags"
3223         AC_SUBST(BUILD_WITH_LIBRRD_CFLAGS)
3224         AC_SUBST(BUILD_WITH_LIBRRD_LDFLAGS)
3225 fi
3226 if test "x$librrd_threadsafe" = "xyes"
3227 then
3228         AC_DEFINE(HAVE_THREADSAFE_LIBRRD, 1, [Define to 1 if you have the threadsafe rrd library (-lrrd_th).])
3229 fi
3230 # }}}
3231
3232 # --with-libsensors {{{
3233 with_sensors_cflags=""
3234 with_sensors_ldflags=""
3235 AC_ARG_WITH(libsensors, [AS_HELP_STRING([--with-libsensors@<:@=PREFIX@:>@], [Path to lm_sensors.])],
3236 [
3237         if test "x$withval" = "xno"
3238         then
3239                 with_libsensors="no"
3240         else
3241                 with_libsensors="yes"
3242                 if test "x$withval" != "xyes"
3243                 then
3244                         with_sensors_cflags="-I$withval/include"
3245                         with_sensors_ldflags="-L$withval/lib"
3246                         with_libsensors="yes"
3247                 fi
3248         fi
3249 ],
3250 [
3251         if test "x$ac_system" = "xLinux"
3252         then
3253                 with_libsensors="yes"
3254         else
3255                 with_libsensors="no (Linux only library)"
3256         fi
3257 ])
3258 if test "x$with_libsensors" = "xyes"
3259 then
3260         SAVE_CPPFLAGS="$CPPFLAGS"
3261         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
3262
3263 #       AC_CHECK_HEADERS(sensors/sensors.h,
3264 #       [
3265 #               AC_DEFINE(HAVE_SENSORS_SENSORS_H, 1, [Define to 1 if you have the <sensors/sensors.h> header file.])
3266 #       ],
3267 #       [with_libsensors="no (sensors/sensors.h not found)"])
3268         AC_CHECK_HEADERS(sensors/sensors.h, [], [with_libsensors="no (sensors/sensors.h not found)"])
3269
3270         CPPFLAGS="$SAVE_CPPFLAGS"
3271 fi
3272 if test "x$with_libsensors" = "xyes"
3273 then
3274         SAVE_CPPFLAGS="$CPPFLAGS"
3275         SAVE_LDFLAGS="$LDFLAGS"
3276         CPPFLAGS="$CPPFLAGS $with_sensors_cflags"
3277         LDFLAGS="$LDFLAGS $with_sensors_ldflags"
3278
3279         AC_CHECK_LIB(sensors, sensors_init,
3280         [
3281                 AC_DEFINE(HAVE_LIBSENSORS, 1, [Define to 1 if you have the sensors library (-lsensors).])
3282         ],
3283         [with_libsensors="no (libsensors not found)"])
3284
3285         CPPFLAGS="$SAVE_CPPFLAGS"
3286         LDFLAGS="$SAVE_LDFLAGS"
3287 fi
3288 if test "x$with_libsensors" = "xyes"
3289 then
3290         BUILD_WITH_LIBSENSORS_CFLAGS="$with_sensors_cflags"
3291         BUILD_WITH_LIBSENSORS_LDFLAGS="$with_sensors_ldflags"
3292         AC_SUBST(BUILD_WITH_LIBSENSORS_CFLAGS)
3293         AC_SUBST(BUILD_WITH_LIBSENSORS_LDFLAGS)
3294 fi
3295 AM_CONDITIONAL(BUILD_WITH_LM_SENSORS, test "x$with_libsensors" = "xyes")
3296 # }}}
3297
3298 # --with-libstatgrab {{{
3299 with_libstatgrab_cflags=""
3300 with_libstatgrab_ldflags=""
3301 AC_ARG_WITH(libstatgrab, [AS_HELP_STRING([--with-libstatgrab@<:@=PREFIX@:>@], [Path to libstatgrab.])],
3302 [
3303  if test "x$withval" != "xno" \
3304    && test "x$withval" != "xyes"
3305  then
3306    with_libstatgrab_cflags="-I$withval/include"
3307    with_libstatgrab_ldflags="-L$withval/lib -lstatgrab"
3308    with_libstatgrab="yes"
3309    with_libstatgrab_pkg_config="no"
3310  else
3311    with_libstatgrab="$withval"
3312    with_libstatgrab_pkg_config="yes"
3313  fi
3314  ],
3315 [
3316  with_libstatgrab="yes"
3317  with_libstatgrab_pkg_config="yes"
3318 ])
3319
3320 if test "x$with_libstatgrab" = "xyes" \
3321   && test "x$with_libstatgrab_pkg_config" = "xyes"
3322 then
3323   if test "x$PKG_CONFIG" != "x"
3324   then
3325     AC_MSG_CHECKING([pkg-config for libstatgrab])
3326     temp_result="found"
3327     $PKG_CONFIG --exists libstatgrab 2>/dev/null
3328     if test "$?" != "0"
3329     then
3330       with_libstatgrab_pkg_config="no"
3331       with_libstatgrab="no ($PKG_CONFIG doesn't know libstatgrab)"
3332       temp_result="not found"
3333     fi
3334     AC_MSG_RESULT([$temp_result])
3335   else
3336     AC_MSG_NOTICE([pkg-config not available, trying to guess flags for the statgrab library.])
3337     with_libstatgrab_pkg_config="no"
3338     with_libstatgrab_ldflags="$with_libstatgrab_ldflags -lstatgrab"
3339   fi
3340 fi
3341
3342 if test "x$with_libstatgrab" = "xyes" \
3343   && test "x$with_libstatgrab_pkg_config" = "xyes" \
3344   && test "x$with_libstatgrab_cflags" = "x"
3345 then
3346   AC_MSG_CHECKING([for libstatgrab CFLAGS])
3347   temp_result="`$PKG_CONFIG --cflags libstatgrab`"
3348   if test "$?" = "0"
3349   then
3350     with_libstatgrab_cflags="$temp_result"
3351   else
3352     with_libstatgrab="no ($PKG_CONFIG --cflags libstatgrab failed)"
3353     temp_result="$PKG_CONFIG --cflags libstatgrab failed"
3354   fi
3355   AC_MSG_RESULT([$temp_result])
3356 fi
3357
3358 if test "x$with_libstatgrab" = "xyes" \
3359   && test "x$with_libstatgrab_pkg_config" = "xyes" \
3360   && test "x$with_libstatgrab_ldflags" = "x"
3361 then
3362   AC_MSG_CHECKING([for libstatgrab LDFLAGS])
3363   temp_result="`$PKG_CONFIG --libs libstatgrab`"
3364   if test "$?" = "0"
3365   then
3366     with_libstatgrab_ldflags="$temp_result"
3367   else
3368     with_libstatgrab="no ($PKG_CONFIG --libs libstatgrab failed)"
3369     temp_result="$PKG_CONFIG --libs libstatgrab failed"
3370   fi
3371   AC_MSG_RESULT([$temp_result])
3372 fi
3373
3374 if test "x$with_libstatgrab" = "xyes"
3375 then
3376   SAVE_CPPFLAGS="$CPPFLAGS"
3377   CPPFLAGS="$CPPFLAGS $with_libstatgrab_cflags"
3378
3379   AC_CHECK_HEADERS(statgrab.h,
3380                    [with_libstatgrab="yes"],
3381                    [with_libstatgrab="no (statgrab.h not found)"])
3382
3383   CPPFLAGS="$SAVE_CPPFLAGS"
3384 fi
3385
3386 if test "x$with_libstatgrab" = "xyes"
3387 then
3388   SAVE_CFLAGS="$CFLAGS"
3389   SAVE_LDFLAGS="$LDFLAGS"
3390
3391   CFLAGS="$CFLAGS $with_libstatgrab_cflags"
3392   LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags"
3393
3394   AC_CHECK_LIB(statgrab, sg_init,
3395                [with_libstatgrab="yes"],
3396                [with_libstatgrab="no (symbol sg_init not found)"])
3397
3398   CFLAGS="$SAVE_CFLAGS"
3399   LDFLAGS="$SAVE_LDFLAGS"
3400 fi
3401
3402 AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes")
3403 if test "x$with_libstatgrab" = "xyes"
3404 then
3405   AC_DEFINE(HAVE_LIBSTATGRAB, 1, [Define to 1 if you have the 'statgrab' library (-lstatgrab)])
3406   BUILD_WITH_LIBSTATGRAB_CFLAGS="$with_libstatgrab_cflags"
3407   BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags"
3408   AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS)
3409   AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS)
3410 fi
3411 # }}}
3412
3413 # --with-libtokyotyrant {{{
3414 with_libtokyotyrant_cppflags=""
3415 with_libtokyotyrant_ldflags=""
3416 with_libtokyotyrant_libs=""
3417 AC_ARG_WITH(libtokyotyrant, [AS_HELP_STRING([--with-libtokyotyrant@<:@=PREFIX@:>@], [Path to libtokyotyrant.])],
3418 [
3419   if test "x$withval" = "xno"
3420   then
3421     with_libtokyotyrant="no"
3422   else if test "x$withval" = "xyes"
3423   then
3424     with_libtokyotyrant="yes"
3425   else
3426     with_libtokyotyrant_cppflags="-I$withval/include"
3427     with_libtokyotyrant_ldflags="-L$withval/include"
3428     with_libtokyotyrant_libs="-ltokyotyrant"
3429     with_libtokyotyrant="yes"
3430   fi; fi
3431 ],
3432 [
3433   with_libtokyotyrant="yes"
3434 ])
3435
3436 if test "x$with_libtokyotyrant" = "xyes"
3437 then
3438   if $PKG_CONFIG --exists tokyotyrant
3439   then
3440     with_libtokyotyrant_cppflags="$with_libtokyotyrant_cppflags `$PKG_CONFIG --cflags tokyotyrant`"
3441     with_libtokyotyrant_ldflags="$with_libtokyotyrant_ldflags `pkg-config --libs-only-L tokyotyrant`"
3442     with_libtokyotyrant_libs="$with_libtokyotyrant_libs `pkg-config --libs-only-l tokyotyrant`"
3443   fi
3444 fi
3445
3446 SAVE_CPPFLAGS="$CPPFLAGS"
3447 SAVE_LDFLAGS="$LDFLAGS"
3448 CPPFLAGS="$CPPFLAGS $with_libtokyotyrant_cppflags"
3449 LDFLAGS="$LDFLAGS $with_libtokyotyrant_ldflags"
3450
3451 if test "x$with_libtokyotyrant" = "xyes"
3452 then
3453   AC_CHECK_HEADERS(tcrdb.h,
3454   [
3455           AC_DEFINE(HAVE_TCRDB_H, 1,
3456                     [Define to 1 if you have the <tcrdb.h> header file.])
3457   ], [with_libtokyotyrant="no (tcrdb.h not found)"])
3458 fi
3459
3460 if test "x$with_libtokyotyrant" = "xyes"
3461 then
3462   AC_CHECK_LIB(tokyotyrant, tcrdbrnum,
3463   [
3464           AC_DEFINE(HAVE_LIBTOKYOTYRANT, 1,
3465                     [Define to 1 if you have the tokyotyrant library (-ltokyotyrant).])
3466   ],
3467   [with_libtokyotyrant="no (symbol tcrdbrnum not found)"],
3468   [$with_libtokyotyrant_libs])
3469 fi
3470
3471 CPPFLAGS="$SAVE_CPPFLAGS"
3472 LDFLAGS="$SAVE_LDFLAGS"
3473
3474 if test "x$with_libtokyotyrant" = "xyes"
3475 then 
3476   BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS="$with_libtokyotyrant_cppflags"
3477   BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS="$with_libtokyotyrant_ldflags"
3478   BUILD_WITH_LIBTOKYOTYRANT_LIBS="$with_libtokyotyrant_libs"
3479   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_CPPFLAGS)
3480   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LDFLAGS)
3481   AC_SUBST(BUILD_WITH_LIBTOKYOTYRANT_LIBS)
3482 fi
3483 AM_CONDITIONAL(BUILD_WITH_LIBTOKYOTYRANT, test "x$with_libtokyotyrant" = "xyes")
3484 # }}}
3485
3486 # --with-libupsclient {{{
3487 with_libupsclient_config=""
3488 with_libupsclient_cflags=""
3489 with_libupsclient_libs=""
3490 AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@], [Path to the upsclient library.])],
3491 [
3492         if test "x$withval" = "xno"
3493         then
3494                 with_libupsclient="no"
3495         else if test "x$withval" = "xyes"
3496         then
3497                 with_libupsclient="use_pkgconfig"
3498         else
3499                 if test -x "$withval"
3500                 then
3501                         with_libupsclient_config="$withval"
3502                         with_libupsclient="use_libupsclient_config"
3503                 else if test -x "$withval/bin/libupsclient-config"
3504                 then
3505                         with_libupsclient_config="$withval/bin/libupsclient-config"
3506                         with_libupsclient="use_libupsclient_config"
3507                 else
3508                         AC_MSG_NOTICE([Not checking for libupsclient: Manually configured])
3509                         with_libupsclient_cflags="-I$withval/include"
3510                         with_libupsclient_libs="-L$withval/lib -lupsclient"
3511                         with_libupsclient="yes"
3512                 fi; fi
3513         fi; fi
3514 ],
3515 [with_libupsclient="use_pkgconfig"])
3516
3517 # configure using libupsclient-config
3518 if test "x$with_libupsclient" = "xuse_libupsclient_config"
3519 then
3520         AC_MSG_NOTICE([Checking for libupsclient using $with_libupsclient_config])
3521         with_libupsclient_cflags="`$with_libupsclient_config --cflags`"
3522         if test $? -ne 0
3523         then
3524                 with_libupsclient="no ($with_libupsclient_config failed)"
3525         fi
3526         with_libupsclient_libs="`$with_libupsclient_config --libs`"
3527         if test $? -ne 0
3528         then
3529                 with_libupsclient="no ($with_libupsclient_config failed)"
3530         fi
3531 fi
3532 if test "x$with_libupsclient" = "xuse_libupsclient_config"
3533 then
3534         with_libupsclient="yes"
3535 fi
3536
3537 # configure using pkg-config
3538 if test "x$with_libupsclient" = "xuse_pkgconfig"
3539 then
3540         if test "x$PKG_CONFIG" = "x"
3541         then
3542                 with_libupsclient="no (Don't have pkg-config)"
3543         fi
3544 fi
3545 if test "x$with_libupsclient" = "xuse_pkgconfig"
3546 then
3547         AC_MSG_NOTICE([Checking for libupsclient using $PKG_CONFIG])
3548         $PKG_CONFIG --exists 'libupsclient' 2>/dev/null
3549         if test $? -ne 0
3550         then
3551                 with_libupsclient="no (pkg-config doesn't know library)"
3552         fi
3553 fi
3554 if test "x$with_libupsclient" = "xuse_pkgconfig"
3555 then
3556         with_libupsclient_cflags="`$PKG_CONFIG --cflags 'libupsclient'`"
3557         if test $? -ne 0
3558         then
3559                 with_libupsclient="no ($PKG_CONFIG failed)"
3560         fi
3561         with_libupsclient_libs="`$PKG_CONFIG --libs 'libupsclient'`"
3562         if test $? -ne 0
3563         then
3564                 with_libupsclient="no ($PKG_CONFIG failed)"
3565         fi
3566 fi
3567 if test "x$with_libupsclient" = "xuse_pkgconfig"
3568 then
3569         with_libupsclient="yes"
3570 fi
3571
3572 # with_libupsclient_cflags and with_libupsclient_libs are set up now, let's do
3573 # the actual checks.
3574 if test "x$with_libupsclient" = "xyes"
3575 then
3576         SAVE_CPPFLAGS="$CPPFLAGS"
3577         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3578
3579         AC_CHECK_HEADERS(upsclient.h, [], [with_libupsclient="no (upsclient.h not found)"])
3580
3581         CPPFLAGS="$SAVE_CPPFLAGS"
3582 fi
3583 if test "x$with_libupsclient" = "xyes"
3584 then
3585         SAVE_CPPFLAGS="$CPPFLAGS"
3586         SAVE_LDFLAGS="$LDFLAGS"
3587
3588         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3589         LDFLAGS="$LDFLAGS $with_libupsclient_libs"
3590
3591         AC_CHECK_LIB(upsclient, upscli_connect,
3592                      [with_libupsclient="yes"],
3593                      [with_libupsclient="no (symbol upscli_connect not found)"])
3594
3595         CPPFLAGS="$SAVE_CPPFLAGS"
3596         LDFLAGS="$SAVE_LDFLAGS"
3597 fi
3598 if test "x$with_libupsclient" = "xyes"
3599 then
3600         SAVE_CPPFLAGS="$CPPFLAGS"
3601         CPPFLAGS="$CPPFLAGS $with_libupsclient_cflags"
3602
3603         AC_CHECK_TYPES([UPSCONN_t, UPSCONN], [], [],
3604 [#include <stdlib.h>
3605 #include <stdio.h>
3606 #include <upsclient.h>])
3607
3608         CPPFLAGS="$SAVE_CPPFLAGS"
3609 fi
3610 if test "x$with_libupsclient" = "xyes"
3611 then
3612         BUILD_WITH_LIBUPSCLIENT_CFLAGS="$with_libupsclient_cflags"
3613         BUILD_WITH_LIBUPSCLIENT_LIBS="$with_libupsclient_libs"
3614         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_CFLAGS)
3615         AC_SUBST(BUILD_WITH_LIBUPSCLIENT_LIBS)
3616 fi
3617 # }}}
3618
3619 # --with-libxmms {{{
3620 with_xmms_config="xmms-config"
3621 with_xmms_cflags=""
3622 with_xmms_libs=""
3623 AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to libxmms.])],
3624 [
3625         if test "x$withval" != "xno" \
3626                 && test "x$withval" != "xyes"
3627         then
3628                 if test -f "$withval" && test -x "$withval";
3629                 then
3630                         with_xmms_config="$withval"
3631                 else if test -x "$withval/bin/xmms-config"
3632                 then
3633                         with_xmms_config="$withval/bin/xmms-config"
3634                 fi; fi
3635                 with_libxmms="yes"
3636         else if test "x$withval" = "xno"
3637         then
3638                 with_libxmms="no"
3639         else
3640                 with_libxmms="yes"
3641         fi; fi
3642 ],
3643 [
3644         with_libxmms="yes"
3645 ])
3646 if test "x$with_libxmms" = "xyes"
3647 then
3648         with_xmms_cflags=`$with_xmms_config --cflags 2>/dev/null`
3649         xmms_config_status=$?
3650
3651         if test $xmms_config_status -ne 0
3652         then
3653                 with_libxmms="no"
3654         fi
3655 fi
3656 if test "x$with_libxmms" = "xyes"
3657 then
3658         with_xmms_libs=`$with_xmms_config --libs 2>/dev/null`
3659         xmms_config_status=$?
3660
3661         if test $xmms_config_status -ne 0
3662         then
3663                 with_libxmms="no"
3664         fi
3665 fi
3666 if test "x$with_libxmms" = "xyes"
3667 then
3668         AC_CHECK_LIB(xmms, xmms_remote_get_info,
3669         [
3670                 BUILD_WITH_LIBXMMS_CFLAGS="$with_xmms_cflags"
3671                 BUILD_WITH_LIBXMMS_LIBS="$with_xmms_libs"
3672                 AC_SUBST(BUILD_WITH_LIBXMMS_CFLAGS)
3673                 AC_SUBST(BUILD_WITH_LIBXMMS_LIBS)
3674         ],
3675         [
3676                 with_libxmms="no"
3677         ],
3678         [$with_xmms_libs])
3679 fi
3680 with_libxmms_numeric=0
3681 if test "x$with_libxmms" = "xyes"
3682 then
3683         with_libxmms_numeric=1
3684 fi
3685 AC_DEFINE_UNQUOTED(HAVE_LIBXMMS, [$with_libxmms_numeric], [Define to 1 if you have the 'xmms' library (-lxmms).])
3686 AM_CONDITIONAL(BUILD_WITH_LIBXMMS, test "x$with_libxmms" = "xyes")
3687 # }}}
3688
3689 # --with-libyajl {{{
3690 with_libyajl_cppflags=""
3691 with_libyajl_ldflags=""
3692 AC_ARG_WITH(libyajl, [AS_HELP_STRING([--with-libyajl@<:@=PREFIX@:>@], [Path to libyajl.])],
3693 [
3694         if test "x$withval" != "xno" && test "x$withval" != "xyes"
3695         then
3696                 with_libyajl_cppflags="-I$withval/include"
3697                 with_libyajl_ldflags="-L$withval/lib"
3698                 with_libyajl="yes"
3699         else
3700                 with_libyajl="$withval"
3701         fi
3702 ],
3703 [
3704         with_libyajl="yes"
3705 ])
3706 if test "x$with_libyajl" = "xyes"
3707 then
3708         SAVE_CPPFLAGS="$CPPFLAGS"
3709         CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
3710
3711         AC_CHECK_HEADERS(yajl/yajl_parse.h, [with_libyajl="yes"], [with_libyajl="no (yajl/yajl_parse.h not found)"])
3712         AC_CHECK_HEADERS(yajl/yajl_version.h)
3713
3714         CPPFLAGS="$SAVE_CPPFLAGS"
3715 fi
3716 if test "x$with_libyajl" = "xyes"
3717 then
3718         SAVE_CPPFLAGS="$CPPFLAGS"
3719         SAVE_LDFLAGS="$LDFLAGS"
3720         CPPFLAGS="$CPPFLAGS $with_libyajl_cppflags"
3721         LDFLAGS="$LDFLAGS $with_libyajl_ldflags"
3722
3723         AC_CHECK_LIB(yajl, yajl_alloc, [with_libyajl="yes"], [with_libyajl="no (Symbol 'yajl_alloc' not found)"])
3724
3725         CPPFLAGS="$SAVE_CPPFLAGS"
3726         LDFLAGS="$SAVE_LDFLAGS"
3727 fi
3728 if test "x$with_libyajl" = "xyes"
3729 then
3730         BUILD_WITH_LIBYAJL_CPPFLAGS="$with_libyajl_cppflags"
3731         BUILD_WITH_LIBYAJL_LDFLAGS="$with_libyajl_ldflags"
3732         BUILD_WITH_LIBYAJL_LIBS="-lyajl"
3733         AC_SUBST(BUILD_WITH_LIBYAJL_CPPFLAGS)
3734         AC_SUBST(BUILD_WITH_LIBYAJL_LDFLAGS)
3735         AC_SUBST(BUILD_WITH_LIBYAJL_LIBS)
3736         AC_DEFINE(HAVE_LIBYAJL, 1, [Define if libyajl is present and usable.])
3737 fi
3738 AM_CONDITIONAL(BUILD_WITH_LIBYAJL, test "x$with_libyajl" = "xyes")
3739 # }}}
3740
3741 # pkg-config --exists 'libxml-2.0'; pkg-config --exists libvirt {{{
3742 with_libxml2="no (pkg-config isn't available)"
3743 with_libxml2_cflags=""
3744 with_libxml2_ldflags=""
3745 with_libvirt="no (pkg-config isn't available)"
3746 with_libvirt_cflags=""
3747 with_libvirt_ldflags=""
3748 if test "x$PKG_CONFIG" != "x"
3749 then
3750         pkg-config --exists 'libxml-2.0' 2>/dev/null
3751         if test "$?" = "0"
3752         then
3753                 with_libxml2="yes"
3754         else
3755                 with_libxml2="no (pkg-config doesn't know library)"
3756         fi
3757
3758         pkg-config --exists libvirt 2>/dev/null
3759         if test "$?" = "0"
3760         then
3761                 with_libvirt="yes"
3762         else
3763                 with_libvirt="no (pkg-config doesn't know library)"
3764         fi
3765 fi
3766 if test "x$with_libxml2" = "xyes"
3767 then
3768         with_libxml2_cflags="`pkg-config --cflags libxml-2.0`"
3769         if test $? -ne 0
3770         then
3771                 with_libxml2="no"
3772         fi
3773         with_libxml2_ldflags="`pkg-config --libs libxml-2.0`"
3774         if test $? -ne 0
3775         then
3776                 with_libxml2="no"
3777         fi
3778 fi
3779 if test "x$with_libxml2" = "xyes"
3780 then
3781         SAVE_CPPFLAGS="$CPPFLAGS"
3782         CPPFLAGS="$CPPFLAGS $with_libxml2_cflags"
3783
3784         AC_CHECK_HEADERS(libxml/parser.h, [],
3785                       [with_libxml2="no (libxml/parser.h not found)"])
3786
3787         CPPFLAGS="$SAVE_CPPFLAGS"
3788 fi
3789 if test "x$with_libxml2" = "xyes"
3790 then
3791         SAVE_CFLAGS="$CFLAGS"
3792         SAVE_LDFLAGS="$LDFLAGS"
3793
3794         CFLAGS="$CFLAGS $with_libxml2_cflags"
3795         LDFLAGS="$LDFLAGS $with_libxml2_ldflags"
3796
3797         AC_CHECK_LIB(xml2, xmlXPathEval,
3798                      [with_libxml2="yes"],
3799                      [with_libxml2="no (symbol xmlXPathEval not found)"])
3800
3801         CFLAGS="$SAVE_CFLAGS"
3802         LDFLAGS="$SAVE_LDFLAGS"
3803 fi
3804 dnl Add the right compiler flags and libraries.
3805 if test "x$with_libxml2" = "xyes"; then
3806         BUILD_WITH_LIBXML2_CFLAGS="$with_libxml2_cflags"
3807         BUILD_WITH_LIBXML2_LIBS="$with_libxml2_ldflags"
3808         AC_SUBST(BUILD_WITH_LIBXML2_CFLAGS)
3809         AC_SUBST(BUILD_WITH_LIBXML2_LIBS)
3810 fi
3811 if test "x$with_libvirt" = "xyes"
3812 then
3813         with_libvirt_cflags="`pkg-config --cflags libvirt`"
3814         if test $? -ne 0
3815         then
3816                 with_libvirt="no"
3817         fi
3818         with_libvirt_ldflags="`pkg-config --libs libvirt`"
3819         if test $? -ne 0
3820         then
3821                 with_libvirt="no"
3822         fi
3823 fi
3824 if test "x$with_libvirt" = "xyes"
3825 then
3826         SAVE_CPPFLAGS="$CPPFLAGS"
3827         CPPFLAGS="$CPPFLAGS $with_libvirt_cflags"
3828
3829         AC_CHECK_HEADERS(libvirt/libvirt.h, [],
3830                       [with_libvirt="no (libvirt/libvirt.h not found)"])
3831
3832         CPPFLAGS="$SAVE_CPPFLAGS"
3833 fi
3834 if test "x$with_libvirt" = "xyes"
3835 then
3836         SAVE_CFLAGS="$CFLAGS"
3837         SAVE_LDFLAGS="$LDFLAGS"
3838
3839         CFLAGS="$CFLAGS $with_libvirt_cflags"
3840         LDFLAGS="$LDFLAGS $with_libvirt_ldflags"
3841
3842         AC_CHECK_LIB(virt, virDomainBlockStats,
3843                      [with_libvirt="yes"],
3844                      [with_libvirt="no (symbol virDomainBlockStats not found)"])
3845
3846         CFLAGS="$SAVE_CFLAGS"
3847         LDFLAGS="$SAVE_LDFLAGS"
3848 fi
3849 dnl Add the right compiler flags and libraries.
3850 if test "x$with_libvirt" = "xyes"; then
3851         BUILD_WITH_LIBVIRT_CFLAGS="$with_libvirt_cflags"
3852         BUILD_WITH_LIBVIRT_LIBS="$with_libvirt_ldflags"
3853         AC_SUBST(BUILD_WITH_LIBVIRT_CFLAGS)
3854         AC_SUBST(BUILD_WITH_LIBVIRT_LIBS)
3855 fi
3856 # }}}
3857
3858 # $PKG_CONFIG --exists OpenIPMIpthread {{{
3859 with_libopenipmipthread="yes"
3860 with_libopenipmipthread_cflags=""
3861 with_libopenipmipthread_libs=""
3862
3863 AC_MSG_CHECKING([for pkg-config])
3864 temp_result="no"
3865 if test "x$PKG_CONFIG" = "x"
3866 then
3867         with_libopenipmipthread="no"
3868         temp_result="no"
3869 else
3870         temp_result="$PKG_CONFIG"
3871 fi
3872 AC_MSG_RESULT([$temp_result])
3873
3874 if test "x$with_libopenipmipthread" = "xyes"
3875 then
3876         AC_MSG_CHECKING([for libOpenIPMIpthread])
3877         $PKG_CONFIG --exists OpenIPMIpthread 2>/dev/null
3878         if test "$?" != "0"
3879         then
3880                 with_libopenipmipthread="no ($PKG_CONFIG doesn't know OpenIPMIpthread)"
3881         fi
3882         AC_MSG_RESULT([$with_libopenipmipthread])
3883 fi
3884
3885 if test "x$with_libopenipmipthread" = "xyes"
3886 then
3887         AC_MSG_CHECKING([for libOpenIPMIpthread CFLAGS])
3888         temp_result="`$PKG_CONFIG --cflags OpenIPMIpthread`"
3889         if test "$?" = "0"
3890         then
3891                 with_libopenipmipthread_cflags="$temp_result"
3892         else
3893                 with_libopenipmipthread="no ($PKG_CONFIG --cflags OpenIPMIpthread failed)"
3894                 temp_result="$PKG_CONFIG --cflags OpenIPMIpthread failed"
3895         fi
3896         AC_MSG_RESULT([$temp_result])
3897 fi
3898
3899 if test "x$with_libopenipmipthread" = "xyes"
3900 then
3901         AC_MSG_CHECKING([for libOpenIPMIpthread LDFLAGS])
3902         temp_result="`$PKG_CONFIG --libs OpenIPMIpthread`"
3903         if test "$?" = "0"
3904         then
3905                 with_libopenipmipthread_ldflags="$temp_result"
3906         else
3907                 with_libopenipmipthread="no ($PKG_CONFIG --libs OpenIPMIpthread failed)"
3908                 temp_result="$PKG_CONFIG --libs OpenIPMIpthread failed"
3909         fi
3910         AC_MSG_RESULT([$temp_result])
3911 fi
3912
3913 if test "x$with_libopenipmipthread" = "xyes"
3914 then
3915         SAVE_CPPFLAGS="$CPPFLAGS"
3916         CPPFLAGS="$CPPFLAGS $with_libopenipmipthread_cflags"
3917
3918         AC_CHECK_HEADERS(OpenIPMI/ipmi_smi.h,
3919                          [with_libopenipmipthread="yes"],
3920                          [with_libopenipmipthread="no (OpenIPMI/ipmi_smi.h not found)"],
3921 [#include <OpenIPMI/ipmiif.h>
3922 #include <OpenIPMI/ipmi_err.h>
3923 #include <OpenIPMI/ipmi_posix.h>
3924 #include <OpenIPMI/ipmi_conn.h>
3925 ])
3926
3927         CPPFLAGS="$SAVE_CPPFLAGS"
3928 fi
3929
3930 if test "x$with_libopenipmipthread" = "xyes"
3931 then
3932         BUILD_WITH_OPENIPMI_CFLAGS="$with_libopenipmipthread_cflags"
3933         BUILD_WITH_OPENIPMI_LIBS="$with_libopenipmipthread_ldflags"
3934         AC_SUBST(BUILD_WITH_OPENIPMI_CFLAGS)
3935         AC_SUBST(BUILD_WITH_OPENIPMI_LIBS)
3936 fi
3937 # }}}
3938
3939 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify],
3940                 [with_libnotify="yes"],
3941                 [with_libnotify="no ($LIBNOTIFY_PKG_ERRORS)"])
3942
3943 # Check for enabled/disabled features
3944 #
3945
3946 # AC_COLLECTD(name, enable/disable, info-text, feature/module)
3947 # ------------------------------------------------------------
3948 dnl
3949 m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))])
3950 dnl
3951 AC_DEFUN(
3952         [AC_COLLECTD],
3953         [
3954         m4_if([$1], [], [AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 1st argument must not be empty])])dnl
3955         m4_if(
3956                 [$2],
3957                 [enable],
3958                 [dnl
3959                 m4_define([EnDis],[disabled])dnl
3960                 m4_define([YesNo],[no])dnl
3961                 ],dnl
3962                 [m4_if(
3963                         [$2],
3964                         [disable],
3965                         [dnl
3966                         m4_define([EnDis],[enabled])dnl
3967                         m4_define([YesNo],[yes])dnl
3968                         ],
3969                         [dnl
3970                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 2nd argument must be either enable or disable])dnl
3971                         ]dnl
3972                 )]dnl
3973         )dnl
3974         m4_if([$3], [feature], [],
3975                 [m4_if(
3976                         [$3], [module], [],
3977                         [dnl
3978                         AC_FATAL([AC_COLLECTD([$1], [$2], [$3], [$4]): 3rd argument must be either feature or disable])dnl
3979                         ]dnl
3980                 )]dnl
3981         )dnl
3982         AC_ARG_ENABLE(
3983                 [$1],
3984                 AS_HELP_STRING([--$2-$1], [$2 $4 (EnDis by def)]),
3985                 [],
3986                 enable_$1='[YesNo]'dnl
3987         )# AC_ARG_ENABLE
3988 if test "x$enable_$1" = "xno"
3989 then
3990         collectd_$1=0
3991 else
3992         if test "x$enable_$1" = "xyes"
3993         then
3994                 collectd_$1=1
3995         else
3996                 AC_MSG_NOTICE([please specify either --enable-$1 or --disable-$1; enabling $1.])
3997                 collectd_$1=1
3998                 enable_$1='yes'
3999         fi
4000 fi
4001         AC_DEFINE_UNQUOTED([COLLECT_]my_toupper([$1]), [$collectd_$1], [wether or not to enable $3 $4])
4002         AM_CONDITIONAL([BUILD_]my_toupper([$3])[_]my_toupper([$1]), [test "x$enable_$1" = "xyes"])dnl
4003         ]dnl
4004 )# AC_COLLECTD(name, enable/disable, info-text, feature/module)
4005
4006 # AC_PLUGIN(name, default, info)
4007 # ------------------------------------------------------------
4008 dnl
4009 AC_DEFUN(
4010   [AC_PLUGIN],
4011   [
4012     enable_plugin="no"
4013     force="no"
4014     AC_ARG_ENABLE([$1], AC_HELP_STRING([--enable-$1], [$3]),
4015     [
4016      if test "x$enableval" = "xyes"
4017      then
4018              enable_plugin="yes"
4019      else if test "x$enableval" = "xforce"
4020      then
4021              enable_plugin="yes"
4022              force="yes"
4023      else
4024              enable_plugin="no (disabled on command line)"
4025      fi; fi
4026     ],
4027     [
4028          if test "x$enable_all_plugins" = "xauto"
4029          then
4030              if test "x$2" = "xyes"
4031              then
4032                      enable_plugin="yes"
4033              else
4034                      enable_plugin="no"
4035              fi
4036          else
4037              enable_plugin="$enable_all_plugins"
4038          fi
4039     ])
4040     if test "x$enable_plugin" = "xyes"
4041     then
4042             if test "x$2" = "xyes" || test "x$force" = "xyes"
4043             then
4044                     AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.])
4045                     if test "x$2" != "xyes"
4046                     then
4047                             dependency_warning="yes"
4048                     fi
4049             else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
4050                     dependency_error="yes"
4051                     enable_plugin="no (dependency error)"
4052             fi
4053     fi
4054     AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes")
4055     enable_$1="$enable_plugin"
4056   ]
4057 )# AC_PLUGIN(name, default, info)
4058
4059 m4_divert_once([HELP_ENABLE], [
4060 collectd features:])
4061 # FIXME: Remove these calls to `AC_COLLECTD' and then remove that macro.
4062 AC_COLLECTD([debug],     [enable],  [feature], [debugging])
4063 AC_COLLECTD([daemon],    [disable], [feature], [daemon mode])
4064 AC_COLLECTD([getifaddrs],[enable],  [feature], [getifaddrs under Linux])
4065
4066 dependency_warning="no"
4067 dependency_error="no"
4068
4069 plugin_ascent="no"
4070 plugin_battery="no"
4071 plugin_bind="no"
4072 plugin_conntrack="no"
4073 plugin_contextswitch="no"
4074 plugin_cpu="no"
4075 plugin_cpufreq="no"
4076 plugin_curl_json="no"
4077 plugin_curl_xml="no"
4078 plugin_df="no"
4079 plugin_disk="no"
4080 plugin_entropy="no"
4081 plugin_interface="no"
4082 plugin_ipmi="no"
4083 plugin_ipvs="no"
4084 plugin_irq="no"
4085 plugin_libvirt="no"
4086 plugin_load="no"
4087 plugin_memory="no"
4088 plugin_multimeter="no"
4089 plugin_nfs="no"
4090 plugin_fscache="no"
4091 plugin_perl="no"
4092 plugin_processes="no"
4093 plugin_protocols="no"
4094 plugin_serial="no"
4095 plugin_swap="no"
4096 plugin_tape="no"
4097 plugin_tcpconns="no"
4098 plugin_ted="no"
4099 plugin_thermal="no"
4100 plugin_users="no"
4101 plugin_uptime="no"
4102 plugin_vmem="no"
4103 plugin_vserver="no"
4104 plugin_wireless="no"
4105 plugin_zfs_arc="no"
4106
4107 # Linux
4108 if test "x$ac_system" = "xLinux"
4109 then
4110         plugin_battery="yes"
4111         plugin_conntrack="yes"
4112         plugin_contextswitch="yes"
4113         plugin_cpu="yes"
4114         plugin_cpufreq="yes"
4115         plugin_disk="yes"
4116         plugin_entropy="yes"
4117         plugin_interface="yes"
4118         plugin_irq="yes"
4119         plugin_load="yes"
4120         plugin_memory="yes"
4121         plugin_nfs="yes"
4122         plugin_fscache="yes"
4123         plugin_processes="yes"
4124         plugin_protocols="yes"
4125         plugin_serial="yes"
4126         plugin_swap="yes"
4127         plugin_tcpconns="yes"
4128         plugin_thermal="yes"
4129         plugin_uptime="yes"
4130         plugin_vmem="yes"
4131         plugin_vserver="yes"
4132         plugin_wireless="yes"
4133
4134         if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"
4135         then
4136                 plugin_ipvs="yes"
4137         fi
4138 fi
4139
4140 if test "x$ac_system" = "xOpenBSD"
4141 then
4142         plugin_tcpconns="yes"
4143 fi
4144
4145 # Mac OS X devices
4146 if test "x$with_libiokit" = "xyes"
4147 then
4148         plugin_battery="yes"
4149         plugin_disk="yes"
4150 fi
4151
4152 # AIX
4153 if test "x$with_perfstat" = "xyes"
4154 then
4155         plugin_cpu="yes"
4156         plugin_disk="yes"
4157         plugin_memory="yes"
4158         plugin_swap="yes"
4159         plugin_interface="yes"
4160         plugin_load="yes"
4161 fi
4162
4163 if test "x$with_procinfo" = "xyes"
4164 then
4165         plugin_processes="yes"
4166 fi
4167
4168 # Solaris
4169 if test "x$with_kstat" = "xyes"
4170 then
4171         plugin_uptime="yes"
4172         plugin_zfs_arc="yes"
4173 fi
4174
4175 if test "x$with_devinfo$with_kstat" = "xyesyes"
4176 then
4177         plugin_cpu="yes"
4178         plugin_disk="yes"
4179         plugin_interface="yes"
4180         plugin_memory="yes"
4181         plugin_tape="yes"
4182 fi
4183
4184 if test "x$have_sys_swap_h$with_kstat$ac_system" = "xyesyesSolaris"
4185 then
4186         plugin_swap="yes"
4187 fi
4188
4189 # libstatgrab
4190 if test "x$with_libstatgrab" = "xyes"
4191 then
4192         plugin_cpu="yes"
4193         plugin_disk="yes"
4194         plugin_interface="yes"
4195         plugin_load="yes"
4196         plugin_memory="yes"
4197         plugin_swap="yes"
4198         plugin_users="yes"
4199 fi
4200
4201 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
4202 then
4203         plugin_ascent="yes"
4204         plugin_bind="yes"
4205 fi
4206
4207 if test "x$with_libopenipmipthread" = "xyes"
4208 then
4209         plugin_ipmi="yes"
4210 fi
4211
4212 if test "x$with_libcurl" = "xyes" && test "x$with_libyajl" = "xyes"
4213 then
4214         plugin_curl_json="yes"
4215 fi
4216
4217 if test "x$with_libcurl" = "xyes" && test "x$with_libxml2" = "xyes"
4218 then
4219         plugin_curl_xml="yes"
4220 fi
4221
4222 if test "x$have_processor_info" = "xyes"
4223 then
4224         plugin_cpu="yes"
4225 fi
4226 if test "x$have_sysctl" = "xyes"
4227 then
4228         plugin_cpu="yes"
4229         plugin_memory="yes"
4230         plugin_swap="yes"
4231         plugin_uptime="yes"
4232 fi
4233 if test "x$have_sysctlbyname" = "xyes"
4234 then
4235         plugin_cpu="yes"
4236         plugin_memory="yes"
4237         plugin_tcpconns="yes"
4238 fi
4239
4240 # Df plugin: Check if we know how to determine mount points first.
4241 #if test "x$have_listmntent" = "xyes"; then
4242 #       plugin_df="yes"
4243 #fi
4244 if test "x$have_getvfsstat" = "xyes" || test "x$have_getfsstat" = "xyes"
4245 then
4246         plugin_df="yes"
4247 fi
4248 if test "x$c_cv_have_two_getmntent" = "xyes" || test "x$have_getmntent" = "xgen" || test "x$have_getmntent" = "xsun"
4249 then
4250         plugin_df="yes"
4251 fi
4252 #if test "x$have_getmntent" = "xseq"
4253 #then
4254 #       plugin_df="yes"
4255 #fi
4256 if test "x$c_cv_have_one_getmntent" = "xyes"
4257 then
4258         plugin_df="yes"
4259 fi
4260
4261 # Df plugin: Check if we have either `statfs' or `statvfs' second.
4262 if test "x$plugin_df" = "xyes"
4263 then
4264         plugin_df="no"
4265         if test "x$have_statfs" = "xyes"
4266         then
4267                 plugin_df="yes"
4268         fi
4269         if test "x$have_statvfs" = "xyes"
4270         then
4271                 plugin_df="yes"
4272         fi
4273 fi
4274
4275 if test "x$have_getifaddrs" = "xyes"
4276 then
4277         plugin_interface="yes"
4278 fi
4279
4280 if test "x$with_libxml2" = "xyes" && test "x$with_libvirt" = "xyes"
4281 then
4282         plugin_libvirt="yes"
4283 fi
4284
4285 if test "x$have_getloadavg" = "xyes"
4286 then
4287         plugin_load="yes"
4288 fi
4289
4290 if test "x$c_cv_have_libperl$c_cv_have_perl_ithreads" = "xyesyes"
4291 then
4292         plugin_perl="yes"
4293 fi
4294
4295 # Mac OS X memory interface
4296 if test "x$have_host_statistics" = "xyes"
4297 then
4298         plugin_memory="yes"
4299 fi
4300
4301 if test "x$have_termios_h" = "xyes"
4302 then
4303         plugin_multimeter="yes"
4304         plugin_ted="yes"
4305 fi
4306
4307 if test "x$have_thread_info" = "xyes"
4308 then
4309         plugin_processes="yes"
4310 fi
4311
4312 if test "x$with_kvm_getprocs" = "xyes" && test "x$have_struct_kinfo_proc_freebsd" = "xyes"
4313 then
4314         plugin_processes="yes"
4315 fi
4316
4317 if test "x$with_kvm_getswapinfo" = "xyes"
4318 then
4319         plugin_swap="yes"
4320 fi
4321
4322 if test "x$have_swapctl" = "xyes"
4323 then
4324         plugin_swap="yes"
4325 fi
4326
4327 if test "x$with_kvm_openfiles$with_kvm_nlist" = "xyesyes"
4328 then
4329         plugin_tcpconns="yes"
4330 fi
4331
4332 if test "x$have_getutent" = "xyes"
4333 then
4334         plugin_users="yes"
4335 fi
4336 if test "x$have_getutxent" = "xyes"
4337 then
4338         plugin_users="yes"
4339 fi
4340
4341 m4_divert_once([HELP_ENABLE], [
4342 collectd plugins:])
4343
4344 AC_ARG_ENABLE([all-plugins],
4345                 AC_HELP_STRING([--enable-all-plugins],
4346                                 [enable all plugins (auto by def)]),
4347                 [
4348                  if test "x$enableval" = "xyes"
4349                  then
4350                          enable_all_plugins="yes"
4351                  else if test "x$enableval" = "xauto"
4352                  then
4353                          enable_all_plugins="auto"
4354                  else
4355                          enable_all_plugins="no"
4356                  fi; fi
4357                 ],
4358                 [enable_all_plugins="auto"])
4359
4360 m4_divert_once([HELP_ENABLE], [])
4361
4362 AC_PLUGIN([apache],      [$with_libcurl],      [Apache httpd statistics])
4363 AC_PLUGIN([apcups],      [yes],                [Statistics of UPSes by APC])
4364 AC_PLUGIN([apple_sensors], [$with_libiokit],   [Apple's hardware sensors])
4365 AC_PLUGIN([ascent],      [$plugin_ascent],     [AscentEmu player statistics])
4366 AC_PLUGIN([battery],     [$plugin_battery],    [Battery statistics])
4367 AC_PLUGIN([bind],        [$plugin_bind],       [ISC Bind nameserver statistics])
4368 AC_PLUGIN([conntrack],   [$plugin_conntrack],  [nf_conntrack statistics])
4369 AC_PLUGIN([contextswitch], [$plugin_contextswitch], [context switch statistics])
4370 AC_PLUGIN([cpufreq],     [$plugin_cpufreq],    [CPU frequency statistics])
4371 AC_PLUGIN([cpu],         [$plugin_cpu],        [CPU usage statistics])
4372 AC_PLUGIN([csv],         [yes],                [CSV output plugin])
4373 AC_PLUGIN([curl],        [$with_libcurl],      [CURL generic web statistics])
4374 AC_PLUGIN([curl_json],   [$plugin_curl_json],    [CouchDB statistics])
4375 AC_PLUGIN([curl_xml],   [$plugin_curl_xml],    [CURL generic xml statistics])
4376 AC_PLUGIN([dbi],         [$with_libdbi],       [General database statistics])
4377 AC_PLUGIN([df],          [$plugin_df],         [Filesystem usage statistics])
4378 AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
4379 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
4380 AC_PLUGIN([email],       [yes],                [EMail statistics])
4381 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
4382 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
4383 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
4384 AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
4385 AC_PLUGIN([gmond],       [$with_libganglia],   [Ganglia plugin])
4386 AC_PLUGIN([hddtemp],     [yes],                [Query hddtempd])
4387 AC_PLUGIN([interface],   [$plugin_interface],  [Interface traffic statistics])
4388 AC_PLUGIN([ipmi],        [$plugin_ipmi],       [IPMI sensor statistics])
4389 AC_PLUGIN([iptables],    [$with_libiptc],      [IPTables rule counters])
4390 AC_PLUGIN([ipvs],        [$plugin_ipvs],       [IPVS connection statistics])
4391 AC_PLUGIN([irq],         [$plugin_irq],        [IRQ statistics])
4392 AC_PLUGIN([java],        [$with_java],         [Embed the Java Virtual Machine])
4393 AC_PLUGIN([libvirt],     [$plugin_libvirt],    [Virtual machine statistics])
4394 AC_PLUGIN([load],        [$plugin_load],       [System load])
4395 AC_PLUGIN([logfile],     [yes],                [File logging plugin])
4396 AC_PLUGIN([madwifi],     [$have_linux_wireless_h], [Madwifi wireless statistics])
4397 AC_PLUGIN([match_empty_counter], [yes],        [The empty counter match])
4398 AC_PLUGIN([match_hashed], [yes],               [The hashed match])
4399 AC_PLUGIN([match_regex], [yes],                [The regex match])
4400 AC_PLUGIN([match_timediff], [yes],             [The timediff match])
4401 AC_PLUGIN([match_value], [yes],                [The value match])
4402 AC_PLUGIN([mbmon],       [yes],                [Query mbmond])
4403 AC_PLUGIN([memcachec],   [$with_libmemcached], [memcachec statistics])
4404 AC_PLUGIN([memcached],   [yes],                [memcached statistics])
4405 AC_PLUGIN([memory],      [$plugin_memory],     [Memory usage])
4406 AC_PLUGIN([modbus],      [$with_libmodbus],    [Modbus plugin])
4407 AC_PLUGIN([multimeter],  [$plugin_multimeter], [Read multimeter values])
4408 AC_PLUGIN([mysql],       [$with_libmysql],     [MySQL statistics])
4409 AC_PLUGIN([netapp],      [$with_libnetapp],    [NetApp plugin])
4410 AC_PLUGIN([netlink],     [$with_libnetlink],   [Enhanced Linux network statistics])
4411 AC_PLUGIN([network],     [yes],                [Network communication plugin])
4412 AC_PLUGIN([nfs],         [$plugin_nfs],        [NFS statistics])
4413 AC_PLUGIN([nginx],       [$with_libcurl],      [nginx statistics])
4414 AC_PLUGIN([notify_desktop], [$with_libnotify], [Desktop notifications])
4415 AC_PLUGIN([notify_email], [$with_libesmtp],    [Email notifier])
4416 AC_PLUGIN([ntpd],        [yes],                [NTPd statistics])
4417 AC_PLUGIN([nut],         [$with_libupsclient], [Network UPS tools statistics])
4418 AC_PLUGIN([olsrd],       [yes],                [olsrd statistics])
4419 AC_PLUGIN([onewire],     [$with_libowcapi],    [OneWire sensor statistics])
4420 AC_PLUGIN([openvpn],     [yes],                [OpenVPN client statistics])
4421 AC_PLUGIN([oracle],      [$with_oracle],       [Oracle plugin])
4422 AC_PLUGIN([perl],        [$plugin_perl],       [Embed a Perl interpreter])
4423 # FIXME: Check for libevent, too.
4424 AC_PLUGIN([pinba],       [$have_protoc_c],     [Pinba statistics])
4425 AC_PLUGIN([ping],        [$with_liboping],     [Network latency statistics])
4426 AC_PLUGIN([postgresql],  [$with_libpq],        [PostgreSQL database statistics])
4427 AC_PLUGIN([powerdns],    [yes],                [PowerDNS statistics])
4428 AC_PLUGIN([processes],   [$plugin_processes],  [Process statistics])
4429 AC_PLUGIN([protocols],   [$plugin_protocols],  [Protocol (IP, TCP, ...) statistics])
4430 AC_PLUGIN([python],      [$with_python],       [Embed a Python interpreter])
4431 AC_PLUGIN([routeros],    [$with_librouteros],  [RouterOS plugin])
4432 AC_PLUGIN([rrdcached],   [$librrd_rrdc_update], [RRDTool output plugin])
4433 AC_PLUGIN([rrdtool],     [$with_librrd],       [RRDTool output plugin])
4434 AC_PLUGIN([sensors],     [$with_libsensors],   [lm_sensors statistics])
4435 AC_PLUGIN([serial],      [$plugin_serial],     [serial port traffic])
4436 AC_PLUGIN([snmp],        [$with_libnetsnmp],   [SNMP querying plugin])
4437 AC_PLUGIN([swap],        [$plugin_swap],       [Swap usage statistics])
4438 AC_PLUGIN([syslog],      [$have_syslog],       [Syslog logging plugin])
4439 AC_PLUGIN([table],       [yes],                [Parsing of tabular data])
4440 AC_PLUGIN([tail],        [yes],                [Parsing of logfiles])
4441 AC_PLUGIN([tape],        [$plugin_tape],       [Tape drive statistics])
4442 AC_PLUGIN([target_notification], [yes],        [The notification target])
4443 AC_PLUGIN([target_replace], [yes],             [The replace target])
4444 AC_PLUGIN([target_scale],[yes],                [The scale target])
4445 AC_PLUGIN([target_set],  [yes],                [The set target])
4446 AC_PLUGIN([tcpconns],    [$plugin_tcpconns],   [TCP connection statistics])
4447 AC_PLUGIN([teamspeak2],  [yes],                [TeamSpeak2 server statistics])
4448 AC_PLUGIN([ted],         [$plugin_ted],        [Read The Energy Detective values])
4449 AC_PLUGIN([thermal],     [$plugin_thermal],    [Linux ACPI thermal zone statistics])
4450 AC_PLUGIN([tokyotyrant], [$with_libtokyotyrant],  [TokyoTyrant database statistics])
4451 AC_PLUGIN([unixsock],    [yes],                [Unixsock communication plugin])
4452 AC_PLUGIN([uptime],      [$plugin_uptime],     [Uptime statistics])
4453 AC_PLUGIN([users],       [$plugin_users],      [User statistics])
4454 AC_PLUGIN([uuid],        [yes],                [UUID as hostname plugin])
4455 AC_PLUGIN([vmem],        [$plugin_vmem],       [Virtual memory statistics])
4456 AC_PLUGIN([vserver],     [$plugin_vserver],    [Linux VServer statistics])
4457 AC_PLUGIN([wireless],    [$plugin_wireless],   [Wireless statistics])
4458 AC_PLUGIN([write_http],  [$with_libcurl],      [HTTP output plugin])
4459 AC_PLUGIN([xmms],        [$with_libxmms],      [XMMS statistics])
4460 AC_PLUGIN([zfs_arc],     [$plugin_zfs_arc],    [ZFS ARC statistics])
4461
4462 dnl Default configuration file
4463 # Load either syslog or logfile
4464 LOAD_PLUGIN_SYSLOG=""
4465 LOAD_PLUGIN_LOGFILE=""
4466
4467 AC_MSG_CHECKING([which default log plugin to load])
4468 default_log_plugin="none"
4469 if test "x$enable_syslog" = "xyes"
4470 then
4471         default_log_plugin="syslog"
4472 else
4473         LOAD_PLUGIN_SYSLOG="##"
4474 fi
4475
4476 if test "x$enable_logfile" = "xyes"
4477 then
4478         if test "x$default_log_plugin" = "xnone"
4479         then
4480                 default_log_plugin="logfile"
4481         else
4482                 LOAD_PLUGIN_LOGFILE="#"
4483         fi
4484 else
4485         LOAD_PLUGIN_LOGFILE="##"
4486 fi
4487 AC_MSG_RESULT([$default_log_plugin])
4488
4489 AC_SUBST(LOAD_PLUGIN_SYSLOG)
4490 AC_SUBST(LOAD_PLUGIN_LOGFILE)
4491
4492 DEFAULT_LOG_LEVEL="info"
4493 if test "x$enable_debug" = "xyes"
4494 then
4495         DEFAULT_LOG_LEVEL="debug"
4496 fi
4497 AC_SUBST(DEFAULT_LOG_LEVEL)
4498
4499 # Load only one of rrdtool, network, csv in the default config.
4500 LOAD_PLUGIN_RRDTOOL=""
4501 LOAD_PLUGIN_NETWORK=""
4502 LOAD_PLUGIN_CSV=""
4503
4504 AC_MSG_CHECKING([which default write plugin to load])
4505 default_write_plugin="none"
4506 if test "x$enable_rrdtool" = "xyes"
4507 then
4508         default_write_plugin="rrdtool"
4509 else
4510         LOAD_PLUGIN_RRDTOOL="##"
4511 fi
4512
4513 if test "x$enable_network" = "xyes"
4514 then
4515         if test "x$default_write_plugin" = "xnone"
4516         then
4517                 default_write_plugin="network"
4518         else
4519                 LOAD_PLUGIN_NETWORK="#"
4520         fi
4521 else
4522         LOAD_PLUGIN_NETWORK="##"
4523 fi
4524
4525 if test "x$enable_csv" = "xyes"
4526 then
4527         if test "x$default_write_plugin" = "xnone"
4528         then
4529                 default_write_plugin="csv"
4530         else
4531                 LOAD_PLUGIN_CSV="#"
4532         fi
4533 else
4534         LOAD_PLUGIN_CSV="##"
4535 fi
4536 AC_MSG_RESULT([$default_write_plugin])
4537
4538 AC_SUBST(LOAD_PLUGIN_RRDTOOL)
4539 AC_SUBST(LOAD_PLUGIN_NETWORK)
4540 AC_SUBST(LOAD_PLUGIN_CSV)
4541
4542 dnl ip_vs.h
4543 if test "x$ac_system" = "xLinux" \
4544         && test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono"
4545 then
4546         enable_ipvs="$enable_ipvs (ip_vs.h not found)"
4547 fi
4548
4549 if test "x$ip_vs_h_needs_kernel_cflags" = "xyes"
4550 then
4551         enable_ipvs="$enable_ipvs (needs $KERNEL_CFLAGS)"
4552 fi
4553
4554 dnl Perl bindings
4555 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
4556 [
4557         if test "x$withval" != "xno" && test "x$withval" != "xyes"
4558         then
4559                 PERL_BINDINGS_OPTIONS="$withval"
4560                 with_perl_bindings="yes"
4561         else
4562                 PERL_BINDINGS_OPTIONS=""
4563                 with_perl_bindings="$withval"
4564         fi
4565 ],
4566 [
4567         PERL_BINDINGS_OPTIONS=""
4568         if test -n "$perl_interpreter"
4569         then
4570                 with_perl_bindings="yes"
4571         else
4572                 with_perl_bindings="no (no perl interpreter found)"
4573         fi
4574 ])
4575 if test "x$with_perl_bindings" = "xyes"
4576 then
4577         PERL_BINDINGS="perl"
4578 else
4579         PERL_BINDINGS=""
4580 fi
4581 AC_SUBST(PERL_BINDINGS)
4582 AC_SUBST(PERL_BINDINGS_OPTIONS)
4583
4584 dnl libcollectdclient
4585 LCC_VERSION_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
4586 LCC_VERSION_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
4587 LCC_VERSION_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
4588
4589 LCC_VERSION_EXTRA=`echo $PACKAGE_VERSION | cut -d'.' -f4-`
4590
4591 LCC_VERSION_STRING="$LCC_VERSION_MAJOR.$LCC_VERSION_MINOR.$LCC_VERSION_PATCH"
4592
4593 AC_SUBST(LCC_VERSION_MAJOR)
4594 AC_SUBST(LCC_VERSION_MINOR)
4595 AC_SUBST(LCC_VERSION_PATCH)
4596 AC_SUBST(LCC_VERSION_EXTRA)
4597 AC_SUBST(LCC_VERSION_STRING)
4598
4599 AC_CONFIG_FILES(src/libcollectdclient/lcc_features.h)
4600
4601 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)
4602
4603 if test "x$with_librrd" = "xyes" \
4604         && test "x$librrd_threadsafe" != "xyes"
4605 then
4606         with_librrd="yes (warning: librrd is not thread-safe)"
4607 fi
4608
4609 if test "x$with_libperl" = "xyes"
4610 then
4611         with_libperl="yes (version `$perl_interpreter -MConfig -e 'print $Config{version};'`)"
4612 else
4613         enable_perl="no (needs libperl)"
4614 fi
4615
4616 if test "x$enable_perl" = "xno" && test "x$c_cv_have_perl_ithreads" = "xno"
4617 then
4618         enable_perl="no (libperl doesn't support ithreads)"
4619 fi
4620
4621 if test "x$with_perl_bindings" = "xyes" \
4622         && test "x$PERL_BINDINGS_OPTIONS" != "x"
4623 then
4624         with_perl_bindings="yes ($PERL_BINDINGS_OPTIONS)"
4625 fi
4626
4627 cat <<EOF;
4628
4629 Configuration:
4630   Libraries:
4631     libcurl . . . . . . . $with_libcurl
4632     libdbi  . . . . . . . $with_libdbi
4633     libesmtp  . . . . . . $with_libesmtp
4634     libganglia  . . . . . $with_libganglia
4635     libgcrypt . . . . . . $with_libgcrypt
4636     libiokit  . . . . . . $with_libiokit
4637     libiptc . . . . . . . $with_libiptc
4638     libjvm  . . . . . . . $with_java
4639     libkstat  . . . . . . $with_kstat
4640     libkvm  . . . . . . . $with_libkvm
4641     libmemcached  . . . . $with_libmemcached
4642     libmodbus . . . . . . $with_libmodbus
4643     libmysql  . . . . . . $with_libmysql
4644     libnetapp . . . . . . $with_libnetapp
4645     libnetlink  . . . . . $with_libnetlink
4646     libnetsnmp  . . . . . $with_libnetsnmp
4647     libnotify . . . . . . $with_libnotify
4648     liboconfig  . . . . . $with_liboconfig
4649     libopenipmi . . . . . $with_libopenipmipthread
4650     liboping  . . . . . . $with_liboping
4651     libpcap . . . . . . . $with_libpcap
4652     libperfstat . . . . . $with_perfstat
4653     libperl . . . . . . . $with_libperl
4654     libpq . . . . . . . . $with_libpq
4655     libpthread  . . . . . $with_libpthread
4656     librouteros . . . . . $with_librouteros
4657     librrd  . . . . . . . $with_librrd
4658     libsensors  . . . . . $with_libsensors
4659     libstatgrab . . . . . $with_libstatgrab
4660     libtokyotyrant  . . . $with_libtokyotyrant
4661     libupsclient  . . . . $with_libupsclient
4662     libvirt . . . . . . . $with_libvirt
4663     libxml2 . . . . . . . $with_libxml2
4664     libxmms . . . . . . . $with_libxmms
4665     libyajl . . . . . . . $with_libyajl
4666     libevent  . . . . . . $with_libevent
4667     protobuf-c  . . . . . $have_protoc_c
4668     oracle  . . . . . . . $with_oracle
4669     python  . . . . . . . $with_python
4670
4671   Features:
4672     daemon mode . . . . . $enable_daemon
4673     debug . . . . . . . . $enable_debug
4674
4675   Bindings:
4676     perl  . . . . . . . . $with_perl_bindings
4677
4678   Modules:
4679     apache  . . . . . . . $enable_apache
4680     apcups  . . . . . . . $enable_apcups
4681     apple_sensors . . . . $enable_apple_sensors
4682     ascent  . . . . . . . $enable_ascent
4683     battery . . . . . . . $enable_battery
4684     bind  . . . . . . . . $enable_bind
4685     conntrack . . . . . . $enable_conntrack
4686     contextswitch . . . . $enable_contextswitch
4687     cpu . . . . . . . . . $enable_cpu
4688     cpufreq . . . . . . . $enable_cpufreq
4689     csv . . . . . . . . . $enable_csv
4690     curl  . . . . . . . . $enable_curl
4691     curl_json . . . . . . $enable_curl_json
4692     curl_xml  . . . . . . $enable_curl_xml
4693     dbi . . . . . . . . . $enable_dbi
4694     df  . . . . . . . . . $enable_df
4695     disk  . . . . . . . . $enable_disk
4696     dns . . . . . . . . . $enable_dns
4697     email . . . . . . . . $enable_email
4698     entropy . . . . . . . $enable_entropy
4699     exec  . . . . . . . . $enable_exec
4700     filecount . . . . . . $enable_filecount
4701     fscache . . . . . . . $enable_fscache
4702     gmond . . . . . . . . $enable_gmond
4703     hddtemp . . . . . . . $enable_hddtemp
4704     interface . . . . . . $enable_interface
4705     ipmi  . . . . . . . . $enable_ipmi
4706     iptables  . . . . . . $enable_iptables
4707     ipvs  . . . . . . . . $enable_ipvs
4708     irq . . . . . . . . . $enable_irq
4709     java  . . . . . . . . $enable_java
4710     libvirt . . . . . . . $enable_libvirt
4711     load  . . . . . . . . $enable_load
4712     logfile . . . . . . . $enable_logfile
4713     madwifi . . . . . . . $enable_madwifi
4714     match_empty_counter . $enable_match_empty_counter
4715     match_hashed  . . . . $enable_match_hashed
4716     match_regex . . . . . $enable_match_regex
4717     match_timediff  . . . $enable_match_timediff
4718     match_value . . . . . $enable_match_value
4719     mbmon . . . . . . . . $enable_mbmon
4720     memcachec . . . . . . $enable_memcachec
4721     memcached . . . . . . $enable_memcached
4722     memory  . . . . . . . $enable_memory
4723     modbus  . . . . . . . $enable_modbus
4724     multimeter  . . . . . $enable_multimeter
4725     mysql . . . . . . . . $enable_mysql
4726     netapp  . . . . . . . $enable_netapp
4727     netlink . . . . . . . $enable_netlink
4728     network . . . . . . . $enable_network
4729     nfs . . . . . . . . . $enable_nfs
4730     nginx . . . . . . . . $enable_nginx
4731     notify_desktop  . . . $enable_notify_desktop
4732     notify_email  . . . . $enable_notify_email
4733     ntpd  . . . . . . . . $enable_ntpd
4734     nut . . . . . . . . . $enable_nut
4735     olsrd . . . . . . . . $enable_olsrd
4736     onewire . . . . . . . $enable_onewire
4737     openvpn . . . . . . . $enable_openvpn
4738     oracle  . . . . . . . $enable_oracle
4739     perl  . . . . . . . . $enable_perl
4740     pinba . . . . . . . . $enable_pinba
4741     ping  . . . . . . . . $enable_ping
4742     postgresql  . . . . . $enable_postgresql
4743     powerdns  . . . . . . $enable_powerdns
4744     processes . . . . . . $enable_processes
4745     protocols . . . . . . $enable_protocols
4746     python  . . . . . . . $enable_python
4747     routeros  . . . . . . $enable_routeros
4748     rrdcached . . . . . . $enable_rrdcached
4749     rrdtool . . . . . . . $enable_rrdtool
4750     sensors . . . . . . . $enable_sensors
4751     serial  . . . . . . . $enable_serial
4752     snmp  . . . . . . . . $enable_snmp
4753     swap  . . . . . . . . $enable_swap
4754     syslog  . . . . . . . $enable_syslog
4755     table . . . . . . . . $enable_table
4756     tail  . . . . . . . . $enable_tail
4757     tape  . . . . . . . . $enable_tape
4758     target_notification . $enable_target_notification
4759     target_replace  . . . $enable_target_replace
4760     target_scale  . . . . $enable_target_scale
4761     target_set  . . . . . $enable_target_set
4762     tcpconns  . . . . . . $enable_tcpconns
4763     teamspeak2  . . . . . $enable_teamspeak2
4764     ted . . . . . . . . . $enable_ted
4765     thermal . . . . . . . $enable_thermal
4766     tokyotyrant . . . . . $enable_tokyotyrant
4767     unixsock  . . . . . . $enable_unixsock
4768     uptime  . . . . . . . $enable_uptime
4769     users . . . . . . . . $enable_users
4770     uuid  . . . . . . . . $enable_uuid
4771     vmem  . . . . . . . . $enable_vmem
4772     vserver . . . . . . . $enable_vserver
4773     wireless  . . . . . . $enable_wireless
4774     write_http  . . . . . $enable_write_http
4775     xmms  . . . . . . . . $enable_xmms
4776     zfs_arc . . . . . . . $enable_zfs_arc
4777
4778 EOF
4779
4780 if test "x$dependency_error" = "xyes"; then
4781         AC_MSG_ERROR("Some plugins are missing dependencies - see the summary above for details")
4782 fi
4783
4784 if test "x$dependency_warning" = "xyes"; then
4785         AC_MSG_WARN("Some plugins seem to have missing dependencies but have been enabled forcibly - see the summary above for details")
4786 fi
4787
4788 # vim: set fdm=marker :