unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* v2 man page build fixups
@ 2014-03-11 12:05 David Bremner
  2014-03-11 12:05 ` [Patch v2 1/3] doc: have prerst2man.py generate roff files all in one directory David Bremner
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: David Bremner @ 2014-03-11 12:05 UTC (permalink / raw)
  To: notmuch

Here is an improved version of somewhat hasty series of last night.

It incorporates fixups from Jani that he sent to me off list.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Patch v2 1/3] doc: have prerst2man.py generate roff files all in one directory
  2014-03-11 12:05 v2 man page build fixups David Bremner
@ 2014-03-11 12:05 ` David Bremner
  2014-03-11 12:05 ` [Patch v2 2/3] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN David Bremner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2014-03-11 12:05 UTC (permalink / raw)
  To: notmuch

Originally it seemed tidier to put them in subdirectories, but it
turned out not to be obvious how to do that with sphinx. Bring the two
methods back in sync again, and unbreak the generation of gzipped
manpages.

As a side-effect, fix a particular egregious combination of format and
string concatenation.
---
 doc/prerst2man.py | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/doc/prerst2man.py b/doc/prerst2man.py
index 720deb6..ec343e7 100644
--- a/doc/prerst2man.py
+++ b/doc/prerst2man.py
@@ -32,10 +32,7 @@ date.today().isoformat(), release, section, project))
 
 blankre = re.compile("^\s*$")
 for page in man_pages:
-    outdirname = outdir + '/' + dirname(page[0])
-    if not isdir(outdirname):
-        makedirs(outdirname, 0755)
-    filename = outdir + '/' + page[0] + '.rst'
+    filename = outdir + '/' + page[1] + '.rst'
     outfile = open(filename, 'w')
     infile = open(sourcedir + '/' + page[0] + '.rst', 'r')
 
@@ -59,4 +56,5 @@ for page in man_pages:
     outfile.write("".join(lines))
     outfile.close()
 
-    os.system('set -x; rst2man {0} {1}'.format(filename, outdir + '/' + page[0] + '.' + str(page[4])))
+    os.system('set -x; rst2man {0} {1}/{2}.{3}'
+              .format(filename, outdir, page[1],page[4]))
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Patch v2 2/3] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN
  2014-03-11 12:05 v2 man page build fixups David Bremner
  2014-03-11 12:05 ` [Patch v2 1/3] doc: have prerst2man.py generate roff files all in one directory David Bremner
