1
2##-------------------------------------------------------------
3## HACK: stuff to avoid making the print docs if installing the
4## tools to do so is impractical / too difficult
5##-------------------------------------------------------------
6
7# Comment out the next line to skip building print docs.  The default
8# is not to skip building print docs.  Note, after changing it
9# you need to re-run autogen.sh and configure to make it take effect.
10BUILD_ALL_DOCS=yes
11
12##-------------------------------------------------------------
13## END OF HACK
14##-------------------------------------------------------------
15
16EXTRA_DIST = \
17	README \
18	images/home.png \
19	images/next.png \
20	images/prev.png \
21	images/up.png \
22	internals/3_0_BUGSTATUS.txt \
23	internals/3_1_BUGSTATUS.txt \
24	internals/3_2_BUGSTATUS.txt \
25	internals/3_3_BUGSTATUS.txt \
26	internals/3_4_BUGSTATUS.txt \
27	internals/3_5_BUGSTATUS.txt \
28	internals/3_7_BUGSTATUS.txt \
29	internals/3_8_BUGSTATUS.txt \
30	internals/3_9_BUGSTATUS.txt \
31	internals/3_10_BUGSTATUS.txt \
32	internals/MERGE_3_10_1.txt \
33	internals/arm_thumb_notes_gdbserver.txt \
34	internals/avx-notes.txt \
35	internals/BIG_APP_NOTES.txt \
36	internals/Darwin-notes.txt \
37	internals/SPEC-notes.txt \
38	internals/directory-structure.txt \
39	internals/howto_BUILD_KDE42.txt \
40	internals/howto_oprofile.txt \
41	internals/m_replacemalloc.txt \
42	internals/m_syswrap.txt \
43	internals/module-structure.txt \
44	internals/multiple-architectures.txt \
45	internals/notes.txt \
46	internals/performance.txt \
47	internals/porting-HOWTO.txt \
48	internals/mpi2entries.txt \
49	internals/porting-to-ARM.txt \
50	internals/qemu-aarch64-linux-HOWTO.txt \
51	internals/qemu-mips64-linux-HOWTO.txt \
52	internals/register-uses.txt \
53	internals/release-HOWTO.txt \
54	internals/segments-seginfos.txt \
55	internals/t-chaining-notes.txt \
56	internals/threads-syscalls-signals.txt \
57	internals/tm-mutexstates.dot \
58	internals/tm-threadstates.dot \
59	internals/tracking-fn-entry-exit.txt \
60	internals/why-no-libc.txt \
61	internals/xml-output.txt \
62	internals/xml-output-protocol4.txt \
63	lib/line-wrap.xsl \
64	lib/vg_basic.css \
65	lib/vg-fo.xsl \
66	lib/vg-faq2txt.xsl \
67	lib/vg-html-chunk.xsl \
68	lib/vg-html-website.xsl \
69	lib/vg-html-common.xsl \
70	xml/FAQ.xml \
71	xml/dist-docs.xml \
72	xml/index.xml \
73	xml/licenses.xml \
74	xml/manpages-index.xml \
75	xml/manual.xml \
76	xml/manual-intro.xml \
77	xml/manual-core.xml \
78	xml/manual-core-adv.xml \
79	xml/manual-writing-tools.xml \
80	xml/design-impl.xml \
81	xml/quick-start-guide.xml \
82	xml/tech-docs.xml \
83	xml/valgrind-manpage.xml \
84	xml/vg-entities.xml \
85	xml/xml_help.txt
86
87
88##-------------------------------------------------------------------
89## Below here is more ordinary make stuff...
90##-------------------------------------------------------------------
91myxmldir   = $(top_srcdir)/docs/xml
92myimgdir   = $(top_srcdir)/docs/images
93mylibdir   = $(top_srcdir)/docs/lib
94
95myhtmldir  = $(top_builddir)/docs/html
96myprintdir = $(top_builddir)/docs/print
97
98websitedir   = $(top_builddir)/docs/website
99valkyriedir  = $(top_builddir)/docs/vg-html
100downloadsdir = $(top_builddir)/docs/downloads
101vgdir        = $(top_builddir)/docs/valgrind
102
103XML_CATALOG_FILES = /etc/xml/catalog
104
105# file to log print output to
106LOGFILE = print.log
107
108# validation stuff
109XMLLINT       = xmllint
110LINT_FLAGS    = --noblanks --noout --xinclude --postvalid --noent
111# validate with docbook 4.3 'cos it supports xml:base natively
112VALID_FLAGS   = --dtdvalid http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd
113XMLLINT_FLAGS = $(LINT_FLAGS) $(VALID_FLAGS)
114
115# stylesheet processor
116XSLTPROC       = xsltproc
117XSLTPROC_FLAGS = --nonet --xinclude
118
119# stylesheets
120XSL_HTML_CHUNK_STYLE  = $(mylibdir)/vg-html-chunk.xsl
121XSL_FO_STYLE          = $(mylibdir)/vg-fo.xsl
122XSL_TEXT_STYLE        = $(mylibdir)/vg-faq2txt.xsl
123XSL_WEBSITE_STYLE     = $(mylibdir)/vg-html-website.xsl
124XSL_MAN_STYLES = \
125    /usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl \
126    /usr/share/xml/docbook/stylesheet/nwalsh/current/manpages/docbook.xsl \
127    /usr/share/xml/docbook/stylesheet/nwalsh/manpages/docbook.xsl
128
129all-docs: FAQ.txt man-pages html-docs print-docs
130
131valid:
132	$(XMLLINT) $(XMLLINT_FLAGS) $(myxmldir)/index.xml
133
134# The text version of the FAQ.
135FAQ.txt:
136	@echo "Generating the text version of the FAQ ..."
137	export XML_CATALOG_FILES=$(XML_CATALOG_FILES) && \
138	$(XSLTPROC) $(XSLTPROC_FLAGS) -o ./FAQ.txt $(XSL_TEXT_STYLE) $(myxmldir)/FAQ.xml
139
140# the valgrind manpages
141man-pages:
142	set -e; \
143	for x in $(XSL_MAN_STYLES) ; do \
144	    if test -f $$x; then \
145		echo "Using manpage stylesheet: $$x"; \
146		export XML_CATALOG_FILES=$(XML_CATALOG_FILES) && \
147		$(XSLTPROC) $(XSLTPROC_FLAGS) -o ./ $$x $(myxmldir)/manpages-index.xml; \
148		exit 0; \
149	    fi; \
150	done; \
151	echo ""; \
152	echo "Error: I can't find the XSL_MAN_STYLE file";     \
153	echo "Please check where it lives on your system, and"      \
154	     "amend the line 'XSL_MAN_STYLES = ' in this Makefile."; \
155	exit 1;
156
157# chunked html, on a chapter-by-chapter basis
158html-docs:
159	@echo "Generating html files..."
160	export XML_CATALOG_FILES=$(XML_CATALOG_FILES) && \
161	mkdir -p $(myhtmldir) && \
162	/bin/rm -fr $(myhtmldir)/ && \
163	mkdir -p $(myhtmldir)/ && \
164	mkdir -p $(myhtmldir)/images && \
165	cp $(mylibdir)/vg_basic.css $(myhtmldir)/ && \
166	cp $(myimgdir)/*.png $(myhtmldir)/images && \
167	$(XSLTPROC) $(XSLTPROC_FLAGS) -o $(myhtmldir)/ $(XSL_HTML_CHUNK_STYLE) $(myxmldir)/index.xml
168
169# pdf and postscript
170print-docs:
171	@echo "Generating PDF file: $(myprintdir)/index.pdf (please be patient)...";
172	export XML_CATALOG_FILES=$(XML_CATALOG_FILES) && \
173	mkdir -p $(myprintdir) && \
174	mkdir -p $(myprintdir)/images && \
175	$(XSLTPROC) $(XSLTPROC_FLAGS) -o $(myprintdir)/index.fo $(XSL_FO_STYLE) $(myxmldir)/index.xml && \
176	(cd $(myprintdir) && \
177         ( pdfxmltex index.fo && \
178	   pdfxmltex index.fo && \
179	   pdfxmltex index.fo ) &> $(LOGFILE) < /dev/null && \
180	 echo "Generating PS file: $(myprintdir)/index.ps ..." && \
181	 pdftops index.pdf && \
182	 rm -f *.log *.aux *.fo *.out)
183
184# If the docs have been built, install them.  But don't worry if they have
185# not -- developers do 'make install' not from a 'make dist'-ified distro all
186# the time.
187#
188# Note: this is done at 'make install' time.
189# Note 2: the ifeq/else/endif have to be indented one space
190# because otherwise it seems that automake thinks it should
191# be the one to handle the else/endif parts, not GNU make
192# as we intend.
193install-data-hook:
194	set -e; \
195	if test -r html ; then \
196		mkdir -p $(DESTDIR)$(datadir)/doc/valgrind; \
197		cp -r html $(DESTDIR)$(datadir)/doc/valgrind; \
198	fi
199	for f in *.1 ; do \
200		if test -r $$f ; then \
201			mkdir -p $(DESTDIR)$(mandir)/man1; \
202			cp $$f $(DESTDIR)$(mandir)/man1; \
203		fi \
204	done
205 ifeq ($(BUILD_ALL_DOCS),yes)
206	set -e; \
207	if test -r index.pdf ; then \
208		mkdir -p $(DESTDIR)$(datadir)/doc/valgrind; \
209		cp index.pdf $(DESTDIR)$(datadir)/doc/valgrind/valgrind_manual.pdf; \
210	fi
211	set -e; \
212	if test -r index.ps ; then \
213		mkdir -p $(DESTDIR)$(datadir)/doc/valgrind; \
214		cp index.ps $(DESTDIR)$(datadir)/doc/valgrind/valgrind_manual.ps; \
215	fi
216 endif
217
218# This is done at 'make dist' time.  It builds the html docs, print
219# docs and man pages and copies them into the docs/ directory in the
220# tarball.
221 ifeq ($(BUILD_ALL_DOCS),yes)
222dist-hook: FAQ.txt html-docs man-pages print-docs
223	cp -r html $(distdir)
224	cp FAQ.txt $(distdir)/..
225	cp *.1 $(distdir)
226	cp print/index.pdf $(distdir)
227	cp print/index.ps $(distdir)
228 else
229dist-hook: FAQ.txt html-docs man-pages
230	cp -r html $(distdir)
231	cp FAQ.txt $(distdir)/..
232	cp *.1 $(distdir)
233 endif
234
235distclean-local:
236	rm -rf html print
237	rm -f FAQ.txt
238	rm -f $(top_builddir)/FAQ.txt $(top_builddir)/docs/*.1
239
240
241
242# -----------------------------------------------------------------------
243# Note: the rest of this file is nothing to do with the normal build
244# tree.  The stuff below contains special targets for web-site
245# artefacts.
246
247# chunked html with no html/body tags, css, or top nav, to fit into the website
248website-docs:
249	@echo "Generating website html files ..."
250	export XML_CATALOG_FILES=$(XML_CATALOG_FILES)
251	/bin/rm -fr $(websitedir)
252	mkdir -p $(websitedir)
253	$(XSLTPROC) $(XSLTPROC_FLAGS) -o $(websitedir)/ $(XSL_WEBSITE_STYLE) $(myxmldir)/index.xml
254
255# valkyrie carries around her own copy of the valgrind manual
256valkyrie-docs:
257	@echo "Generating a set of valgrind docs for valkyrie..."
258	export XML_CATALOG_FILES=$(XML_CATALOG_FILES)
259	/bin/rm -fr $(valkyriedir)
260	mkdir -p $(valkyriedir)
261	mkdir -p $(valkyriedir)/images
262	cp $(mylibdir)/vg_basic.css $(valkyriedir)/
263	cp $(myimgdir)/*.png $(valkyriedir)/images/
264	$(XSLTPROC) $(XSLTPROC_FLAGS) -o $(valkyriedir)/ $(XSL_HTML_CHUNK_STYLE) $(myxmldir)/index.xml
265
266# html.tar.bz2, .pdf, .ps.bz2 files for downloading from the website
267download-docs:
268	export XML_CATALOG_FILES=$(XML_CATALOG_FILES)
269	/bin/rm -fr $(downloadsdir)
270	mkdir -p $(downloadsdir)
271	@echo ""
272	@echo "Generating valgrind_manual.html.tar.bz2 ..."
273	export XML_CATALOG_FILES=$(XML_CATALOG_FILES)
274	/bin/rm -fr $(vgdir)
275	mkdir -p $(vgdir)
276	mkdir -p $(vgdir)/html
277	mkdir -p $(vgdir)/html/images
278	cp $(mylibdir)/vg_basic.css $(vgdir)/html/
279	cp $(myimgdir)/*.png $(vgdir)/html/images/
280	$(XSLTPROC) $(XSLTPROC_FLAGS) -o $(vgdir)/html/ $(XSL_HTML_CHUNK_STYLE) $(myxmldir)/index.xml
281	(cd $(top_builddir)/docs/ && \
282		(tar cfj $(downloadsdir)/valgrind_manual.html.tar.bz2 ./valgrind/html/ ) )
283	/bin/rm -fr $(vgdir)/html/
284	@echo ""
285	@echo "Generating valgrind_manual.pdf ..."
286	mkdir -p $(vgdir)/print
287	mkdir -p $(vgdir)/print/images
288	$(XSLTPROC) $(XSLTPROC_FLAGS) -o $(vgdir)/print/manual.fo $(XSL_FO_STYLE) $(myxmldir)/index.xml
289	(cd $(vgdir)/print/ && \
290		( pdfxmltex manual.fo && \
291		  pdfxmltex manual.fo && \
292		  pdfxmltex manual.fo ) &> $(LOGFILE) < /dev/null )
293	@echo ""
294	@echo "Generating valgrind_manual.ps.bz2 ..."
295	(cd $(vgdir)/print/ && \
296		( pdftops manual.pdf ) )
297	mv $(vgdir)/print/manual.pdf $(downloadsdir)/valgrind_manual.pdf
298	mv $(vgdir)/print/manual.ps $(downloadsdir)/valgrind_manual.ps
299	bzip2 $(downloadsdir)/valgrind_manual.ps
300	/bin/rm -fr $(vgdir)
301