Imported Upstream version 16.11
[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 .PHONY: help
58 help:
59         @cat $(RTE_SDK)/doc/build-sdk-quick.txt
60         @$(MAKE) -rR showconfigs | sed 's,^,\t\t\t\t,'
61
62 .PHONY: all
63 all: api-html guides-html guides-pdf
64
65 .PHONY: clean
66 clean: api-html-clean guides-html-clean guides-pdf-clean guides-man-clean
67
68 .PHONY: api-html
69 api-html: api-html-clean
70         @echo 'doxygen for API...'
71         $(Q)mkdir -p $(RTE_OUTPUT)/doc/html
72         $(Q)(cat $(RTE_SDK)/doc/api/doxy-api.conf     && \
73             printf 'PROJECT_NUMBER = '                && \
74                               $(MAKE) -rR showversion && \
75             echo OUTPUT_DIRECTORY = $(RTE_OUTPUT)/doc && \
76             echo HTML_OUTPUT      = html/api          && \
77             echo GENERATE_HTML    = YES               && \
78             echo GENERATE_LATEX   = NO                && \
79             echo GENERATE_MAN     = NO                )| \
80             doxygen -
81         $(Q)$(RTE_SDK)/doc/api/doxy-html-custom.sh $(RTE_OUTPUT)/doc/html/api/doxygen.css
82
83 .PHONY: api-html-clean
84 api-html-clean:
85         $(Q)rm -f $(RTE_OUTPUT)/doc/html/api/*
86         $(Q)rmdir -p --ignore-fail-on-non-empty $(RTE_OUTPUT)/doc/html/api 2>&- || true
87
88 guides-pdf-clean: guides-pdf-img-clean
89 guides-pdf-img-clean:
90         $(Q)rm -f $(RTE_SDK)/doc/guides/*/img/*.pdf
91
92 guides-%-clean:
93         $(Q)rm -rf $(RTE_OUTPUT)/doc/$*/guides
94         $(Q)rmdir -p --ignore-fail-on-non-empty $(RTE_OUTPUT)/doc/$* 2>&- || true
95
96 guides-pdf: $(addprefix guides-pdf-, $(notdir $(RTE_GUIDES:/=))) ;
97 guides-pdf-%:
98         @echo 'sphinx processing $@...'
99         $(Q)$(RTE_SPHINX_BUILD) -b latex $(RTE_SPHINX_VERBOSE) \
100                 -c $(RTE_SDK)/doc/guides $(RTE_SDK)/doc/guides/$* \
101                 $(RTE_OUTPUT)/doc/pdf/guides/$*
102         $(if $^,$(Q)rm -f $^)
103         @echo 'pdflatex processing $@...'
104         $(Q)$(MAKE) all-pdf -sC $(RTE_OUTPUT)/doc/pdf/guides/$* \
105                 LATEXOPTS=$(RTE_PDFLATEX_VERBOSE)
106         $(Q)mv $(RTE_OUTPUT)/doc/pdf/guides/$*/doc.pdf \
107                 $(RTE_OUTPUT)/doc/pdf/guides/$*.pdf
108
109 guides-%:
110         @echo 'sphinx processing $@...'
111         $(Q)$(RTE_SPHINX_BUILD) -b $* $(RTE_SPHINX_VERBOSE) \
112                 -c $(RTE_SDK)/doc/guides $(RTE_SDK)/doc/guides \
113                 $(RTE_OUTPUT)/doc/$*/guides
114
115 # Each PDF depends on generated images *.pdf from *.svg
116 $(foreach guide, $(RTE_GUIDES), $(foreach img, $(wildcard $(guide)img/*.svg), \
117         $(eval guides-pdf-$(notdir $(guide:/=)): $(img:svg=pdf))))
118 %.pdf: %.svg
119         $(Q)inkscape -d $(RTE_PDF_DPI) -D -f $< -A $@ $(RTE_INKSCAPE_VERBOSE)