diff mbox

[dpdk-dev,v3,1/4] mk: Add 'make doc-pdf' target to convert guide docs to pdf

Message ID 1422882967-27060-2-git-send-email-john.mcnamara@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Mcnamara, John Feb. 2, 2015, 1:16 p.m. UTC
Added make system support for building PDF versions of
the guides. Requires Python Sphinx and TexLive Full.

Signed-off-by: John McNamara <john.mcnamara@intel.com>
---
 mk/rte.sdkdoc.mk |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)
diff mbox

Patch

diff --git a/mk/rte.sdkdoc.mk b/mk/rte.sdkdoc.mk
index dabc0d6..41e9391 100644
--- a/mk/rte.sdkdoc.mk
+++ b/mk/rte.sdkdoc.mk
@@ -37,13 +37,24 @@  endif
 endif
 
 RTE_SPHINX_BUILD = sphinx-build
+RTE_PDFLATEX_VERBOSE := --interaction=nonstopmode
+
 ifndef V
 RTE_SPHINX_VERBOSE := -q
+RTE_PDFLATEX_VERBOSE := --interaction=batchmode
+RTE_INKSCAPE_VERBOSE := > /dev/null 2>&1
 endif
 ifeq '$V' '0'
 RTE_SPHINX_VERBOSE := -q
+RTE_PDFLATEX_VERBOSE := --interaction=batchmode
+RTE_INKSCAPE_VERBOSE := > /dev/null 2>&1
 endif
 
+RTE_GUIDE_PDFS := $(filter %/, $(wildcard $(RTE_SDK)/doc/guides/*/))
+RTE_GUIDE_PDFS := $(RTE_GUIDE_PDFS:$(RTE_SDK)/doc/guides%=$(RTE_OUTPUT)/doc/latex/guides%)
+RTE_GUIDE_PDFS := $(RTE_GUIDE_PDFS:%/=%.pdf)
+RTE_DEFAULT_DPI ?= 300
+
 .PHONY: help
 help:
 	@cat $(RTE_SDK)/doc/build-sdk-quick.txt
@@ -53,7 +64,7 @@  help:
 all: api-html guides-html
 
 .PHONY: clean
-clean: api-html-clean guides-html-clean
+clean: api-html-clean guides-html-clean guides-latex-clean
 
 .PHONY: api-html
 api-html: api-html-clean
@@ -83,3 +94,34 @@  guides-%:
 	@echo 'sphinx for guides...'
 	$(Q)$(RTE_SPHINX_BUILD) -b $* $(RTE_SPHINX_VERBOSE) \
 		-c $(RTE_SDK)/doc/guides $(RTE_SDK)/doc/guides $(RTE_OUTPUT)/doc/$*/guides
+
+
+pdf: $(RTE_GUIDE_PDFS)
+
+.SECONDEXPANSION:
+# Use wildcard expansion to avoid * expansion issue with make 3.82.
+$(RTE_OUTPUT)/doc/latex/guides/%.pdf: $$(wildcard $(RTE_SDK)/doc/guides/%/*.rst)
+	@echo 'creating' $* 'pdf ...'
+
+	@# Generate the latex files.
+	$(Q)$(RTE_SPHINX_BUILD) -b latex $(RTE_SPHINX_VERBOSE) \
+		-c $(RTE_SDK)/doc/guides  $(RTE_SDK)/doc/guides/$* \
+		$(RTE_OUTPUT)/doc/latex/guides/$*
+
+	@# Convert the svg files to png for pdflatex.
+	$(eval svg_files=$(notdir $(wildcard $(RTE_SDK)/doc/guides/$*/img/*.svg)))
+	$(Q)for svg in $(svg_files:.svg=); do \
+		inkscape -d $(RTE_DEFAULT_DPI) -D -b ffffff  \
+			-f $(RTE_SDK)/doc/guides/$*/img/$$svg.svg \
+			-e $(RTE_OUTPUT)/doc/latex/guides/$*/$$svg.png \
+				$(RTE_INKSCAPE_VERBOSE); \
+	done
+
+	@# Change the svg image includes to png in the latex docs.
+	$(Q)sed -i.bak 's/\.svg/.png/g' $(RTE_OUTPUT)/doc/latex/guides/$*/*.tex
+
+	@# Convert latex to pdf (from .tex dir to avoid image include issues).
+	$(Q)cd $(RTE_OUTPUT)/doc/latex/guides/$*; \
+		pdflatex $(RTE_PDFLATEX_VERBOSE) dpdk_doc.tex
+
+	$(Q)mv $(RTE_OUTPUT)/doc/latex/guides/$*/dpdk_doc.pdf $@