blob: 9f2e44f2b17a724425a829c2509985b6c8bafc95 [file] [log] [blame]
Franck Bui-Huu762b2932012-02-06 16:17:23 +01001OUTPUT := ./
2ifeq ("$(origin O)", "command line")
3 ifneq ($(O),)
4 OUTPUT := $(O)/
5 endif
6endif
7
Ingo Molnarc1c23652009-05-30 12:38:51 +02008MAN1_TXT= \
9 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
10 $(wildcard perf-*.txt)) \
11 perf.txt
12MAN5_TXT=
13MAN7_TXT=
14
15MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
Franck Bui-Huu762b2932012-02-06 16:17:23 +010016_MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
17_MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
Ingo Molnarc1c23652009-05-30 12:38:51 +020018
Franck Bui-Huu762b2932012-02-06 16:17:23 +010019MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML))
20MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML))
Ingo Molnarc1c23652009-05-30 12:38:51 +020021
22ARTICLES =
23# with their own formatting rules.
24SP_ARTICLES =
25API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
26SP_ARTICLES += $(API_DOCS)
27SP_ARTICLES += technical/api-index
28
Franck Bui-Huu762b2932012-02-06 16:17:23 +010029_DOC_HTML = $(_MAN_HTML)
30_DOC_HTML+=$(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
31DOC_HTML=$(addprefix $(OUTPUT),$(_DOC_HTML))
Ingo Molnarc1c23652009-05-30 12:38:51 +020032
Franck Bui-Huu762b2932012-02-06 16:17:23 +010033_DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
34_DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
35_DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
36
37DOC_MAN1=$(addprefix $(OUTPUT),$(_DOC_MAN1))
38DOC_MAN5=$(addprefix $(OUTPUT),$(_DOC_MAN5))
39DOC_MAN7=$(addprefix $(OUTPUT),$(_DOC_MAN7))
Ingo Molnarc1c23652009-05-30 12:38:51 +020040
John Kacur7ae5f2132010-03-11 13:57:00 +010041# Make the path relative to DESTDIR, not prefix
42ifndef DESTDIR
Ingo Molnarc1c23652009-05-30 12:38:51 +020043prefix?=$(HOME)
John Kacur7ae5f2132010-03-11 13:57:00 +010044endif
Ingo Molnarc1c23652009-05-30 12:38:51 +020045bindir?=$(prefix)/bin
46htmldir?=$(prefix)/share/doc/perf-doc
47pdfdir?=$(prefix)/share/doc/perf-doc
48mandir?=$(prefix)/share/man
49man1dir=$(mandir)/man1
50man5dir=$(mandir)/man5
51man7dir=$(mandir)/man7
Ingo Molnarc1c23652009-05-30 12:38:51 +020052
53ASCIIDOC=asciidoc
Kyle McMartinb395cd82009-08-18 12:41:25 -040054ASCIIDOC_EXTRA = --unsafe
Ingo Molnarc1c23652009-05-30 12:38:51 +020055MANPAGE_XSL = manpage-normal.xsl
56XMLTO_EXTRA =
57INSTALL?=install
58RM ?= rm -f
59DOC_REF = origin/man
60HTML_REF = origin/html
61
62infodir?=$(prefix)/share/info
63MAKEINFO=makeinfo
64INSTALL_INFO=install-info
65DOCBOOK2X_TEXI=docbook2x-texi
66DBLATEX=dblatex
67ifndef PERL_PATH
68 PERL_PATH = /usr/bin/perl
69endif
70
71-include ../config.mak.autogen
72-include ../config.mak
73
74#
75# For asciidoc ...
76# -7.1.2, no extra settings are needed.
77# 8.0-, set ASCIIDOC8.
78#
79
80#
81# For docbook-xsl ...
82# -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
83# 1.69.0, no extra settings are needed?
84# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
85# 1.71.1, no extra settings are needed?
86# 1.72.0, set DOCBOOK_XSL_172.
87# 1.73.0-, set ASCIIDOC_NO_ROFF
88#
89
90#
91# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
92# of 'the ".ft C" problem' in your generated manpages, and you
93# instead ended up with weird characters around callouts, try
94# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
95#
96
97ifdef ASCIIDOC8
98ASCIIDOC_EXTRA += -a asciidoc7compatible
99endif
100ifdef DOCBOOK_XSL_172
101ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff
102MANPAGE_XSL = manpage-1.72.xsl
103else
104 ifdef ASCIIDOC_NO_ROFF
105 # docbook-xsl after 1.72 needs the regular XSL, but will not
106 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
107 ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff
108 endif
109endif
110ifdef MAN_BOLD_LITERAL
111XMLTO_EXTRA += -m manpage-bold-literal.xsl
112endif
113ifdef DOCBOOK_SUPPRESS_SP
114XMLTO_EXTRA += -m manpage-suppress-sp.xsl
115endif
116
117SHELL_PATH ?= $(SHELL)
118# Shell quote;
119SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
120
121#
122# Please note that there is a minor bug in asciidoc.
123# The version after 6.0.3 _will_ include the patch found here:
124# http://marc.theaimsgroup.com/?l=perf&m=111558757202243&w=2
125#
126# Until that version is released you may have to apply the patch
127# yourself - yes, all 6 characters of it!
128#
129
130QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
131QUIET_SUBDIR1 =
132
133ifneq ($(findstring $(MAKEFLAGS),w),w)
134PRINT_DIR = --no-print-directory
135else # "make -w"
136NO_SUBDIR = :
137endif
138
139ifneq ($(findstring $(MAKEFLAGS),s),s)
140ifndef V
141 QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
142 QUIET_XMLTO = @echo ' ' XMLTO $@;
143 QUIET_DB2TEXI = @echo ' ' DB2TEXI $@;
144 QUIET_MAKEINFO = @echo ' ' MAKEINFO $@;
145 QUIET_DBLATEX = @echo ' ' DBLATEX $@;
146 QUIET_XSLTPROC = @echo ' ' XSLTPROC $@;
147 QUIET_GEN = @echo ' ' GEN $@;
148 QUIET_STDERR = 2> /dev/null
149 QUIET_SUBDIR0 = +@subdir=
150 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
151 $(MAKE) $(PRINT_DIR) -C $$subdir
152 export V
153endif
154endif
155
156all: html man
157
158html: $(DOC_HTML)
159
160$(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
161
162man: man1 man5 man7
163man1: $(DOC_MAN1)
164man5: $(DOC_MAN5)
165man7: $(DOC_MAN7)
166
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100167info: $(OUTPUT)perf.info $(OUTPUT)perfman.info
Ingo Molnarc1c23652009-05-30 12:38:51 +0200168
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100169pdf: $(OUTPUT)user-manual.pdf
Ingo Molnarc1c23652009-05-30 12:38:51 +0200170
171install: install-man
172
173install-man: man
174 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
175# $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
176# $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
177 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
178# $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
179# $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
180
181install-info: info
182 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100183 $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200184 if test -r $(DESTDIR)$(infodir)/dir; then \
185 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\
186 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\
187 else \
188 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
189 fi
190
191install-pdf: pdf
192 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100193 $(INSTALL) -m 644 $(OUTPUT)user-manual.pdf $(DESTDIR)$(pdfdir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200194
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800195#install-html: html
196# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200197
Robert Richtere6b97832012-08-07 19:43:11 +0200198$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
199 $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) $(OUTPUT)PERF-VERSION-FILE
Ingo Molnarc1c23652009-05-30 12:38:51 +0200200
Robert Richtere6b97832012-08-07 19:43:11 +0200201-include $(OUTPUT)PERF-VERSION-FILE
Ingo Molnarc1c23652009-05-30 12:38:51 +0200202
203#
204# Determine "include::" file references in asciidoc files.
205#
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100206$(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl
Ingo Molnarc1c23652009-05-30 12:38:51 +0200207 $(QUIET_GEN)$(RM) $@+ $@ && \
208 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
209 mv $@+ $@
210
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100211-include $(OUPTUT)doc.dep
Ingo Molnarc1c23652009-05-30 12:38:51 +0200212
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100213_cmds_txt = cmds-ancillaryinterrogators.txt \
Ingo Molnarc1c23652009-05-30 12:38:51 +0200214 cmds-ancillarymanipulators.txt \
215 cmds-mainporcelain.txt \
216 cmds-plumbinginterrogators.txt \
217 cmds-plumbingmanipulators.txt \
218 cmds-synchingrepositories.txt \
219 cmds-synchelpers.txt \
220 cmds-purehelpers.txt \
221 cmds-foreignscminterface.txt
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100222cmds_txt=$(addprefix $(OUTPUT),$(_cmds_txt))
Ingo Molnarc1c23652009-05-30 12:38:51 +0200223
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100224$(cmds_txt): $(OUTPUT)cmd-list.made
Ingo Molnarc1c23652009-05-30 12:38:51 +0200225
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100226$(OUTPUT)cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200227 $(QUIET_GEN)$(RM) $@ && \
228 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
229 date >$@
230
231clean:
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100232 $(RM) $(MAN_XML) $(addsuffix +,$(MAN_XML))
233 $(RM) $(MAN_HTML) $(addsuffix +,$(MAN_HTML))
234 $(RM) $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7)
235 $(RM) $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++
236 $(RM) $(OUTPUT)perf.info $(OUTPUT)perfman.info
237 $(RM) $(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep
238 $(RM) $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt
239 $(RM) $(cmds_txt) $(OUTPUT)*.made
Ingo Molnarc1c23652009-05-30 12:38:51 +0200240
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100241$(MAN_HTML): $(OUTPUT)%.html : %.txt
Ingo Molnarc1c23652009-05-30 12:38:51 +0200242 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
243 $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
244 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
245 mv $@+ $@
246
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100247$(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200248 $(QUIET_XMLTO)$(RM) $@ && \
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100249 xmlto -o $(OUTPUT) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
Ingo Molnarc1c23652009-05-30 12:38:51 +0200250
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100251$(OUTPUT)%.xml : %.txt
Ingo Molnarc1c23652009-05-30 12:38:51 +0200252 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
253 $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
254 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
255 mv $@+ $@
256
257XSLT = docbook.xsl
258XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
259
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100260$(OUTPUT)user-manual.html: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200261 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
262
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100263$(OUTPUT)perf.info: $(OUTPUT)user-manual.texi
264 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ $(OUTPUT)user-manual.texi
Ingo Molnarc1c23652009-05-30 12:38:51 +0200265
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100266$(OUTPUT)user-manual.texi: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200267 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100268 $(DOCBOOK2X_TEXI) $(OUTPUT)user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
Ingo Molnarc1c23652009-05-30 12:38:51 +0200269 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
270 rm $@++ && \
271 mv $@+ $@
272
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100273$(OUTPUT)user-manual.pdf: $(OUTPUT)user-manual.xml
Ingo Molnarc1c23652009-05-30 12:38:51 +0200274 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
275 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
276 mv $@+ $@
277
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100278$(OUTPUT)perfman.texi: $(MAN_XML) cat-texi.perl
Ingo Molnarc1c23652009-05-30 12:38:51 +0200279 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
280 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
281 --to-stdout $(xml) &&) true) > $@++ && \
282 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
283 rm $@++ && \
284 mv $@+ $@
285
Franck Bui-Huu762b2932012-02-06 16:17:23 +0100286$(OUTPUT)perfman.info: $(OUTPUT)perfman.texi
Ingo Molnarc1c23652009-05-30 12:38:51 +0200287 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
288
289$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
290 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
291 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
292 mv $@+ $@
293
294howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
295 $(QUIET_GEN)$(RM) $@+ $@ && \
296 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
297 mv $@+ $@
298
299$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
300 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 $*.txt
301
302WEBDOC_DEST = /pub/software/tools/perf/docs
303
304$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
305 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
306 sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b xhtml11 - >$@+ && \
307 mv $@+ $@
308
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800309# UNIMPLEMENTED
310#install-webdoc : html
311# '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200312
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800313# quick-install: quick-install-man
Ingo Molnarc1c23652009-05-30 12:38:51 +0200314
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800315# quick-install-man:
316# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200317
Jesse Brandeburg4187e262011-02-09 17:11:00 -0800318#quick-install-html:
319# '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)
Ingo Molnarc1c23652009-05-30 12:38:51 +0200320
321.PHONY: .FORCE-PERF-VERSION-FILE