blob: f75175757892272847e97c22ef6493052450fb70 [file] [log] [blame]
Borislav Petkovaf3df2c2012-09-28 19:47:07 +02001include ../config/utilities.mak
2
Franck Bui-Huu762b2932012-02-06 16:17:23 +01003OUTPUT := ./
4ifeq ("$(origin O)", "command line")
5 ifneq ($(O),)
6 OUTPUT := $(O)/
7 endif
8endif
9
Ingo Molnarc1c23652009-05-30 12:38:51 +020010MAN1_TXT= \
11 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
12 $(wildcard perf-*.txt)) \
13 perf.txt
14MAN5_TXT=
15MAN7_TXT=
16
17MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
Franck Bui-Huu762b2932012-02-06 16:17:23 +010018_MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
19_MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
Ingo Molnarc1c23652009-05-30 12:38:51 +020020
Franck Bui-Huu762b2932012-02-06 16:17:23 +010021MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML))
22MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML))
Ingo Molnarc1c23652009-05-30 12:38:51 +020023
24ARTICLES =
25# with their own formatting rules.
26SP_ARTICLES =
27API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
28SP_ARTICLES += $(API_DOCS)
29SP_ARTICLES += technical/api-index
30
Franck Bui-Huu762b2932012-02-06 16:17:23 +010031_DOC_HTML = $(_MAN_HTML)
32_DOC_HTML+=$(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
33DOC_HTML=$(addprefix $(OUTPUT),$(_DOC_HTML))
Ingo Molnarc1c23652009-05-30 12:38:51 +020034
Franck Bui-Huu762b2932012-02-06 16:17:23 +010035_DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
36_DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
37_DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
38
39DOC_MAN1=$(addprefix $(OUTPUT),$(_DOC_MAN1))
40DOC_MAN5=$(addprefix $(OUTPUT),$(_DOC_MAN5))
41DOC_MAN7=$(addprefix $(OUTPUT),$(_DOC_MAN7))
Ingo Molnarc1c23652009-05-30 12:38:51 +020042
John Kacur7ae5f2132010-03-11 13:57:00 +010043# Make the path relative to DESTDIR, not prefix
44ifndef DESTDIR
Ingo Molnarc1c23652009-05-30 12:38:51 +020045prefix?=$(HOME)
John Kacur7ae5f2132010-03-11 13:57:00 +010046endif
Ingo Molnarc1c23652009-05-30 12:38:51 +020047bindir?=$(prefix)/bin
48htmldir?=$(prefix)/share/doc/perf-doc
49pdfdir?=$(prefix)/share/doc/perf-doc
50mandir?=$(prefix)/share/man
51man1dir=$(mandir)/man1
52man5dir=$(mandir)/man5
53man7dir=$(mandir)/man7
Ingo Molnarc1c23652009-05-30 12:38:51 +020054
55ASCIIDOC=asciidoc
Kyle McMartinb395cd82009-08-18 12:41:25 -040056ASCIIDOC_EXTRA = --unsafe
Ingo Molnarc1c23652009-05-30 12:38:51 +020057MANPAGE_XSL = manpage-normal.xsl
58XMLTO_EXTRA =
59INSTALL?=install
60RM ?= rm -f
61DOC_REF = origin/man
62HTML_REF = origin/html
63
64infodir?=$(prefix)/share/info
65MAKEINFO=makeinfo
66INSTALL_INFO=install-info
67DOCBOOK2X_TEXI=docbook2x-texi
68DBLATEX=dblatex
Borislav Petkovaf3df2c2012-09-28 19:47:07 +020069XMLTO=xmlto
Ingo Molnarc1c23652009-05-30 12:38:51 +020070ifndef PERL_PATH
71 PERL_PATH = /usr/bin/perl
72endif
73
74-include ../config.mak.autogen
75-include ../config.mak
76
Borislav Petkovaf3df2c2012-09-28 19:47:07 +020077_tmp_tool_path := $(call get-executable,$(ASCIIDOC))
78ifeq ($(_tmp_tool_path),)
79 missing_tools = $(ASCIIDOC)
80endif
81
82_tmp_tool_path := $(call get-executable,$(XMLTO))
83ifeq ($(_tmp_tool_path),)
84 missing_tools += $(XMLTO)
85endif
86
Ingo Molnarc1c23652009-05-30 12:38:51 +020087#
88# For asciidoc ...
89# -7.1.2, no extra settings are needed.
90# 8.0-, set ASCIIDOC8.
91#
92
93#
94# For docbook-xsl ...
95# -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
96# 1.69.0, no extra settings are needed?
97# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
98# 1.71.1, no extra settings are needed?
99# 1.72.0, set DOCBOOK_XSL_172.
100# 1.73.0-, set ASCIIDOC_NO_ROFF
101#
102
103#
104# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
105# of 'the ".ft C" problem' in your generated manpages, and you
106# instead ended up with weird characters around callouts, try
107# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
108#
109
110ifdef ASCIIDOC8
111ASCIIDOC_EXTRA += -a asciidoc7compatible
112endif
113ifdef DOCBOOK_XSL_172
114ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff
115MANPAGE_XSL = manpage-1.72.xsl
116else
117 ifdef ASCIIDOC_NO_ROFF
118 # docbook-xsl after 1.72 needs the regular XSL, but will not
119 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
120 ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff
121 endif
122endif
123ifdef MAN_BOLD_LITERAL
124XMLTO_EXTRA += -m manpage-bold-literal.xsl
125endif
126ifdef DOCBOOK_SUPPRESS_SP
127XMLTO_EXTRA += -m manpage-suppress-sp.xsl
128endif
129
130SHELL_PATH ?= $(SHELL)
131# Shell quote;
132SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
133
134#
135# Please note that there is a minor bug in asciidoc.
136# The version after 6.0.3 _will_ include the patch found here:
137# http://marc.theaimsgroup.com/?l=perf&m=111558757202243&w=2
138#
139# Until that version is released you may have to apply the patch
140# yourself - yes, all 6 characters of it!
141#
142
143QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
144QUIET_SUBDIR1 =
145
146ifneq ($(findstring $(MAKEFLAGS),w),w)
147PRINT_DIR = --no-print-directory
148else # "make -w"
149NO_SUBDIR = :
150endif
151
152ifneq ($(findstring $(MAKEFLAGS),s),s)
Robert Richter5125bc22013-05-03 15:49:53 +0200153ifneq ($(V),1)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200154 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
155 QUIET_XMLTO = @echo ' ' XMLTO $@;
156 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
157 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
158 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
159 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
160 QUIET_GEN = @echo ' ' GEN $@;
161 QUIET_STDERR = 2> /dev/null
162 QUIET_SUBDIR0 = +@subdir=
163 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
164 $(MAKE) $(PRINT_DIR) -C $$subdir
165 export V
166endif
167endif
168
169all: html man
170
171html: $(DOC_HTML)
172
173$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
174
175man: man1 man5 man7
176man1: $(DOC_MAN1)
177man5: $(DOC_MAN5)
178man7: $(DOC_MAN7)
179
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100180info: $(OUTPUT)perf.info $(OUTPUT)perfman.info
Ingo Molnarc1c23652009-05-30 12:38:51 +0200181
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100182pdf: $(OUTPUT)user-manual.pdf
Ingo Molnarc1c23652009-05-30 12:38:51 +0200183
184install: install-man
185
Borislav Petkovaf3df2c2012-09-28 19:47:07 +0200186check-man-tools:
187ifdef missing_tools
188 $(error "You need to install $(missing_tools) for man pages")
189endif
190
191do-install-man: man
Ingo Molnarc1c23652009-05-30 12:38:51 +0200192 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
193# $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
194# $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
195 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
196# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
197# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
198
Borislav Petkovaf3df2c2012-09-28 19:47:07 +0200199install-man: check-man-tools man
200
201try-install-man:
202ifdef missing_tools
203 $(warning Please install $(missing_tools) to have the man pages installed)
204else
205 $(MAKE) do-install-man
206endif
207
Ingo Molnarc1c23652009-05-30 12:38:51 +0200208install-info: info
209 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100210 $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200211 if test -r $(DESTDIR)$(infodir)/dir; then \
212 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\
213 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\
214 else \
215 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
216 fi
217
218install-pdf: pdf
219 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100220 $(INSTALL) -m 644 $(OUTPUT)user-manual.pdf $(DESTDIR)$(pdfdir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200221
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800222#install-html: html
223# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200224
Namhyung Kim3cde41b2012-11-14 13:39:50 +0900225ifneq ($(MAKECMDGOALS),clean)
Arnaldo Carvalho de Melo3b761f92012-11-29 16:34:21 -0300226ifneq ($(MAKECMDGOALS),tags)
Robert Richtere6b97832012-08-07 19:43:11 +0200227$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
228 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) $(OUTPUT)PERF-VERSION-FILE
Ingo Molnarc1c23652009-05-30 12:38:51 +0200229
Robert Richtere6b97832012-08-07 19:43:11 +0200230-include $(OUTPUT)PERF-VERSION-FILE
Namhyung Kim3cde41b2012-11-14 13:39:50 +0900231endif
Arnaldo Carvalho de Melo3b761f92012-11-29 16:34:21 -0300232endif
Ingo Molnarc1c23652009-05-30 12:38:51 +0200233
234#
235# Determine "include::" file references in asciidoc files.
236#
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100237$(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl
Ingo Molnarc1c23652009-05-30 12:38:51 +0200238 $(QUIET_GEN)$(RM) $@+ $@ && \
239 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
240 mv $@+ $@
241
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100242-include $(OUPTUT)doc.dep
Ingo Molnarc1c23652009-05-30 12:38:51 +0200243
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100244_cmds_txt = cmds-ancillaryinterrogators.txt \
Ingo Molnarc1c23652009-05-30 12:38:51 +0200245 cmds-ancillarymanipulators.txt \
246 cmds-mainporcelain.txt \
247 cmds-plumbinginterrogators.txt \
248 cmds-plumbingmanipulators.txt \
249 cmds-synchingrepositories.txt \
250 cmds-synchelpers.txt \
251 cmds-purehelpers.txt \
252 cmds-foreignscminterface.txt
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100253cmds_txt=$(addprefix $(OUTPUT),$(_cmds_txt))
Ingo Molnarc1c23652009-05-30 12:38:51 +0200254
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100255$(cmds_txt): $(OUTPUT)cmd-list.made
Ingo Molnarc1c23652009-05-30 12:38:51 +0200256
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100257$(OUTPUT)cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200258 $(QUIET_GEN)$(RM) $@ && \
259 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
260 date >$@
261
262clean:
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100263 $(RM) $(MAN_XML) $(addsuffix +,$(MAN_XML))
264 $(RM) $(MAN_HTML) $(addsuffix +,$(MAN_HTML))
265 $(RM) $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7)
266 $(RM) $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++
267 $(RM) $(OUTPUT)perf.info $(OUTPUT)perfman.info
268 $(RM) $(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep
269 $(RM) $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt
270 $(RM) $(cmds_txt) $(OUTPUT)*.made
Ingo Molnarc1c23652009-05-30 12:38:51 +0200271
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100272$(MAN_HTML): $(OUTPUT)%.html : %.txt
Ingo Molnarc1c23652009-05-30 12:38:51 +0200273 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
274 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
275 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
276 mv $@+ $@
277
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100278$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200279 $(QUIET_XMLTO)$(RM) $@ && \
Borislav Petkovaf3df2c2012-09-28 19:47:07 +0200280 $(XMLTO) -o $(OUTPUT) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
Ingo Molnarc1c23652009-05-30 12:38:51 +0200281
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100282$(OUTPUT)%.xml : %.txt
Ingo Molnarc1c23652009-05-30 12:38:51 +0200283 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
284 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
285 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
286 mv $@+ $@
287
288XSLT = docbook.xsl
289XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
290
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100291$(OUTPUT)user-manual.html: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200292 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
293
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100294$(OUTPUT)perf.info: $(OUTPUT)user-manual.texi
295 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ $(OUTPUT)user-manual.texi
Ingo Molnarc1c23652009-05-30 12:38:51 +0200296
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100297$(OUTPUT)user-manual.texi: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200298 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100299 $(DOCBOOK2X_TEXI) $(OUTPUT)user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
Ingo Molnarc1c23652009-05-30 12:38:51 +0200300 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
301 rm $@++ && \
302 mv $@+ $@
303
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100304$(OUTPUT)user-manual.pdf: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200305 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
306 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
307 mv $@+ $@
308
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100309$(OUTPUT)perfman.texi: $(MAN_XML) cat-texi.perl
Ingo Molnarc1c23652009-05-30 12:38:51 +0200310 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
311 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
312 --to-stdout $(xml) &&) true) > $@++ && \
313 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
314 rm $@++ && \
315 mv $@+ $@
316
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100317$(OUTPUT)perfman.info: $(OUTPUT)perfman.texi
Ingo Molnarc1c23652009-05-30 12:38:51 +0200318 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
319
320$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
321 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
322 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
323 mv $@+ $@
324
325howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
326 $(QUIET_GEN)$(RM) $@+ $@ && \
327 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
328 mv $@+ $@
329
330$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
331 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 $*.txt
332
333WEBDOC_DEST = /pub/software/tools/perf/docs
334
335$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
336 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
337 sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+ && \
338 mv $@+ $@
339
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800340# UNIMPLEMENTED
341#install-webdoc : html
342# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200343
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800344# quick-install: quick-install-man
Ingo Molnarc1c23652009-05-30 12:38:51 +0200345
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800346# quick-install-man:
347# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200348
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800349#quick-install-html:
350# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200351
352.PHONY: .FORCE-PERF-VERSION-FILE