From 389457bb8f879f70f06eddd4b957a1000dc9e279 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sat, 21 Dec 2013 21:10:13 +0100
Subject: [PATCH] lib-sieve: Moved utility source modules to sub-directory. In
 the future, much of these can be moved to Dovecot.

---
 configure.ac                                  |  1 +
 src/lib-sieve/Makefile.am                     | 21 ++++++++++++-------
 src/lib-sieve/plugins/editheader/Makefile.am  |  3 ++-
 .../plugins/enotify/mailto/Makefile.am        |  1 +
 src/lib-sieve/plugins/ihave/Makefile.am       |  2 +-
 src/lib-sieve/plugins/metadata/Makefile.am    |  5 ++---
 src/lib-sieve/plugins/notify/Makefile.am      |  1 +
 src/lib-sieve/plugins/subaddress/Makefile.am  |  2 +-
 src/lib-sieve/plugins/vacation/Makefile.am    |  3 ++-
 .../plugins/vnd.dovecot/debug/Makefile.am     |  2 +-
 .../plugins/vnd.dovecot/duplicate/Makefile.am |  2 +-
 src/lib-sieve/util/Makefile.am                | 19 +++++++++++++++++
 src/lib-sieve/{ => util}/edit-mail.c          |  0
 src/lib-sieve/{ => util}/edit-mail.h          |  0
 src/lib-sieve/{ => util}/rfc2822.c            |  0
 src/lib-sieve/{ => util}/rfc2822.h            |  0
 16 files changed, 46 insertions(+), 16 deletions(-)
 create mode 100644 src/lib-sieve/util/Makefile.am
 rename src/lib-sieve/{ => util}/edit-mail.c (100%)
 rename src/lib-sieve/{ => util}/edit-mail.h (100%)
 rename src/lib-sieve/{ => util}/rfc2822.c (100%)
 rename src/lib-sieve/{ => util}/rfc2822.h (100%)

diff --git a/configure.ac b/configure.ac
index 2e925f35c..2adf4d843 100644
--- a/configure.ac
+++ b/configure.ac
@@ -100,6 +100,7 @@ doc/example-config/conf.d/Makefile
 doc/rfc/Makefile
 src/Makefile
 src/lib-sieve/Makefile
+src/lib-sieve/util/Makefile
 src/lib-sieve/plugins/Makefile
 src/lib-sieve/plugins/vacation/Makefile
 src/lib-sieve/plugins/subaddress/Makefile
diff --git a/src/lib-sieve/Makefile.am b/src/lib-sieve/Makefile.am
index eea61baac..0f8f15619 100644
--- a/src/lib-sieve/Makefile.am
+++ b/src/lib-sieve/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = plugins
+SUBDIRS = util plugins
 
 dovecot_pkglib_LTLIBRARIES = libdovecot-sieve.la
 
@@ -6,6 +6,7 @@ AM_CPPFLAGS = \
 	$(LIBDOVECOT_INCLUDE) \
 	$(LIBDOVECOT_LDA_INCLUDE) \
 	$(LIBDOVECOT_SERVICE_INCLUDE) \
+	-I$(top_srcdir)/src/lib-sieve/util \
 	-DMODULEDIR=\""$(dovecot_moduledir)"\"
 
 tests = \
@@ -71,12 +72,20 @@ plugins = \
 	$(extdir)/vnd.dovecot/duplicate/libsieve_ext_duplicate.la \
 	$(unfinished_plugins)
 
-libdovecot_sieve_la_DEPENDENCIES = $(plugins) $(LIBDOVECOT_LDA_DEPS) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_DEPS)
-libdovecot_sieve_la_LIBADD = $(plugins) $(LIBDOVECOT_LDA) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT)
+libdovecot_sieve_la_DEPENDENCIES = \
+	$(plugins) \
+	$(top_builddir)/src/lib-sieve/util/libsieve_util.la \
+	$(LIBDOVECOT_LDA_DEPS) \
+	$(LIBDOVECOT_STORAGE_DEPS) \
+	$(LIBDOVECOT_DEPS)
+libdovecot_sieve_la_LIBADD = \
+	$(plugins) \
+	$(top_builddir)/src/lib-sieve/util/libsieve_util.la \
+	$(LIBDOVECOT_LDA) \
+	$(LIBDOVECOT_STORAGE) \
+	$(LIBDOVECOT)
 
 libdovecot_sieve_la_SOURCES = \
