devtools: use a common prefix for temporary files
[dpdk.git] / mk / rte.sdkdoc.mk
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2010-2015 Intel Corporation.
3 # Copyright(c) 2013-2015 6WIND S.A.
4
5 ifdef T
6 ifeq ("$(origin T)", "command line")
7 $(error "Cannot use T= with doc target")
8 endif
9 endif
10
11 RTE_SPHINX_BUILD = sphinx-build
12 RTE_PDFLATEX_VERBOSE := --interaction=nonstopmode
13
14 ifndef V
15 RTE_SPHINX_VERBOSE := -q
16 RTE_PDFLATEX_VERBOSE := --interaction=batchmode
17 RTE_INKSCAPE_VERBOSE := >/dev/null 2>&1
18 endif
19 ifeq '$V' '0'
20 RTE_SPHINX_VERBOSE := -q
21 RTE_PDFLATEX_VERBOSE := --interaction=batchmode
22 RTE_INKSCAPE_VERBOSE := >/dev/null 2>&1
23 endif
24
25 RTE_PDF_DPI ?= 300
26
27 RTE_GUIDES := $(filter %/, $(wildcard $(RTE_SDK)/doc/guides/*/))
28
29 API_EXAMPLES := $(RTE_OUTPUT)/doc/html/examples.dox
30
31 .PHONY: help
32 help:
33         @cat $(RTE_SDK)/doc/build-sdk-quick.txt
34         @$(MAKE) -rR showconfigs | sed 's,^,\t\t\t\t,'
35
36 .PHONY: all
37 all: api-html guides-html guides-pdf
38
39 .PHONY: clean
40 clean: api-html-clean guides-html-clean guides-pdf-clean guides-man-clean
41
42 .PHONY: api-html
43 api-html: $(API_EXAMPLES)
44         @echo 'doxygen for API...'
45         $(Q)mkdir -p $(RTE_OUTPUT)/doc/html
46         $(Q)(sed -e "s|@VERSION@|`$(MAKE) -rRs showversion`|" \
47                  -e "s|@API_EXAMPLES@|$(API_EXAMPLES)|"       \
48                  -e "s|@OUTPUT@|$(RTE_OUTPUT)/doc|"           \
49                  -e "s|@HTML_OUTPUT@|html/api|"               \
50                  -e "s|@TOPDIR@|./|g"                         \
51                  -e "s|@STRIP_FROM_PATH@|./|g"                \
52                  $(RTE_SDK)/doc/api/doxy-api.conf.in)|        \
53             doxygen -
54         $(Q)$(RTE_SDK)/doc/api/doxy-html-custom.sh $(RTE_OUTPUT)/doc/html/api/doxygen.css
55
56 .PHONY: api-html-clean
57 api-html-clean:
58         $(Q)rm -f $(API_EXAMPLES)
59         $(Q)rm -f $(RTE_OUTPUT)/doc/html/api/*
60         $(Q)rmdir -p --ignore-fail-on-non-empty $(RTE_OUTPUT)/doc/html/api 2>&- || true
61
62 $(API_EXAMPLES): api-html-clean
63         $(Q)mkdir -p $(@D)
64         $(Q)doc/api/generate_examples.sh examples $(API_EXAMPLES)
65
66 guides-pdf-clean: guides-pdf-img-clean
67 guides-pdf-img-clean:
68         $(Q)rm -f $(RTE_SDK)/doc/guides/*/img/*.pdf
69
70 guides-%-clean:
71         $(Q)rm -rf $(RTE_OUTPUT)/doc/$*/guides
72         $(Q)rmdir -p --ignore-fail-on-non-empty $(RTE_OUTPUT)/doc/$* 2>&- || true
73
74 guides-pdf: $(addprefix guides-pdf-, $(notdir $(RTE_GUIDES:/=))) ;
75 guides-pdf-%:
76         @echo 'sphinx processing $@...'
77         $(Q)$(RTE_SPHINX_BUILD) -b latex $(RTE_SPHINX_VERBOSE) \
78                 -c $(RTE_SDK)/doc/guides $(RTE_SDK)/doc/guides/$* \
79                 $(RTE_OUTPUT)/doc/pdf/guides/$*
80         $(if $^,$(Q)rm -f $^)
81         @echo 'pdflatex processing $@...'
82         $(Q)$(MAKE) all-pdf -sC $(RTE_OUTPUT)/doc/pdf/guides/$* \
83                 LATEXOPTS=$(RTE_PDFLATEX_VERBOSE)
84         $(Q)mv $(RTE_OUTPUT)/doc/pdf/guides/$*/doc.pdf \
85                 $(RTE_OUTPUT)/doc/pdf/guides/$*.pdf
86
87 guides-html-prepare:
88         $(Q)install -D -m0644 $(RTE_SDK)/doc/guides/custom.css \
89                 $(RTE_OUTPUT)/doc/html/guides/_static/css/custom.css
90
91 guides-%-prepare: ;
92
93 guides-%: guides-%-prepare
94         @echo 'sphinx processing $@...'
95         $(Q)$(RTE_SPHINX_BUILD) -b $* $(RTE_SPHINX_VERBOSE) \
96                 -c $(RTE_SDK)/doc/guides $(RTE_SDK)/doc/guides \
97                 $(RTE_OUTPUT)/doc/$*/guides
98
99 # Each PDF depends on generated images *.pdf from *.svg
100 $(foreach guide, $(RTE_GUIDES), $(foreach img, $(wildcard $(guide)img/*.svg), \
101         $(eval guides-pdf-$(notdir $(guide:/=)): $(img:svg=pdf))))
102 %.pdf: %.svg
103         $(Q)inkscape -d $(RTE_PDF_DPI) -D -f $< -A $@ $(RTE_INKSCAPE_VERBOSE)