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