-	rfc2822.c \
-	edit-mail.c \
 	sieve-settings.c \
 	sieve-message.c \
 	sieve-smtp.c \
@@ -118,8 +127,6 @@ libdovecot_sieve_la_SOURCES = \
 	sieve.c
 
 headers = \
-	rfc2822.h \
-	edit-mail.h \
 	sieve-config.h \
 	sieve-types.h \
 	sieve-common.h \
diff --git a/src/lib-sieve/plugins/editheader/Makefile.am b/src/lib-sieve/plugins/editheader/Makefile.am
index d4524525c..6824ec070 100644
--- a/src/lib-sieve/plugins/editheader/Makefile.am
+++ b/src/lib-sieve/plugins/editheader/Makefile.am
@@ -1,7 +1,8 @@
 noinst_LTLIBRARIES = libsieve_ext_editheader.la
 
 AM_CPPFLAGS = \
-	-I$(top_srcdir)/src/lib-sieve \
+	-I$(srcdir)/../.. \
+	-I$(srcdir)/../../util \
 	$(LIBDOVECOT_INCLUDE)
 
 commands = \
diff --git a/src/lib-sieve/plugins/enotify/mailto/Makefile.am b/src/lib-sieve/plugins/enotify/mailto/Makefile.am
index 06b926293..83f129c62 100644
--- a/src/lib-sieve/plugins/enotify/mailto/Makefile.am
+++ b/src/lib-sieve/plugins/enotify/mailto/Makefile.am
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libsieve_ext_enotify_mailto.la
 AM_CPPFLAGS = \
 	-I$(srcdir)/.. \
 	-I$(srcdir)/../../.. \
+	-I$(srcdir)/../../../util \
 	$(LIBDOVECOT_INCLUDE)
 
 libsieve_ext_enotify_mailto_la_SOURCES = \
diff --git a/src/lib-sieve/plugins/ihave/Makefile.am b/src/lib-sieve/plugins/ihave/Makefile.am
index 41aa3c67f..1eb0472ef 100644
--- a/src/lib-sieve/plugins/ihave/Makefile.am
+++ b/src/lib-sieve/plugins/ihave/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_ihave.la
 
 AM_CPPFLAGS = \
-	-I$(top_srcdir)/src/lib-sieve \
+	-I$(srcdir)/../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 tests = \
diff --git a/src/lib-sieve/plugins/metadata/Makefile.am b/src/lib-sieve/plugins/metadata/Makefile.am
index bac6f5d75..7aeaf2e18 100644
--- a/src/lib-sieve/plugins/metadata/Makefile.am
+++ b/src/lib-sieve/plugins/metadata/Makefile.am
@@ -1,11 +1,10 @@
-
 noinst_LTLIBRARIES = libsieve_ext_metadata.la
 
 libsieve_ext_metadata_la_LDFLAGS = -module -avoid-version
 
 AM_CPPFLAGS = \
-	-I$(top_srcdir)/src/lib-sieve \
-	-I$(top_srcdir)/src/lib-sieve/plugins/variables \
+	-I$(srcdir)/../.. \
+	-I$(srcdir)/../variables \
 	$(LIBDOVECOT_INCLUDE)
 
 tests = \
diff --git a/src/lib-sieve/plugins/notify/Makefile.am b/src/lib-sieve/plugins/notify/Makefile.am
index b5165b9c5..aaa76b357 100644
--- a/src/lib-sieve/plugins/notify/Makefile.am
+++ b/src/lib-sieve/plugins/notify/Makefile.am
@@ -2,6 +2,7 @@ noinst_LTLIBRARIES = libsieve_ext_notify.la
 
 AM_CPPFLAGS = \
 	-I$(srcdir)/../.. \
+	-I$(srcdir)/../../util \
 	$(LIBDOVECOT_INCLUDE)
 
 commands = \
