From 15c2ff1dd5b37bd3c3127b5e894338b53a9c066e Mon Sep 17 00:00:00 2001
From: Matthias Andree <matthias.andree@gmx.de>
Date: Fri, 6 Jun 2025 11:13:33 +0200
Subject: [PATCH] Add --disable-documentation ./configure option. Fixes #17.

---
 bogofilter/NEWS            |  7 +++++++
 bogofilter/configure.ac    | 11 +++++++++++
 bogofilter/doc/Makefile.am | 37 ++++++++++++++++++++++---------------
 3 files changed, 40 insertions(+), 15 deletions(-)

--- a/bogofilter/NEWS
+++ b/bogofilter/NEWS
@@ -15,6 +15,13 @@
 
 -------------------------------------------------------------------------------
 
+1.3.0.rc2 (in progress)
+	2025-06-06
+	* Add --disable-documentation configure option, to skip building
+	  the documentation.  This will break "make dist" like targets
+	  if documentation needs to be rebuilt. Fixes #17.
+
+
 1.3.0.rc1
 
 	2025-04-18
--- a/bogofilter/configure.ac
+++ b/bogofilter/configure.ac
@@ -306,6 +306,17 @@ if test x$USE_CP866 = xYES ; then
 fi
 fi
 
+AC_ARG_ENABLE([documentation],
+    AS_HELP_STRING([--disable-documentation],
+		   [do not build documentation]),
+    [case "${enableval}" in
+         yes) docs=true ;;
+         no)  docs=false ;;
+         *)   AC_MSG_ERROR([bad value ${enableval} for --enable-documentation])
+	      ;;
+     esac],[docs=true])
+AM_CONDITIONAL([ENABLE_DOCS], [test x$docs = xtrue])
+
 dnl Allow the user to specify a default charset
 AC_ARG_WITH(charset, 
 	    AS_HELP_STRING([--with-charset=name], 
--- a/bogofilter/doc/Makefile.am
+++ b/bogofilter/doc/Makefile.am
@@ -7,15 +7,21 @@ SUFFIXES= .1 .1in .htmlin .html
 #   nsgmls (opensp)
 
 # what to build
+if ENABLE_DOCS
 man_MANS = bogofilter.1 bogoutil.1 bogoupgrade.1 bogolexer.1 bogotune.1 \
 	   bf_copy.1 bf_tar.1 bf_compact.1
 
 html_MANS = bogofilter.html bogoutil.html bogoupgrade.html \
 	    bogolexer.html bogotune.html \
 	    bf_copy.html bf_tar.html bf_compact.html
+else
+man_MANS=
+html_MANS=
+endif
 
 all: $(man_MANS) $(html_MANS)
 
+
 CLEANFILES = $(man_MANS) $(html_MANS)
 
 HTML_DOCS = bogofilter-faq.html bogofilter-faq-fr.html bogofilter-faq-it.html bogotune-faq.html
@@ -23,14 +29,14 @@ XHTML_DOCS= bogofilter-faq-bg.xhtml
 
 # what to distribute
 EXTRA_DIST = \
-	     bogofilter.xml bogofilter.1in bogofilter.htmlin \
-	     bogolexer.xml bogolexer.1in bogolexer.htmlin \
-	     bogotune.xml bogotune.1in bogotune.htmlin \
-	     bogoupgrade.xml bogoupgrade.1in bogoupgrade.htmlin \
-	     bogoutil.xml bogoutil.1in bogoutil.htmlin \
-	     bf_compact.xml bf_compact.1in bf_compact.htmlin \
-	     bf_copy.xml bf_copy.1in bf_copy.htmlin \
-	     bf_tar.xml bf_tar.1in bf_tar.htmlin \
+	     bogofilter.xml $(srcdir)/bogofilter.1in $(srcdir)/bogofilter.htmlin \
+	     bogolexer.xml $(srcdir)/bogolexer.1in $(srcdir)/bogolexer.htmlin \
+	     bogotune.xml $(srcdir)/bogotune.1in $(srcdir)/bogotune.htmlin \
+	     bogoupgrade.xml $(srcdir)/bogoupgrade.1in $(srcdir)/bogoupgrade.htmlin \
+	     bogoutil.xml $(srcdir)/bogoutil.1in $(srcdir)/bogoutil.htmlin \
+	     bf_compact.xml $(srcdir)/bf_compact.1in $(srcdir)/bf_compact.htmlin \
+	     bf_copy.xml $(srcdir)/bf_copy.1in $(srcdir)/bf_copy.htmlin \
+	     bf_tar.xml $(srcdir)/bf_tar.1in $(srcdir)/bf_tar.htmlin \
 	     $(HTML_DOCS) \
 	     $(XHTML_DOCS) \
 	     bogofilter-tuning.HOWTO.html \
@@ -77,18 +83,19 @@ dist-hook:
 # respectively.
 .xml.htmlin:
 	$(XMLLINT) --noout --postvalid $<
-	if test -f $(srcdir)/$@ && test $(srcdir)/$@ -nt $< ; then \
-	    cp $(srcdir)/$@ . ; else \
-	  if xmlto html-nochunks $< ; then f=$@ ; mv $${f%%in} $@ ; else rm -f $@ ; exit 1 ; fi ; \
+	if test -f $@ && test $@ -nt $< ; then \
+	    cp $@ . ; else \
+	  if xmlto html-nochunks -o "$(srcdir)" $< ; then f=$@ ; mv $${f%%in} $@ ; else rm -f $@ ; exit 1 ; fi ; \
 	  perl -pl -e "s|\xA0|&nbsp;|g" -i $@ || { rm -f $@ ; exit 1 ; } \
 	fi
 
 .xml.1in:
 	$(XMLLINT) --noout --postvalid $<
-	if test -f $(srcdir)/$@ && test $(srcdir)/$@ -nt $< ; then \
-	    cp $(srcdir)/$@ . ; else \
-	if xmlto man $< ; then f=$@ ; mv $${f%in} $@ ; else rm -f $@ ; exit 1 ; fi ; \
-	perl -pl -e "s|\xA0|\\ |g" -i $@ || { rm -f $@ ; exit 1 ; } \
+	if test -f $@ && test $@ -nt $< ; then \
+	    cp $@ . ; \
+	else \
+		if xmlto man -o "$(srcdir)" $< ; then f=$@ ; mv $${f%in} $@ ; else rm -f $@ ; exit 1 ; fi ; \
+		perl -pl -e "s|\xA0|\\ |g" -i $@ || { rm -f $@ ; exit 1 ; } \
 	fi
 else
 dist-hook:
