Gentoo's dev-python/docutils-0.10 installs Docutils scripts with a
*.py extension, so I have /usr/bin/rst2man.py and no rst2man script.
This patch supports users with both types of systems by checking for
rst2man, falling back on rst2man.py, and giving up only if neither is
found. Users can also set the new RST2MAN path variable explicitly
when they call Make:
make RST2MAN=/my/custom/rst_to_man_converter build-man
I use POSIX's 'command -v' [1] to find the path to rst2man or
rst2man.py, and save that as RST2MAN in Makefile.config. Then pass
the configured RST2MAN path through to prerst2man.py to use in its
system call.
We can use a non-empty RST2MAN to check for the availability of an
rst2man program, so there's no need for a separate HAVE_RST2MAN.
However, we keep the existing HAVE_RST2MAN for consistency with
HAVE_SPHINX.
[1]: http://pubs.opengroup.org/onlinepubs/
9699919799/utilities/command.html
printf "Yes.\n"
have_sphinx=1
have_rst2man=0
+ RST2MAN=
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
+ RST2MAN=$(command -v rst2man)
+ printf "Yes (${RST2MAN}).\n"
+ elif rst2man.py -V > /dev/null 2>&1; then
+ have_rst2man=1
+ RST2MAN=$(command -v rst2man.py)
+ printf "Yes (${RST2MAN}).\n"
else
- printf "No (so will not install man pages).\n"
have_rst2man=0
+ RST2MAN=
+ printf "No (so will not install man pages).\n"
fi
fi
# Whether there's a rst2man binary available for building documentation
HAVE_RST2MAN=${have_rst2man}
+# The path to the rst2man program for building documentation. Set to
+# an empty string if no such program is available.
+RST2MAN=${RST2MAN}
+
# The directory to which desktop files should be installed
desktop_dir = \$(prefix)/share/applications
mv $(DOCBUILDDIR)/man/*.$${section} $(DOCBUILDDIR)/man/man$${section}; \
done
else ifeq ($(HAVE_RST2MAN),1)
- $(prerst2man) $(srcdir)/doc $(DOCBUILDDIR)/man
+ $(prerst2man) "$(RST2MAN)" $(srcdir)/doc $(DOCBUILDDIR)/man
else
@echo "Fatal: build dependency fail."
@false
from os import makedirs, system
import re
-sourcedir = argv[1]
-outdir = argv[2]
+rst2man = argv[1]
+sourcedir = argv[2]
+outdir = argv[3]
if not isdir(outdir):
makedirs(outdir, 0o755)
outfile.write("".join(lines))
outfile.close()
- system('set -x; rst2man {0} {1}/{2}.{3}'
- .format(filename, outdir, page[0], page[4]))
+ system('set -x; {0} {1} {2}/{3}.{4}'
+ .format(rst2man, filename, outdir, page[0], page[4]))