blob: ef6d22e879eb59dbf370096aaecda6d2344a42b0 [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)
153ifndef V
154 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
Robert Richtere6b97832012-08-07 19:43:11 +0200225$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
226 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) $(OUTPUT)PERF-VERSION-FILE
Ingo Molnarc1c23652009-05-30 12:38:51 +0200227
Robert Richtere6b97832012-08-07 19:43:11 +0200228-include $(OUTPUT)PERF-VERSION-FILE
Ingo Molnarc1c23652009-05-30 12:38:51 +0200229
230#
231# Determine "include::" file references in asciidoc files.
232#
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100233$(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl
Ingo Molnarc1c23652009-05-30 12:38:51 +0200234 $(QUIET_GEN)$(RM) $@+ $@ && \
235 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
236 mv $@+ $@
237
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100238-include $(OUPTUT)doc.dep
Ingo Molnarc1c23652009-05-30 12:38:51 +0200239
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100240_cmds_txt = cmds-ancillaryinterrogators.txt \
Ingo Molnarc1c23652009-05-30 12:38:51 +0200241 cmds-ancillarymanipulators.txt \
242 cmds-mainporcelain.txt \
243 cmds-plumbinginterrogators.txt \
244 cmds-plumbingmanipulators.txt \
245 cmds-synchingrepositories.txt \
246 cmds-synchelpers.txt \
247 cmds-purehelpers.txt \
248 cmds-foreignscminterface.txt
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100249cmds_txt=$(addprefix $(OUTPUT),$(_cmds_txt))
Ingo Molnarc1c23652009-05-30 12:38:51 +0200250
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100251$(cmds_txt): $(OUTPUT)cmd-list.made
Ingo Molnarc1c23652009-05-30 12:38:51 +0200252
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100253$(OUTPUT)cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200254 $(QUIET_GEN)$(RM) $@ && \
255 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
256 date >$@
257
258clean:
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100259 $(RM) $(MAN_XML) $(addsuffix +,$(MAN_XML))
260 $(RM) $(MAN_HTML) $(addsuffix +,$(MAN_HTML))
261 $(RM) $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7)
262 $(RM) $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++
263 $(RM) $(OUTPUT)perf.info $(OUTPUT)perfman.info
264 $(RM) $(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep
265 $(RM) $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt
266 $(RM) $(cmds_txt) $(OUTPUT)*.made
Ingo Molnarc1c23652009-05-30 12:38:51 +0200267
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100268$(MAN_HTML): $(OUTPUT)%.html : %.txt
Ingo Molnarc1c23652009-05-30 12:38:51 +0200269 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
270 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
271 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
272 mv $@+ $@
273
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100274$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200275 $(QUIET_XMLTO)$(RM) $@ && \
Borislav Petkovaf3df2c2012-09-28 19:47:07 +0200276 $(XMLTO) -o $(OUTPUT) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
Ingo Molnarc1c23652009-05-30 12:38:51 +0200277
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100278$(OUTPUT)%.xml : %.txt
Ingo Molnarc1c23652009-05-30 12:38:51 +0200279 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
280 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
281 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
282 mv $@+ $@
283
284XSLT = docbook.xsl
285XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
286
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100287$(OUTPUT)user-manual.html: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200288 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
289
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100290$(OUTPUT)perf.info: $(OUTPUT)user-manual.texi
291 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ $(OUTPUT)user-manual.texi
Ingo Molnarc1c23652009-05-30 12:38:51 +0200292
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100293$(OUTPUT)user-manual.texi: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200294 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100295 $(DOCBOOK2X_TEXI) $(OUTPUT)user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
Ingo Molnarc1c23652009-05-30 12:38:51 +0200296 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
297 rm $@++ && \
298 mv $@+ $@
299
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100300$(OUTPUT)user-manual.pdf: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200301 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
302 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
303 mv $@+ $@
304
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100305$(OUTPUT)perfman.texi: $(MAN_XML) cat-texi.perl
Ingo Molnarc1c23652009-05-30 12:38:51 +0200306 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
307 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
308 --to-stdout $(xml) &&) true) > $@++ && \
309 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
310 rm $@++ && \
311 mv $@+ $@
312
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100313$(OUTPUT)perfman.info: $(OUTPUT)perfman.texi
Ingo Molnarc1c23652009-05-30 12:38:51 +0200314 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
315
316$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
317 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
318 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
319 mv $@+ $@
320
321howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
322 $(QUIET_GEN)$(RM) $@+ $@ && \
323 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
324 mv $@+ $@
325
326$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
327 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 $*.txt
328
329WEBDOC_DEST = /pub/software/tools/perf/docs
330
331$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
332 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
333 sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+ && \
334 mv $@+ $@
335
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800336# UNIMPLEMENTED
337#install-webdoc : html
338# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200339
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800340# quick-install: quick-install-man
Ingo Molnarc1c23652009-05-30 12:38:51 +0200341
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800342# quick-install-man:
343# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200344
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800345#quick-install-html:
346# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200347
348.PHONY: .FORCE-PERF-VERSION-FILE