Code

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