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