# HG changeset patch
# User Daniel Mierswa <impulze@impulze.org>
# Date 1246141364 -7200
# Branch HEAD
# Node ID dc0b04ce6df3aab99d9c0f4cd6d00df8efd433da
# Parent  d14e8b8df025fc6581321e7bea6e74e3a2021f48
do not automagically depend on libcap if it's installed

diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -196,6 +196,11 @@
   TEST_WITH(bzlib, $withval),
   want_bzlib=auto)
 
+AC_ARG_WITH(libcap,
+[  --with-libcap           Build with libcap support (Dropping capabilities).],
+  TEST_WITH(libcap, $withval),
+  want_libcap=auto)
+
 AC_ARG_WITH(ssl,
 [  --with-ssl=gnutls|openssl Build with GNUTLS or OpenSSL (default)],
 	if test x$withval = xno; then
@@ -358,11 +363,17 @@
   AC_DEFINE(HAVE_FDATASYNC,, Define if you have fdatasync())
 ])
 
-AC_CHECK_LIB(cap, cap_init, [
-  AC_DEFINE(HAVE_LIBCAP,, libcap is installed for cap_init())
-  LIBCAP="-lcap"
-])
-AC_SUBST(LIBCAP)
+if test $want_libcap != no; then
+  AC_CHECK_LIB(cap, cap_init, [
+    AC_DEFINE(HAVE_LIBCAP,, libcap is installed for cap_init())
+    LIBCAP="-lcap"
+    AC_SUBST(LIBCAP)
+  ], [
+    if test "$want_libcap" = "yes"; then
+      AC_ERROR([Can't build with libcap support: libcap not found])
+    fi
+  ])
+fi
 
 AC_DEFINE(PACKAGE_WEBPAGE, "http://www.dovecot.org/", Support URL)
 
