docs: look for sphinx-pre-install in the source tree
[linux-2.6-block.git] / Documentation / Makefile
CommitLineData
cb43fb57
MCC
1# -*- makefile -*-
2# Makefile for Sphinx documentation
3#
4
4f0e3a57 5subdir-y := devicetree/bindings/
cb43fb57
MCC
6
7# You can set these variables from the command line.
8SPHINXBUILD = sphinx-build
9SPHINXOPTS =
10SPHINXDIRS = .
11_SPHINXDIRS = $(patsubst $(srctree)/Documentation/%/conf.py,%,$(wildcard $(srctree)/Documentation/*/conf.py))
12SPHINX_CONF = conf.py
13PAPER =
14BUILDDIR = $(obj)/output
15PDFLATEX = xelatex
16LATEXOPTS = -interaction=batchmode
17
18# User-friendly check for sphinx-build
19HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
20
21ifeq ($(HAVE_SPHINX),0)
22
23.DEFAULT:
24 $(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.)
92a037f0 25 @echo
6c01edd3 26 @$(srctree)/scripts/sphinx-pre-install
cb43fb57
MCC
27 @echo " SKIP Sphinx $@ target."
28
29else # HAVE_SPHINX
30
cf08508d
MCC
31export SPHINXOPTS = $(shell perl -e 'open IN,"sphinx-build --version 2>&1 |"; while (<IN>) { if (m/([\d\.]+)/) { print "-jauto" if ($$1 >= "1.7") } ;} close IN')
32
28f7c994 33# User-friendly check for pdflatex and latexmk
cb43fb57 34HAVE_PDFLATEX := $(shell if which $(PDFLATEX) >/dev/null 2>&1; then echo 1; else echo 0; fi)
28f7c994
MCC
35HAVE_LATEXMK := $(shell if which latexmk >/dev/null 2>&1; then echo 1; else echo 0; fi)
36
37ifeq ($(HAVE_LATEXMK),1)
38 PDFLATEX := latexmk -$(PDFLATEX)
39endif #HAVE_LATEXMK
cb43fb57
MCC
40
41# Internal variables.
42PAPEROPT_a4 = -D latex_paper_size=a4
43PAPEROPT_letter = -D latex_paper_size=letter
44KERNELDOC = $(srctree)/scripts/kernel-doc
45KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
46ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
47# the i18n builder cannot share the environment and doctrees with the others
48I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
49
50# commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
51loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;
52
53# $2 sphinx builder e.g. "html"
54# $3 name of the build subfolder / e.g. "media", used as:
55# * dest folder relative to $(BUILDDIR) and
56# * cache folder relative to $(BUILDDIR)/.doctrees
57# $4 dest subfolder e.g. "man" for man pages at media/man
58# $5 reST source folder relative to $(srctree)/$(src),
59# e.g. "media" for the linux-tv book-set at ./Documentation/media
60
61quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
62 cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media $2 && \
63 PYTHONDONTWRITEBYTECODE=1 \
64 BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
65 $(SPHINXBUILD) \
66 -b $2 \
67 -c $(abspath $(srctree)/$(src)) \
68 -d $(abspath $(BUILDDIR)/.doctrees/$3) \
69 -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
70 $(ALLSPHINXOPTS) \
71 $(abspath $(srctree)/$(src)/$5) \
72 $(abspath $(BUILDDIR)/$3/$4)
73
74htmldocs:
9b88ad54 75 @./scripts/sphinx-pre-install --version-check
cb43fb57
MCC
76 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
77
78linkcheckdocs:
79 @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
80
81latexdocs:
9b88ad54 82 @./scripts/sphinx-pre-install --version-check
cb43fb57
MCC
83 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
84
85ifeq ($(HAVE_PDFLATEX),0)
86
87pdfdocs:
88 $(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.)
89 @echo " SKIP Sphinx $@ target."
90
91else # HAVE_PDFLATEX
92
93pdfdocs: latexdocs
9b88ad54 94 @./scripts/sphinx-pre-install --version-check
28f7c994 95 $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX="$(PDFLATEX)" LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit;)
cb43fb57
MCC
96
97endif # HAVE_PDFLATEX
98
99epubdocs:
9b88ad54 100 @./scripts/sphinx-pre-install --version-check
cb43fb57
MCC
101 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
102
103xmldocs:
9b88ad54 104 @./scripts/sphinx-pre-install --version-check
cb43fb57
MCC
105 @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
106
107endif # HAVE_SPHINX
108
109# The following targets are independent of HAVE_SPHINX, and the rules should
110# work or silently pass without Sphinx.
111
e8939222
JN
112refcheckdocs:
113 $(Q)cd $(srctree);scripts/documentation-file-ref-check
114
cb43fb57
MCC
115cleandocs:
116 $(Q)rm -rf $(BUILDDIR)
117 $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media clean
118
119dochelp:
120 @echo ' Linux kernel internal documentation in different formats from ReST:'
121 @echo ' htmldocs - HTML'
122 @echo ' latexdocs - LaTeX'
123 @echo ' pdfdocs - PDF'
124 @echo ' epubdocs - EPUB'
125 @echo ' xmldocs - XML'
126 @echo ' linkcheckdocs - check for broken external links (will connect to external hosts)'
e8939222 127 @echo ' refcheckdocs - check for references to non-existing files under Documentation'
cb43fb57
MCC
128 @echo ' cleandocs - clean all generated files'
129 @echo
130 @echo ' make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
131 @echo ' valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
132 @echo
133 @echo ' make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
134 @echo ' configuration. This is e.g. useful to build with nit-picking config.'
9effc8f7
SK
135 @echo
136 @echo ' Default location for the generated documents is Documentation/output'