From: Nathan Phillip Brink <binki@gentoo.org>
Subject: Prevent libarchive check from being automagic.

--- a/configure.in
+++ b/configure.in
@@ -231,22 +231,28 @@
 dnl XXX I don't understand why this is even necessary.
-have_libarchive=""
-orig_LIBS="$LIBS"
-AC_CHECK_LIB(archive, archive_read_new, [LIBS="$LIBS -larchive"])
-AC_MSG_CHECKING(whether libarchive works the way I expect)
-AC_TRY_LINK([#include <archive.h>], [
-	struct archive *x; 
-	const char *s = "bogus.zip";
-	x = archive_read_new();
-	archive_read_support_format_all(x);
-	archive_read_open_file(x, s, 10240);
-], have_libarchive="yes")
-if test "x$have_libarchive" = "x"; then
-	LIBS="$orig_LIBS"
-	AC_MSG_RESULT(no)
-else
-	AC_MSG_RESULT(yes)
-	AC_DEFINE(HAVE_LIBARCHIVE)
-fi
+AC_ARG_WITH([libarchive], [AS_HELP_STRING([--without-libarchive], [Disable libarchive support.])],
+	[], [with_libarchive=maybe])
+AS_IF([test "x$with_libarchive" != "xno"],
+	[
+	have_libarchive=""
+	orig_LIBS="$LIBS"
+	AC_CHECK_LIB(archive, archive_read_new, [LIBS="$LIBS -larchive"])
+	AC_MSG_CHECKING(whether libarchive works the way I expect)
+	AC_TRY_LINK([#include <archive.h>], [
+		struct archive *x; 
+		const char *s = "bogus.zip";
+		x = archive_read_new();
+		archive_read_support_format_all(x);
+		archive_read_open_file(x, s, 10240);
+	], have_libarchive="yes")
+	if test "x$have_libarchive" = "x"; then
+		LIBS="$orig_LIBS"
+		AC_MSG_RESULT(no)
+		AS_IF([test "x$with_libarchive" = "xyes"],
+			[AC_MSG_ERROR([--with-libarchive was specified but libarchive could not be found. Please do not specify --with-libarchive or install libarchive.])])
+	else
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_LIBARCHIVE)
+	fi])
 
 dnl -----
 AC_ARG_WITH(ssl,

