+ BUILD_WITH_LIBLUA_CFLAGS="$LUA_CFLAGS"
+ BUILD_WITH_LIBLUA_LIBS="$LUA_LIBS"
+fi
+AC_SUBST(BUILD_WITH_LIBLUA_CFLAGS)
+AC_SUBST(BUILD_WITH_LIBLUA_LIBS)
+# }}}
+
+# --with-liblvm2app {{{
+AC_ARG_WITH([liblvm2app],
+ [AS_HELP_STRING([--with-liblvm2app@<:@=PREFIX@:>@], [Path to liblvm2app.])],
+ [
+ if test "x$withval" = "xno"; then
+ with_liblvm2app="no"
+ else
+ with_liblvm2app="yes"
+ if test "x$withval" != "xyes"; then
+ with_liblvm2app_cppflags="-I$withval/include"
+ with_liblvm2app_ldflags="-L$withval/lib"
+ fi
+ fi
+ ],
+ [
+ if test "x$ac_system" = "xLinux"; then
+ with_liblvm2app="yes"
+ else
+ with_liblvm2app="no (Linux only library)"
+ fi
+ ]
+)
+
+if test "x$with_liblvm2app" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
+
+ AC_CHECK_HEADERS([lvm2app.h],
+ [with_liblvm2app="yes"],
+ [with_liblvm2app="no (lvm2app.h not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_liblvm2app" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ SAVE_LDFLAGS="$LDFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_liblvm2app_cppflags"
+ LDFLAGS="$LDFLAGS $with_liblvm2app_ldflags"
+
+ AC_CHECK_LIB([lvm2app], [lvm_lv_get_property],
+ [with_liblvm2app="yes"],
+ [with_liblvm2app="no (Symbol 'lvm_lv_get_property' not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+ LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_liblvm2app" = "xyes"; then
+ BUILD_WITH_LIBLVM2APP_CPPFLAGS="$with_liblvm2app_cppflags"
+ BUILD_WITH_LIBLVM2APP_LDFLAGS="$with_liblvm2app_ldflags"
+ BUILD_WITH_LIBLVM2APP_LIBS="-llvm2app"
+fi
+
+AC_SUBST([BUILD_WITH_LIBLVM2APP_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBLVM2APP_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBLVM2APP_LIBS])
+# }}}
+
+# --with-libmemcached {{{
+AC_ARG_WITH([libmemcached],
+ [AS_HELP_STRING([--with-libmemcached@<:@=PREFIX@:>@], [Path to libmemcached.])],
+ [
+ if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+ with_libmemcached_cppflags="-I$withval/include"
+ with_libmemcached_ldflags="-L$withval/lib"
+ with_libmemcached="yes"
+ else
+ with_libmemcached="$withval"
+ fi
+ ],
+ [with_libmemcached="yes"]
+)
+
+if test "x$with_libmemcached" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
+
+ AC_CHECK_HEADERS([libmemcached/memcached.h],
+ [with_libmemcached="yes"],
+ [with_libmemcached="no (libmemcached/memcached.h not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+fi
+
+if test "x$with_libmemcached" = "xyes"; then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ SAVE_LDFLAGS="$LDFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_libmemcached_cppflags"
+ LDFLAGS="$LDFLAGS $with_libmemcached_ldflags"
+
+ AC_CHECK_LIB([memcached], [memcached_create],
+ [with_libmemcached="yes"],
+ [with_libmemcached="no (Symbol 'memcached_create' not found)"]
+ )
+
+ CPPFLAGS="$SAVE_CPPFLAGS"
+ LDFLAGS="$SAVE_LDFLAGS"
+fi
+
+if test "x$with_libmemcached" = "xyes"; then
+ BUILD_WITH_LIBMEMCACHED_CPPFLAGS="$with_libmemcached_cppflags"
+ BUILD_WITH_LIBMEMCACHED_LDFLAGS="$with_libmemcached_ldflags"
+ BUILD_WITH_LIBMEMCACHED_LIBS="-lmemcached"
+fi
+
+AC_SUBST([BUILD_WITH_LIBMEMCACHED_CPPFLAGS])
+AC_SUBST([BUILD_WITH_LIBMEMCACHED_LDFLAGS])
+AC_SUBST([BUILD_WITH_LIBMEMCACHED_LIBS])
+# }}}
+
+# --with-libmicrohttpd {{{
+with_libmicrohttpd_cppflags=""
+with_libmicrohttpd_ldflags=""
+AC_ARG_WITH([libmicrohttpd], [AS_HELP_STRING([--with-libmicrohttpd@<:@=PREFIX@:>@], [Path to libmicrohttpd.])],
+ [
+ if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
+ with_libmicrohttpd_cppflags="-I$withval/include"
+ with_libmicrohttpd_ldflags="-L$withval/lib"
+ with_libmicrohttpd="yes"
+ fi
+ if test "x$withval" = "xno"; then
+ with_libmicrohttpd="no (disabled on command line)"
+ fi
+ ],
+ [withval="yes"]
+)
+if test "x$withval" = "xyes"; then
+ PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd],
+ [with_libmicrohttpd="yes"],
+ [with_libmicrohttpd="no (pkg-config could not find libmicrohttpd)"]
+ )
+fi
+
+if test "x$MICROHTTPD_LIBS" = "x"; then
+ MICROHTTPD_LIBS="-lmicrohttpd"
+fi
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+SAVE_LIBS="$LIBS"
+CPPFLAGS="$with_libmicrohttpd_cppflags $MICROHTTPD_CFLAGS"
+LDFLAGS="$with_libmicrohttpd_ldflags $LDFLAGS"
+LIBS="$LIBS $MICROHTTPD_LIBS"
+
+if test "x$with_libmicrohttpd" = "xyes"; then
+ AC_CHECK_HEADERS([microhttpd.h],
+ [with_libmicrohttpd="yes"],
+ [with_libmicrohttpd="no (<microhttpd.h> not found)"]
+ )
+fi
+
+if test "x$with_libmicrohttpd" = "xyes"; then
+ AC_CHECK_LIB([microhttpd], [MHD_start_daemon],
+ [with_libmicrohttpd="yes"],
+ [with_libmicrohttpd="no (libmicrohttpd not found)"]
+ )
+fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+LIBS="$SAVE_LIBS"
+
+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"
+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"