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