* [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