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