blob: b88f666f72bb413105a3c6263935419e103b105d [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*
46loop_cmd = $(echo-cmd) $(cmd_$(1))
47
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)
Mauro Carvalho Chehab15a04d42016-11-14 14:32:32 -020057 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) \
67 $(abspath $(BUILDDIR)/$3/$4);
Jani Nikula22cba312016-05-19 15:14:05 +030068
69htmldocs:
Markus Heiser606b9ac2016-08-13 16:12:42 +020070 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
Jani Nikula22cba312016-05-19 15:14:05 +030071
Mauro Carvalho Chehabd5651272016-08-18 11:53:39 -030072latexdocs:
Jani Nikula207fc552016-11-02 11:13:19 +020073 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
74
Jani Nikulaf907ba92016-08-10 18:54:08 +030075ifeq ($(HAVE_PDFLATEX),0)
Jani Nikula207fc552016-11-02 11:13:19 +020076
77pdfdocs:
Jani Nikula1171a282016-11-02 10:38:43 +020078 $(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 +030079 @echo " SKIP Sphinx $@ target."
Jani Nikula207fc552016-11-02 11:13:19 +020080
Jani Nikulaf907ba92016-08-10 18:54:08 +030081else # HAVE_PDFLATEX
Mauro Carvalho Chehabd5651272016-08-18 11:53:39 -030082
83pdfdocs: latexdocs
Markus Heiser0af205e2016-11-02 16:37:11 +020084 $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex;)
Jani Nikula1171a282016-11-02 10:38:43 +020085
Jani Nikulaf907ba92016-08-10 18:54:08 +030086endif # HAVE_PDFLATEX
Jani Nikula22cba312016-05-19 15:14:05 +030087
88epubdocs:
Markus Heiser606b9ac2016-08-13 16:12:42 +020089 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
Jani Nikula22cba312016-05-19 15:14:05 +030090
91xmldocs:
Markus Heiser606b9ac2016-08-13 16:12:42 +020092 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
Jani Nikula22cba312016-05-19 15:14:05 +030093
94# no-ops for the Sphinx toolchain
95sgmldocs:
96psdocs:
97mandocs:
98installmandocs:
99
100cleandocs:
101 $(Q)rm -rf $(BUILDDIR)
Markus Heiser7cabd5a2017-01-31 10:57:41 +0100102 $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media clean
Jani Nikula22cba312016-05-19 15:14:05 +0300103
Jani Nikulad9a77fe2016-08-01 12:37:05 +0300104endif # HAVE_SPHINX
105
Jani Nikulaebc88ef2016-06-22 15:41:48 +0300106dochelp:
107 @echo ' Linux kernel internal documentation in different formats (Sphinx):'
108 @echo ' htmldocs - HTML'
Mauro Carvalho Chehabd5651272016-08-18 11:53:39 -0300109 @echo ' latexdocs - LaTeX'
Jani Nikulaebc88ef2016-06-22 15:41:48 +0300110 @echo ' pdfdocs - PDF'
111 @echo ' epubdocs - EPUB'
112 @echo ' xmldocs - XML'
113 @echo ' cleandocs - clean all generated files'
Markus Heiser606b9ac2016-08-13 16:12:42 +0200114 @echo
115 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
116 @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
117 @echo
118 @echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
119 @echo ' configuration. This is e.g. useful to build with nit-picking config.'