@ 2014-03-11 12:05 ` David Bremner
  2014-03-11 12:05 ` [Patch v2 3/3] doc: configure detection of sphinx and rst2man David Bremner
  2014-03-11 18:16 ` v2 man page build fixups Tomi Ollila
  3 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2014-03-11 12:05 UTC (permalink / raw)
  To: notmuch

This helps avoid build artifacts (namely, nroff and gzipped-nroff man
pages) owned by root.

The variables allow choosing which generator to use for the man page.
These will be hooked to configure in a following commit.
---
 Makefile.local     |  2 +-
 doc/Makefile.local | 31 ++++++++++++++++++-------------
 doc/mkdocdeps.py   |  3 +++
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index 5f797ad..cb7b106 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -53,7 +53,7 @@ endif
 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS)
 
 .PHONY: all
-all: notmuch notmuch-shared
+all: notmuch notmuch-shared build-man
 ifeq ($(MAKECMDGOALS),)
 ifeq ($(shell cat .first-build-message 2>/dev/null),)
 	@NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
diff --git a/doc/Makefile.local b/doc/Makefile.local
index fd64f70..23f4095 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -13,10 +13,9 @@ mkdocdeps := python $(dir)/mkdocdeps.py
 # Internal variables.
 ALLSPHINXOPTS   := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(dir)
 
-.PHONY: sphinx-html sphinx-man sphinx-texinfo sphinx-info
-.PHONY: rst2man
+.PHONY: sphinx-html sphinx-texinfo sphinx-info
 
-.PHONY: install-man
+.PHONY: install-man build-man
 
 %.gz: %
 	rm -f $@ && gzip --stdout $^ > $@
@@ -24,24 +23,30 @@ ALLSPHINXOPTS   := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(dir)
 sphinx-html:
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
 
-sphinx-man:
-	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
-
 sphinx-texinfo:
 	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
 
 sphinx-info: sphinx-texinfo
 	make -C $(DOCBUILDDIR)/texinfo info
 
-# fallback target in case sphinx not installed
-rst2man:
-	$(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
-
 -include $(dir)/docdeps.mk
 
 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
 
-${MAN_ROFF_FILES} : sphinx-man
+build-man: ${MAN_GZIP_FILES}
+
+${MAN_ROFF_FILES}: ${dir}/man.stamp
+
+$(dir)/man.stamp: ${MAN_RST_FILES}
+ifeq ($(HAVE_SPHINX),1)
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
+	touch $@
+else ifeq ($(HAVE_RST2MAN),1)
+	$(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
+	touch $@
+else
+	@echo "No sphinx or rst2man, will not install man pages."
+endif
 
 install-man: ${MAN_GZIP_FILES}
 	mkdir -p "$(DESTDIR)$(mandir)/man1"
@@ -52,8 +57,8 @@ install-man: ${MAN_GZIP_FILES}
 	install -m0644 $(DOCBUILDDIR)/man/*.7.gz $(DESTDIR)/$(mandir)/man7
 	cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
 
-
 $(dir)/docdeps.mk: $(dir)/conf.py $(dir)/mkdocdeps.py
 	$(mkdocdeps) $< $(DOCBUILDDIR) $@
 
-CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk
+CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk $(dir)/man.stamp
+CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES)
diff --git a/doc/mkdocdeps.py b/doc/mkdocdeps.py
index 2f4a959..e61bea6 100644
--- a/doc/mkdocdeps.py
+++ b/doc/mkdocdeps.py
@@ -6,8 +6,11 @@ outfile = argv[3]
 execfile(conffile)
 
 roff_files = []
+rst_files = []
 out=open(outfile,'w')
 for page in man_pages:
+    rst_files = rst_files + ["doc/{0:s}.rst".format(page[0])]
     roff_files = roff_files + ["{0:s}/man/{1:s}.{2:d}".format(builddir,page[1],page[4])]
 
 out.write ('MAN_ROFF_FILES := ' + ' \\\n\t'.join(roff_files)+'\n')
+out.write ('MAN_RST_FILES := ' + ' \\\n\t'.join(rst_files)+'\n')
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Patch v2 3/3] doc: configure detection of sphinx and rst2man
  2014-03-11 12:05 v2 man page build fixups David Bremner
  2014-03-11 12:05 ` [Patch v2 1/3] doc: have prerst2man.py generate roff files all in one directory David Bremner
  2014-03-11 12:05 ` [Patch v2 2/3] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN David Bremner
@ 2014-03-11 12:05 ` David Bremner
  2014-03-11 18:16 ` v2 man page build fixups Tomi Ollila
  3 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2014-03-11 12:05 UTC (permalink / raw)
  To: notmuch

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 | 24 +++++++++++++++---------
 2 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 2eaed4a..4aaecc6 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 > /dev/null 2>&1 && 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 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 23f4095..4883c4a 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -33,21 +33,26 @@ sphinx-info: sphinx-texinfo
 
 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
 
-build-man: ${MAN_GZIP_FILES}
-
-${MAN_ROFF_FILES}: ${dir}/man.stamp
-
-$(dir)/man.stamp: ${MAN_RST_FILES}
+# Use the man page converter that is available. We should never depend
+# on MAN_ROFF_FILES if a converter is not available.
+${MAN_ROFF_FILES}: ${MAN_RST_FILES}
 ifeq ($(HAVE_SPHINX),1)
 	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
-	touch $@
 else ifeq ($(HAVE_RST2MAN),1)
 	$(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
-	touch $@
 else
-	@echo "No sphinx or rst2man, will not install man pages."
+	@echo "Fatal: build dependency fail."
+	@false
 endif
 
+# Do not try to build or install man pages if a man page converter is
+# not available.
+ifeq ($(HAVE_SPHINX)$(HAVE_RST2MAN),00)
+build-man:
+install-man:
+	@echo "No sphinx or rst2man, will not install man pages."
+else
+build-man: ${MAN_GZIP_FILES}
 install-man: ${MAN_GZIP_FILES}
 	mkdir -p "$(DESTDIR)$(mandir)/man1"
 	mkdir -p "$(DESTDIR)$(mandir)/man5"
@@ -56,9 +61,10 @@ install-man: ${MAN_GZIP_FILES}
 	install -m0644 $(DOCBUILDDIR)/man/*.5.gz $(DESTDIR)/$(mandir)/man5
 	install -m0644 $(DOCBUILDDIR)/man/*.7.gz $(DESTDIR)/$(mandir)/man7
 	cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
+endif
 
 $(dir)/docdeps.mk: $(dir)/conf.py $(dir)/mkdocdeps.py
 	$(mkdocdeps) $< $(DOCBUILDDIR) $@
 
-CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk $(dir)/man.stamp
+CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk
 CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES)
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: v2 man page build fixups
  2014-03-11 12:05 v2 man page build fixups David Bremner
                   ` (2 preceding siblings ...)
  2014-03-11 12:05 ` [Patch v2 3/3] doc: configure detection of sphinx and rst2man David Bremner
@ 2014-03-11 18:16 ` Tomi Ollila
  2014-03-13  3:21   ` David Bremner
  3 siblings, 1 reply; 12+ messages in thread
From: Tomi Ollila @ 2014-03-11 18:16 UTC (permalink / raw)
  To: David Bremner, notmuch

On Tue, Mar 11 2014, David Bremner <david@tethera.net> wrote:

> Here is an improved version of somewhat hasty series of last night.
>
> It incorporates fixups from Jani that he sent to me off list.

I played with the series trying various tricks and all seems to
work fine. Also it is nice to see that one line in prerst2man.py
is fixed to better shape :D

Also a command line, should anyone ever need it (I doubt ;)

$ make SPHINXBUILD=sphinx-1.0-build HAVE_SPHINX=1 build-man

worked fine.

+1

Tomi

^ permalink raw reply	[flat|nested] 12+ messages in thread

* (no subject)
  2014-03-11 18:16 ` v2 man page build fixups Tomi Ollila
