xref: /OK3568_Linux_fs/yocto/poky/documentation/Makefile (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1# Minimal makefile for Sphinx documentation
2#
3
4# You can set these variables from the command line, and also
5# from the environment for the first two.
6SPHINXOPTS    ?= -W --keep-going -j auto
7SPHINXBUILD   ?= sphinx-build
8SOURCEDIR     = .
9IMAGEDIRS     = */svg
10BUILDDIR      = _build
11DESTDIR       = final
12SVG2PNG       = inkscape
13SVG2PDF       = inkscape
14
15ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
16$(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed")
17endif
18
19# Put it first so that "make" without argument is like "make help".
20help:
21	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
22
23.PHONY: all help Makefile clean publish epub latexpdf
24
25publish: Makefile html singlehtml
26	rm -rf $(BUILDDIR)/$(DESTDIR)/
27	mkdir -p $(BUILDDIR)/$(DESTDIR)/
28	cp -r $(BUILDDIR)/html/* $(BUILDDIR)/$(DESTDIR)/
29	cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html
30	sed -i -e 's@index.html#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
31
32# Build a list of SVG files to convert to PDFs
33PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
34
35# Build a list of SVG files to convert to PNGs
36PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
37
38# Pattern rule for converting SVG to PDF
39%.pdf : %.svg
40	$(SVG2PDF) --export-filename=$@ $<
41
42# Pattern rule for converting SVG to PNG
43%.png : %.svg
44	$(SVG2PNG) --export-filename=$@ $<
45
46clean:
47	@rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js
48
49epub: $(PNGs)
50	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
51
52latexpdf: $(PDFs)
53	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
54
55all: html epub latexpdf
56
57# Catch-all target: route all unknown targets to Sphinx using the new
58# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
59%:
60	$(SOURCEDIR)/set_versions.py
61	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
62