blob: 5a37a7c84e69891fc753f205c50b81d22238499f [file] [log] [blame]
Robert Richter761a0f32013-05-06 20:40:14 +02001include ../../scripts/Makefile.include
Borislav Petkovaf3df2c2012-09-28 19:47:07 +02002include ../config/utilities.mak
3
Ingo Molnarc1c23652009-05-30 12:38:51 +02004MAN1_TXT= \
5 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
6 $(wildcard perf-*.txt)) \
7 perf.txt
8MAN5_TXT=
9MAN7_TXT=
10
11MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
Franck Bui-Huu762b2932012-02-06 16:17:23 +010012_MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
13_MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
Ingo Molnarc1c23652009-05-30 12:38:51 +020014
Franck Bui-Huu762b2932012-02-06 16:17:23 +010015MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML))
16MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML))
Ingo Molnarc1c23652009-05-30 12:38:51 +020017
18ARTICLES =
19# with their own formatting rules.
20SP_ARTICLES =
21API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
22SP_ARTICLES += $(API_DOCS)
23SP_ARTICLES += technical/api-index
24
Franck Bui-Huu762b2932012-02-06 16:17:23 +010025_DOC_HTML = $(_MAN_HTML)
26_DOC_HTML+=$(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
27DOC_HTML=$(addprefix $(OUTPUT),$(_DOC_HTML))
Ingo Molnarc1c23652009-05-30 12:38:51 +020028
Franck Bui-Huu762b2932012-02-06 16:17:23 +010029_DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
30_DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
31_DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
32
33DOC_MAN1=$(addprefix $(OUTPUT),$(_DOC_MAN1))
34DOC_MAN5=$(addprefix $(OUTPUT),$(_DOC_MAN5))
35DOC_MAN7=$(addprefix $(OUTPUT),$(_DOC_MAN7))
Ingo Molnarc1c23652009-05-30 12:38:51 +020036
John Kacur7ae5f2132010-03-11 13:57:00 +010037# Make the path relative to DESTDIR, not prefix
38ifndef DESTDIR
Ingo Molnarc1c23652009-05-30 12:38:51 +020039prefix?=$(HOME)
John Kacur7ae5f2132010-03-11 13:57:00 +010040endif
Ingo Molnarc1c23652009-05-30 12:38:51 +020041bindir?=$(prefix)/bin
42htmldir?=$(prefix)/share/doc/perf-doc
43pdfdir?=$(prefix)/share/doc/perf-doc
44mandir?=$(prefix)/share/man
45man1dir=$(mandir)/man1
46man5dir=$(mandir)/man5
47man7dir=$(mandir)/man7
Ingo Molnarc1c23652009-05-30 12:38:51 +020048
49ASCIIDOC=asciidoc
Kyle McMartinb395cd82009-08-18 12:41:25 -040050ASCIIDOC_EXTRA = --unsafe
Ingo Molnarc1c23652009-05-30 12:38:51 +020051MANPAGE_XSL = manpage-normal.xsl
52XMLTO_EXTRA =
53INSTALL?=install
54RM ?= rm -f
55DOC_REF = origin/man
56HTML_REF = origin/html
57
58infodir?=$(prefix)/share/info
59MAKEINFO=makeinfo
60INSTALL_INFO=install-info
61DOCBOOK2X_TEXI=docbook2x-texi
62DBLATEX=dblatex
Borislav Petkovaf3df2c2012-09-28 19:47:07 +020063XMLTO=xmlto
Ingo Molnarc1c23652009-05-30 12:38:51 +020064ifndef PERL_PATH
65 PERL_PATH = /usr/bin/perl
66endif
67
68-include ../config.mak.autogen
69-include ../config.mak
70
Borislav Petkovaf3df2c2012-09-28 19:47:07 +020071_tmp_tool_path := $(call get-executable,$(ASCIIDOC))
72ifeq ($(_tmp_tool_path),)
73 missing_tools = $(ASCIIDOC)
74endif
75
76_tmp_tool_path := $(call get-executable,$(XMLTO))
77ifeq ($(_tmp_tool_path),)
78 missing_tools += $(XMLTO)
79endif
80
Ingo Molnarc1c23652009-05-30 12:38:51 +020081#
82# For asciidoc ...
83# -7.1.2, no extra settings are needed.
84# 8.0-, set ASCIIDOC8.
85#
86
87#
88# For docbook-xsl ...
89# -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
90# 1.69.0, no extra settings are needed?
91# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
92# 1.71.1, no extra settings are needed?
93# 1.72.0, set DOCBOOK_XSL_172.
94# 1.73.0-, set ASCIIDOC_NO_ROFF
95#
96
97#
98# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
99# of 'the ".ft C" problem' in your generated manpages, and you
100# instead ended up with weird characters around callouts, try
101# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
102#
103
104ifdef ASCIIDOC8
105ASCIIDOC_EXTRA += -a asciidoc7compatible
106endif
107ifdef DOCBOOK_XSL_172
108ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff
109MANPAGE_XSL = manpage-1.72.xsl
110else
111 ifdef ASCIIDOC_NO_ROFF
112 # docbook-xsl after 1.72 needs the regular XSL, but will not
113 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
114 ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff
115 endif
116endif
117ifdef MAN_BOLD_LITERAL
118XMLTO_EXTRA += -m manpage-bold-literal.xsl
119endif
120ifdef DOCBOOK_SUPPRESS_SP
121XMLTO_EXTRA += -m manpage-suppress-sp.xsl
122endif
123
124SHELL_PATH ?= $(SHELL)
125# Shell quote;
126SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
127
128#
129# Please note that there is a minor bug in asciidoc.
130# The version after 6.0.3 _will_ include the patch found here:
131# http://marc.theaimsgroup.com/?l=perf&m=111558757202243&w=2
132#
133# Until that version is released you may have to apply the patch
134# yourself - yes, all 6 characters of it!
135#
136
137QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
138QUIET_SUBDIR1 =
139
140ifneq ($(findstring $(MAKEFLAGS),w),w)
141PRINT_DIR = --no-print-directory
142else # "make -w"
143NO_SUBDIR = :
144endif
145
146ifneq ($(findstring $(MAKEFLAGS),s),s)
Robert Richter5125bc22013-05-03 15:49:53 +0200147ifneq ($(V),1)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200148 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
149 QUIET_XMLTO = @echo ' ' XMLTO $@;
150 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
151 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
152 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
153 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
154 QUIET_GEN = @echo ' ' GEN $@;
155 QUIET_STDERR = 2> /dev/null
156 QUIET_SUBDIR0 = +@subdir=
157 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
158 $(MAKE) $(PRINT_DIR) -C $$subdir
159 export V
160endif
161endif
162
163all: html man
164
165html: $(DOC_HTML)
166
167$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
168
169man: man1 man5 man7
170man1: $(DOC_MAN1)
171man5: $(DOC_MAN5)
172man7: $(DOC_MAN7)
173
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100174info: $(OUTPUT)perf.info $(OUTPUT)perfman.info
Ingo Molnarc1c23652009-05-30 12:38:51 +0200175
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100176pdf: $(OUTPUT)user-manual.pdf
Ingo Molnarc1c23652009-05-30 12:38:51 +0200177
178install: install-man
179
Borislav Petkovaf3df2c2012-09-28 19:47:07 +0200180check-man-tools:
181ifdef missing_tools
182 $(error "You need to install $(missing_tools) for man pages")
183endif
184
185do-install-man: man
Ingo Molnarc1c23652009-05-30 12:38:51 +0200186 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
187# $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
188# $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
189 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
190# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
191# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
192
Borislav Petkovaf3df2c2012-09-28 19:47:07 +0200193install-man: check-man-tools man
194
195try-install-man:
196ifdef missing_tools
197 $(warning Please install $(missing_tools) to have the man pages installed)
198else
199 $(MAKE) do-install-man
200endif
201
Ingo Molnarc1c23652009-05-30 12:38:51 +0200202install-info: info
203 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100204 $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200205 if test -r $(DESTDIR)$(infodir)/dir; then \
206 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\
207 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\
208 else \
209 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
210 fi
211
212install-pdf: pdf
213 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100214 $(INSTALL) -m 644 $(OUTPUT)user-manual.pdf $(DESTDIR)$(pdfdir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200215
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800216#install-html: html
217# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200218
Namhyung Kim3cde41b2012-11-14 13:39:50 +0900219ifneq ($(MAKECMDGOALS),clean)
Arnaldo Carvalho de Melo3b761f92012-11-29 16:34:21 -0300220ifneq ($(MAKECMDGOALS),tags)
Robert Richtere6b97832012-08-07 19:43:11 +0200221$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
222 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) $(OUTPUT)PERF-VERSION-FILE
Ingo Molnarc1c23652009-05-30 12:38:51 +0200223
Robert Richtere6b97832012-08-07 19:43:11 +0200224-include $(OUTPUT)PERF-VERSION-FILE
Namhyung Kim3cde41b2012-11-14 13:39:50 +0900225endif
Arnaldo Carvalho de Melo3b761f92012-11-29 16:34:21 -0300226endif
Ingo Molnarc1c23652009-05-30 12:38:51 +0200227
228#
229# Determine "include::" file references in asciidoc files.
230#
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100231$(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl
Ingo Molnarc1c23652009-05-30 12:38:51 +0200232 $(QUIET_GEN)$(RM) $@+ $@ && \
233 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
234 mv $@+ $@
235
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100236-include $(OUPTUT)doc.dep
Ingo Molnarc1c23652009-05-30 12:38:51 +0200237
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100238_cmds_txt = cmds-ancillaryinterrogators.txt \
Ingo Molnarc1c23652009-05-30 12:38:51 +0200239 cmds-ancillarymanipulators.txt \
240 cmds-mainporcelain.txt \
241 cmds-plumbinginterrogators.txt \
242 cmds-plumbingmanipulators.txt \
243 cmds-synchingrepositories.txt \
244 cmds-synchelpers.txt \
245 cmds-purehelpers.txt \
246 cmds-foreignscminterface.txt
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100247cmds_txt=$(addprefix $(OUTPUT),$(_cmds_txt))
Ingo Molnarc1c23652009-05-30 12:38:51 +0200248
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100249$(cmds_txt): $(OUTPUT)cmd-list.made
Ingo Molnarc1c23652009-05-30 12:38:51 +0200250
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100251$(OUTPUT)cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200252 $(QUIET_GEN)$(RM) $@ && \
253 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
254 date >$@
255
256clean:
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100257 $(RM) $(MAN_XML) $(addsuffix +,$(MAN_XML))
258 $(RM) $(MAN_HTML) $(addsuffix +,$(MAN_HTML))
259 $(RM) $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7)
260 $(RM) $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++
261 $(RM) $(OUTPUT)perf.info $(OUTPUT)perfman.info
262 $(RM) $(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep
263 $(RM) $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt
264 $(RM) $(cmds_txt) $(OUTPUT)*.made
Ingo Molnarc1c23652009-05-30 12:38:51 +0200265
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100266$(MAN_HTML): $(OUTPUT)%.html : %.txt
Ingo Molnarc1c23652009-05-30 12:38:51 +0200267 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
268 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
269 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
270 mv $@+ $@
271
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100272$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200273 $(QUIET_XMLTO)$(RM) $@ && \
Robert Richter761a0f32013-05-06 20:40:14 +0200274 $(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
Ingo Molnarc1c23652009-05-30 12:38:51 +0200275
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100276$(OUTPUT)%.xml : %.txt
Ingo Molnarc1c23652009-05-30 12:38:51 +0200277 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
278 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
279 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
280 mv $@+ $@
281
282XSLT = docbook.xsl
283XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
284
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100285$(OUTPUT)user-manual.html: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200286 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
287
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100288$(OUTPUT)perf.info: $(OUTPUT)user-manual.texi
289 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ $(OUTPUT)user-manual.texi
Ingo Molnarc1c23652009-05-30 12:38:51 +0200290
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100291$(OUTPUT)user-manual.texi: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200292 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100293 $(DOCBOOK2X_TEXI) $(OUTPUT)user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
Ingo Molnarc1c23652009-05-30 12:38:51 +0200294 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
295 rm $@++ && \
296 mv $@+ $@
297
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100298$(OUTPUT)user-manual.pdf: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200299 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
300 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
301 mv $@+ $@
302
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100303$(OUTPUT)perfman.texi: $(MAN_XML) cat-texi.perl
Ingo Molnarc1c23652009-05-30 12:38:51 +0200304 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
305 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
306 --to-stdout $(xml) &&) true) > $@++ && \
307 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
308 rm $@++ && \
309 mv $@+ $@
310
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100311$(OUTPUT)perfman.info: $(OUTPUT)perfman.texi
Ingo Molnarc1c23652009-05-30 12:38:51 +0200312 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
313
314$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
315 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
316 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
317 mv $@+ $@
318
319howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
320 $(QUIET_GEN)$(RM) $@+ $@ && \
321 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
322 mv $@+ $@
323
324$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
325 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 $*.txt
326
327WEBDOC_DEST = /pub/software/tools/perf/docs
328
329$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
330 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
331 sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+ && \
332 mv $@+ $@
333
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800334# UNIMPLEMENTED
335#install-webdoc : html
336# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200337
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800338# quick-install: quick-install-man
Ingo Molnarc1c23652009-05-30 12:38:51 +0200339
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800340# quick-install-man:
341# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200342
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800343#quick-install-html:
344# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200345
346.PHONY: .FORCE-PERF-VERSION-FILE