@ 2014-03-13  3:21   ` David Bremner
  2014-03-13  3:21     ` [Patch v3 1/4] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN David Bremner
                       ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: David Bremner @ 2014-03-13  3:21 UTC (permalink / raw)
  To: notmuch

Several people observed a problem with the test T010-help not finding
the man pages anymore. To fix that, I had change the previous fix:
instead of flattening the rst2man output into one directory, I had to
move the sphinx output into a hierarchy.

Patches 1 and 3 should be the same as 

	id:1394539555-28334-1-git-send-email-david@tethera.net

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Patch v3 1/4] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN
  2014-03-13  3:21   ` David Bremner
@ 2014-03-13  3:21     ` David Bremner
  2014-03-13  3:21     ` [Patch v3 2/4] doc: build man pages into hierarchy, fix help test David Bremner
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2014-03-13  3:21 UTC (permalink / raw)
  To: notmuch

This helps avoid build artifacts (namely, nroff and gzipped-nroff man
pages) owned by root.

The variables allow choosing which generator to use for the man page.
These will be hooked to configure in a following commit.
---
 Makefile.local     |  2 +-
 doc/Makefile.local | 31 ++++++++++++++++++-------------
 doc/mkdocdeps.py   |  3 +++
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index 5f797ad..cb7b106 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -53,7 +53,7 @@ endif
 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS)
 
 .PHONY: all
-all: notmuch notmuch-shared
+all: notmuch notmuch-shared build-man
 ifeq ($(MAKECMDGOALS),)
 ifeq ($(shell cat .first-build-message 2>/dev/null),)
 	@NOTMUCH_FIRST_BUILD=1 $(MAKE) --no-print-directory all
diff --git a/doc/Makefile.local b/doc/Makefile.local
index fd64f70..23f4095 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -13,10 +13,9 @@ mkdocdeps := python $(dir)/mkdocdeps.py
 # Internal variables.
 ALLSPHINXOPTS   := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(dir)
 
-.PHONY: sphinx-html sphinx-man sphinx-texinfo sphinx-info
-.PHONY: rst2man
+.PHONY: sphinx-html sphinx-texinfo sphinx-info
 
-.PHONY: install-man
+.PHONY: install-man build-man
 
 %.gz: %
 	rm -f $@ && gzip --stdout $^ > $@
@@ -24,24 +23,30 @@ ALLSPHINXOPTS   := -d $(DOCBUILDDIR)/doctrees $(SPHINXOPTS) $(dir)
 sphinx-html:
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCBUILDDIR)/html
 
-sphinx-man:
-	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
-
 sphinx-texinfo:
 	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(DOCBUILDDIR)/texinfo
 
 sphinx-info: sphinx-texinfo
 	make -C $(DOCBUILDDIR)/texinfo info
 
-# fallback target in case sphinx not installed
-rst2man:
-	$(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
-
 -include $(dir)/docdeps.mk
 
 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
 
-${MAN_ROFF_FILES} : sphinx-man
+build-man: ${MAN_GZIP_FILES}
+
+${MAN_ROFF_FILES}: ${dir}/man.stamp
+
+$(dir)/man.stamp: ${MAN_RST_FILES}
+ifeq ($(HAVE_SPHINX),1)
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
+	touch $@
+else ifeq ($(HAVE_RST2MAN),1)
+	$(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
+	touch $@
+else
+	@echo "No sphinx or rst2man, will not install man pages."
+endif
 
 install-man: ${MAN_GZIP_FILES}
 	mkdir -p "$(DESTDIR)$(mandir)/man1"
@@ -52,8 +57,8 @@ install-man: ${MAN_GZIP_FILES}
 	install -m0644 $(DOCBUILDDIR)/man/*.7.gz $(DESTDIR)/$(mandir)/man7
 	cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
 
-
 $(dir)/docdeps.mk: $(dir)/conf.py $(dir)/mkdocdeps.py
 	$(mkdocdeps) $< $(DOCBUILDDIR) $@
 
-CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk
+CLEAN := $(CLEAN) $(DOCBUILDDIR) $(dir)/docdeps.mk $(dir)/man.stamp
+CLEAN := $(CLEAN) $(MAN_GZIP_FILES) $(MAN_ROFF_FILES)
diff --git a/doc/mkdocdeps.py b/doc/mkdocdeps.py
index 2f4a959..e61bea6 100644
--- a/doc/mkdocdeps.py
+++ b/doc/mkdocdeps.py
@@ -6,8 +6,11 @@ outfile = argv[3]
 execfile(conffile)
 
 roff_files = []
+rst_files = []
 out=open(outfile,'w')
 for page in man_pages:
+    rst_files = rst_files + ["doc/{0:s}.rst".format(page[0])]
     roff_files = roff_files + ["{0:s}/man/{1:s}.{2:d}".format(builddir,page[1],page[4])]
 
 out.write ('MAN_ROFF_FILES := ' + ' \\\n\t'.join(roff_files)+'\n')
+out.write ('MAN_RST_FILES := ' + ' \\\n\t'.join(rst_files)+'\n')
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Patch v3 2/4] doc: build man pages into hierarchy, fix help test.
  2014-03-13  3:21   ` David Bremner
  2014-03-13  3:21     ` [Patch v3 1/4] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN David Bremner
@ 2014-03-13  3:21     ` David Bremner
  2014-03-13  3:21     ` [Patch v3 3/4] doc: configure detection of sphinx and rst2man David Bremner
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2014-03-13  3:21 UTC (permalink / raw)
  To: notmuch

It turns out there was a reason the old man pages were stored in a man
compatible hierarchy, namely so that we could run man on them before
installing.

Hardcode doc build location into test suite.  This isn't ideal, but
let's unbreak the test suite for now.
---
 doc/Makefile.local      | 11 +++++++----
 doc/mkdocdeps.py        |  2 +-
 test/test-lib-common.sh |  4 ++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/doc/Makefile.local b/doc/Makefile.local
index 23f4095..fab6d48 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -40,7 +40,10 @@ ${MAN_ROFF_FILES}: ${dir}/man.stamp
 $(dir)/man.stamp: ${MAN_RST_FILES}
 ifeq ($(HAVE_SPHINX),1)
 	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
-	touch $@
+	for section in 1 5 7; do \
+	    mkdir -p $(DOCBUILDDIR)/man/man$${section}; \
+	    mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \
+	done
 else ifeq ($(HAVE_RST2MAN),1)
 	$(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
 	touch $@
@@ -52,9 +55,9 @@ install-man: ${MAN_GZIP_FILES}
 	mkdir -p "$(DESTDIR)$(mandir)/man1"
 	mkdir -p "$(DESTDIR)$(mandir)/man5"
 	mkdir -p "$(DESTDIR)$(mandir)/man7"
-	install -m0644 $(DOCBUILDDIR)/man/*.1.gz $(DESTDIR)/$(mandir)/man1
-	install -m0644 $(DOCBUILDDIR)/man/*.5.gz $(DESTDIR)/$(mandir)/man5
-	install -m0644 $(DOCBUILDDIR)/man/*.7.gz $(DESTDIR)/$(mandir)/man7
+	install -m0644 $(DOCBUILDDIR)/man/man1/*.1.gz $(DESTDIR)/$(mandir)/man1
+	install -m0644 $(DOCBUILDDIR)/man/man5/*.5.gz $(DESTDIR)/$(mandir)/man5
+	install -m0644 $(DOCBUILDDIR)/man/man7/*.7.gz $(DESTDIR)/$(mandir)/man7
 	cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
 
 $(dir)/docdeps.mk: $(dir)/conf.py $(dir)/mkdocdeps.py
diff --git a/doc/mkdocdeps.py b/doc/mkdocdeps.py
index e61bea6..3effdd8 100644
--- a/doc/mkdocdeps.py
+++ b/doc/mkdocdeps.py
@@ -10,7 +10,7 @@ rst_files = []
 out=open(outfile,'w')
 for page in man_pages:
     rst_files = rst_files + ["doc/{0:s}.rst".format(page[0])]
-    roff_files = roff_files + ["{0:s}/man/{1:s}.{2:d}".format(builddir,page[1],page[4])]
+    roff_files = roff_files + ["{0:s}/man/{1:s}.{2:d}".format(builddir,page[0],page[4])]
 
 out.write ('MAN_ROFF_FILES := ' + ' \\\n\t'.join(roff_files)+'\n')
 out.write ('MAN_RST_FILES := ' + ' \\\n\t'.join(rst_files)+'\n')
diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
index e1eaa5a..892991e 100644
--- a/test/test-lib-common.sh
+++ b/test/test-lib-common.sh
@@ -98,12 +98,12 @@ then
 	PATH=$GIT_VALGRIND/bin:$PATH
 	GIT_EXEC_PATH=$GIT_VALGRIND/bin
 	export GIT_VALGRIND
-	test -n "$notmuch_path" && MANPATH="$notmuch_path/man:$MANPATH"
+	test -n "$notmuch_path" && MANPATH="$notmuch_path/doc/_build/man"
 else # normal case
 	if test -n "$notmuch_path"
 		then
 			PATH="$notmuch_path:$PATH"
-			MANPATH="$notmuch_path/man:$MANPATH"
+			MANPATH="$notmuch_path/doc/_build/man"
 		fi
 fi
 export PATH MANPATH
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Patch v3 3/4] doc: configure detection of sphinx and rst2man
  2014-03-13  3:21   ` David Bremner
  2014-03-13  3:21     ` [Patch v3 1/4] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN David Bremner
  2014-03-13  3:21     ` [Patch v3 2/4] doc: build man pages into hierarchy, fix help test David Bremner
