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