Jani Nikula | 22cba31 | 2016-05-19 15:14:05 +0300 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # Makefile for Sphinx documentation |
| 3 | # |
| 4 | |
| 5 | # You can set these variables from the command line. |
| 6 | SPHINXBUILD = sphinx-build |
| 7 | SPHINXOPTS = |
| 8 | PAPER = |
| 9 | BUILDDIR = $(obj)/output |
| 10 | |
| 11 | # User-friendly check for sphinx-build |
| 12 | HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi) |
| 13 | |
| 14 | ifeq ($(HAVE_SPHINX),0) |
| 15 | |
| 16 | .DEFAULT: |
| 17 | $(warning The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed and in PATH, or set the SPHINXBUILD make variable to point to the full path of the '$(SPHINXBUILD)' executable.) |
| 18 | @echo " SKIP Sphinx $@ target." |
| 19 | |
Jani Nikula | 6387872 | 2016-07-01 15:24:44 +0300 | [diff] [blame] | 20 | else ifneq ($(DOCBOOKS),) |
| 21 | |
| 22 | # Skip Sphinx build if the user explicitly requested DOCBOOKS. |
| 23 | .DEFAULT: |
| 24 | @echo " SKIP Sphinx $@ target (DOCBOOKS specified)." |
| 25 | |
Jani Nikula | 22cba31 | 2016-05-19 15:14:05 +0300 | [diff] [blame] | 26 | else # HAVE_SPHINX |
| 27 | |
| 28 | # User-friendly check for rst2pdf |
| 29 | HAVE_RST2PDF := $(shell if python -c "import rst2pdf" >/dev/null 2>&1; then echo 1; else echo 0; fi) |
| 30 | |
| 31 | # Internal variables. |
| 32 | PAPEROPT_a4 = -D latex_paper_size=a4 |
| 33 | PAPEROPT_letter = -D latex_paper_size=letter |
Jani Nikula | 24dcdeb | 2016-05-20 11:51:47 +0300 | [diff] [blame] | 34 | KERNELDOC = $(srctree)/scripts/kernel-doc |
| 35 | KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC) |
Jani Nikula | c13ce44 | 2016-05-28 15:25:41 +0300 | [diff] [blame] | 36 | ALLSPHINXOPTS = -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) -d $(BUILDDIR)/.doctrees $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) -c $(srctree)/$(src) $(SPHINXOPTS) $(srctree)/$(src) |
Jani Nikula | 22cba31 | 2016-05-19 15:14:05 +0300 | [diff] [blame] | 37 | # the i18n builder cannot share the environment and doctrees with the others |
| 38 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . |
| 39 | |
| 40 | quiet_cmd_sphinx = SPHINX $@ |
Markus Heiser | 627e32d | 2016-07-08 14:15:05 +0200 | [diff] [blame] | 41 | cmd_sphinx = BUILDDIR=$(BUILDDIR) $(SPHINXBUILD) -b $2 $(ALLSPHINXOPTS) $(BUILDDIR)/$2 |
Jani Nikula | 22cba31 | 2016-05-19 15:14:05 +0300 | [diff] [blame] | 42 | |
| 43 | htmldocs: |
Mauro Carvalho Chehab | 60c2820 | 2016-07-08 11:40:06 -0300 | [diff] [blame] | 44 | $(MAKE) BUILDDIR=$(BUILDDIR) -f $(srctree)/Documentation/media/Makefile $@ |
Jani Nikula | 22cba31 | 2016-05-19 15:14:05 +0300 | [diff] [blame] | 45 | $(call cmd,sphinx,html) |
| 46 | |
| 47 | pdfdocs: |
| 48 | ifeq ($(HAVE_RST2PDF),0) |
| 49 | $(warning The Python 'rst2pdf' module was not found. Make sure you have the module installed to produce PDF output.) |
| 50 | @echo " SKIP Sphinx $@ target." |
| 51 | else # HAVE_RST2PDF |
| 52 | $(call cmd,sphinx,pdf) |
| 53 | endif # HAVE_RST2PDF |
| 54 | |
| 55 | epubdocs: |
| 56 | $(call cmd,sphinx,epub) |
| 57 | |
| 58 | xmldocs: |
| 59 | $(call cmd,sphinx,xml) |
| 60 | |
| 61 | # no-ops for the Sphinx toolchain |
| 62 | sgmldocs: |
| 63 | psdocs: |
| 64 | mandocs: |
| 65 | installmandocs: |
Jani Nikula | a569bf6 | 2016-07-01 15:03:34 +0300 | [diff] [blame] | 66 | cleanmediadocs: |
Jani Nikula | 22cba31 | 2016-05-19 15:14:05 +0300 | [diff] [blame] | 67 | |
| 68 | cleandocs: |
| 69 | $(Q)rm -rf $(BUILDDIR) |
| 70 | |
Jani Nikula | ebc88ef | 2016-06-22 15:41:48 +0300 | [diff] [blame] | 71 | dochelp: |
| 72 | @echo ' Linux kernel internal documentation in different formats (Sphinx):' |
| 73 | @echo ' htmldocs - HTML' |
| 74 | @echo ' pdfdocs - PDF' |
| 75 | @echo ' epubdocs - EPUB' |
| 76 | @echo ' xmldocs - XML' |
| 77 | @echo ' cleandocs - clean all generated files' |
| 78 | |
Jani Nikula | 22cba31 | 2016-05-19 15:14:05 +0300 | [diff] [blame] | 79 | endif # HAVE_SPHINX |