18c2ecf20Sopenharmony_ci# -*- makefile -*-
28c2ecf20Sopenharmony_ci# Makefile for Sphinx documentation
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci# for cleaning
68c2ecf20Sopenharmony_cisubdir- := devicetree/bindings
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci# Check for broken documentation file references
98c2ecf20Sopenharmony_ciifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
108c2ecf20Sopenharmony_ci$(shell $(srctree)/scripts/documentation-file-ref-check --warn)
118c2ecf20Sopenharmony_ciendif
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci# Check for broken ABI files
148c2ecf20Sopenharmony_ciifeq ($(CONFIG_WARN_ABI_ERRORS),y)
158c2ecf20Sopenharmony_ci$(shell $(srctree)/scripts/get_abi.pl validate --dir $(srctree)/Documentation/ABI)
168c2ecf20Sopenharmony_ciendif
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci# You can set these variables from the command line.
198c2ecf20Sopenharmony_ciSPHINXBUILD   = sphinx-build
208c2ecf20Sopenharmony_ciSPHINXOPTS    =
218c2ecf20Sopenharmony_ciSPHINXDIRS    = .
228c2ecf20Sopenharmony_ci_SPHINXDIRS   = $(sort $(patsubst $(srctree)/Documentation/%/index.rst,%,$(wildcard $(srctree)/Documentation/*/index.rst)))
238c2ecf20Sopenharmony_ciSPHINX_CONF   = conf.py
248c2ecf20Sopenharmony_ciPAPER         =
258c2ecf20Sopenharmony_ciBUILDDIR      = $(obj)/output
268c2ecf20Sopenharmony_ciPDFLATEX      = xelatex
278c2ecf20Sopenharmony_ciLATEXOPTS     = -interaction=batchmode
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ciifeq ($(KBUILD_VERBOSE),0)
308c2ecf20Sopenharmony_ciSPHINXOPTS    += "-q"
318c2ecf20Sopenharmony_ciendif
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci# User-friendly check for sphinx-build
348c2ecf20Sopenharmony_ciHAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciifeq ($(HAVE_SPHINX),0)
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci.DEFAULT:
398c2ecf20Sopenharmony_ci	$(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.)
408c2ecf20Sopenharmony_ci	@echo
418c2ecf20Sopenharmony_ci	@$(srctree)/scripts/sphinx-pre-install
428c2ecf20Sopenharmony_ci	@echo "  SKIP    Sphinx $@ target."
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cielse # HAVE_SPHINX
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci# User-friendly check for pdflatex and latexmk
478c2ecf20Sopenharmony_ciHAVE_PDFLATEX := $(shell if which $(PDFLATEX) >/dev/null 2>&1; then echo 1; else echo 0; fi)
488c2ecf20Sopenharmony_ciHAVE_LATEXMK := $(shell if which latexmk >/dev/null 2>&1; then echo 1; else echo 0; fi)
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciifeq ($(HAVE_LATEXMK),1)
518c2ecf20Sopenharmony_ci	PDFLATEX := latexmk -$(PDFLATEX)
528c2ecf20Sopenharmony_ciendif #HAVE_LATEXMK
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci# Internal variables.
558c2ecf20Sopenharmony_ciPAPEROPT_a4     = -D latex_paper_size=a4
568c2ecf20Sopenharmony_ciPAPEROPT_letter = -D latex_paper_size=letter
578c2ecf20Sopenharmony_ciKERNELDOC       = $(srctree)/scripts/kernel-doc
588c2ecf20Sopenharmony_ciKERNELDOC_CONF  = -D kerneldoc_srctree=$(srctree) -D kerneldoc_bin=$(KERNELDOC)
598c2ecf20Sopenharmony_ciALLSPHINXOPTS   =  $(KERNELDOC_CONF) $(PAPEROPT_$(PAPER)) $(SPHINXOPTS)
608c2ecf20Sopenharmony_ci# the i18n builder cannot share the environment and doctrees with the others
618c2ecf20Sopenharmony_ciI18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci# commands; the 'cmd' from scripts/Kbuild.include is not *loopable*
648c2ecf20Sopenharmony_ciloop_cmd = $(echo-cmd) $(cmd_$(1)) || exit;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci# $2 sphinx builder e.g. "html"
678c2ecf20Sopenharmony_ci# $3 name of the build subfolder / e.g. "userspace-api/media", used as:
688c2ecf20Sopenharmony_ci#    * dest folder relative to $(BUILDDIR) and
698c2ecf20Sopenharmony_ci#    * cache folder relative to $(BUILDDIR)/.doctrees
708c2ecf20Sopenharmony_ci# $4 dest subfolder e.g. "man" for man pages at userspace-api/media/man
718c2ecf20Sopenharmony_ci# $5 reST source folder relative to $(srctree)/$(src),
728c2ecf20Sopenharmony_ci#    e.g. "userspace-api/media" for the linux-tv book-set at ./Documentation/userspace-api/media
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciquiet_cmd_sphinx = SPHINX  $@ --> file://$(abspath $(BUILDDIR)/$3/$4)
758c2ecf20Sopenharmony_ci      cmd_sphinx = $(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media $2 && \
768c2ecf20Sopenharmony_ci	PYTHONDONTWRITEBYTECODE=1 \
778c2ecf20Sopenharmony_ci	BUILDDIR=$(abspath $(BUILDDIR)) SPHINX_CONF=$(abspath $(srctree)/$(src)/$5/$(SPHINX_CONF)) \
788c2ecf20Sopenharmony_ci	$(PYTHON) $(srctree)/scripts/jobserver-exec \
798c2ecf20Sopenharmony_ci	$(SHELL) $(srctree)/Documentation/sphinx/parallel-wrapper.sh \
808c2ecf20Sopenharmony_ci	$(SPHINXBUILD) \
818c2ecf20Sopenharmony_ci	-b $2 \
828c2ecf20Sopenharmony_ci	-c $(abspath $(srctree)/$(src)) \
838c2ecf20Sopenharmony_ci	-d $(abspath $(BUILDDIR)/.doctrees/$3) \
848c2ecf20Sopenharmony_ci	-D version=$(KERNELVERSION) -D release=$(KERNELRELEASE) \
858c2ecf20Sopenharmony_ci	$(ALLSPHINXOPTS) \
868c2ecf20Sopenharmony_ci	$(abspath $(srctree)/$(src)/$5) \
878c2ecf20Sopenharmony_ci	$(abspath $(BUILDDIR)/$3/$4)
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_cihtmldocs:
908c2ecf20Sopenharmony_ci	@$(srctree)/scripts/sphinx-pre-install --version-check
918c2ecf20Sopenharmony_ci	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,html,$(var),,$(var)))
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cilinkcheckdocs:
948c2ecf20Sopenharmony_ci	@$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,linkcheck,$(var),,$(var)))
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cilatexdocs:
978c2ecf20Sopenharmony_ci	@$(srctree)/scripts/sphinx-pre-install --version-check
988c2ecf20Sopenharmony_ci	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,latex,$(var),latex,$(var)))
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ciifeq ($(HAVE_PDFLATEX),0)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_cipdfdocs:
1038c2ecf20Sopenharmony_ci	$(warning The '$(PDFLATEX)' command was not found. Make sure you have it installed and in PATH to produce PDF output.)
1048c2ecf20Sopenharmony_ci	@echo "  SKIP    Sphinx $@ target."
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cielse # HAVE_PDFLATEX
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_cipdfdocs: latexdocs
1098c2ecf20Sopenharmony_ci	@$(srctree)/scripts/sphinx-pre-install --version-check
1108c2ecf20Sopenharmony_ci	$(foreach var,$(SPHINXDIRS), \
1118c2ecf20Sopenharmony_ci	   $(MAKE) PDFLATEX="$(PDFLATEX)" LATEXOPTS="$(LATEXOPTS)" -C $(BUILDDIR)/$(var)/latex || exit; \
1128c2ecf20Sopenharmony_ci	   mkdir -p $(BUILDDIR)/$(var)/pdf; \
1138c2ecf20Sopenharmony_ci	   mv $(subst .tex,.pdf,$(wildcard $(BUILDDIR)/$(var)/latex/*.tex)) $(BUILDDIR)/$(var)/pdf/; \
1148c2ecf20Sopenharmony_ci	)
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ciendif # HAVE_PDFLATEX
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ciepubdocs:
1198c2ecf20Sopenharmony_ci	@$(srctree)/scripts/sphinx-pre-install --version-check
1208c2ecf20Sopenharmony_ci	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,epub,$(var),epub,$(var)))
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_cixmldocs:
1238c2ecf20Sopenharmony_ci	@$(srctree)/scripts/sphinx-pre-install --version-check
1248c2ecf20Sopenharmony_ci	@+$(foreach var,$(SPHINXDIRS),$(call loop_cmd,sphinx,xml,$(var),xml,$(var)))
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ciendif # HAVE_SPHINX
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci# The following targets are independent of HAVE_SPHINX, and the rules should
1298c2ecf20Sopenharmony_ci# work or silently pass without Sphinx.
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_cirefcheckdocs:
1328c2ecf20Sopenharmony_ci	$(Q)cd $(srctree);scripts/documentation-file-ref-check
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_cicleandocs:
1358c2ecf20Sopenharmony_ci	$(Q)rm -rf $(BUILDDIR)
1368c2ecf20Sopenharmony_ci	$(Q)$(MAKE) BUILDDIR=$(abspath $(BUILDDIR)) $(build)=Documentation/userspace-api/media clean
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cidochelp:
1398c2ecf20Sopenharmony_ci	@echo  ' Linux kernel internal documentation in different formats from ReST:'
1408c2ecf20Sopenharmony_ci	@echo  '  htmldocs        - HTML'
1418c2ecf20Sopenharmony_ci	@echo  '  latexdocs       - LaTeX'
1428c2ecf20Sopenharmony_ci	@echo  '  pdfdocs         - PDF'
1438c2ecf20Sopenharmony_ci	@echo  '  epubdocs        - EPUB'
1448c2ecf20Sopenharmony_ci	@echo  '  xmldocs         - XML'
1458c2ecf20Sopenharmony_ci	@echo  '  linkcheckdocs   - check for broken external links'
1468c2ecf20Sopenharmony_ci	@echo  '                    (will connect to external hosts)'
1478c2ecf20Sopenharmony_ci	@echo  '  refcheckdocs    - check for references to non-existing files under'
1488c2ecf20Sopenharmony_ci	@echo  '                    Documentation'
1498c2ecf20Sopenharmony_ci	@echo  '  cleandocs       - clean all generated files'
1508c2ecf20Sopenharmony_ci	@echo
1518c2ecf20Sopenharmony_ci	@echo  '  make SPHINXDIRS="s1 s2" [target] Generate only docs of folder s1, s2'
1528c2ecf20Sopenharmony_ci	@echo  '  valid values for SPHINXDIRS are: $(_SPHINXDIRS)'
1538c2ecf20Sopenharmony_ci	@echo
1548c2ecf20Sopenharmony_ci	@echo  '  make SPHINX_CONF={conf-file} [target] use *additional* sphinx-build'
1558c2ecf20Sopenharmony_ci	@echo  '  configuration. This is e.g. useful to build with nit-picking config.'
1568c2ecf20Sopenharmony_ci	@echo
1578c2ecf20Sopenharmony_ci	@echo  '  Default location for the generated documents is Documentation/output'
158