blob: bcf529f6cf9b258e4389377a4cf04796fb1594de [file] [log] [blame]
Jani Nikula22cba312016-05-19 15:14:05 +03001# -*- makefile -*-
2# Makefile for Sphinx documentation
3#
4
5# You can set these variables from the command line.
6SPHINXBUILD = sphinx-build
7SPHINXOPTS =
Markus Heiser606b9ac2016-08-13 16:12:42 +02008SPHINXDIRS = .
9_SPHINXDIRS = $(patsubst $(srctree)/Documentation/%/conf.py,%,$(wildcard $(srctree)/Documentation/*/conf.py))
10SPHINX_CONF = conf.py
Jani Nikula22cba312016-05-19 15:14:05 +030011PAPER =
12BUILDDIR = $(obj)/output
Jani Nikula1171a282016-11-02 10:38:43 +020013PDFLATEX = xelatex
Jani Nikulaeaed1b22016-11-02 13:20:15 +020014LATEXOPTS = -interaction=batchmode
Jani Nikula22cba312016-05-19 15:14:05 +030015
16# User-friendly check for sphinx-build
17HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
18
19ifeq ($(HAVE_SPHINX),0)
20
21.DEFAULT:
22 $(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.)
23 @echo " SKIP Sphinx $@ target."
24
Jani Nikula63878722016-07-01 15:24:44 +030025else ifneq ($(DOCBOOKS),)
26
27# Skip Sphinx build if the user explicitly requested DOCBOOKS.
28.DEFAULT:
29 @echo " SKIP Sphinx $@ target (DOCBOOKS specified)."
30
Jani Nikula22cba312016-05-19 15:14:05 +030031else # HAVE_SPHINX
32
Jani Nikulaf907ba92016-08-10 18:54:08 +030033# User-friendly check for pdflatex
Jani Nikula1171a282016-11-02 10:38:43 +020034HAVE_PDFLATEX := $(shell if which $(PDFLATEX) >/dev/null 2>&1; then echo 1; else echo 0; fi)
Jani Nikula22cba312016-05-19 15:14:05 +030035
36# Internal variables.
37PAPEROPT_a4 = -D latex_paper_size=a4
38PAPEROPT_letter = -D latex_paper_size=letter
Jani Nikula24dcdeb2016-05-20 11:51:47 +030039KERNELDOC = $(srctree)/scripts/kernel-doc
40KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
Markus Heiser606b9ac2016-08-13 16:12:42 +020041ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
Jani Nikula22cba312016-05-19 15:14:05 +030042# the i18n builder cannot share the environment and doctrees with the others
43I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
44
Markus Heiser606b9ac2016-08-13 16:12:42 +020045# commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
Ben Hutchings85bd9022017-01-31 00:18:34 +000046loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;
Markus Heiser606b9ac2016-08-13 16:12:42 +020047
48# $2 sphinx builder e.g. "html"
49# $3 name of the build subfolder / e.g. "media", used as:
50# * dest folder relative to $(BUILDDIR) and
51# * cache folder relative to $(BUILDDIR)/.doctrees
52# $4 dest subfolder e.g. "man" for man pages at media/man
53# $5 reST source folder relative to $(srctree)/$(src),
54# e.g. "media" for the linux-tv book-set at ./Documentation/media
55
Jani Nikulac8556962016-11-02 10:56:31 +020056quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
Ben Hutchings85bd9022017-01-31 00:18:34 +000057 cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media $2 && \
Jani Nikula2a0f4032017-01-31 20:18:05 +020058 PYTHONDONTWRITEBYTECODE=1 \
Markus Heiser606b9ac2016-08-13 16:12:42 +020059 BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
60 $(SPHINXBUILD) \
61 -b $2 \
62 -c $(abspath $(srctree)/$(src)) \
63 -d $(abspath $(BUILDDIR)/.doctrees/$3) \
64 -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
65 $(ALLSPHINXOPTS) \
66 $(abspath $(srctree)/$(src)/$5) \
Ben Hutchings85bd9022017-01-31 00:18:34 +000067 $(abspath $(BUILDDIR)/$3/$4)
Jani Nikula22cba312016-05-19 15:14:05 +030068
69htmldocs:
Ben Hutchings4b0b0d92017-01-31 00:18:56 +000070 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
Jani Nikula22cba312016-05-19 15:14:05 +030071
Rémy Léone62924fd2017-02-15 13:16:35 +010072linkcheckdocs:
73 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
74
Mauro Carvalho Chehabd5651272016-08-18 11:53:39 -030075latexdocs:
Ben Hutchings4b0b0d92017-01-31 00:18:56 +000076 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
Jani Nikula207fc552016-11-02 11:13:19 +020077
Jani Nikulaf907ba92016-08-10 18:54:08 +030078ifeq ($(HAVE_PDFLATEX),0)
Jani Nikula207fc552016-11-02 11:13:19 +020079
80pdfdocs:
Jani Nikula1171a282016-11-02 10:38:43 +020081 $(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.)
Jani Nikula22cba312016-05-19 15:14:05 +030082 @echo " SKIP Sphinx $@ target."
Jani Nikula207fc552016-11-02 11:13:19 +020083
Jani Nikulaf907ba92016-08-10 18:54:08 +030084else # HAVE_PDFLATEX
Mauro Carvalho Chehabd5651272016-08-18 11:53:39 -030085
86pdfdocs: latexdocs
Ben Hutchings85bd9022017-01-31 00:18:34 +000087 $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit;)
Jani Nikula1171a282016-11-02 10:38:43 +020088
Jani Nikulaf907ba92016-08-10 18:54:08 +030089endif # HAVE_PDFLATEX
Jani Nikula22cba312016-05-19 15:14:05 +030090
91epubdocs:
Ben Hutchings4b0b0d92017-01-31 00:18:56 +000092 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
Jani Nikula22cba312016-05-19 15:14:05 +030093
94xmldocs:
Ben Hutchings4b0b0d92017-01-31 00:18:56 +000095 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
Jani Nikula22cba312016-05-19 15:14:05 +030096
Jani Nikulac8929252017-01-30 18:58:15 +020097endif # HAVE_SPHINX
98
99# The following targets are independent of HAVE_SPHINX, and the rules should
100# work or silently pass without Sphinx.
101
Jani Nikula22cba312016-05-19 15:14:05 +0300102# no-ops for the Sphinx toolchain
103sgmldocs:
Jim Davisc33dea12017-02-10 17:06:50 -0700104 @:
Jani Nikula22cba312016-05-19 15:14:05 +0300105psdocs:
Jim Davisc33dea12017-02-10 17:06:50 -0700106 @:
Jani Nikula22cba312016-05-19 15:14:05 +0300107mandocs:
Jim Davisc33dea12017-02-10 17:06:50 -0700108 @:
Jani Nikula22cba312016-05-19 15:14:05 +0300109installmandocs:
Jim Davisc33dea12017-02-10 17:06:50 -0700110 @:
Jani Nikula22cba312016-05-19 15:14:05 +0300111
112cleandocs:
113 $(Q)rm -rf $(BUILDDIR)
Markus Heiser7cabd5a2017-01-31 10:57:41 +0100114 $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media clean
Jani Nikula22cba312016-05-19 15:14:05 +0300115
Jani Nikulaebc88ef2016-06-22 15:41:48 +0300116dochelp:
117 @echo ' Linux kernel internal documentation in different formats (Sphinx):'
118 @echo ' htmldocs - HTML'
Mauro Carvalho Chehabd5651272016-08-18 11:53:39 -0300119 @echo ' latexdocs - LaTeX'
Jani Nikulaebc88ef2016-06-22 15:41:48 +0300120 @echo ' pdfdocs - PDF'
121 @echo ' epubdocs - EPUB'
122 @echo ' xmldocs - XML'
Rémy Léone62924fd2017-02-15 13:16:35 +0100123 @echo ' linkcheckdocs - check for broken external links (will connect to external hosts)'
Jani Nikulaebc88ef2016-06-22 15:41:48 +0300124 @echo ' cleandocs - clean all generated files'
Markus Heiser606b9ac2016-08-13 16:12:42 +0200125 @echo
126 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
127 @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
128 @echo
129 @echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
130 @echo ' configuration. This is e.g. useful to build with nit-picking config.'