blob: aa72ab96c3c1dbe2982c157ae22b50adae9e1bb3 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001include ../../../scripts/Makefile.include
2include ../../../scripts/utilities.mak
3
4# This Makefile and manpage XSL files were taken from tools/perf/Documentation
5# and modified for libtraceevent.
6
7MAN3_TXT= \
8 $(wildcard libtraceevent-*.txt) \
9 libtraceevent.txt
10
11MAN_TXT = $(MAN3_TXT)
12_MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
13_MAN_HTML=$(patsubst %.txt,%.html,$(MAN_TXT))
14_DOC_MAN3=$(patsubst %.txt,%.3,$(MAN3_TXT))
15
16MAN_XML=$(addprefix $(OUTPUT),$(_MAN_XML))
17MAN_HTML=$(addprefix $(OUTPUT),$(_MAN_HTML))
18DOC_MAN3=$(addprefix $(OUTPUT),$(_DOC_MAN3))
19
20# Make the path relative to DESTDIR, not prefix
21ifndef DESTDIR
22prefix?=$(HOME)
23endif
24bindir?=$(prefix)/bin
25htmldir?=$(prefix)/share/doc/libtraceevent-doc
26pdfdir?=$(prefix)/share/doc/libtraceevent-doc
27mandir?=$(prefix)/share/man
28man3dir=$(mandir)/man3
29
30ASCIIDOC=asciidoc
31ASCIIDOC_EXTRA = --unsafe -f asciidoc.conf
32ASCIIDOC_HTML = xhtml11
33MANPAGE_XSL = manpage-normal.xsl
34XMLTO_EXTRA =
35INSTALL?=install
36RM ?= rm -f
37
38ifdef USE_ASCIIDOCTOR
39ASCIIDOC = asciidoctor
40ASCIIDOC_EXTRA = -a compat-mode
41ASCIIDOC_EXTRA += -I. -rasciidoctor-extensions
42ASCIIDOC_EXTRA += -a mansource="libtraceevent" -a manmanual="libtraceevent Manual"
43ASCIIDOC_HTML = xhtml5
44endif
45
46XMLTO=xmlto
47
48_tmp_tool_path := $(call get-executable,$(ASCIIDOC))
49ifeq ($(_tmp_tool_path),)
50 missing_tools = $(ASCIIDOC)
51endif
52
53ifndef USE_ASCIIDOCTOR
54_tmp_tool_path := $(call get-executable,$(XMLTO))
55ifeq ($(_tmp_tool_path),)
56 missing_tools += $(XMLTO)
57endif
58endif
59
60#
61# For asciidoc ...
62# -7.1.2, no extra settings are needed.
63# 8.0-, set ASCIIDOC8.
64#
65
66#
67# For docbook-xsl ...
68# -1.68.1, set ASCIIDOC_NO_ROFF? (based on changelog from 1.73.0)
69# 1.69.0, no extra settings are needed?
70# 1.69.1-1.71.0, set DOCBOOK_SUPPRESS_SP?
71# 1.71.1, no extra settings are needed?
72# 1.72.0, set DOCBOOK_XSL_172.
73# 1.73.0-, set ASCIIDOC_NO_ROFF
74#
75
76#
77# If you had been using DOCBOOK_XSL_172 in an attempt to get rid
78# of 'the ".ft C" problem' in your generated manpages, and you
79# instead ended up with weird characters around callouts, try
80# using ASCIIDOC_NO_ROFF instead (it works fine with ASCIIDOC8).
81#
82
83ifdef ASCIIDOC8
84ASCIIDOC_EXTRA += -a asciidoc7compatible
85endif
86ifdef DOCBOOK_XSL_172
87ASCIIDOC_EXTRA += -a libtraceevent-asciidoc-no-roff
88MANPAGE_XSL = manpage-1.72.xsl
89else
90 ifdef ASCIIDOC_NO_ROFF
91 # docbook-xsl after 1.72 needs the regular XSL, but will not
92 # pass-thru raw roff codes from asciidoc.conf, so turn them off.
93 ASCIIDOC_EXTRA += -a libtraceevent-asciidoc-no-roff
94 endif
95endif
96ifdef MAN_BOLD_LITERAL
97XMLTO_EXTRA += -m manpage-bold-literal.xsl
98endif
99ifdef DOCBOOK_SUPPRESS_SP
100XMLTO_EXTRA += -m manpage-suppress-sp.xsl
101endif
102
103SHELL_PATH ?= $(SHELL)
104# Shell quote;
105SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
106
107DESTDIR ?=
108DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
109
110export DESTDIR DESTDIR_SQ
111
112#
113# Please note that there is a minor bug in asciidoc.
114# The version after 6.0.3 _will_ include the patch found here:
115# http://marc.theaimsgroup.com/?l=libtraceevent&m=111558757202243&w=2
116#
117# Until that version is released you may have to apply the patch
118# yourself - yes, all 6 characters of it!
119#
120QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
121QUIET_SUBDIR1 =
122
123ifneq ($(findstring $(MAKEFLAGS),w),w)
124PRINT_DIR = --no-print-directory
125else # "make -w"
126NO_SUBDIR = :
127endif
128
129ifneq ($(findstring $(MAKEFLAGS),s),s)
130ifneq ($(V),1)
131 QUIET_ASCIIDOC = @echo ' ASCIIDOC '$@;
132 QUIET_XMLTO = @echo ' XMLTO '$@;
133 QUIET_SUBDIR0 = +@subdir=
134 QUIET_SUBDIR1 = ;$(NO_SUBDIR) \
135 echo ' SUBDIR ' $$subdir; \
136 $(MAKE) $(PRINT_DIR) -C $$subdir
137 export V
138endif
139endif
140
141all: html man
142
143man: man3
144man3: $(DOC_MAN3)
145
146html: $(MAN_HTML)
147
148$(MAN_HTML) $(DOC_MAN3): asciidoc.conf
149
150install: install-man
151
152check-man-tools:
153ifdef missing_tools
154 $(error "You need to install $(missing_tools) for man pages")
155endif
156
157do-install-man: man
158 $(call QUIET_INSTALL, Documentation-man) \
159 $(INSTALL) -d -m 755 $(DESTDIR)$(man3dir); \
160 $(INSTALL) -m 644 $(DOC_MAN3) $(DESTDIR)$(man3dir);
161
162install-man: check-man-tools man do-install-man
163
164uninstall: uninstall-man
165
166uninstall-man:
167 $(call QUIET_UNINST, Documentation-man) \
168 $(Q)$(RM) $(addprefix $(DESTDIR)$(man3dir)/,$(DOC_MAN3))
169
170
171ifdef missing_tools
172 DO_INSTALL_MAN = $(warning Please install $(missing_tools) to have the man pages installed)
173else
174 DO_INSTALL_MAN = do-install-man
175endif
176
177CLEAN_FILES = \
178 $(MAN_XML) $(addsuffix +,$(MAN_XML)) \
179 $(MAN_HTML) $(addsuffix +,$(MAN_HTML)) \
180 $(DOC_MAN3) *.3
181
182clean:
183 $(call QUIET_CLEAN, Documentation) $(RM) $(CLEAN_FILES)
184
185ifdef USE_ASCIIDOCTOR
186$(OUTPUT)%.3 : $(OUTPUT)%.txt
187 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
188 $(ASCIIDOC) -b manpage -d manpage \
189 $(ASCIIDOC_EXTRA) -alibtraceevent_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \
190 mv $@+ $@
191endif
192
193$(OUTPUT)%.3 : $(OUTPUT)%.xml
194 $(QUIET_XMLTO)$(RM) $@ && \
195 $(XMLTO) -o $(OUTPUT). -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
196
197$(OUTPUT)%.xml : %.txt
198 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
199 $(ASCIIDOC) -b docbook -d manpage \
200 $(ASCIIDOC_EXTRA) -alibtraceevent_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \
201 mv $@+ $@
202
203$(MAN_HTML): $(OUTPUT)%.html : %.txt
204 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
205 $(ASCIIDOC) -b $(ASCIIDOC_HTML) -d manpage \
206 $(ASCIIDOC_EXTRA) -aperf_version=$(EVENT_PARSE_VERSION) -o $@+ $< && \
207 mv $@+ $@