diff --git a/src/lib-sieve/plugins/subaddress/Makefile.am b/src/lib-sieve/plugins/subaddress/Makefile.am
index 02386f290..2bab53f78 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$(srcdir)/../../ \
+	-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 10389fd46..09df27b98 100644
--- a/src/lib-sieve/plugins/vacation/Makefile.am
+++ b/src/lib-sieve/plugins/vacation/Makefile.am
@@ -1,7 +1,8 @@
 noinst_LTLIBRARIES = libsieve_ext_vacation.la
 
 AM_CPPFLAGS = \
-	-I$(srcdir)/../../ \
+	-I$(srcdir)/../.. \
+	-I$(srcdir)/../../util \
 	$(LIBDOVECOT_INCLUDE)
 
 cmds = \
diff --git a/src/lib-sieve/plugins/vnd.dovecot/debug/Makefile.am b/src/lib-sieve/plugins/vnd.dovecot/debug/Makefile.am
index 04d2b0f50..1e0894633 100644
--- a/src/lib-sieve/plugins/vnd.dovecot/debug/Makefile.am
+++ b/src/lib-sieve/plugins/vnd.dovecot/debug/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_debug.la
 
 AM_CPPFLAGS = \
-	-I$(top_srcdir)/src/lib-sieve \
+	-I$(srcdir)/../../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 commands = \
diff --git a/src/lib-sieve/plugins/vnd.dovecot/duplicate/Makefile.am b/src/lib-sieve/plugins/vnd.dovecot/duplicate/Makefile.am
index d50e0c4dd..3d72ae223 100644
--- a/src/lib-sieve/plugins/vnd.dovecot/duplicate/Makefile.am
+++ b/src/lib-sieve/plugins/vnd.dovecot/duplicate/Makefile.am
@@ -1,7 +1,7 @@
 noinst_LTLIBRARIES = libsieve_ext_duplicate.la
 
 AM_CPPFLAGS = \
-	-I$(top_srcdir)/src/lib-sieve \
+	-I$(srcdir)/../../.. \
 	$(LIBDOVECOT_INCLUDE)
 
 tests = \
diff --git a/src/lib-sieve/util/Makefile.am b/src/lib-sieve/util/Makefile.am
new file mode 100644
index 000000000..31c9a746b
--- /dev/null
+++ b/src/lib-sieve/util/Makefile.am
@@ -0,0 +1,19 @@
+noinst_LTLIBRARIES = libsieve_util.la
+
+AM_CPPFLAGS = \
+	$(LIBDOVECOT_INCLUDE) \
+	$(LIBDOVECOT_SERVICE_INCLUDE) \
+	-DMODULEDIR=\""$(dovecot_moduledir)"\"
+
+libsieve_util_la_DEPENDENCIES = $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_DEPS)
+
+libsieve_util_la_SOURCES = \
+	rfc2822.c \
+	edit-mail.c
+
+headers = \
+	rfc2822.h \
+	edit-mail.h
+
+pkginc_libdir=$(dovecot_pkgincludedir)/sieve
+pkginc_lib_HEADERS = $(headers)
diff --git a/src/lib-sieve/edit-mail.c b/src/lib-sieve/util/edit-mail.c
similarity index 100%
rename from src/lib-sieve/edit-mail.c
rename to src/lib-sieve/util/edit-mail.c
diff --git a/src/lib-sieve/edit-mail.h b/src/lib-sieve/util/edit-mail.h
similarity index 100%
rename from src/lib-sieve/edit-mail.h
rename to src/lib-sieve/util/edit-mail.h
diff --git a/src/lib-sieve/rfc2822.c b/src/lib-sieve/util/rfc2822.c
similarity index 100%
rename from src/lib-sieve/rfc2822.c
rename to src/lib-sieve/util/rfc2822.c
diff --git a/src/lib-sieve/rfc2822.h b/src/lib-sieve/util/rfc2822.h
similarity index 100%
rename from src/lib-sieve/rfc2822.h
rename to src/lib-sieve/util/rfc2822.h
-- 
GitLab