+
+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])