[evolution] Check for Bogofilter during configure.



commit b46da7735a5f58c3477f7725d88f4374a9c5dd84
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Aug 20 10:13:57 2012 -0400

    Check for Bogofilter during configure.
    
    If the bogofilter program cannot be found with AC_PATH_PROG, configure
    will abort with an error message.
    
    You can then either:
    a) install the Bogofilter software
    b) specify the path with BOGOFILTER=/path/to/bogofilter
    c) pass --disable-bogofilter to configure to exclude the module

 configure.ac                              |   29 +++++++++++++++++++++++++++++
 modules/Makefile.am                       |    6 +++++-
 modules/bogofilter/evolution-bogofilter.c |   12 ++++--------
 3 files changed, 38 insertions(+), 9 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 316d40c..1dd2f69 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1044,6 +1044,34 @@ else
 	fi
 fi
 
+dnl **********************************
+dnl Check for Bogofilter (spam filter)
+dnl **********************************
+AC_ARG_ENABLE([bogofilter],
+	[AS_HELP_STRING([--enable-bogofilter],
+	[enable spam filtering using Bogofilter (default=yes)])],
+	[enable_bogofilter=$enableval], [enable_bogofilter=yes])
+AC_MSG_CHECKING([if Bogofilter support is enabled])
+AC_MSG_RESULT([$enable_bogofilter])
+msg_bogofilter="$enable_bogofilter"
+if test "x$enable_bogofilter" = "xyes"; then
+	AC_ARG_VAR([BOGOFILTER], [Bogofilter spam filtering program])
+	AC_PATH_PROG([BOGOFILTER], [bogofilter])
+	if test "x$BOGOFILTER" == "x"; then
+		AC_MSG_ERROR([
+
+	Bogofilter spam filtering program not found.
+
+	If you want to disable spam filtering using Bogofilter,
+	please append --disable-bogofilter to configure.])
+	fi
+	AC_DEFINE_UNQUOTED(
+		BOGOFILTER_COMMAND, "$BOGOFILTER",
+		[Bogofilter spam filtering program])
+	msg_bogofilter="$msg_bogofilter ($BOGOFILTER)"
+fi
+AM_CONDITIONAL([ENABLE_BOGOFILTER], [test "x$enable_bogofilter" = "xyes"])
+
 dnl ******************************
 dnl CERT_UI Flags
 dnl ******************************
@@ -1571,6 +1599,7 @@ echo "
 	Kerberos 5:		$msg_krb5
 	SSL support:		$msg_ssl
 	SMIME support:		$msg_smime
+	Bogofilter support:	$msg_bogofilter
 	Plugins:		$msg_plugins
 	User documentation:	$with_help
 "
diff --git a/modules/Makefile.am b/modules/Makefile.am
index 227f9d1..b2ec916 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -1,3 +1,7 @@
+if ENABLE_BOGOFILTER
+BOGOFILTER_DIR = bogofilter
+endif
+
 if ENABLE_LDAP
 CONFIG_LDAP_DIR = book-config-ldap
 endif
@@ -20,7 +24,6 @@ endif
 
 SUBDIRS = \
 	addressbook \
-	bogofilter \
 	calendar \
 	mail \
 	backup-restore \
@@ -49,6 +52,7 @@ SUBDIRS = \
 	text-highlight \
 	vcard-inline \
 	web-inspector \
+	$(BOGOFILTER_DIR) \
 	$(ONLINE_ACCOUNTS_DIR) \
 	$(TNEF_ATTACHMENT_DIR) \
 	$(AUDIO_INLINE_DIR)
diff --git a/modules/bogofilter/evolution-bogofilter.c b/modules/bogofilter/evolution-bogofilter.c
index 933fa6f..f486580 100644
--- a/modules/bogofilter/evolution-bogofilter.c
+++ b/modules/bogofilter/evolution-bogofilter.c
@@ -36,10 +36,6 @@
 	(G_TYPE_CHECK_INSTANCE_CAST \
 	((obj), E_TYPE_BOGOFILTER, EBogofilter))
 
-#ifndef BOGOFILTER_BINARY
-#define BOGOFILTER_BINARY "/usr/bin/bogofilter"
-#endif
-
 #define BOGOFILTER_EXIT_STATUS_SPAM		0
 #define BOGOFILTER_EXIT_STATUS_HAM		1
 #define BOGOFILTER_EXIT_STATUS_UNSURE		2
@@ -302,7 +298,7 @@ bogofilter_get_property (GObject *object,
 static gboolean
 bogofilter_available (EMailJunkFilter *junk_filter)
 {
-	return g_file_test (BOGOFILTER_BINARY, G_FILE_TEST_IS_EXECUTABLE);
+	return g_file_test (BOGOFILTER_COMMAND, G_FILE_TEST_IS_EXECUTABLE);
 }
 
 static GtkWidget *
@@ -350,7 +346,7 @@ bogofilter_classify (CamelJunkFilter *junk_filter,
 	gint exit_code;
 
 	const gchar *argv[] = {
-		BOGOFILTER_BINARY,
+		BOGOFILTER_COMMAND,
 		NULL,  /* leave room for unicode option */
 		NULL
 	};
@@ -408,7 +404,7 @@ bogofilter_learn_junk (CamelJunkFilter *junk_filter,
 	gint exit_code;
 
 	const gchar *argv[] = {
-		BOGOFILTER_BINARY,
+		BOGOFILTER_COMMAND,
 		"--register-spam",
 		NULL,  /* leave room for unicode option */
 		NULL
@@ -443,7 +439,7 @@ bogofilter_learn_not_junk (CamelJunkFilter *junk_filter,
 	gint exit_code;
 
 	const gchar *argv[] = {
-		BOGOFILTER_BINARY,
+		BOGOFILTER_COMMAND,
 		"--register-ham",
 		NULL,  /* leave room for unicode option */
 		NULL



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]