+if test "x$with_libmongoc" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+
+ CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
+
+ if test "x$CPPFLAGS" != "x"; then
+ AC_MSG_NOTICE([libmongoc CPPFLAGS: $LIBMONGOC_CFLAGS])
+ fi
+
+ AC_CHECK_HEADERS([mongoc.h],
+ [with_libmongoc="yes"],
+ [with_libmongoc="no ('mongoc.h' not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libmongoc" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ SAVE_LDFLAGS="$LDFLAGS"
+
+ CPPFLAGS="$CPPFLAGS $LIBMONGOC_CFLAGS"
+ LDFLAGS="$LDFLAGS $LIBMONGOC_LDFLAGS"
+
+ if test "x$LIBMONGOC_LDFLAGS" != "x"; then
+ AC_MSG_NOTICE([libmongoc LDFLAGS: $LIBMONGOC_LDFLAGS])
+ fi
+
+ AC_CHECK_LIB([mongoc-1.0], [mongoc_init],
+ [with_libmongoc="yes"],
+ [with_libmongoc="no (symbol 'mongoc_init' not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+ LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libmongoc" = "xyes"; then
+ BUILD_WITH_LIBMONGOC_CFLAGS="$LIBMONGOC_CFLAGS"
+ BUILD_WITH_LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS"
+fi
+
+AC_SUBST([BUILD_WITH_LIBMONGOC_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBMONGOC_LDFLAGS])
+# }}}
+
+# --with-libmosquitto {{{
+AC_ARG_WITH([libmosquitto],
+ [AS_HELP_STRING([--with-libmosquitto@<:@=PREFIX@:>@], [Path to libmosquitto.])],
+ [
+ if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+ with_libmosquitto_cppflags="-I$withval/include"
+ with_libmosquitto_ldflags="-L$withval/lib"
+ with_libmosquitto="yes"
+ else
+ with_libmosquitto="$withval"
+ fi
+ ],
+ [with_libmosquitto="yes"]
+)
+
+if test "x$with_libmosquitto" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_libmosquitto_cppflags"
+
+ AC_CHECK_HEADERS([mosquitto.h],
+ [with_libmosquitto="yes"],
+ [with_libmosquitto="no (mosquitto.h not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libmosquitto" = "xyes"; then
+ SAVE_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $with_libmosquitto_ldflags"
+
+ AC_CHECK_LIB([mosquitto], [mosquitto_connect],
+ [with_libmosquitto="yes"],
+ [with_libmosquitto="no (libmosquitto not found)"]
+ )
+
+ LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libmosquitto" = "xyes"; then
+ BUILD_WITH_LIBMOSQUITTO_CPPFLAGS="$with_libmosquitto_cppflags"
+ BUILD_WITH_LIBMOSQUITTO_LDFLAGS="$with_libmosquitto_ldflags"
+ BUILD_WITH_LIBMOSQUITTO_LIBS="-lmosquitto"
+fi
+
+AC_SUBST([BUILD_WITH_LIBMOSQUITTO_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBMOSQUITTO_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBMOSQUITTO_LIBS])
+# }}}
+
+# --with-libmysql {{{
+with_mysql_config="mysql_config"
+AC_ARG_WITH([libmysql],
+ [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to libmysql.])],
+ [
+ if test "x$withval" = "xno"; then
+ with_libmysql="no"
+ else if test "x$withval" = "xyes"; then
+ with_libmysql="yes"
+ else
+ if test -f "$withval" && test -x "$withval"; then
+ with_mysql_config="$withval"
+ else if test -x "$withval/bin/mysql_config"; then
+ with_mysql_config="$withval/bin/mysql_config"
+ fi; fi
+ with_libmysql="yes"
+ fi; fi
+ ],
+ [with_libmysql="yes"]
+)
+
+if test "x$with_libmysql" = "xyes"; then
+ with_mysql_cflags=`$with_mysql_config --include 2>/dev/null`
+ if test $? -ne 0; then
+ with_libmysql="no ($with_mysql_config failed)"
+ else
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_mysql_cflags"
+
+ AC_CHECK_HEADERS([mysql.h],
+ [have_mysql_h="yes"],
+ [have_mysql_h="no"]
+ )
+
+ if test "x$have_mysql_h" != "xyes"; then
+ AC_CHECK_HEADERS([mysql/mysql.h],
+ [have_mysql_mysql_h="yes"],
+ [],
+ )
+ fi
+
+ if test "x$have_mysql_h" != "xyes" && test "x$have_mysql_mysql_h" != "xyes"; then
+ with_libmysql="no (mysql.h not found)"
+ fi
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+ fi
+fi
+
+if test "x$with_libmysql" = "xyes"; then
+ with_mysql_libs=`$with_mysql_config --libs_r 2>/dev/null`
+ if test $? -ne 0; then
+ with_libmysql="no ($with_mysql_config failed)"
+ else
+ SAVE_LIBS="$LIBS"
+ LIBS="$with_mysql_libs"
+
+ AC_SEARCH_LIBS([mysql_get_server_version],
+ [],
+ [with_libmysql="yes"],
+ [with_libmysql="no (symbol 'mysql_get_server_version' not found in ${LIBS})"],
+ []
+ )
+ LIBS="$SAVE_LIBS"
+ fi
+fi
+
+if test "x$with_libmysql" = "xyes"; then
+ BUILD_WITH_LIBMYSQL_CFLAGS="$with_mysql_cflags"
+ BUILD_WITH_LIBMYSQL_LIBS="$with_mysql_libs"
+fi
+
+AC_SUBST([BUILD_WITH_LIBMYSQL_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBMYSQL_LIBS])
+# }}}
+
+# --with-libmnl {{{
+AC_ARG_WITH([libmnl],
+ [AS_HELP_STRING([--with-libmnl@<:@=PREFIX@:>@], [Path to libmnl.])],
+ [
+ if test "x$withval" = "xyes"; then
+ with_libmnl="yes"
+ else if test "x$withval" = "xno"; then
+ with_libmnl="no"
+ else
+ if test -d "$withval/include"; then
+ with_libmnl_cflags="-I$withval/include"
+ with_libmnl_libs="-L$withval/lib -lmnl"
+ with_libmnl="yes"
+ else
+ AC_MSG_ERROR("no such directory: $withval/include")
+ fi
+ fi; fi
+ ],
+ [
+ if test "x$ac_system" = "xLinux"; then
+ with_libmnl="yes"
+ else
+ with_libmnl="no (Linux only library)"
+ fi
+ ]
+)
+
+if test "x$with_libmnl" = "xyes"; then
+ if $PKG_CONFIG --exists libmnl 2>/dev/null; then
+ with_libmnl_cflags="$with_libmnl_ldflags `$PKG_CONFIG --cflags libmnl`"
+ with_libmnl_libs="$with_libmnl_libs `$PKG_CONFIG --libs libmnl`"
+ fi
+
+ AC_CHECK_HEADERS([libmnl.h libmnl/libmnl.h],
+ [
+ with_libmnl="yes"
+ break
+ ],
+ [],
+ [[
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <asm/types.h>
+ #include <sys/socket.h>
+ #include <linux/netlink.h>
+ #include <linux/rtnetlink.h>]]
+ )
+
+ AC_CHECK_HEADERS([linux/gen_stats.h linux/pkt_sched.h],
+ [],
+ [],
+ [[
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <asm/types.h>
+ #include <sys/socket.h>
+ ]]
+ )
+
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [[
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <asm/types.h>
+ #include <sys/socket.h>
+ #include <linux/netlink.h>
+ #include <linux/rtnetlink.h>
+ ]],
+ [[
+ int retval = TCA_STATS2;
+ return (retval);
+ ]]
+ )
+ ],
+ [AC_DEFINE([HAVE_TCA_STATS2], [1], [True if the enum-member TCA_STATS2 exists])]
+ )
+
+ AC_COMPILE_IFELSE(
+ [
+ AC_LANG_PROGRAM(
+ [[
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <asm/types.h>
+ #include <sys/socket.h>
+ #include <linux/netlink.h>
+ #include <linux/rtnetlink.h>
+ ]],
+ [[
+ int retval = TCA_STATS;
+ return (retval);
+ ]]
+ )
+ ],
+ [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
+ )
+
+ AC_CHECK_MEMBERS([struct rtnl_link_stats64.tx_window_errors],
+ [AC_DEFINE(HAVE_RTNL_LINK_STATS64, 1, [Define if struct rtnl_link_stats64 exists and is usable.])],
+ [],
+ [[#include <linux/if_link.h>]]
+ )
+
+ AC_CHECK_LIB([mnl], [mnl_nlmsg_get_payload],
+ [with_libmnl="yes"],
+ [with_libmnl="no (symbol 'mnl_nlmsg_get_payload' not found)"],
+ [$with_libmnl_libs]
+ )
+fi
+
+if test "x$with_libmnl" = "xyes"; then
+ BUILD_WITH_LIBMNL_CFLAGS="$with_libmnl_cflags"
+ BUILD_WITH_LIBMNL_LIBS="$with_libmnl_libs"
+fi
+AC_SUBST([BUILD_WITH_LIBMNL_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBMNL_LIBS])
+# }}}
+
+# --with-libnetapp {{{
+AC_ARG_VAR([LIBNETAPP_CPPFLAGS], [C preprocessor flags required to build with libnetapp])
+AC_ARG_VAR([LIBNETAPP_LDFLAGS], [Linker flags required to build with libnetapp])