docs-rst: improve output for .. notes:: on LaTeX
[linux-2.6-block.git] / Documentation / Makefile.sphinx
CommitLineData
22cba31b
JN
1# -*- makefile -*-
2# Makefile for Sphinx documentation
3#
4
5# You can set these variables from the command line.
6SPHINXBUILD = sphinx-build
7SPHINXOPTS =
606b9ac8
MH
8SPHINXDIRS = .
9_SPHINXDIRS = $(patsubst $(srctree)/Documentation/%/conf.py,%,$(wildcard $(srctree)/Documentation/*/conf.py))
10SPHINX_CONF = conf.py
22cba31b
JN
11PAPER =
12BUILDDIR = $(obj)/output
13
14# User-friendly check for sphinx-build
15HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
16
17ifeq ($(HAVE_SPHINX),0)
18
19.DEFAULT:
20 $(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.)
21 @echo " SKIP Sphinx $@ target."
22
6387872c
JN
23else ifneq ($(DOCBOOKS),)
24
25# Skip Sphinx build if the user explicitly requested DOCBOOKS.
26.DEFAULT:
27 @echo " SKIP Sphinx $@ target (DOCBOOKS specified)."
28
22cba31b
JN
29else # HAVE_SPHINX
30
f907ba93
JN
31# User-friendly check for pdflatex
32HAVE_PDFLATEX := $(shell if which pdflatex >/dev/null 2>&1; then echo 1; else echo 0; fi)
22cba31b
JN
33
34# Internal variables.
35PAPEROPT_a4 = -D latex_paper_size=a4
36PAPEROPT_letter = -D latex_paper_size=letter
24dcdeb2
JN
37KERNELDOC = $(srctree)/scripts/kernel-doc
38KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
606b9ac8 39ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
22cba31b
JN
40# the i18n builder cannot share the environment and doctrees with the others
41I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
42
606b9ac8
MH
43# commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
44loop_cmd = $(echo-cmd) $(cmd_$(1))
45
46# $2 sphinx builder e.g. "html"
47# $3 name of the build subfolder / e.g. "media", used as:
48# * dest folder relative to $(BUILDDIR) and
49# * cache folder relative to $(BUILDDIR)/.doctrees
50# $4 dest subfolder e.g. "man" for man pages at media/man
51# $5 reST source folder relative to $(srctree)/$(src),
52# e.g. "media" for the linux-tv book-set at ./Documentation/media
53
54quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4);
55 cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media all;\
56 BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
57 $(SPHINXBUILD) \
58 -b $2 \
59 -c $(abspath $(srctree)/$(src)) \
60 -d $(abspath $(BUILDDIR)/.doctrees/$3) \
61 -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
62 $(ALLSPHINXOPTS) \
63 $(abspath $(srctree)/$(src)/$5) \
64 $(abspath $(BUILDDIR)/$3/$4);
22cba31b
JN
65
66htmldocs:
606b9ac8 67 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
22cba31b
JN
68
69pdfdocs:
f907ba93
JN
70ifeq ($(HAVE_PDFLATEX),0)
71 $(warning The 'pdflatex' command was not found. Make sure you have it installed and in PATH to produce PDF output.)
22cba31b 72 @echo " SKIP Sphinx $@ target."
f907ba93 73else # HAVE_PDFLATEX
16dbe804 74 @$(call loop_cmd,sphinx,latex,.,latex,.)
f907ba93
JN
75 $(Q)$(MAKE) -C $(BUILDDIR)/latex
76endif # HAVE_PDFLATEX
22cba31b
JN
77
78epubdocs:
606b9ac8 79 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
22cba31b
JN
80
81xmldocs:
606b9ac8 82 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
22cba31b
JN
83
84# no-ops for the Sphinx toolchain
85sgmldocs:
86psdocs:
87mandocs:
88installmandocs:
89
90cleandocs:
91 $(Q)rm -rf $(BUILDDIR)
92
d9a77fe2
JN
93endif # HAVE_SPHINX
94
ebc88ef0
JN
95dochelp:
96 @echo ' Linux kernel internal documentation in different formats (Sphinx):'
97 @echo ' htmldocs - HTML'
98 @echo ' pdfdocs - PDF'
99 @echo ' epubdocs - EPUB'
100 @echo ' xmldocs - XML'
101 @echo ' cleandocs - clean all generated files'
606b9ac8
MH
102 @echo
103 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
104 @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
105 @echo
106 @echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
107 @echo ' configuration. This is e.g. useful to build with nit-picking config.'