doc: whitespace changes in licenses
[dpdk.git] / mk / rte.doc.mk
1 #   BSD LICENSE
2
3 #   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
4 #   All rights reserved.
5
6 #   Redistribution and use in source and binary forms, with or without
7 #   modification, are permitted provided that the following conditions
8 #   are met:
9
10 #     * Redistributions of source code must retain the above copyright
11 #       notice, this list of conditions and the following disclaimer.
12 #     * Redistributions in binary form must reproduce the above copyright
13 #       notice, this list of conditions and the following disclaimer in
14 #       the documentation and/or other materials provided with the
15 #       distribution.
16 #     * Neither the name of Intel Corporation nor the names of its
17 #       contributors may be used to endorse or promote products derived
18 #       from this software without specific prior written permission.
19
20 #   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 #   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 #   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 #   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 #   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 #   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 #   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 DEFAULT_DPI ?= 300
33
34 ifeq ($(BASEDOCDIR),)
35 $(error "must be called from RTE root Makefile")
36 endif
37 ifeq ($(DOCDIR),)
38 $(error "must be called from RTE root Makefile")
39 endif
40
41 VPATH = $(abspath $(BASEDOCDIR)/$(DOCDIR))
42
43 pngfiles = $(patsubst %.svg,%.png,$(SVG))
44 pdfimgfiles = $(patsubst %.svg,%.pdf,$(SVG))
45 pdffiles = $(patsubst %.rst,%.pdf,$(RST))
46
47 .PHONY: all doc clean
48
49 compare = $(strip $(subst $(1),,$(2)) $(subst $(2),,$(1)))
50 dirname = $(patsubst %/,%,$(dir $1))
51
52 # windows only: this is needed for native programs that do not handle
53 # unix-like paths on win32
54 ifdef COMSPEC
55 winpath = "$(shell cygpath --windows $(abspath $(1)))"
56 else
57 winpath = $(1)
58 endif
59
60 all doc: $(pngfiles) $(pdffiles) $(DIRS)
61         @true
62
63 pdfdoc: $(pngfiles) $(pdffiles) $(DIRS)
64         @true
65
66 doxydoc: $(pdfimgfiles) $(DIRS)
67         @true
68
69 .PHONY: $(DIRS)
70 $(DIRS):
71         @[ -d $(CURDIR)/$@ ] || mkdir -p $(CURDIR)/$@
72         $(Q)$(MAKE) DOCDIR=$(DOCDIR)/$@ BASEDOCDIR=$(BASEDOCDIR)/.. \
73                 -f $(RTE_SDK)/doc/$(DOCDIR)/$@/Makefile -C $(CURDIR)/$@ $(MAKECMDGOALS)
74
75 %.png: %.svg
76         @echo "  INKSCAPE $(@)"
77         $(Q)inkscape -d $(DEFAULT_DPI) -D -b ffffff -y 1.0 -e $(call winpath,$(@)) $(call winpath,$(<))
78
79 %.pdf: %.svg
80         @echo "  INKSCAPE $(@)"
81         $(Q)inkscape -d $(DEFAULT_DPI) -D -b ffffff -y 1.0 -A $(call winpath,$(@)) $(call winpath,$(<))
82
83 .SECONDEXPANSION:
84 $(foreach f,$(RST),$(eval DEP_$(f:%.rst=%.html) = $(DEP_$(f))))
85 %.html: %.rst $$(DEP_$$@)
86         @echo "  RST2HTML $(@)"
87         $(Q)mkdir -p `dirname $(@)` ; \
88         python $(BASEDOCDIR)/gen/gen-common.py html $(BASEDOCDIR) > $(BASEDOCDIR)/gen/rte.rst ; \
89         python $(BASEDOCDIR)/html/rst2html-highlight.py --link-stylesheet \
90                 --stylesheet-path=$(BASEDOCDIR)/html/rte.css \
91                 --strip-comments< $(<) > $(@) ; \
92
93 # there is a bug in rst2pdf (issue 311): replacement of DSTDIR is not
94 # what we expect: we should not have to add doc/
95 ifdef COMSPEC
96 WORKAROUND_PATH=$(BASEDOCDIR)
97 else
98 WORKAROUND_PATH=$(BASEDOCDIR)/doc
99 endif
100
101 .SECONDEXPANSION:
102 $(foreach f,$(RST),$(eval DEP_$(f:%.rst=%.pdf) = $(DEP_$(f))))
103 %.pdf: %.rst $$(DEP_$$@)
104         @echo "  RST2PDF $(@)"
105         $(Q)mkdir -p `dirname $(@)` ; \
106         python $(BASEDOCDIR)/gen/gen-common.py pdf $(BASEDOCDIR) > $(BASEDOCDIR)/gen/rte.rst ; \
107         rst2pdf -s $(BASEDOCDIR)/pdf/rte-stylesheet.json \
108                 --default-dpi=300 < $(<) > $(@)
109
110 CLEANDIRS = $(addsuffix _clean,$(DIRS))
111
112 docclean clean: $(CLEANDIRS)
113         @rm -f $(htmlfiles) $(pdffiles) $(pngfiles) $(pdfimgfiles) $(BASEDOCDIR)/gen/rte.rst
114
115 %_clean:
116         @if [ -f $(RTE_SDK)/doc/$(DOCDIR)/$*/Makefile -a -d $(CURDIR)/$* ]; then \
117                 $(MAKE) DOCDIR=$(DOCDIR)/$* BASEDOCDIR=$(BASEDOCDIR)/.. \
118                 -f $(RTE_SDK)/doc/$(DOCDIR)/$*/Makefile -C $(CURDIR)/$* clean ; \
119         fi
120
121 .NOTPARALLEL: