Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # Makefile for Sphinx documentation |
| 3 | # |
| 4 | |
| 5 | subdir-y := |
| 6 | |
| 7 | # You can set these variables from the command line. |
| 8 | SPHINXBUILD = sphinx-build |
Heinrich Schuchardt | e3abd4d | 2021-08-01 22:11:39 +0200 | [diff] [blame] | 9 | SPHINXOPTS = -W |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 10 | SPHINXDIRS = . |
Breno Matheus Lima | 7e3400b | 2019-06-05 18:18:30 +0000 | [diff] [blame] | 11 | _SPHINXDIRS = $(patsubst $(srctree)/doc/%/conf.py,%,$(wildcard $(srctree)/doc/*/conf.py)) |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 12 | SPHINX_CONF = conf.py |
| 13 | PAPER = |
| 14 | BUILDDIR = $(obj)/output |
| 15 | PDFLATEX = xelatex |
| 16 | LATEXOPTS = -interaction=batchmode |
| 17 | |
| 18 | # User-friendly check for sphinx-build |
| 19 | HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi) |
| 20 | |
| 21 | ifeq ($(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.) |
| 25 | @echo |
| 26 | @./scripts/sphinx-pre-install |
| 27 | @echo " SKIP Sphinx $@ target." |
| 28 | |
| 29 | else # HAVE_SPHINX |
| 30 | |
| 31 | # User-friendly check for pdflatex |
| 32 | HAVE_PDFLATEX := $(shell if which $(PDFLATEX) >/dev/null 2>&1; then echo 1; else echo 0; fi) |
| 33 | |
| 34 | # Internal variables. |
| 35 | PAPEROPT_a4 = -D latex_paper_size=a4 |
| 36 | PAPEROPT_letter = -D latex_paper_size=letter |
| 37 | KERNELDOC = $(srctree)/scripts/kernel-doc |
| 38 | KERNELDOC_CONF = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC) |
| 39 | ALLSPHINXOPTS = $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) |
| 40 | # the i18n builder cannot share the environment and doctrees with the others |
| 41 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . |
| 42 | |
| 43 | # commands; the 'cmd' from scripts/Kbuild.include is not *loopable* |
| 44 | loop_cmd = $(echo-cmd) $(cmd_$(1)) || exit; |
| 45 | |
| 46 | # $2 sphinx builder e.g. "html" |
| 47 | # $3 name of the build subfolder / e.g. "media", used as: |
| 48 | # * dest folder relative to $(BUILDDIR) and |
| 49 | # * cache folder relative to $(BUILDDIR)/.doctrees |
| 50 | # $4 dest subfolder e.g. "man" for man pages at media/man |
| 51 | # $5 reST source folder relative to $(srctree)/$(src), |
Breno Matheus Lima | 7e3400b | 2019-06-05 18:18:30 +0000 | [diff] [blame] | 52 | # e.g. "media" for the linux-tv book-set at ./doc/media |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 53 | |
| 54 | quiet_cmd_sphinx = SPHINX $@ --> file://$(abspath $(BUILDDIR)/$3/$4) |
Breno Matheus Lima | 7e3400b | 2019-06-05 18:18:30 +0000 | [diff] [blame] | 55 | cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=doc/media $2 && \ |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 56 | PYTHONDONTWRITEBYTECODE=1 \ |
| 57 | BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \ |
| 58 | $(SPHINXBUILD) \ |
Simon Glass | 76d71b0 | 2022-08-07 16:33:26 -0600 | [diff] [blame] | 59 | -j$(shell nproc) \ |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 60 | -b $2 \ |
Simon Glass | f1710f0 | 2022-08-13 11:40:40 -0600 | [diff] [blame] | 61 | -j auto \ |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 62 | -c $(abspath $(srctree)/$(src)) \ |
| 63 | -d $(abspath $(BUILDDIR)/.doctrees/$3) \ |
| 64 | -D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \ |
| 65 | $(ALLSPHINXOPTS) \ |
| 66 | $(abspath $(srctree)/$(src)/$5) \ |
| 67 | $(abspath $(BUILDDIR)/$3/$4) |
| 68 | |
| 69 | htmldocs: |
| 70 | @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var))) |
| 71 | |
Maxim Cournoyer | 52ac5e4 | 2022-12-18 21:48:08 -0500 | [diff] [blame] | 72 | texinfodocs: |
| 73 | @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,texinfo,$(var),texinfo,$(var))) |
| 74 | |
| 75 | # Note: the 'info' Make target is generated by sphinx itself when |
| 76 | # running the texinfodocs target defined above. |
| 77 | infodocs: texinfodocs |
| 78 | $(MAKE) -C $(BUILDDIR)/texinfo info |
| 79 | |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 80 | linkcheckdocs: |
| 81 | @$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var))) |
| 82 | |
| 83 | latexdocs: |
| 84 | @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var))) |
| 85 | |
| 86 | ifeq ($(HAVE_PDFLATEX),0) |
| 87 | |
| 88 | pdfdocs: |
| 89 | $(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.) |
| 90 | @echo " SKIP Sphinx $@ target." |
| 91 | |
| 92 | else # HAVE_PDFLATEX |
| 93 | |
| 94 | pdfdocs: latexdocs |
| 95 | $(foreach var,$(SPHINXDIRS), $(MAKE) PDFLATEX=$(PDFLATEX) LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit;) |
| 96 | |
| 97 | endif # HAVE_PDFLATEX |
| 98 | |
| 99 | epubdocs: |
| 100 | @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var))) |
| 101 | |
| 102 | xmldocs: |
| 103 | @+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var))) |
| 104 | |
| 105 | endif # HAVE_SPHINX |
| 106 | |
| 107 | # The following targets are independent of HAVE_SPHINX, and the rules should |
| 108 | # work or silently pass without Sphinx. |
| 109 | |
| 110 | refcheckdocs: |
| 111 | $(Q)cd $(srctree);scripts/documentation-file-ref-check |
| 112 | |
| 113 | cleandocs: |
| 114 | $(Q)rm -rf $(BUILDDIR) |
Breno Matheus Lima | 7e3400b | 2019-06-05 18:18:30 +0000 | [diff] [blame] | 115 | $(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=doc/media clean |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 116 | |
| 117 | dochelp: |
Patrick Delaunay | b5c3856 | 2021-01-14 12:04:04 +0100 | [diff] [blame] | 118 | @echo ' U-Boot documentation in different formats from ReST:' |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 119 | @echo ' htmldocs - HTML' |
Maxim Cournoyer | 52ac5e4 | 2022-12-18 21:48:08 -0500 | [diff] [blame] | 120 | @echo ' texinfodocs - Texinfo' |
| 121 | @echo ' infodocs - Info' |
Mario Six | 8fac291 | 2018-07-10 08:40:17 +0200 | [diff] [blame] | 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)' |
| 127 | @echo ' refcheckdocs - check for references to non-existing files under Documentation' |
| 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.' |
| 135 | @echo |
Breno Matheus Lima | 7e3400b | 2019-06-05 18:18:30 +0000 | [diff] [blame] | 136 | @echo ' Default location for the generated documents is doc/output' |