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