diff --git a/.hgignore b/.hgignore
index c5f4bdeee8394b1606bfcf321865ae66e7192c9f..9f30fb8d02758b3361d3db69ef6617f66fd43301 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 ef7e681bb2c067ccb5262c9818f012aec09eb3f1..d4954805d59c54d00eaedec73fe92b9a1a00e1e0 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 0000000000000000000000000000000000000000..df9c26ca170f5d6c61d6d38d6efb5cd45f22096c
--- /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 0ef8ae684d1378a78bb4cda735a59336e0025708..e48a868d807d1c21fef834e443706053597b0e3a 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 1ee4fc1992046bb9842a6c94d227ee63372297d2..f8400bcdcf9e150ce4b7184ec38b179d4e0c75d6 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 0000000000000000000000000000000000000000..75b6f1c92df09c2a0ce35143bc9b8b45d9a7f5b2
--- /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 ee2ede3d00afa261398ecd54022f601c30b9653d..ef82b6011c0b474a424deeb5aac4404437650042 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 a8720357f424fa40160fddaf310c2a70f92dde27..417393eacac14c6d2ff048f8c21b5ec39520d7c5 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"