Back to home page

LXR

 
 

    


0001 # -*- makefile -*-
0002 # Makefile for Sphinx documentation
0003 #
0004 
0005 # You can set these variables from the command line.
0006 SPHINXBUILD   = sphinx-build
0007 SPHINXOPTS    =
0008 SPHINXDIRS    = .
0009 _SPHINXDIRS   = $(patsubst $(srctree)/Documentation/%/conf.py,%,$(wildcard $(srctree)/Documentation/*/conf.py))
0010 SPHINX_CONF   = conf.py
0011 PAPER         =
0012 BUILDDIR      = $(obj)/output
0013 PDFLATEX      = xelatex
0014 LATEXOPTS     = -interaction=batchmode
0015 
0016 # User-friendly check for sphinx-build
0017 HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
0018 
0019 ifeq ($(HAVE_SPHINX),0)
0020 
0021 .DEFAULT:
0022         $(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.)
0023         @echo "  SKIP    Sphinx $@ target."
0024 
0025 else ifneq ($(DOCBOOKS),)
0026 
0027 # Skip Sphinx build if the user explicitly requested DOCBOOKS.
0028 .DEFAULT:
0029         @echo "  SKIP    Sphinx $@ target (DOCBOOKS specified)."
0030 
0031 else # HAVE_SPHINX
0032 
0033 # User-friendly check for pdflatex
0034 HAVE_PDFLATEX := $(shell if which $(PDFLATEX) >/dev/null 2>&1; then echo 1; else echo 0; fi)
0035 
0036 # Internal variables.
0037 PAPEROPT_a4     = -D latex_paper_size=a4
0038 PAPEROPT_letter = -D latex_paper_size=letter
0039 KERNELDOC       = $(srctree)/scripts/kernel-doc
0040 KERNELDOC_CONF  = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
0041 ALLSPHINXOPTS   =  $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
0042 # the i18n builder cannot share the environment and doctrees with the others
0043 I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
0044 
0045 # commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
0046 loop_cmd = $(echo-cmd) $(cmd_$(1))
0047 
0048 # $2 sphinx builder e.g. "html"
0049 # $3 name of the build subfolder / e.g. "media", used as:
0050 #    * dest folder relative to $(BUILDDIR) and
0051 #    * cache folder relative to $(BUILDDIR)/.doctrees
0052 # $4 dest subfolder e.g. "man" for man pages at media/man
0053 # $5 reST source folder relative to $(srctree)/$(src),
0054 #    e.g. "media" for the linux-tv book-set at ./Documentation/media
0055 
0056 quiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
0057       cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/media $2;\
0058         BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
0059         $(SPHINXBUILD) \
0060         -b $2 \
0061         -c $(abspath $(srctree)/$(src)) \
0062         -d $(abspath $(BUILDDIR)/.doctrees/$3) \
0063         -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
0064         $(ALLSPHINXOPTS) \
0065         $(abspath $(srctree)/$(src)/$5) \
0066         $(abspath $(BUILDDIR)/$3/$4);
0067 
0068 htmldocs:
0069         @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
0070 
0071 latexdocs:
0072         @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
0073 
0074 ifeq ($(HAVE_PDFLATEX),0)
0075 
0076 pdfdocs:
0077         $(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.)
0078         @echo "  SKIP    Sphinx $@ target."
0079 
0080 else # HAVE_PDFLATEX
0081 
0082 pdfdocs: latexdocs
0083         $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex;)
0084 
0085 endif # HAVE_PDFLATEX
0086 
0087 epubdocs:
0088         @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
0089 
0090 xmldocs:
0091         @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
0092 
0093 # no-ops for the Sphinx toolchain
0094 sgmldocs:
0095 psdocs:
0096 mandocs:
0097 installmandocs:
0098 
0099 cleandocs:
0100         $(Q)rm -rf $(BUILDDIR)
0101         $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) -C Documentation/media clean
0102 
0103 endif # HAVE_SPHINX
0104 
0105 dochelp:
0106         @echo  ' Linux kernel internal documentation in different formats (Sphinx):'
0107         @echo  '  htmldocs        - HTML'
0108         @echo  '  latexdocs       - LaTeX'
0109         @echo  '  pdfdocs         - PDF'
0110         @echo  '  epubdocs        - EPUB'
0111         @echo  '  xmldocs         - XML'
0112         @echo  '  cleandocs       - clean all generated files'
0113         @echo
0114         @echo  '  make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
0115         @echo  '  valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
0116         @echo
0117         @echo  '  make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
0118         @echo  '  configuration. This is e.g. useful to build with nit-picking config.'