+if test "x$with_libowcapi" = "xyes"; then
+ SAVE_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $with_libowcapi_ldflags"
+
+ AC_CHECK_LIB([owcapi], [OW_get],
+ [with_libowcapi="yes"],
+ [with_libowcapi="no (libowcapi not found)"]
+ )
+
+ LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libowcapi" = "xyes"; then
+ BUILD_WITH_LIBOWCAPI_CPPFLAGS="$with_libowcapi_cppflags"
+ BUILD_WITH_LIBOWCAPI_LDFLAGS="$with_libowcapi_ldflags"
+ BUILD_WITH_LIBOWCAPI_LIBS="-lowcapi"
+fi
+
+AC_SUBST([BUILD_WITH_LIBOWCAPI_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBOWCAPI_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBOWCAPI_LIBS])
+# }}}
+
+# --with-libpcap {{{
+AC_ARG_WITH([libpcap],
+ [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
+ [
+ if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+ with_libpcap_cppflags="-I$withval/include"
+ with_libpcap_ldflags="$LDFLAGS -L$withval/lib"
+ with_libpcap="yes"
+ else
+ with_libpcap="$withval"
+ fi
+ ],
+ [with_libpcap="yes"]
+)
+
+if test "x$with_libpcap" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_libpcap_cppflags"
+
+ AC_CHECK_HEADERS([pcap.h],
+ [with_libpcap="yes"],
+ [with_libpcap="no (pcap.h not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libpcap" = "xyes"; then
+ SAVE_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $with_libpcap_ldflags"
+
+ AC_CHECK_LIB([pcap], [pcap_open_live],
+ [with_libpcap="yes"],
+ [with_libpcap="no (libpcap not found)"]
+ )
+
+ LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libpcap" = "xyes"; then
+ AC_CACHE_CHECK([whether libpcap has PCAP_ERROR_IFACE_NOT_UP],
+ [c_cv_libpcap_have_pcap_error_iface_not_up],
+ [
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [[#include <pcap.h>]],
+ [[
+ int val = PCAP_ERROR_IFACE_NOT_UP;
+ return(val);
+ ]]
+ )
+ ],
+ [c_cv_libpcap_have_pcap_error_iface_not_up="yes"],
+ [c_cv_libpcap_have_pcap_error_iface_not_up="no"]
+ )
+ ]
+ )
+fi
+
+if test "x$c_cv_libpcap_have_pcap_error_iface_not_up" != "xyes"; then
+ with_libpcap="no (pcap.h misses PCAP_ERROR_IFACE_NOT_UP)"
+fi
+
+if test "x$with_libpcap" = "xyes"; then
+ BUILD_WITH_LIBPCAP_CPPFLAGS="$with_libpcap_cppflags"
+ BUILD_WITH_LIBPCAP_LDFLAGS="$with_libpcap_ldflags"
+ BUILD_WITH_LIBPCAP_LIBS="-lpcap"
+fi
+
+AC_SUBST([BUILD_WITH_LIBPCAP_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBPCAP_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBPCAP_LIBS])
+# }}}
+
+# --with-libperl {{{
+AC_ARG_WITH([libperl],
+ [AS_HELP_STRING([--with-libperl@<:@=PREFIX@:>@], [Path to libperl.])],
+ [
+ if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+ LDFLAGS="$LDFLAGS -L$withval/lib"
+ CPPFLAGS="$CPPFLAGS -I$withval/include"
+ with_libperl="yes"
+ else
+ with_libperl="$withval"
+ fi
+ ],
+ [with_libperl="yes"]
+)
+
+AC_ARG_VAR([PERL], [path to Perl interpreter])
+AC_PATH_PROG([PERL], [perl])
+
+if test "x$PERL" = "x"; then
+ with_libperl="no (no Perl interpreter found)"
+fi
+
+if test "x$with_libperl" = "xyes"; then
+ SAVE_CFLAGS="$CFLAGS"
+ SAVE_LIBS="$LIBS"
+ dnl ARCHFLAGS="" -> disable multi -arch on OSX (see Config_heavy.pl:fetch_string)
+ PERL_CFLAGS=`ARCHFLAGS="" $PERL -MExtUtils::Embed -e perl_inc`
+ PERL_LIBS=`ARCHFLAGS="" $PERL -MExtUtils::Embed -e ldopts`
+ CFLAGS="$CFLAGS $PERL_CFLAGS"
+ LIBS="$LIBS $PERL_LIBS"
+
+ AC_CACHE_CHECK([for libperl],
+ [c_cv_have_libperl],
+ [
+ AC_LINK_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [[
+ #define PERL_NO_GET_CONTEXT
+ #include <EXTERN.h>
+ #include <perl.h>
+ #include <XSUB.h>
+ ]],
+ [[
+ dTHX;
+ load_module (PERL_LOADMOD_NOIMPORT,
+ newSVpv ("Collectd::Plugin::FooBar", 24),
+ Nullsv);
+ ]]
+ )
+ ],
+ [c_cv_have_libperl="yes"],
+ [c_cv_have_libperl="no"]
+ )
+ ]
+ )
+
+ CFLAGS="$SAVE_CFLAGS"
+ LIBS="$SAVE_LIBS"
+
+ if test "x$c_cv_have_libperl" = "xno"; then
+ with_libperl="no"
+ fi
+fi
+
+if test "x$with_libperl" = "xyes"; then
+ SAVE_CFLAGS="$CFLAGS"
+ SAVE_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $PERL_CFLAGS"
+ LIBS="$LIBS $PERL_LIBS"
+
+ AC_CACHE_CHECK([if Perl supports ithreads],
+ [c_cv_have_perl_ithreads],
+ [
+ AC_LINK_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [[
+ #include <EXTERN.h>
+ #include <perl.h>
+ #include <XSUB.h>
+
+ #if !defined(USE_ITHREADS)
+ # error "Perl does not support ithreads!"
+ #endif /* !defined(USE_ITHREADS) */
+ ]],
+ []
+ )
+ ],
+ [c_cv_have_perl_ithreads="yes"],
+ [c_cv_have_perl_ithreads="no"]
+ )
+ ]
+ )