xref: /linux/tools/lib/perf/Documentation/Makefile (revision c34e9ab9a612ee8b18273398ef75c207b01f516d)
1# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
2# Most of this file is copied from tools/perf/Documentation/Makefile
3
4include ../../../scripts/Makefile.include
5include ../../../scripts/utilities.mak
6
7MAN3_TXT  = libperf.txt
8MAN7_TXT  = libperf-counting.txt libperf-sampling.txt
9MAN_EX    = examples/*.c
10
11MAN_TXT   = $(MAN3_TXT) $(MAN7_TXT)
12
13_MAN_XML  = $(patsubst %.txt,%.xml,$(MAN_TXT))
14_MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
15_MAN_3    = $(patsubst %.txt,%.3,$(MAN3_TXT))
16_MAN_7    = $(patsubst %.txt,%.7,$(MAN7_TXT))
17
18MAN_XML   = $(addprefix $(OUTPUT),$(_MAN_XML))
19MAN_HTML  = $(addprefix $(OUTPUT),$(_MAN_HTML))
20MAN_3     = $(addprefix $(OUTPUT),$(_MAN_3))
21MAN_7     = $(addprefix $(OUTPUT),$(_MAN_7))
22MAN_X     = $(MAN_3) $(MAN_7)
23
24# Make the path relative to DESTDIR, not prefix
25ifndef DESTDIR
26  prefix ?=$(HOME)
27endif
28
29mandir  ?= $(prefix)/share/man
30man3dir  = $(mandir)/man3
31man7dir  = $(mandir)/man7
32
33docdir  ?= $(prefix)/share/doc/libperf
34htmldir  = $(docdir)/html
35exdir    = $(docdir)/examples
36
37ASCIIDOC        = asciidoc
38ASCIIDOC_EXTRA  = --unsafe -f asciidoc.conf
39ASCIIDOC_HTML   = xhtml11
40MANPAGE_XSL     = manpage-normal.xsl
41XMLTO_EXTRA     =
42XMLTO           =xmlto
43
44INSTALL ?= install
45RM      ?= rm -f
46
47# For asciidoc ...
48#	-7.1.2,	no extra settings are needed.
49#	8.0-,	set ASCIIDOC8.
50#
51
52# For docbook-xsl ...
53#	-1.68.1,	set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
54#	1.69.0,		no extra settings are needed?
55#	1.69.1-1.71.0,	set DOCBOOK_SUPPRESS_SP?
56#	1.71.1,		no extra settings are needed?
57#	1.72.0,		set DOCBOOK_XSL_172.
58#	1.73.0-,	set ASCIIDOC_NO_ROFF
59
60# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
61# of 'the ".ft C" problem' in your generated manpages, and you
62# instead ended up with weird characters around callouts, try
63# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
64
65ifdef ASCIIDOC8
66  ASCIIDOC_EXTRA += -a asciidoc7compatible
67endif
68ifdef DOCBOOK_XSL_172
69  ASCIIDOC_EXTRA += -a libperf-asciidoc-no-roff
70  MANPAGE_XSL = manpage-1.72.xsl
71else
72  ifdef ASCIIDOC_NO_ROFF
73    # docbook-xsl after 1.72 needs the regular XSL, but will not
74    # pass-thru raw roff codes from asciidoc.conf, so turn them off.
75    ASCIIDOC_EXTRA += -a libperf-asciidoc-no-roff
76  endif
77endif
78ifdef MAN_BOLD_LITERAL
79  XMLTO_EXTRA += -m manpage-bold-literal.xsl
80endif
81ifdef DOCBOOK_SUPPRESS_SP
82  XMLTO_EXTRA += -m manpage-suppress-sp.xsl
83endif
84
85DESTDIR ?=
86DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
87
88export DESTDIR DESTDIR_SQ
89
90# Please note that there is a minor bug in asciidoc.
91# The version after 6.0.3 _will_ include the patch found here:
92#   http://marc.theaimsgroup.com/?l=libtraceevent&m=111558757202243&w=2
93#
94# Until that version is released you may have to apply the patch
95# yourself - yes, all 6 characters of it!
96
97QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
98QUIET_SUBDIR1  =
99
100ifneq ($(findstring $(MAKEFLAGS),w),w)
101  PRINT_DIR = --no-print-directory
102else # "make -w"
103  NO_SUBDIR = :
104endif
105
106ifneq ($(findstring $(MAKEFLAGS),s),s)
107  ifneq ($(V),1)
108    QUIET_ASCIIDOC = @echo '  ASCIIDOC '$@;
109    QUIET_XMLTO    = @echo '  XMLTO    '$@;
110  endif
111endif
112
113all: $(MAN_X) $(MAN_HTML)
114
115$(MAN_HTML) $(MAN_X): asciidoc.conf
116
117install-man: all
118	$(call QUIET_INSTALL, man) \
119		$(INSTALL) -d -m 755 $(DESTDIR)$(man3dir); \
120		$(INSTALL) -m 644 $(MAN_3) $(DESTDIR)$(man3dir); \
121		$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir); \
122		$(INSTALL) -m 644 $(MAN_7) $(DESTDIR)$(man7dir);
123
124install-html: $(MAN_HTML)
125	$(call QUIET_INSTALL, html) \
126		$(INSTALL) -d -m 755 $(DESTDIR)$(htmldir); \
127		$(INSTALL) -m 644 $(MAN_HTML) $(DESTDIR)$(htmldir); \
128
129install-examples:
130	$(call QUIET_INSTALL, examples) \
131		$(INSTALL) -d -m 755 $(DESTDIR)$(exdir); \
132		$(INSTALL) -m 644 $(MAN_EX) $(DESTDIR)$(exdir); \
133
134CLEAN_FILES =					\
135	$(MAN_XML) $(addsuffix +,$(MAN_XML))	\
136	$(MAN_HTML) $(addsuffix +,$(MAN_HTML))	\
137	$(MAN_X)
138
139clean:
140	$(call QUIET_CLEAN, Documentation) $(RM) $(CLEAN_FILES)
141
142$(MAN_3): $(OUTPUT)%.3: %.xml
143	$(QUIET_XMLTO)$(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
144
145$(MAN_7): $(OUTPUT)%.7: %.xml
146	$(QUIET_XMLTO)$(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
147
148$(MAN_XML): $(OUTPUT)%.xml: %.txt
149	$(QUIET_ASCIIDOC)$(ASCIIDOC) -b docbook -d manpage \
150		$(ASCIIDOC_EXTRA) -alibperf_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \
151	mv $@+ $@
152
153$(MAN_HTML): $(OUTPUT)%.html: %.txt
154	$(QUIET_ASCIIDOC)$(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \
155	$(ASCIIDOC_EXTRA) -aperf_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \
156	mv $@+ $@
157