]>
Commit | Line | Data |
---|---|---|
22cba31b JN |
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 = | |
606b9ac8 MH |
8 | SPHINXDIRS = . |
9 | _SPHINXDIRS = $(patsubst $(srctree)/Documentation/%/conf.py,%,$(wildcard $(srctree)/Documentation/*/conf.py)) | |
10 | SPHINX_CONF = conf.py | |
22cba31b JN |
11 | PAPER = |
12 | BUILDDIR = $(obj)/output | |
1171a28b | 13 | PDFLATEX = xelatex |
eaed1b25 | 14 | LATEXOPTS = -interaction=batchmode |
22cba31b JN |
15 | |
16 | # User-friendly check for sphinx-build | |
17 | HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi) | |
18 | ||
19 | ifeq ($(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 | ||
6387872c JN |
25 | else ifneq ($(DOCBOOKS),) |
26 | ||
27 | # Skip Sphinx build if the user explicitly requested DOCBOOKS. | |
28 | .DEFAULT: | |
29 | @echo " SKIP Sphinx $@ target (DOCBOOKS specified)." | |
30 | ||
22cba31b JN |
31 | else # HAVE_SPHINX |
32 | ||
f907ba93 | 33 | # User-friendly check for pdflatex |
1171a28b | 34 | HAVE_PDFLATEX := $(shell if which $(PDFLATEX) >/dev/null 2>&1; then echo 1; else echo 0; fi) |
22cba31b JN |
35 | |
36 | # Internal variables. | |
37 | PAPEROPT_a4 = -D latex_paper_size=a4 | |
38 | PAPEROPT_letter = -D latex_paper_size=letter | |
24dcdeb2 JN |
39 | KERNELDOC = $(srctree)/scripts/kernel-doc |
40 | KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC) | |
606b9ac8 | 41 | ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) |
22cba31b JN |
42 | # the i18n builder cannot share the environment and doctrees with the others |
43 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . | |
44 | ||
606b9ac8 MH |
45 | # commands; the 'cmd' from scripts/Kbuild.include is not *loopable* |
46 | loop_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 | ||
c8556966 | 56 | quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4) |
15a04d4e | 57 | cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media $2;\ |
606b9ac8 MH |
58 | BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \ |
59 | $(SPHINXBUILD) \ | |
60 | -b $2 \ | |
61 | -c $(abspath $(srctree)/$(src)) \ | |
62 | -d $(abspath $(BUILDDIR)/.doctrees/$3) \ | |
63 | -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \ | |
64 | $(ALLSPHINXOPTS) \ | |
65 | $(abspath $(srctree)/$(src)/$5) \ | |
66 | $(abspath $(BUILDDIR)/$3/$4); | |
22cba31b JN |
67 | |
68 | htmldocs: | |
606b9ac8 | 69 | @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) |
22cba31b | 70 | |
d565127d | 71 | latexdocs: |
207fc55b JN |
72 | @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var))) |
73 | ||
f907ba93 | 74 | ifeq ($(HAVE_PDFLATEX),0) |
207fc55b JN |
75 | |
76 | pdfdocs: | |
1171a28b | 77 | $(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.) |
22cba31b | 78 | @echo " SKIP Sphinx $@ target." |
207fc55b | 79 | |
f907ba93 | 80 | else # HAVE_PDFLATEX |
d565127d MCC |
81 | |
82 | pdfdocs: latexdocs | |
0af205ea | 83 | $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex;) |
1171a28b | 84 | |
f907ba93 | 85 | endif # HAVE_PDFLATEX |
22cba31b JN |
86 | |
87 | epubdocs: | |
606b9ac8 | 88 | @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var))) |
22cba31b JN |
89 | |
90 | xmldocs: | |
606b9ac8 | 91 | @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var))) |
22cba31b JN |
92 | |
93 | # no-ops for the Sphinx toolchain | |
94 | sgmldocs: | |
95 | psdocs: | |
96 | mandocs: | |
97 | installmandocs: | |
98 | ||
99 | cleandocs: | |
100 | $(Q)rm -rf $(BUILDDIR) | |
293fbd4f | 101 | $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) -C Documentation/media clean |
22cba31b | 102 | |
d9a77fe2 JN |
103 | endif # HAVE_SPHINX |
104 | ||
ebc88ef0 JN |
105 | dochelp: |
106 | @echo ' Linux kernel internal documentation in different formats (Sphinx):' | |
107 | @echo ' htmldocs - HTML' | |
d565127d | 108 | @echo ' latexdocs - LaTeX' |
ebc88ef0 JN |
109 | @echo ' pdfdocs - PDF' |
110 | @echo ' epubdocs - EPUB' | |
111 | @echo ' xmldocs - XML' | |
112 | @echo ' cleandocs - clean all generated files' | |
606b9ac8 MH |
113 | @echo |
114 | @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2' | |
115 | @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)' | |
116 | @echo | |
117 | @echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build' | |
118 | @echo ' configuration. This is e.g. useful to build with nit-picking config.' |