doc: use separate doctrees for distinct builders

It seems our previous attempt with order-only targets was not
sufficient to avoid problems with sphinx-builds doctree cache [0].
Looking around at other people's approaches [1], using separate
doctrees was suggested. I guess there might be a slight loss of
efficiency, but it seems more robust.

[0]: build failures were first noticed in Debian experimental, but I was able to duplicate it in
     my usual build environment about 1 in 8 builds.

[1]: in particular
     9e3fc1657d
This commit is contained in:
David Bremner 2019-05-31 23:24:52 -03:00
parent 80cfc48af5
commit 6edc073e44

View file

@ -8,7 +8,7 @@ SPHINXBUILD = HAVE_EMACS=${HAVE_EMACS} sphinx-build
DOCBUILDDIR := $(dir)/_build DOCBUILDDIR := $(dir)/_build
# Internal variables. # Internal variables.
ALLSPHINXOPTS := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(srcdir)/$(dir) ALLSPHINXOPTS := $(SPHINXOPTS) $(srcdir)/$(dir)
APIMAN := $(DOCBUILDDIR)/man/man3/notmuch.3 APIMAN := $(DOCBUILDDIR)/man/man3/notmuch.3
DOXYFILE := $(srcdir)/$(dir)/doxygen.cfg DOXYFILE := $(srcdir)/$(dir)/doxygen.cfg
@ -42,24 +42,16 @@ ifeq ($(WITH_EMACS),1)
$(DOCBUILDDIR)/.roff.stamp sphinx-html sphinx-texinfo: docstring.stamp $(DOCBUILDDIR)/.roff.stamp sphinx-html sphinx-texinfo: docstring.stamp
endif endif
# Sequentialize the calls to sphinx-build to avoid races with
# reading/writing cached state. This uses GNU make specific
# "order-only" prerequisites.
sphinx-html: | $(DOCBUILDDIR)/.roff.stamp
sphinx-texinfo: | sphinx-html
sphinx-info: | sphinx-texinfo
sphinx-html: $(DOCBUILDDIR)/.html.stamp sphinx-html: $(DOCBUILDDIR)/.html.stamp
$(DOCBUILDDIR)/.html.stamp: $(ALL_RST_FILES) $(DOCBUILDDIR)/.html.stamp: $(ALL_RST_FILES)
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html $(SPHINXBUILD) -b html -d $(DOCBUILDDIR)/html_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
touch $@ touch $@
sphinx-texinfo: $(DOCBUILDDIR)/.texi.stamp sphinx-texinfo: $(DOCBUILDDIR)/.texi.stamp
$(DOCBUILDDIR)/.texi.stamp: $(ALL_RST_FILES) $(DOCBUILDDIR)/.texi.stamp: $(ALL_RST_FILES)
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo $(SPHINXBUILD) -b texinfo -d $(DOCBUILDDIR)/texinfo_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
touch $@ touch $@
sphinx-info: sphinx-texinfo sphinx-info: sphinx-texinfo
@ -75,7 +67,7 @@ ${MAN_ROFF_FILES}: $(DOCBUILDDIR)/.roff.stamp
# instance of this recipe for each roff file. # instance of this recipe for each roff file.
$(DOCBUILDDIR)/.roff.stamp: ${MAN_RST_FILES} $(DOCBUILDDIR)/.roff.stamp: ${MAN_RST_FILES}
ifeq ($(HAVE_SPHINX),1) ifeq ($(HAVE_SPHINX),1)
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man $(SPHINXBUILD) -b man -d $(DOCBUILDDIR)/man_doctrees $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
for section in 1 5 7; do \ for section in 1 5 7; do \
mkdir -p $(DOCBUILDDIR)/man/man$${section}; \ mkdir -p $(DOCBUILDDIR)/man/man$${section}; \
mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \ mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \