From a539090ed1887fde5a170cf3b3e796948293fe8e Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sat, 17 Jul 2010 19:57:25 +0200
Subject: [PATCH] First changes towards making `make distcheck' work.

---
 Makefile.am                                   |  6 ++--
 configure.in                                  |  2 +-
 src/lib-sieve/Makefile.am                     | 33 ++++++++++---------
 src/lib-sieve/plugins/body/Makefile.am        |  2 +-
 .../comparator-i-ascii-numeric/Makefile.am    |  2 +-
 src/lib-sieve/plugins/copy/Makefile.am        |  2 +-
 src/lib-sieve/plugins/date/Makefile.am        |  2 +-
 src/lib-sieve/plugins/enotify/Makefile.am     |  4 +--
 .../plugins/enotify/mailto/Makefile.am        |  4 +--
 src/lib-sieve/plugins/environment/Makefile.am |  2 +-
 src/lib-sieve/plugins/imap4flags/Makefile.am  |  4 +--
 src/lib-sieve/plugins/include/Makefile.am     |  4 +--
 src/lib-sieve/plugins/mailbox/Makefile.am     |  2 +-
 src/lib-sieve/plugins/notify/Makefile.am      |  2 +-
 src/lib-sieve/plugins/regex/Makefile.am       |  2 +-
 src/lib-sieve/plugins/relational/Makefile.am  |  2 +-
 .../plugins/spamvirustest/Makefile.am         |  2 +-
 src/lib-sieve/plugins/subaddress/Makefile.am  |  2 +-
 src/lib-sieve/plugins/vacation/Makefile.am    |  2 +-
 src/lib-sieve/plugins/variables/Makefile.am   |  2 +-
 src/managesieve-login/Makefile.am             |  2 +-
 src/managesieve/Makefile.am                   |  6 ++--
 src/plugins/lda-sieve/Makefile.am             |  2 +-
 src/sieve-tools/Makefile.am                   |  8 ++---
 src/testsuite/Makefile.am                     |  4 +--
 25 files changed, 54 insertions(+), 51 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b2d59e73e..fc1f3913f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,7 @@ endif
 
 # Testsuite tests
 
-TESTSUITE_BIN = $(top_srcdir)/src/testsuite/testsuite
+TESTSUITE_BIN = $(top_builddir)/src/testsuite/testsuite
 
 if TESTSUITE_VALGRIND
 TEST_BIN = valgrind -q --error-exitcode=1 --show-reachable=yes --leak-check=full $(TESTSUITE_BIN) 
@@ -128,8 +128,10 @@ test_cases = \
 	$(test_unfinished)
 
 $(test_cases):
-	@$(TEST_BIN) $@
+	@$(TEST_BIN) $(top_srcdir)/$@
 
 .PHONY: $(test_cases)
 
 test: $(test_cases)
+
+check: check-am test all-am
diff --git a/configure.in b/configure.in
index c970bc78d..6859b7afd 100644
--- a/configure.in
+++ b/configure.in
@@ -31,7 +31,7 @@ CFLAGS="$DOVECOT_CFLAGS"
 LIBS="$DOVECOT_LIBS"
 AC_SUBST(LIBDOVECOT_INCLUDE)
 
-# Defome Sieve documentation install dir
+# Define Sieve documentation install dir
 #
 
 sieve_docdir='${dovecot_docdir}/sieve'
diff --git a/src/lib-sieve/Makefile.am b/src/lib-sieve/Makefile.am
index 6aca9080c..21336e1be 100644
--- a/src/lib-sieve/Makefile.am
+++ b/src/lib-sieve/Makefile.am
@@ -45,23 +45,24 @@ unfinished_plugins =
 endif
 
 # These are not actual plugins just yet...
+extdir = $(builddir)/plugins
 plugins = \
-	./plugins/vacation/libsieve_ext_vacation.la \
-	./plugins/subaddress/libsieve_ext_subaddress.la \
- 	./plugins/comparator-i-ascii-numeric/libsieve_ext_comparator-i-ascii-numeric.la \
-	./plugins/relational/libsieve_ext_relational.la \
-	./plugins/regex/libsieve_ext_regex.la \
-	./plugins/copy/libsieve_ext_copy.la \
-	./plugins/imap4flags/libsieve_ext_imap4flags.la \
-	./plugins/include/libsieve_ext_include.la \
-	./plugins/body/libsieve_ext_body.la \
-	./plugins/variables/libsieve_ext_variables.la \
-	./plugins/enotify/libsieve_ext_enotify.la \
-	./plugins/notify/libsieve_ext_notify.la \
-	./plugins/environment/libsieve_ext_environment.la \
-	./plugins/mailbox/libsieve_ext_mailbox.la \
-	./plugins/date/libsieve_ext_date.la \
-	./plugins/spamvirustest/libsieve_ext_spamvirustest.la \
+	$(extdir)/vacation/libsieve_ext_vacation.la \
+	$(extdir)/subaddress/libsieve_ext_subaddress.la \
+ 	$(extdir)/comparator-i-ascii-numeric/libsieve_ext_comparator-i-ascii-numeric.la \
+	$(extdir)/relational/libsieve_ext_relational.la \
+	$(extdir)/regex/libsieve_ext_regex.la \
+	$(extdir)/copy/libsieve_ext_copy.la \
+	$(extdir)/imap4flags/libsieve_ext_imap4flags.la \
+	$(extdir)/include/libsieve_ext_include.la \
+	$(extdir)/body/libsieve_ext_body.la \
+	$(extdir)/variables/libsieve_ext_variables.la \
+	$(extdir)/enotify/libsieve_ext_enotify.la \
+	$(extdir)/notify/libsieve_ext_notify.la \
+	$(extdir)/environment/libsieve_ext_environment.la \
+	$(extdir)/mailbox/libsieve_ext_mailbox.la \
+	$(extdir)/date/libsieve_ext_date.la \
+	$(extdir)/spamvirustest/libsieve_ext_spamvirustest.la \
 	$(unfinished_plugins)
 
 libdovecot_sieve_la_DEPENDENCIES = $(plugins)
diff --git a/src/lib-sieve/plugins/body/Makefile.am b/src/lib-sieve/plugins/body/Makefile.am
index 9074541a6..251b8d69b 100644
--- a/src/lib-sieve/plugins/body/Makefile.am
+++ b/src/lib-sieve/plugins/body/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_body.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 tsts = \
diff --git a/src/lib-sieve/plugins/comparator-i-ascii-numeric/Makefile.am b/src/lib-sieve/plugins/comparator-i-ascii-numeric/Makefile.am
index c0b1626a2..8e385c5cf 100644
--- a/src/lib-sieve/plugins/comparator-i-ascii-numeric/Makefile.am
+++ b/src/lib-sieve/plugins/comparator-i-ascii-numeric/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_comparator-i-ascii-numeric.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 libsieve_ext_comparator_i_ascii_numeric_la_SOURCES = \
diff --git a/src/lib-sieve/plugins/copy/Makefile.am b/src/lib-sieve/plugins/copy/Makefile.am
index fb5d11839..d2220d70a 100644
--- a/src/lib-sieve/plugins/copy/Makefile.am
+++ b/src/lib-sieve/plugins/copy/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_copy.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 libsieve_ext_copy_la_SOURCES = \
diff --git a/src/lib-sieve/plugins/date/Makefile.am b/src/lib-sieve/plugins/date/Makefile.am
index 5e959a167..bf257acca 100644
--- a/src/lib-sieve/plugins/date/Makefile.am
+++ b/src/lib-sieve/plugins/date/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_date.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 tests = \
diff --git a/src/lib-sieve/plugins/enotify/Makefile.am b/src/lib-sieve/plugins/enotify/Makefile.am
index 648fe6be1..a3fc8acef 100644
--- a/src/lib-sieve/plugins/enotify/Makefile.am
+++ b/src/lib-sieve/plugins/enotify/Makefile.am
@@ -3,8 +3,8 @@ SUBDIRS = mailto
 noinst_LTLIBRARIES = libsieve_ext_enotify.la
 
 AM_CPPFLAGS = \
-	-I../../ \
-	-I../variables \
+	-I$(srcdir)/../.. \
+	-I$(srcdir)/../variables \
 	$(LIBDOVECOT_INCLUDE)
 
 commands = \
diff --git a/src/lib-sieve/plugins/enotify/mailto/Makefile.am b/src/lib-sieve/plugins/enotify/mailto/Makefile.am
index 80b04ab9c..06b926293 100644
--- a/src/lib-sieve/plugins/enotify/mailto/Makefile.am
+++ b/src/lib-sieve/plugins/enotify/mailto/Makefile.am
@@ -1,8 +1,8 @@
 noinst_LTLIBRARIES = libsieve_ext_enotify_mailto.la
 
 AM_CPPFLAGS = \
-	-I../ \
-	-I../../../ \
+	-I$(srcdir)/.. \
+	-I$(srcdir)/../../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 libsieve_ext_enotify_mailto_la_SOURCES = \
diff --git a/src/lib-sieve/plugins/environment/Makefile.am b/src/lib-sieve/plugins/environment/Makefile.am
index 2dbe522de..a19012863 100644
--- a/src/lib-sieve/plugins/environment/Makefile.am
+++ b/src/lib-sieve/plugins/environment/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_environment.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 tests = \
diff --git a/src/lib-sieve/plugins/imap4flags/Makefile.am b/src/lib-sieve/plugins/imap4flags/Makefile.am
index 867ec831f..c9c099811 100644
--- a/src/lib-sieve/plugins/imap4flags/Makefile.am
+++ b/src/lib-sieve/plugins/imap4flags/Makefile.am
@@ -1,8 +1,8 @@
 noinst_LTLIBRARIES = libsieve_ext_imap4flags.la
 
 AM_CPPFLAGS = \
-	-I../../ \
-    -I../variables \
+	-I$(srcdir)/../.. \
+	-I$(srcdir)/../variables  \
 	$(LIBDOVECOT_INCLUDE)
 
 commands = \
diff --git a/src/lib-sieve/plugins/include/Makefile.am b/src/lib-sieve/plugins/include/Makefile.am
index 9d0f164e5..5ce1599be 100644
--- a/src/lib-sieve/plugins/include/Makefile.am
+++ b/src/lib-sieve/plugins/include/Makefile.am
@@ -1,8 +1,8 @@
 noinst_LTLIBRARIES = libsieve_ext_include.la
 
 AM_CPPFLAGS = \
-	-I../../ \
-	-I../variables \
+	-I$(srcdir)/../.. \
+	-I$(srcdir)/../variables \
 	$(LIBDOVECOT_INCLUDE)
 
 cmds = \
diff --git a/src/lib-sieve/plugins/mailbox/Makefile.am b/src/lib-sieve/plugins/mailbox/Makefile.am
index 79739dba3..95dcf00b7 100644
--- a/src/lib-sieve/plugins/mailbox/Makefile.am
+++ b/src/lib-sieve/plugins/mailbox/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_mailbox.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 tags = \
diff --git a/src/lib-sieve/plugins/notify/Makefile.am b/src/lib-sieve/plugins/notify/Makefile.am
index bb343ebf3..b5165b9c5 100644
--- a/src/lib-sieve/plugins/notify/Makefile.am
+++ b/src/lib-sieve/plugins/notify/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_notify.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 commands = \
diff --git a/src/lib-sieve/plugins/regex/Makefile.am b/src/lib-sieve/plugins/regex/Makefile.am
index 9cc7ef16a..eeb735ef3 100644
--- a/src/lib-sieve/plugins/regex/Makefile.am
+++ b/src/lib-sieve/plugins/regex/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_regex.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 libsieve_ext_regex_la_SOURCES = \
diff --git a/src/lib-sieve/plugins/relational/Makefile.am b/src/lib-sieve/plugins/relational/Makefile.am
index 59a177009..69f8d5a94 100644
--- a/src/lib-sieve/plugins/relational/Makefile.am
+++ b/src/lib-sieve/plugins/relational/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_relational.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 libsieve_ext_relational_la_SOURCES = \
diff --git a/src/lib-sieve/plugins/spamvirustest/Makefile.am b/src/lib-sieve/plugins/spamvirustest/Makefile.am
index 3117517f3..6a15bdd14 100644
--- a/src/lib-sieve/plugins/spamvirustest/Makefile.am
+++ b/src/lib-sieve/plugins/spamvirustest/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_spamvirustest.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 tests = \
diff --git a/src/lib-sieve/plugins/subaddress/Makefile.am b/src/lib-sieve/plugins/subaddress/Makefile.am
index 49fcf718d..02386f290 100644
--- a/src/lib-sieve/plugins/subaddress/Makefile.am
+++ b/src/lib-sieve/plugins/subaddress/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_subaddress.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../../ \
 	$(LIBDOVECOT_INCLUDE)
 
 libsieve_ext_subaddress_la_SOURCES = \
diff --git a/src/lib-sieve/plugins/vacation/Makefile.am b/src/lib-sieve/plugins/vacation/Makefile.am
index 40639eff2..d516af560 100644
--- a/src/lib-sieve/plugins/vacation/Makefile.am
+++ b/src/lib-sieve/plugins/vacation/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_vacation.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../../ \
 	$(LIBDOVECOT_INCLUDE)
 
 cmds = \
diff --git a/src/lib-sieve/plugins/variables/Makefile.am b/src/lib-sieve/plugins/variables/Makefile.am
index f3d456420..bb9e44efd 100644
--- a/src/lib-sieve/plugins/variables/Makefile.am
+++ b/src/lib-sieve/plugins/variables/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_variables.la
 
 AM_CPPFLAGS = \
-	-I../../ \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 cmds = \
diff --git a/src/managesieve-login/Makefile.am b/src/managesieve-login/Makefile.am
index 84652eace..b0ef65d58 100644
--- a/src/managesieve-login/Makefile.am
+++ b/src/managesieve-login/Makefile.am
@@ -22,7 +22,7 @@ libmanagesieve_login_settings_la_CFLAGS = \
 	$(AM_CFLAGS) $(LIBDOVECOT_CONFIG_INCLUDE) -DPKG_LIBEXECDIR=\""$(dovecot_pkglibexecdir)"\"
 
 libs = \
-	$(top_srcdir)/src/lib-managesieve/libmanagesieve.a
+	$(top_builddir)/src/lib-managesieve/libmanagesieve.a
 
 managesieve_login_LDADD = $(libs) $(LIBDOVECOT_LOGIN) $(LIBDOVECOT)
 managesieve_login_DEPENDENCIES = $(libs) $(LIBDOVECOT_LOGIN_DEPS) $(LIBDOVECOT_DEPS)
diff --git a/src/managesieve/Makefile.am b/src/managesieve/Makefile.am
index 972e544e2..28b758ecf 100644
--- a/src/managesieve/Makefile.am
+++ b/src/managesieve/Makefile.am
@@ -23,9 +23,9 @@ managesieve_LDFLAGS = -export-dynamic
 
 libs = \
 	managesieve-settings.lo \
-	$(top_srcdir)/src/lib-managesieve/libmanagesieve.a \
-	$(top_srcdir)/src/lib-sievestorage/libsievestorage.a \
-	$(top_srcdir)/src/lib-sieve/libdovecot-sieve.la
+	$(top_builddir)/src/lib-managesieve/libmanagesieve.a \
+	$(top_builddir)/src/lib-sievestorage/libsievestorage.a \
+	$(top_builddir)/src/lib-sieve/libdovecot-sieve.la
 
 managesieve_LDADD = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT_LDA) $(LIBDOVECOT)
 
diff --git a/src/plugins/lda-sieve/Makefile.am b/src/plugins/lda-sieve/Makefile.am
index 5f8c23ff0..9994a64de 100644
--- a/src/plugins/lda-sieve/Makefile.am
+++ b/src/plugins/lda-sieve/Makefile.am
@@ -9,7 +9,7 @@ lib90_sieve_plugin_la_LDFLAGS = -module -avoid-version
 dovecot_module_LTLIBRARIES = lib90_sieve_plugin.la
 
 lib90_sieve_plugin_la_LIBADD = \
-	$(top_srcdir)/src/lib-sieve/libdovecot-sieve.la
+	$(top_builddir)/src/lib-sieve/libdovecot-sieve.la
 
 lib90_sieve_plugin_la_SOURCES = \
 	lda-sieve-log.c \
diff --git a/src/sieve-tools/Makefile.am b/src/sieve-tools/Makefile.am
index 7c204f2c5..5ce234292 100644
--- a/src/sieve-tools/Makefile.am
+++ b/src/sieve-tools/Makefile.am
@@ -9,14 +9,14 @@ endif
 AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/lib-sieve \
 	-I$(top_srcdir)/src/lib-sieve-tool \
-	-I./debug \
+	-I$(srcdir)/debug \
 	$(LIBDOVECOT_INCLUDE) \
 	$(LIBDOVECOT_SERVICE_INCLUDE)
 
 libs = \
-	$(top_srcdir)/src/lib-sieve/libdovecot-sieve.la \
-	$(top_srcdir)/src/lib-sieve-tool/libsieve-tool.la \
-	./debug/libsieve_ext_debug.la
+	$(top_builddir)/src/lib-sieve/libdovecot-sieve.la \
+	$(top_builddir)/src/lib-sieve-tool/libsieve-tool.la \
+	$(builddir)/debug/libsieve_ext_debug.la
 
 libs_ldadd = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT_LDA) $(LIBDOVECOT)
 libs_deps = $(libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_LDA_DEPS) $(LIBDOVECOT_DEPS)
diff --git a/src/testsuite/Makefile.am b/src/testsuite/Makefile.am
index d9c693f91..a57771cfa 100644
--- a/src/testsuite/Makefile.am
+++ b/src/testsuite/Makefile.am
@@ -9,8 +9,8 @@ AM_CPPFLAGS = \
 testsuite_LDFLAGS = -export-dynamic
 
 libs = \
-	$(top_srcdir)/src/lib-sieve/libdovecot-sieve.la \
-	$(top_srcdir)/src/lib-sieve-tool/libsieve-tool.la
+	$(top_builddir)/src/lib-sieve/libdovecot-sieve.la \
+	$(top_builddir)/src/lib-sieve-tool/libsieve-tool.la
 
 testsuite_LDADD = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT_LDA) $(LIBDOVECOT)
 testsuite_DEPENDENCIES = $(libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_LDA_DEPS) $(LIBDOVECOT_DEPS)
-- 
GitLab