-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"
- AC_SUBST(BUILD_WITH_LIBMEMCACHED_CPPFLAGS)
- AC_SUBST(BUILD_WITH_LIBMEMCACHED_LDFLAGS)
- AC_SUBST(BUILD_WITH_LIBMEMCACHED_LIBS)
- AC_DEFINE(HAVE_LIBMEMCACHED, 1, [Define if libmemcached is present and usable.])
-fi
-AM_CONDITIONAL(BUILD_WITH_LIBMEMCACHED, test "x$with_libmemcached" = "xyes")
+
+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])