[RFC Patch] doc: configure detection of sphinx and rst2man

David Bremner david at tethera.net
Mon Mar 10 05:04:59 PDT 2014


Because sphinx-build does not provide a convenient way of listing
which builders exist, and some people actually have pre 1.0 sphinx, we
try loading a relevant python module.

Currently the assumption is that no python in path -> no sphinx-build
in path.
---
 configure          | 27 +++++++++++++++++++++++++++
 doc/Makefile.local | 22 ++++++++++++++++++++--
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 2eaed4a..0976c67 100755
--- a/configure
+++ b/configure
@@ -393,6 +393,27 @@ else
     have_emacs=0
 fi
 
+printf "Checking if sphinx is available and supports nroff output... "
+if hash sphinx-build && python -m sphinx.writers.manpage > /dev/null 2>&1 ; then
+    printf "Yes.\n"
+    have_sphinx=1
+    have_rst2man=0
+else
+    printf "No (falling back to rst2man).\n"
+    have_sphinx=0
+
+    printf "Checking if rst2man is available... "
+    if rst2man -V > /dev/null 2>&1; then
+       printf "Yes.\n"
+       have_rst2man=1
+    else
+       printf "No (so will not install man pages).\n"
+       have_rst2man=0
+    fi
+fi
+
+
+
 libdir_in_ldconfig=0
 
 printf "Checking which platform we are on... "
@@ -759,6 +780,12 @@ emacsetcdir=${EMACSETCDIR}
 # Whether there's an emacs binary available for byte-compiling
 HAVE_EMACS = ${have_emacs}
 
+# Whether there's a sphinx-build binary available for building documentation
+HAVE_SPHINX=${have_sphinx}
+
+# Whether there's a rst2man binary available and used for building documentation
+HAVE_RST2MAN=${have_rst2man}
+
 # The directory to which desktop files should be installed
 desktop_dir = \$(prefix)/share/applications
 
diff --git a/doc/Makefile.local b/doc/Makefile.local
index 5be49dc..a5e3000 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -16,7 +16,7 @@ ALLSPHINXOPTS   := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(dir)
 .PHONY: sphinx-html sphinx-man sphinx-texinfo sphinx-info
 .PHONY: rst2man
 
-.PHONY: install-man build-man
+.PHONY: install-man build-man build-man-real
 
 %.gz: %
 	rm -f $@ && gzip --stdout $^ > $@
@@ -41,9 +41,27 @@ rst2man:
 
 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
 
+build-man-real: ${MAN_GZIP_FILES}
+
+ifeq ($(HAVE_SPHINX),1)
+
 ${MAN_ROFF_FILES} : sphinx-man
+build-man: build-man-real
+
+else ifeq ($(HAVE_RST2MAN),1)
+
+${MAN_ROFF_FILES} : rst2man
+build-man: build-man-real
+
+else
+
+install-man:
+	@echo "No sphinx or rst2man, will not install man pages."
+
+endif
+
+
 
-build-man: ${MAN_GZIP_FILES}
 
 install-man: build-man
 	mkdir -p "$(DESTDIR)$(mandir)/man1"
-- 
1.8.5.3



More information about the notmuch mailing list