+BUILD_WITH_LIBMICROHTTPD_CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
+BUILD_WITH_LIBMICROHTTPD_LDFLAGS="$with_libmicrohttpd_ldflags"
+BUILD_WITH_LIBMICROHTTPD_LIBS="$MICROHTTPD_LIBS"
+AC_SUBST([BUILD_WITH_LIBMICROHTTPD_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBMICROHTTPD_LIBS])
+# }}}
+
+# --with-libmodbus {{{
+AC_ARG_WITH([libmodbus],
+ [AS_HELP_STRING([--with-libmodbus@<:@=PREFIX@:>@], [Path to the modbus library.])],
+ [
+ if test "x$withval" = "xno"; then
+ with_libmodbus="no"
+ else if test "x$withval" = "xyes"; then
+ with_libmodbus="use_pkgconfig"
+ else if test -d "$with_libmodbus/lib"; then
+ AC_MSG_NOTICE([Not checking for libmodbus: Manually configured])
+ with_libmodbus_cflags="-I$withval/include"
+ with_libmodbus_libs="-L$withval/lib -lmodbus"
+ with_libmodbus="yes"
+ fi; fi; fi
+ ],
+ [with_libmodbus="use_pkgconfig"]
+)
+
+# configure using pkg-config
+if test "x$with_libmodbus" = "xuse_pkgconfig"; then
+ AC_MSG_NOTICE([Checking for libmodbus using $PKG_CONFIG])
+ $PKG_CONFIG --exists 'libmodbus' 2>/dev/null
+ if test $? -ne 0; then
+ with_libmodbus="no (pkg-config doesn't know libmodbus)"
+ fi
+fi
+
+if test "x$with_libmodbus" = "xuse_pkgconfig"; then
+ with_libmodbus_cflags="`$PKG_CONFIG --cflags 'libmodbus'`"
+ if test $? -ne 0; then
+ with_libmodbus="no ($PKG_CONFIG failed)"
+ fi
+
+ with_libmodbus_libs="`$PKG_CONFIG --libs 'libmodbus'`"
+ if test $? -ne 0; then
+ with_libmodbus="no ($PKG_CONFIG failed)"
+ fi
+fi
+
+if test "x$with_libmodbus" = "xuse_pkgconfig"; then
+ with_libmodbus="yes"
+fi
+
+if test "x$with_libmodbus" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_libmodbus_cflags"
+
+ AC_CHECK_HEADERS([modbus.h],
+ [with_libmodbus="yes"],
+ [with_libmodbus="no (modbus.h not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libmodbus" = "xyes"; then
+ SAVE_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $with_libmodbus_libs"
+
+ AC_CHECK_LIB([modbus], [modbus_connect],
+ [with_libmodbus="yes"],
+ [with_libmodbus="no (symbol modbus_connect not found)"]
+ )
+
+ LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libmodbus" = "xyes"; then
+ BUILD_WITH_LIBMODBUS_CFLAGS="$with_libmodbus_cflags"
+ BUILD_WITH_LIBMODBUS_LIBS="$with_libmodbus_libs"
+fi
+
+AC_SUBST([BUILD_WITH_LIBMODBUS_CFLAGS])
+AC_SUBST([BUILD_WITH_LIBMODBUS_LIBS])
+# }}}
+
+# --with-libmongoc {{{
+AC_ARG_WITH([libmongoc],
+ [AS_HELP_STRING([--with-libmongoc@<:@=PREFIX@:>@], [Path to libmongoc.])],
+ [
+ if test "x$withval" = "xyes"; then
+ with_libmongoc="yes"
+ else if test "x$withval" = "xno"; then
+ with_libmongoc="no"
+ else
+ with_libmongoc="no"
+ fi; fi
+ ],
+ [with_libmongoc="yes"]
+)
+
+if test "x$with_libmongoc" = "xyes"; then
+ PKG_CHECK_MODULES([LIBMONGOC], [libmongoc-1.0],
+ [with_libmongoc="yes"],
+ [with_libmongoc="no (pkg-config could not find libmongoc)"]
+ )
+fi
+
+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"