18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
28c2ecf20Sopenharmony_ci# Most of this file is copied from tools/perf/Documentation/Makefile
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciinclude ../../../scripts/Makefile.include
58c2ecf20Sopenharmony_ciinclude ../../../scripts/utilities.mak
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciMAN3_TXT  = libperf.txt
88c2ecf20Sopenharmony_ciMAN7_TXT  = libperf-counting.txt libperf-sampling.txt
98c2ecf20Sopenharmony_ciMAN_EX    = examples/*.c
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciMAN_TXT   = $(MAN3_TXT) $(MAN7_TXT)
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci_MAN_XML  = $(patsubst %.txt,%.xml,$(MAN_TXT))
148c2ecf20Sopenharmony_ci_MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
158c2ecf20Sopenharmony_ci_MAN_3    = $(patsubst %.txt,%.3,$(MAN3_TXT))
168c2ecf20Sopenharmony_ci_MAN_7    = $(patsubst %.txt,%.7,$(MAN7_TXT))
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciMAN_XML   = $(addprefix $(OUTPUT),$(_MAN_XML))
198c2ecf20Sopenharmony_ciMAN_HTML  = $(addprefix $(OUTPUT),$(_MAN_HTML))
208c2ecf20Sopenharmony_ciMAN_3     = $(addprefix $(OUTPUT),$(_MAN_3))
218c2ecf20Sopenharmony_ciMAN_7     = $(addprefix $(OUTPUT),$(_MAN_7))
228c2ecf20Sopenharmony_ciMAN_X     = $(MAN_3) $(MAN_7)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci# Make the path relative to DESTDIR, not prefix
258c2ecf20Sopenharmony_ciifndef DESTDIR
268c2ecf20Sopenharmony_ci  prefix ?=$(HOME)
278c2ecf20Sopenharmony_ciendif
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_cimandir  ?= $(prefix)/share/man
308c2ecf20Sopenharmony_ciman3dir  = $(mandir)/man3
318c2ecf20Sopenharmony_ciman7dir  = $(mandir)/man7
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cidocdir  ?= $(prefix)/share/doc/libperf
348c2ecf20Sopenharmony_cihtmldir  = $(docdir)/html
358c2ecf20Sopenharmony_ciexdir    = $(docdir)/examples
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciASCIIDOC        = asciidoc
388c2ecf20Sopenharmony_ciASCIIDOC_EXTRA  = --unsafe -f asciidoc.conf
398c2ecf20Sopenharmony_ciASCIIDOC_HTML   = xhtml11
408c2ecf20Sopenharmony_ciMANPAGE_XSL     = manpage-normal.xsl
418c2ecf20Sopenharmony_ciXMLTO_EXTRA     =
428c2ecf20Sopenharmony_ciXMLTO           =xmlto
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ciINSTALL ?= install
458c2ecf20Sopenharmony_ciRM      ?= rm -f
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci# For asciidoc ...
488c2ecf20Sopenharmony_ci#	-7.1.2,	no extra settings are needed.
498c2ecf20Sopenharmony_ci#	8.0-,	set ASCIIDOC8.
508c2ecf20Sopenharmony_ci#
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci# For docbook-xsl ...
538c2ecf20Sopenharmony_ci#	-1.68.1,	set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
548c2ecf20Sopenharmony_ci#	1.69.0,		no extra settings are needed?
558c2ecf20Sopenharmony_ci#	1.69.1-1.71.0,	set DOCBOOK_SUPPRESS_SP?
568c2ecf20Sopenharmony_ci#	1.71.1,		no extra settings are needed?
578c2ecf20Sopenharmony_ci#	1.72.0,		set DOCBOOK_XSL_172.
588c2ecf20Sopenharmony_ci#	1.73.0-,	set ASCIIDOC_NO_ROFF
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
618c2ecf20Sopenharmony_ci# of 'the ".ft C" problem' in your generated manpages, and you
628c2ecf20Sopenharmony_ci# instead ended up with weird characters around callouts, try
638c2ecf20Sopenharmony_ci# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciifdef ASCIIDOC8
668c2ecf20Sopenharmony_ci  ASCIIDOC_EXTRA += -a asciidoc7compatible
678c2ecf20Sopenharmony_ciendif
688c2ecf20Sopenharmony_ciifdef DOCBOOK_XSL_172
698c2ecf20Sopenharmony_ci  ASCIIDOC_EXTRA += -a libperf-asciidoc-no-roff
708c2ecf20Sopenharmony_ci  MANPAGE_XSL = manpage-1.72.xsl
718c2ecf20Sopenharmony_cielse
728c2ecf20Sopenharmony_ci  ifdef ASCIIDOC_NO_ROFF
738c2ecf20Sopenharmony_ci    # docbook-xsl after 1.72 needs the regular XSL, but will not
748c2ecf20Sopenharmony_ci    # pass-thru raw roff codes from asciidoc.conf, so turn them off.
758c2ecf20Sopenharmony_ci    ASCIIDOC_EXTRA += -a libperf-asciidoc-no-roff
768c2ecf20Sopenharmony_ci  endif
778c2ecf20Sopenharmony_ciendif
788c2ecf20Sopenharmony_ciifdef MAN_BOLD_LITERAL
798c2ecf20Sopenharmony_ci  XMLTO_EXTRA += -m manpage-bold-literal.xsl
808c2ecf20Sopenharmony_ciendif
818c2ecf20Sopenharmony_ciifdef DOCBOOK_SUPPRESS_SP
828c2ecf20Sopenharmony_ci  XMLTO_EXTRA += -m manpage-suppress-sp.xsl
838c2ecf20Sopenharmony_ciendif
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ciDESTDIR ?=
868c2ecf20Sopenharmony_ciDESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ciexport DESTDIR DESTDIR_SQ
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci# Please note that there is a minor bug in asciidoc.
918c2ecf20Sopenharmony_ci# The version after 6.0.3 _will_ include the patch found here:
928c2ecf20Sopenharmony_ci#   http://marc.theaimsgroup.com/?l=libtraceevent&m=111558757202243&w=2
938c2ecf20Sopenharmony_ci#
948c2ecf20Sopenharmony_ci# Until that version is released you may have to apply the patch
958c2ecf20Sopenharmony_ci# yourself - yes, all 6 characters of it!
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ciQUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
988c2ecf20Sopenharmony_ciQUIET_SUBDIR1  =
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ciifneq ($(findstring $(MAKEFLAGS),w),w)
1018c2ecf20Sopenharmony_ci  PRINT_DIR = --no-print-directory
1028c2ecf20Sopenharmony_cielse # "make -w"
1038c2ecf20Sopenharmony_ci  NO_SUBDIR = :
1048c2ecf20Sopenharmony_ciendif
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ciifneq ($(findstring $(MAKEFLAGS),s),s)
1078c2ecf20Sopenharmony_ci  ifneq ($(V),1)
1088c2ecf20Sopenharmony_ci    QUIET_ASCIIDOC = @echo '  ASCIIDOC '$@;
1098c2ecf20Sopenharmony_ci    QUIET_XMLTO    = @echo '  XMLTO    '$@;
1108c2ecf20Sopenharmony_ci  endif
1118c2ecf20Sopenharmony_ciendif
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ciall: $(MAN_X) $(MAN_HTML)
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci$(MAN_HTML) $(MAN_X): asciidoc.conf
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ciinstall-man: all
1188c2ecf20Sopenharmony_ci	$(call QUIET_INSTALL, man) \
1198c2ecf20Sopenharmony_ci		$(INSTALL) -d -m 755 $(DESTDIR)$(man3dir); \
1208c2ecf20Sopenharmony_ci		$(INSTALL) -m 644 $(MAN_3) $(DESTDIR)$(man3dir); \
1218c2ecf20Sopenharmony_ci		$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir); \
1228c2ecf20Sopenharmony_ci		$(INSTALL) -m 644 $(MAN_7) $(DESTDIR)$(man7dir);
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciinstall-html:
1258c2ecf20Sopenharmony_ci	$(call QUIET_INSTALL, html) \
1268c2ecf20Sopenharmony_ci		$(INSTALL) -d -m 755 $(DESTDIR)$(htmldir); \
1278c2ecf20Sopenharmony_ci		$(INSTALL) -m 644 $(MAN_HTML) $(DESTDIR)$(htmldir); \
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ciinstall-examples:
1308c2ecf20Sopenharmony_ci	$(call QUIET_INSTALL, examples) \
1318c2ecf20Sopenharmony_ci		$(INSTALL) -d -m 755 $(DESTDIR)$(exdir); \
1328c2ecf20Sopenharmony_ci		$(INSTALL) -m 644 $(MAN_EX) $(DESTDIR)$(exdir); \
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ciCLEAN_FILES =					\
1358c2ecf20Sopenharmony_ci	$(MAN_XML) $(addsuffix +,$(MAN_XML))	\
1368c2ecf20Sopenharmony_ci	$(MAN_HTML) $(addsuffix +,$(MAN_HTML))	\
1378c2ecf20Sopenharmony_ci	$(MAN_X)
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ciclean:
1408c2ecf20Sopenharmony_ci	$(call QUIET_CLEAN, Documentation) $(RM) $(CLEAN_FILES)
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci$(MAN_3): $(OUTPUT)%.3: %.xml
1438c2ecf20Sopenharmony_ci	$(QUIET_XMLTO)$(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci$(MAN_7): $(OUTPUT)%.7: %.xml
1468c2ecf20Sopenharmony_ci	$(QUIET_XMLTO)$(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci$(MAN_XML): $(OUTPUT)%.xml: %.txt
1498c2ecf20Sopenharmony_ci	$(QUIET_ASCIIDOC)$(ASCIIDOC) -b docbook -d manpage \
1508c2ecf20Sopenharmony_ci		$(ASCIIDOC_EXTRA) -alibperf_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \
1518c2ecf20Sopenharmony_ci	mv $@+ $@
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci$(MAN_HTML): $(OUTPUT)%.html: %.txt
1548c2ecf20Sopenharmony_ci	$(QUIET_ASCIIDOC)$(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \
1558c2ecf20Sopenharmony_ci	$(ASCIIDOC_EXTRA) -aperf_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \
1568c2ecf20Sopenharmony_ci	mv $@+ $@
157