@ 2014-03-13  3:21     ` David Bremner
  2014-03-13  3:21     ` [Patch v3 4/4] doc: cosmetic fix for prerst2man.py David Bremner
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2014-03-13  3:21 UTC (permalink / raw)
  To: notmuch

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          | 25 +++++++++++++++++++++++++
 doc/Makefile.local | 21 ++++++++++++++-------
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 2eaed4a..fb276f1 100755
--- a/configure
+++ b/configure
@@ -393,6 +393,25 @@ else
     have_emacs=0
 fi
 
+printf "Checking if sphinx is available and supports nroff output... "
+if hash sphinx-build > /dev/null 2>&1 && 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 +778,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 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 fab6d48..9c31c24 100644
--- a/doc/Makefile.local
+++ b/doc/Makefile.local
@@ -33,11 +33,9 @@ sphinx-info: sphinx-texinfo
 
 MAN_GZIP_FILES := $(addsuffix .gz,${MAN_ROFF_FILES})
 
-build-man: ${MAN_GZIP_FILES}
-
-${MAN_ROFF_FILES}: ${dir}/man.stamp
-
-$(dir)/man.stamp: ${MAN_RST_FILES}
+# Use the man page converter that is available. We should never depend
+# on MAN_ROFF_FILES if a converter is not available.
+${MAN_ROFF_FILES}: ${MAN_RST_FILES}
 ifeq ($(HAVE_SPHINX),1)
 	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(DOCBUILDDIR)/man
 	for section in 1 5 7; do \
