New upstream version 18.02
[deb_dpdk.git] / mk / rte.sdkdoc.mk
1 #   BSD LICENSE
2 #
3 #   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
4 #   Copyright(c) 2013-2015 6WIND S.A.
5 #   All rights reserved.
6 #
7 #   Redistribution and use in source and binary forms, with or without
8 #   modification, are permitted provided that the following conditions
9 #   are met:
10 #
11 #     * Redistributions of source code must retain the above copyright
12 #       notice, this list of conditions and the following disclaimer.
13 #     * Redistributions in binary form must reproduce the above copyright
14 #       notice, this list of conditions and the following disclaimer in
15 #       the documentation and/or other materials provided with the
16 #       distribution.
17 #     * Neither the name of Intel Corporation nor the names of its
18 #       contributors may be used to endorse or promote products derived
19 #       from this software without specific prior written permission.
20 #
21 #   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 #   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 #   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 #   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 #   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 #   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 #   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 ifdef T
34 ifeq ("$(origin T)", "command line")
35 $(error "Cannot use T= with doc target")
36 endif
37 endif
38
39 RTE_SPHINX_BUILD = sphinx-build
40 RTE_PDFLATEX_VERBOSE := --interaction=nonstopmode
41
42 ifndef V
43 RTE_SPHINX_VERBOSE := -q
44 RTE_PDFLATEX_VERBOSE := --interaction=batchmode
45 RTE_INKSCAPE_VERBOSE := >/dev/null 2>&1
46 endif
47 ifeq '$V' '0'
48 RTE_SPHINX_VERBOSE := -q
49 RTE_PDFLATEX_VERBOSE := --interaction=batchmode
50 RTE_INKSCAPE_VERBOSE := >/dev/null 2>&1
51 endif
52
53 RTE_PDF_DPI ?= 300
54
55 RTE_GUIDES := $(filter %/, $(wildcard $(RTE_SDK)/doc/guides/*/))
56
57 API_EXAMPLES := $(RTE_OUTPUT)/doc/html/examples.dox
58
59 .PHONY: help
60 help:
61         @cat $(RTE_SDK)/doc/build-sdk-quick.txt
62         @$(MAKE) -rR showconfigs | sed 's,^,\t\t\t\t,'
63
64 .PHONY: all
65 all: api-html guides-html guides-pdf
66
67 .PHONY: clean
68 clean: api-html-clean guides-html-clean guides-pdf-clean guides-man-clean
69
70 .PHONY: api-html
71 api-html: $(API_EXAMPLES)
72         @echo 'doxygen for API...'
73         $(Q)mkdir -p $(RTE_OUTPUT)/doc/html
74         $(Q)(cat $(RTE_SDK)/doc/api/doxy-api.conf     && \
75             printf 'PROJECT_NUMBER = '                && \
76                              $(MAKE) -rRs showversion && \
77             echo INPUT           += $(API_EXAMPLES)   && \
78             echo OUTPUT_DIRECTORY = $(RTE_OUTPUT)/doc && \
79             echo HTML_OUTPUT      = html/api          && \
80             echo GENERATE_HTML    = YES               && \
81             echo GENERATE_LATEX   = NO                && \
82             echo GENERATE_MAN     = NO                )| \
83             doxygen -
84         $(Q)$(RTE_SDK)/doc/api/doxy-html-custom.sh $(RTE_OUTPUT)/doc/html/api/doxygen.css
85
86 .PHONY: api-html-clean
87 api-html-clean:
88         $(Q)rm -f $(API_EXAMPLES)
89         $(Q)rm -f $(RTE_OUTPUT)/doc/html/api/*
90         $(Q)rmdir -p --ignore-fail-on-non-empty $(RTE_OUTPUT)/doc/html/api 2>&- || true
91
92 $(API_EXAMPLES): api-html-clean
93         $(Q)mkdir -p $(@D)
94         @printf '/**\n' > $(API_EXAMPLES)
95         @printf '@page examples DPDK Example Programs\n\n' >> $(API_EXAMPLES)
96         @find examples -type f -name '*.c' -printf '@example %p\n' | LC_ALL=C sort >> $(API_EXAMPLES)
97         @printf '*/\n' >> $(API_EXAMPLES)
98
99 guides-pdf-clean: guides-pdf-img-clean
100 guides-pdf-img-clean:
101         $(Q)rm -f $(RTE_SDK)/doc/guides/*/img/*.pdf
102
103 guides-%-clean:
104         $(Q)rm -rf $(RTE_OUTPUT)/doc/$*/guides
105         $(Q)rmdir -p --ignore-fail-on-non-empty $(RTE_OUTPUT)/doc/$* 2>&- || true
106
107 guides-pdf: $(addprefix guides-pdf-, $(notdir $(RTE_GUIDES:/=))) ;
108 guides-pdf-%:
109         @echo 'sphinx processing $@...'
110         $(Q)$(RTE_SPHINX_BUILD) -b latex $(RTE_SPHINX_VERBOSE) \
111                 -c $(RTE_SDK)/doc/guides $(RTE_SDK)/doc/guides/$* \
112                 $(RTE_OUTPUT)/doc/pdf/guides/$*
113         $(if $^,$(Q)rm -f $^)
114         @echo 'pdflatex processing $@...'
115         $(Q)$(MAKE) all-pdf -sC $(RTE_OUTPUT)/doc/pdf/guides/$* \
116                 LATEXOPTS=$(RTE_PDFLATEX_VERBOSE)
117         $(Q)mv $(RTE_OUTPUT)/doc/pdf/guides/$*/doc.pdf \
118                 $(RTE_OUTPUT)/doc/pdf/guides/$*.pdf
119
120 guides-html-prepare:
121         $(Q)install -D -m0644 $(RTE_SDK)/doc/guides/custom.css \
122                 $(RTE_OUTPUT)/doc/html/guides/_static/css/custom.css
123
124 guides-%-prepare: ;
125
126 guides-%: guides-%-prepare
127         @echo 'sphinx processing $@...'
128         $(Q)$(RTE_SPHINX_BUILD) -b $* $(RTE_SPHINX_VERBOSE) \
129                 -c $(RTE_SDK)/doc/guides $(RTE_SDK)/doc/guides \
130                 $(RTE_OUTPUT)/doc/$*/guides
131
132 # Each PDF depends on generated images *.pdf from *.svg
133 $(foreach guide, $(RTE_GUIDES), $(foreach img, $(wildcard $(guide)img/*.svg), \
134         $(eval guides-pdf-$(notdir $(guide:/=)): $(img:svg=pdf))))
135 %.pdf: %.svg
136         $(Q)inkscape -d $(RTE_PDF_DPI) -D -f $< -A $@ $(RTE_INKSCAPE_VERBOSE)