Debian Codegraph @

Documentation/Makefile

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