remove version in all files
[dpdk.git] / mk / rte.doc.mk
1 #   BSD LICENSE
2
3 #   Copyright(c) 2010-2012 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
33 DEFAULT_DPI ?= 300
34
35 ifeq ($(BASEDOCDIR),)
36 $(error "must be called from RTE root Makefile")
37 endif
38 ifeq ($(DOCDIR),)
39 $(error "must be called from RTE root Makefile")
40 endif
41
42 VPATH = $(abspath $(BASEDOCDIR)/$(DOCDIR))
43
44 pngfiles = $(patsubst %.svg,%.png,$(SVG))
45 pdfimgfiles = $(patsubst %.svg,%.pdf,$(SVG))
46 htmlfiles = $(patsubst %.rst,%.html,$(RST))
47 pdffiles = $(patsubst %.rst,%.pdf,$(RST))
48
49 .PHONY: all doc clean
50
51 compare = $(strip $(subst $(1),,$(2)) $(subst $(2),,$(1)))
52 dirname = $(patsubst %/,%,$(dir $1))
53
54 # windows only: this is needed for native programs that do not handle
55 # unix-like paths on win32
56 ifdef COMSPEC
57 winpath = "$(shell cygpath --windows $(abspath $(1)))"
58 else
59 winpath = $(1)
60 endif
61
62 all doc: $(pngfiles) $(htmlfiles) $(pdffiles) $(DIRS)
63         @true
64
65 htmldoc: $(pngfiles) $(htmlfiles) $(DIRS)
66         @true
67
68 pdfdoc: $(pngfiles) $(pdffiles) $(DIRS)
69         @true
70
71 doxydoc: $(pdfimgfiles) $(DIRS)
72         @true
73
74 .PHONY: $(DIRS)
75 $(DIRS):
76         @[ -d $(CURDIR)/$@ ] || mkdir -p $(CURDIR)/$@
77         $(Q)$(MAKE) DOCDIR=$(DOCDIR)/$@ BASEDOCDIR=$(BASEDOCDIR)/.. \
78                 -f $(RTE_SDK)/doc/$(DOCDIR)/$@/Makefile -C $(CURDIR)/$@ $(MAKECMDGOALS)
79
80 %.png: %.svg
81         @echo "  INKSCAPE $(@)"
82         $(Q)inkscape -d $(DEFAULT_DPI) -D -b ffffff -y 1.0 -e $(call winpath,$(@)) $(call winpath,$(<))
83
84 %.pdf: %.svg
85         @echo "  INKSCAPE $(@)"
86         $(Q)inkscape -d $(DEFAULT_DPI) -D -b ffffff -y 1.0 -A $(call winpath,$(@)) $(call winpath,$(<))
87
88 .SECONDEXPANSION:
89 $(foreach f,$(RST),$(eval DEP_$(f:%.rst=%.html) = $(DEP_$(f))))
90 %.html: %.rst $$(DEP_$$@)
91         @echo "  RST2HTML $(@)"
92         $(Q)mkdir -p `dirname $(@)` ; \
93         python $(BASEDOCDIR)/gen/gen-common.py html $(BASEDOCDIR) > $(BASEDOCDIR)/gen/rte.rst ; \
94         python $(BASEDOCDIR)/html/rst2html-highlight.py --link-stylesheet \
95                 --stylesheet-path=$(BASEDOCDIR)/html/rte.css \
96                 --strip-comments< $(<) > $(@) ; \
97
98 # there is a bug in rst2pdf (issue 311): replacement of DSTDIR is not
99 # what we expect: we should not have to add doc/
100 ifdef COMSPEC
101 WORKAROUND_PATH=$(BASEDOCDIR)
102 else
103 WORKAROUND_PATH=$(BASEDOCDIR)/doc
104 endif
105
106 .SECONDEXPANSION:
107 $(foreach f,$(RST),$(eval DEP_$(f:%.rst=%.pdf) = $(DEP_$(f))))
108 %.pdf: %.rst $$(DEP_$$@)
109         @echo "  RST2PDF $(@)"
110         $(Q)mkdir -p `dirname $(@)` ; \
111         python $(BASEDOCDIR)/gen/gen-common.py pdf $(BASEDOCDIR) > $(BASEDOCDIR)/gen/rte.rst ; \
112         rst2pdf -s $(BASEDOCDIR)/pdf/rte-stylesheet.json \
113                 --default-dpi=300 < $(<) > $(@)
114
115 CLEANDIRS = $(addsuffix _clean,$(DIRS))
116
117 docclean clean: $(CLEANDIRS)
118         @rm -f $(htmlfiles) $(pdffiles) $(pngfiles) $(pdfimgfiles) $(BASEDOCDIR)/gen/rte.rst
119
120 %_clean:
121         @if [ -f $(RTE_SDK)/doc/$(DOCDIR)/$*/Makefile -a -d $(CURDIR)/$* ]; then \
122                 $(MAKE) DOCDIR=$(DOCDIR)/$* BASEDOCDIR=$(BASEDOCDIR)/.. \
123                 -f $(RTE_SDK)/doc/$(DOCDIR)/$*/Makefile -C $(CURDIR)/$* clean ; \
124         fi
125
126 .NOTPARALLEL: