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