From 8a0316ba3818af769d9799b1e172f75568cb09ec Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Fri, 10 Sep 2010 00:16:10 +0200
Subject: [PATCH] Fixed make distcheck to work.

---
 configure.in  |  1 +
 m4/dovecot.m4 | 38 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/configure.in b/configure.in
index 81eeb5307..04f99c3e9 100644
--- a/configure.in
+++ b/configure.in
@@ -26,6 +26,7 @@ AC_PROG_LIBTOOL
 #
 
 DC_DOVECOT
+DC_DOVECOT_MODULEDIR
 LIBDOVECOT_INCLUDE="$LIBDOVECOT_INCLUDE $LIBDOVECOT_STORAGE_INCLUDE" 
 CFLAGS="$DOVECOT_CFLAGS"
 LIBS="$DOVECOT_LIBS"
diff --git a/m4/dovecot.m4 b/m4/dovecot.m4
index 147859b3e..02e6e0153 100644
--- a/m4/dovecot.m4
+++ b/m4/dovecot.m4
@@ -6,7 +6,16 @@
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 2
+# serial 4
+
+AC_DEFUN([DC_DOVECOT_MODULEDIR],[
+	AC_ARG_WITH(moduledir,
+	[  --with-moduledir=DIR    Base directory for dynamically loadable modules],
+		moduledir="$withval",
+		moduledir=$libdir/dovecot
+	)
+	AC_SUBST(moduledir)
+])
 
 AC_DEFUN([DC_PLUGIN_DEPS],[
 	_plugin_deps=yes
@@ -37,6 +46,16 @@ AC_DEFUN([DC_DOVECOT],[
 			]
 	)
 
+	AC_ARG_WITH(dovecot-install-dirs,
+		[AC_HELP_STRING([--with-dovecot-install-dirs],
+	    	[Use install directories configured for Dovecot (default)])],
+	    if test x$withval = xno; then
+    	    use_install_dirs=no
+    	else
+        	use_install_dirs=yes
+	    fi,
+    	use_install_dirs=yes)
+
 	AC_MSG_CHECKING([for dovecot-config in "$dovecotdir"])
 	if test -f "$dovecotdir/dovecot-config"; then
 		AC_MSG_RESULT([$dovecotdir/dovecot-config])
@@ -47,9 +66,24 @@ AC_DEFUN([DC_DOVECOT],[
 		AC_MSG_ERROR([dovecot-config not found])
 	fi
 
+	old=`pwd`
+	cd $dovecotdir
+	abs_dovecotdir=`pwd`
+	cd $old
+	DISTCHECK_CONFIGURE_FLAGS="--with-dovecot=$abs_dovecotdir --without-dovecot-install-dirs"
+
 	eval `grep -i '^dovecot_[[a-z]]*=' "$dovecotdir"/dovecot-config`
 	eval `grep '^LIBDOVECOT[[A-Z_]]*=' "$dovecotdir"/dovecot-config`
-	AX_SUBST_L([dovecot_moduledir], [dovecot_pkgincludedir], [dovecot_pkglibexecdir], [dovecot_pkglibdir], [dovecot_docdir])
+
+	if test "$use_install_dirs" = "no"; then
+		dovecot_pkgincludedir='$(pkgincludedir)'
+		dovecot_pkglibdir='$(pkglibdir)'
+		dovecot_pkglibexecdir='$(libexecdir)/dovecot'
+		dovecot_docdir='$(docdir)'
+		dovecot_moduledir='$(moduledir)'
+	fi
+
+	AX_SUBST_L([DISTCHECK_CONFIGURE_FLAGS], [dovecot_moduledir], [dovecot_pkgincludedir], [dovecot_pkglibexecdir], [dovecot_pkglibdir], [dovecot_docdir])
 	AX_SUBST_L([DOVECOT_CFLAGS], [DOVECOT_LIBS], [DOVECOT_SSL_LIBS])
 	AX_SUBST_L([LIBDOVECOT], [LIBDOVECOT_LOGIN], [LIBDOVECOT_SQL], [LIBDOVECOT_LDA], [LIBDOVECOT_STORAGE])
 	AX_SUBST_L([LIBDOVECOT_DEPS], [LIBDOVECOT_LOGIN_DEPS], [LIBDOVECOT_SQL_DEPS], [LIBDOVECOT_LDA_DEPS], [LIBDOVECOT_STORAGE_DEPS])
-- 
GitLab