Merge tag 'ntb-5.11' of git://github.com/jonmason/ntb
[linux/fpc-iii.git] / tools / perf / Documentation / Makefile
blob6e54979c2124e6d22a4ad501db8ded3673517cb7
1 # SPDX-License-Identifier: GPL-2.0-only
2 include ../../scripts/Makefile.include
3 include ../../scripts/utilities.mak
5 MAN1_TXT= \
6 $(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
7 $(wildcard perf-*.txt)) \
8 perf.txt
9 MAN5_TXT=
10 MAN7_TXT=
12 MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
13 _MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
14 _MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
16 MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML))
17 MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML))
19 ARTICLES =
20 # with their own formatting rules.
21 SP_ARTICLES =
22 API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
23 SP_ARTICLES += $(API_DOCS)
24 SP_ARTICLES += technical/api-index
26 _DOC_HTML = $(_MAN_HTML)
27 _DOC_HTML+=$(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
28 DOC_HTML=$(addprefix $(OUTPUT),$(_DOC_HTML))
30 _DOC_MAN1=$(patsubst %.txt,%.1,$(MAN1_TXT))
31 _DOC_MAN5=$(patsubst %.txt,%.5,$(MAN5_TXT))
32 _DOC_MAN7=$(patsubst %.txt,%.7,$(MAN7_TXT))
34 DOC_MAN1=$(addprefix $(OUTPUT),$(_DOC_MAN1))
35 DOC_MAN5=$(addprefix $(OUTPUT),$(_DOC_MAN5))
36 DOC_MAN7=$(addprefix $(OUTPUT),$(_DOC_MAN7))
38 # Make the path relative to DESTDIR, not prefix
39 ifndef DESTDIR
40 prefix?=$(HOME)
41 endif
42 bindir?=$(prefix)/bin
43 htmldir?=$(prefix)/share/doc/perf-doc
44 pdfdir?=$(prefix)/share/doc/perf-doc
45 mandir?=$(prefix)/share/man
46 man1dir=$(mandir)/man1
47 man5dir=$(mandir)/man5
48 man7dir=$(mandir)/man7
50 ASCIIDOC=asciidoc
51 ASCIIDOC_EXTRA += --unsafe -f asciidoc.conf
52 ASCIIDOC_HTML = xhtml11
53 MANPAGE_XSL = manpage-normal.xsl
54 XMLTO_EXTRA =
55 INSTALL?=install
56 RM ?= rm -f
57 DOC_REF = origin/man
58 HTML_REF = origin/html
60 ifdef USE_ASCIIDOCTOR
61 ASCIIDOC = asciidoctor
62 ASCIIDOC_EXTRA += -a compat-mode
63 ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
64 ASCIIDOC_EXTRA += -a mansource="perf" -a manmanual="perf Manual"
65 ASCIIDOC_HTML = xhtml5
66 endif
68 infodir?=$(prefix)/share/info
69 MAKEINFO=makeinfo
70 INSTALL_INFO=install-info
71 DOCBOOK2X_TEXI=docbook2x-texi
72 DBLATEX=dblatex
73 XMLTO=xmlto
74 ifndef PERL_PATH
75 PERL_PATH = /usr/bin/perl
76 endif
78 -include ../config.mak.autogen
79 -include ../config.mak
81 _tmp_tool_path := $(call get-executable,$(ASCIIDOC))
82 ifeq ($(_tmp_tool_path),)
83 missing_tools = $(ASCIIDOC)
84 endif
86 ifndef USE_ASCIIDOCTOR
87 _tmp_tool_path := $(call get-executable,$(XMLTO))
88 ifeq ($(_tmp_tool_path),)
89 missing_tools += $(XMLTO)
90 endif
91 endif
94 # For asciidoc ...
95 # -7.1.2, no extra settings are needed.
96 # 8.0-, set ASCIIDOC8.
100 # For docbook-xsl ...
101 # -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
102 # 1.69.0, no extra settings are needed?
103 # 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
104 # 1.71.1, no extra settings are needed?
105 # 1.72.0, set DOCBOOK_XSL_172.
106 # 1.73.0-, set ASCIIDOC_NO_ROFF
110 # If you had been using DOCBOOK_XSL_172 in an attempt to get rid
111 # of 'the ".ft C" problem' in your generated manpages, and you
112 # instead ended up with weird characters around callouts, try
113 # using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
116 ifdef ASCIIDOC8
117 ASCIIDOC_EXTRA += -a asciidoc7compatible
118 endif
119 ifdef DOCBOOK_XSL_172
120 ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff
121 MANPAGE_XSL = manpage-1.72.xsl
122 else
123 ifdef ASCIIDOC_NO_ROFF
124 # docbook-xsl after 1.72 needs the regular XSL, but will not
125 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
126 ASCIIDOC_EXTRA += -a perf-asciidoc-no-roff
127 endif
128 endif
129 ifdef MAN_BOLD_LITERAL
130 XMLTO_EXTRA += -m manpage-bold-literal.xsl
131 endif
132 ifdef DOCBOOK_SUPPRESS_SP
133 XMLTO_EXTRA += -m manpage-suppress-sp.xsl
134 endif
136 SHELL_PATH ?= $(SHELL)
137 # Shell quote;
138 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
141 # Please note that there is a minor bug in asciidoc.
142 # The version after 6.0.3 _will_ include the patch found here:
143 # http://marc.theaimsgroup.com/?l=perf&m=111558757202243&w=2
145 # Until that version is released you may have to apply the patch
146 # yourself - yes, all 6 characters of it!
149 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
150 QUIET_SUBDIR1 =
152 ifneq ($(findstring $(MAKEFLAGS),w),w)
153 PRINT_DIR = --no-print-directory
154 else # "make -w"
155 NO_SUBDIR = :
156 endif
158 ifneq ($(findstring $(MAKEFLAGS),s),s)
159 ifneq ($(V),1)
160 QUIET_ASCIIDOC = @echo ' ASCIIDOC '$@;
161 QUIET_XMLTO = @echo ' XMLTO '$@;
162 QUIET_DB2TEXI = @echo ' DB2TEXI '$@;
163 QUIET_MAKEINFO = @echo ' MAKEINFO '$@;
164 QUIET_DBLATEX = @echo ' DBLATEX '$@;
165 QUIET_XSLTPROC = @echo ' XSLTPROC '$@;
166 QUIET_GEN = @echo ' GEN '$@;
167 QUIET_STDERR = 2> /dev/null
168 QUIET_SUBDIR0 = +@subdir=
169 QUIET_SUBDIR1 = ;$(NO_SUBDIR) \
170 echo ' SUBDIR ' $$subdir; \
171 $(MAKE) $(PRINT_DIR) -C $$subdir
172 export V
173 endif
174 endif
176 all: html man
178 html: $(DOC_HTML)
180 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7): asciidoc.conf
182 man: man1 man5 man7
183 man1: $(DOC_MAN1)
184 man5: $(DOC_MAN5)
185 man7: $(DOC_MAN7)
187 info: $(OUTPUT)perf.info $(OUTPUT)perfman.info
189 pdf: $(OUTPUT)user-manual.pdf
191 install: install-man
193 check-man-tools:
194 ifdef missing_tools
195 $(error "You need to install $(missing_tools) for man pages")
196 endif
198 do-install-man: man
199 $(call QUIET_INSTALL, Documentation-man) \
200 $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir); \
201 # $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir); \
202 # $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir); \
203 $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir); \
204 # $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir); \
205 # $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
207 install-man: check-man-tools man do-install-man
209 ifdef missing_tools
210 DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed)
211 else
212 DO_INSTALL_MAN = do-install-man
213 endif
215 try-install-man: $(DO_INSTALL_MAN)
217 install-info: info
218 $(call QUIET_INSTALL, Documentation-info) \
219 $(INSTALL) -d -m 755 $(DESTDIR)$(infodir); \
220 $(INSTALL) -m 644 $(OUTPUT)perf.info $(OUTPUT)perfman.info $(DESTDIR)$(infodir); \
221 if test -r $(DESTDIR)$(infodir)/dir; then \
222 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perf.info ;\
223 $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) perfman.info ;\
224 else \
225 echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
228 install-pdf: pdf
229 $(call QUIET_INSTALL, Documentation-pdf) \
230 $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir); \
231 $(INSTALL) -m 644 $(OUTPUT)user-manual.pdf $(DESTDIR)$(pdfdir)
233 #install-html: html
234 # '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
238 # Determine "include::" file references in asciidoc files.
240 $(OUTPUT)doc.dep : $(wildcard *.txt) build-docdep.perl
241 $(QUIET_GEN)$(RM) $@+ $@ && \
242 $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
243 mv $@+ $@
245 -include $(OUTPUT)doc.dep
247 _cmds_txt = cmds-ancillaryinterrogators.txt \
248 cmds-ancillarymanipulators.txt \
249 cmds-mainporcelain.txt \
250 cmds-plumbinginterrogators.txt \
251 cmds-plumbingmanipulators.txt \
252 cmds-synchingrepositories.txt \
253 cmds-synchelpers.txt \
254 cmds-purehelpers.txt \
255 cmds-foreignscminterface.txt
256 cmds_txt=$(addprefix $(OUTPUT),$(_cmds_txt))
258 $(cmds_txt): $(OUTPUT)cmd-list.made
260 $(OUTPUT)cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
261 $(QUIET_GEN)$(RM) $@ && \
262 $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
263 date >$@
265 CLEAN_FILES = \
266 $(MAN_XML) $(addsuffix +,$(MAN_XML)) \
267 $(MAN_HTML) $(addsuffix +,$(MAN_HTML)) \
268 $(DOC_HTML) $(DOC_MAN1) $(DOC_MAN5) $(DOC_MAN7) \
269 $(OUTPUT)*.texi $(OUTPUT)*.texi+ $(OUTPUT)*.texi++ \
270 $(OUTPUT)perf.info $(OUTPUT)perfman.info \
271 $(OUTPUT)howto-index.txt $(OUTPUT)howto/*.html $(OUTPUT)doc.dep \
272 $(OUTPUT)technical/api-*.html $(OUTPUT)technical/api-index.txt \
273 $(cmds_txt) $(OUTPUT)*.made
274 clean:
275 $(call QUIET_CLEAN, Documentation) $(RM) $(CLEAN_FILES)
277 $(MAN_HTML): $(OUTPUT)%.html : %.txt
278 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
279 $(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \
280 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
281 mv $@+ $@
283 ifdef USE_ASCIIDOCTOR
284 $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : %.txt
285 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
286 $(ASCIIDOC) -b manpage -d manpage \
287 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) -o $@+ $< && \
288 mv $@+ $@
289 endif
291 $(OUTPUT)%.1 $(OUTPUT)%.5 $(OUTPUT)%.7 : $(OUTPUT)%.xml
292 $(QUIET_XMLTO)$(RM) $@ && \
293 $(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
295 $(OUTPUT)%.xml : %.txt
296 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
297 $(ASCIIDOC) -b docbook -d manpage \
298 $(ASCIIDOC_EXTRA) -aperf_version=$(PERF_VERSION) \
299 -aperf_date=$(shell git log -1 --pretty="format:%cd" \
300 --date=short $<) \
301 -o $@+ $< && \
302 mv $@+ $@
304 XSLT = docbook.xsl
305 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
307 $(OUTPUT)user-manual.html: $(OUTPUT)user-manual.xml
308 $(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
310 $(OUTPUT)perf.info: $(OUTPUT)user-manual.texi
311 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ $(OUTPUT)user-manual.texi
313 $(OUTPUT)user-manual.texi: $(OUTPUT)user-manual.xml
314 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
315 $(DOCBOOK2X_TEXI) $(OUTPUT)user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
316 $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
317 rm $@++ && \
318 mv $@+ $@
320 $(OUTPUT)user-manual.pdf: $(OUTPUT)user-manual.xml
321 $(QUIET_DBLATEX)$(RM) $@+ $@ && \
322 $(DBLATEX) -o $@+ -p /etc/asciidoc/dblatex/asciidoc-dblatex.xsl -s /etc/asciidoc/dblatex/asciidoc-dblatex.sty $< && \
323 mv $@+ $@
325 $(OUTPUT)perfman.texi: $(MAN_XML) cat-texi.perl
326 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
327 ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
328 --to-stdout $(xml) &&) true) > $@++ && \
329 $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
330 rm $@++ && \
331 mv $@+ $@
333 $(OUTPUT)perfman.info: $(OUTPUT)perfman.texi
334 $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
336 $(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
337 $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
338 $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
339 mv $@+ $@
341 howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
342 $(QUIET_GEN)$(RM) $@+ $@ && \
343 '$(SHELL_PATH_SQ)' ./howto-index.sh $(wildcard howto/*.txt) >$@+ && \
344 mv $@+ $@
346 $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
347 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b $(ASCIIDOC_HTML) $*.txt
349 WEBDOC_DEST = /pub/software/tools/perf/docs
351 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
352 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
353 sed -e '1,/^$$/d' $< | $(ASCIIDOC) -b $(ASCIIDOC_HTML) - >$@+ && \
354 mv $@+ $@
356 # UNIMPLEMENTED
357 #install-webdoc : html
358 # '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
360 # quick-install: quick-install-man
362 # quick-install-man:
363 # '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(DOC_REF) $(DESTDIR)$(mandir)
365 #quick-install-html:
366 # '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REF) $(DESTDIR)$(htmldir)