From 94af6350972fa692e4c5038c7010cc161026eab5 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sun, 2 Nov 2008 22:52:30 +0100
Subject: [PATCH] Started using autoconf output.

---
 .hgignore                    |  3 ++-
 configure.in                 | 18 +++++++++++++++---
 dsieve-config.h.in           |  9 +++++++++
 src/lib-sieve/Makefile.am    |  2 +-
 src/lib-sieve/sieve-common.h |  1 +
 src/lib-sieve/sieve-config.h | 11 +++++++++++
 src/lib-sieve/sieve-types.h  |  3 ---
 src/lib-sieve/sieve.h        |  1 +
 8 files changed, 40 insertions(+), 8 deletions(-)
 create mode 100644 dsieve-config.h.in
 create mode 100644 src/lib-sieve/sieve-config.h

diff --git a/.hgignore b/.hgignore
index c5f4bdeee..9f30fb8d0 100644
--- a/.hgignore
+++ b/.hgignore
@@ -3,8 +3,9 @@ aclocal.m4
 autom4te.cache
 config.cache
 config.guess
+dummy-config.h
+dummy-config.h.in
 dsieve-config.h
-dsieve-config.h.in
 config.log
 config.status
 config.sub
diff --git a/configure.in b/configure.in
index ef7e681bb..d4954805d 100644
--- a/configure.in
+++ b/configure.in
@@ -1,14 +1,22 @@
 AC_INIT([Dovecot Sieve], [0.1.0], [dovecot@dovecot.org], [dovecot-1.2-sieve])
 AC_CONFIG_SRCDIR([src])
 
-AC_CONFIG_HEADERS([dsieve-config.h])
-AM_INIT_AUTOMAKE
+# Autoheader is not needed and does more harm than good for this package. However, it is 
+# tightly integrated in autoconf/automake and therefore it is difficult not to use it. As 
+# a workaround we give autoheader a dummy config header to chew on and we handle the 
+# real config header ourselves.
+AC_CONFIG_HEADERS([dummy-config.h dsieve-config.h])
+
+AC_DEFINE(SIEVE_NAME, [PACKAGE_NAME], [Define to the full name of this Sieve implementation.])
+AC_DEFINE(SIEVE_VERSION, [PACKAGE_VERSION], [Define to the version of this Sieve implementation.])
+
+AM_INIT_AUTOMAKE(no-define)
 
 AM_MAINTAINER_MODE
 
 AC_PROG_CC
 AC_PROG_CPP
-AM_PROG_LIBTOOL
+AC_PROG_LIBTOOL
 
 AC_ARG_WITH(dovecot,
 [AC_HELP_STRING([--with-dovecot=DIR], [Dovecot base directory [../dovecot]])],
@@ -53,6 +61,10 @@ AC_ARG_WITH(enotify,
         want_enotify=no)
 AM_CONDITIONAL(BUILD_ENOTIFY, test "$want_enotify" = "yes")
 
+if test "$want_enotify" = "yes"; then
+	AC_DEFINE(HAVE_SIEVE_ENOTIFY,,[Define to make Sieve enotify extension available to users.])
+fi
+
 #
 #
 
diff --git a/dsieve-config.h.in b/dsieve-config.h.in
new file mode 100644
index 000000000..df9c26ca1
--- /dev/null
+++ b/dsieve-config.h.in
@@ -0,0 +1,9 @@
+
+/* Define to the full name of this Sieve implementation. */
+#undef SIEVE_NAME
+
+/* Define to the version of this Sieve implementation. */
+#undef SIEVE_VERSION
+
+/* Define to make Sieve enotify extension available to users. */
+#undef HAVE_SIEVE_ENOTIFY
diff --git a/src/lib-sieve/Makefile.am b/src/lib-sieve/Makefile.am
index 0ef8ae684..e48a868d8 100644
--- a/src/lib-sieve/Makefile.am
+++ b/src/lib-sieve/Makefile.am
@@ -6,7 +6,7 @@ AM_CPPFLAGS = \
 	-I$(dovecot_incdir) \
 	-I$(dovecot_incdir)/src/lib \
 	-I$(dovecot_incdir)/src/lib-mail \
-	-I$(dovecot_incdir)/src/lib-storage \ 
+	-I$(dovecot_incdir)/src/lib-storage \
 	-I$(dovecot_incdir)/src/lib-imap
 
 tests = \
diff --git a/src/lib-sieve/sieve-common.h b/src/lib-sieve/sieve-common.h
index 1ee4fc199..f8400bcdc 100644
--- a/src/lib-sieve/sieve-common.h
+++ b/src/lib-sieve/sieve-common.h
@@ -4,6 +4,7 @@
 #ifndef __SIEVE_COMMON_H
 #define __SIEVE_COMMON_H
 
+#include "sieve-config.h"
 #include "sieve-types.h"
 
 #include <sys/types.h>
diff --git a/src/lib-sieve/sieve-config.h b/src/lib-sieve/sieve-config.h
new file mode 100644
index 000000000..75b6f1c92
--- /dev/null
+++ b/src/lib-sieve/sieve-config.h
@@ -0,0 +1,11 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file 
+ */
+
+#ifndef __SIEVE_CONFIG_H
+#define __SIEVE_CONFIG_H
+
+#include "dsieve-config.h"
+
+#define SIEVE_IMPLEMENTATION SIEVE_NAME " " SIEVE_VERSION
+
+#endif
diff --git a/src/lib-sieve/sieve-types.h b/src/lib-sieve/sieve-types.h
index ee2ede3d0..ef82b6011 100644
--- a/src/lib-sieve/sieve-types.h
+++ b/src/lib-sieve/sieve-types.h
@@ -8,9 +8,6 @@
 
 #include <stdio.h>
 
-#define SIEVE_VERSION "0.0.1"
-#define SIEVE_IMPLEMENTATION "Dovecot Sieve " SIEVE_VERSION
-
 /* Enable runtime trace functionality */
 #define SIEVE_RUNTIME_TRACE
 
diff --git a/src/lib-sieve/sieve.h b/src/lib-sieve/sieve.h
index a8720357f..417393eac 100644
--- a/src/lib-sieve/sieve.h
+++ b/src/lib-sieve/sieve.h
@@ -9,6 +9,7 @@
 struct sieve_script;
 struct sieve_binary;
 
+#include "sieve-config.h"
 #include "sieve-types.h"
 #include "sieve-error.h"
 
-- 
GitLab