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