Makefile 4.4 KB

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