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