@@ -46,11 +44,19 @@ ifeq ($(HAVE_SPHINX),1)
 	done
 else ifeq ($(HAVE_RST2MAN),1)
 	$(prerst2man) $(DOCBUILDDIR)/.. $(DOCBUILDDIR)/man
-	touch $@
 else
-	@echo "No sphinx or rst2man, will not install man pages."
+	@echo "Fatal: build dependency fail."
+	@false
 endif
 
+# Do not try to build or install man pages if a man page converter is
+# not available.
+ifeq ($(HAVE_SPHINX)$(HAVE_RST2MAN),00)
+build-man:
+install-man:
+	@echo "No sphinx or rst2man, will not install man pages."
+else
+build-man: ${MAN_GZIP_FILES}
 install-man: ${MAN_GZIP_FILES}
 	mkdir -p "$(DESTDIR)$(mandir)/man1"
 	mkdir -p "$(DESTDIR)$(mandir)/man5"
@@ -59,6 +65,7 @@ install-man: ${MAN_GZIP_FILES}
 	install -m0644 $(DOCBUILDDIR)/man/man5/*.5.gz $(DESTDIR)/$(mandir)/man5
 	install -m0644 $(DOCBUILDDIR)/man/man7/*.7.gz $(DESTDIR)/$(mandir)/man7
 	cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
+endif
 
 $(dir)/docdeps.mk: $(dir)/conf.py $(dir)/mkdocdeps.py
 	$(mkdocdeps) $< $(DOCBUILDDIR) $@
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Patch v3 4/4] doc: cosmetic fix for prerst2man.py
  2014-03-13  3:21   ` David Bremner
                       ` (2 preceding siblings ...)
  2014-03-13  3:21     ` [Patch v3 3/4] doc: configure detection of sphinx and rst2man David Bremner
@ 2014-03-13  3:21     ` David Bremner
  2014-03-17 10:55     ` Tomi Ollila
  2014-03-18 10:52     ` Re: David Bremner
  5 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2014-03-13  3:21 UTC (permalink / raw)
  To: notmuch

Fix a particular egregious combination of format and string
concatenation.
---
 doc/prerst2man.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/doc/prerst2man.py b/doc/prerst2man.py
index 720deb6..4591264 100644
--- a/doc/prerst2man.py
+++ b/doc/prerst2man.py
@@ -59,4 +59,5 @@ for page in man_pages:
     outfile.write("".join(lines))
     outfile.close()
 
-    os.system('set -x; rst2man {0} {1}'.format(filename, outdir + '/' + page[0] + '.' + str(page[4])))
+    os.system('set -x; rst2man {0} {1}/{2}.{3}'
+              .format(filename, outdir, page[0],page[4]))
-- 
1.8.5.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re:
  2014-03-13  3:21   ` David Bremner
                       ` (3 preceding siblings ...)
  2014-03-13  3:21     ` [Patch v3 4/4] doc: cosmetic fix for prerst2man.py David Bremner
@ 2014-03-17 10:55     ` Tomi Ollila
  2014-03-18 10:52     ` Re: David Bremner
  5 siblings, 0 replies; 12+ messages in thread
From: Tomi Ollila @ 2014-03-17 10:55 UTC (permalink / raw)
  To: David Bremner, notmuch

On Thu, Mar 13 2014, David Bremner <david@tethera.net> wrote:

> Several people observed a problem with the test T010-help not finding
> the man pages anymore. To fix that, I had change the previous fix:
> instead of flattening the rst2man output into one directory, I had to
> move the sphinx output into a hierarchy.

These patches fix my build and tests pass. +1

Database upgraded (real men don't use backups or how did it go ?).

Tomi


>
> Patches 1 and 3 should be the same as 
>
> 	id:1394539555-28334-1-git-send-email-david@tethera.net
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re:
  2014-03-13  3:21   ` David Bremner
                       ` (4 preceding siblings ...)
  2014-03-17 10:55     ` Tomi Ollila
@ 2014-03-18 10:52     ` David Bremner
  5 siblings, 0 replies; 12+ messages in thread
From: David Bremner @ 2014-03-18 10:52 UTC (permalink / raw)
  To: notmuch

David Bremner <david@tethera.net> writes:

> Several people observed a problem with the test T010-help not finding
> the man pages anymore. To fix that, I had change the previous fix:
> instead of flattening the rst2man output into one directory, I had to
> move the sphinx output into a hierarchy.
>
> Patches 1 and 3 should be the same as 
>
> 	id:1394539555-28334-1-git-send-email-david@tethera.net
>

pushed this series

d

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-03-18 10:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-11 12:05 v2 man page build fixups David Bremner
2014-03-11 12:05 ` [Patch v2 1/3] doc: have prerst2man.py generate roff files all in one directory David Bremner
2014-03-11 12:05 ` [Patch v2 2/3] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN David Bremner
2014-03-11 12:05 ` [Patch v2 3/3] doc: configure detection of sphinx and rst2man David Bremner
2014-03-11 18:16 ` v2 man page build fixups Tomi Ollila
2014-03-13  3:21   ` David Bremner
2014-03-13  3:21     ` [Patch v3 1/4] doc: build man pages at build time; introduce HAVE_SPHINX, HAVE_RST2MAN David Bremner
2014-03-13  3:21     ` [Patch v3 2/4] doc: build man pages into hierarchy, fix help test David Bremner
2014-03-13  3:21     ` [Patch v3 3/4] doc: configure detection of sphinx and rst2man David Bremner
2014-03-13  3:21     ` [Patch v3 4/4] doc: cosmetic fix for prerst2man.py David Bremner
2014-03-17 10:55     ` Tomi Ollila
2014-03-18 10:52     ` Re: David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).