Fix: Don't override user variables within the build system
[lttng-tools.git] / doc / man / Makefile.am
1 # Man pages are only built if they are enabled at configure time.
2 #
3 # They should always be built before creating a distribution tarball.
4
5 # function which adds the source directory prefix and adds a given suffix
6 manaddsuffix = $(addsuffix $(1),$(addprefix $(srcdir)/,$(2)))
7
8 # List only the names without the .*.txt extension here:
9 MAN1_NAMES = \
10 lttng \
11 lttng-create \
12 lttng-destroy \
13 lttng-set-session \
14 lttng-save \
15 lttng-load \
16 lttng-start \
17 lttng-stop \
18 lttng-version \
19 lttng-view \
20 lttng-enable-channel \
21 lttng-disable-channel \
22 lttng-add-context \
23 lttng-list \
24 lttng-track \
25 lttng-untrack \
26 lttng-status \
27 lttng-help \
28 lttng-snapshot \
29 lttng-enable-event \
30 lttng-disable-event \
31 lttng-crash \
32 lttng-metadata \
33 lttng-regenerate
34 MAN3_NAMES =
35 MAN8_NAMES = lttng-sessiond lttng-relayd
36 MAN1_NO_ASCIIDOC_NAMES =
37 MAN3_NO_ASCIIDOC_NAMES = lttng-health-check
38 MAN8_NO_ASCIIDOC_NAMES =
39
40 # AsciiDoc sources and outputs
41 MAN1_TXT = $(call manaddsuffix,.1.txt,$(MAN1_NAMES))
42 MAN3_TXT = $(call manaddsuffix,.3.txt,$(MAN3_NAMES))
43 MAN8_TXT = $(call manaddsuffix,.8.txt,$(MAN8_NAMES))
44 MAN_TXT = $(MAN1_TXT) $(MAN3_TXT) $(MAN8_TXT)
45 MAN_XML = $(patsubst $(srcdir)/%.txt,%.xml,$(MAN_TXT))
46
47 # common AsciiDoc source files
48 COMMON_TXT = \
49 $(srcdir)/common-footer.txt \
50 $(srcdir)/common-cmd-footer.txt \
51 $(srcdir)/common-cmd-options-head.txt \
52 $(srcdir)/common-cmd-help-options.txt
53
54 # config
55 ASCIIDOC_CONF = $(srcdir)/asciidoc.conf
56 ASCIIDOC_ATTRS_CONF = $(builddir)/asciidoc-attrs.conf
57 XSL_FILES = \
58 manpage.xsl \
59 manpage-callouts.xsl \
60 manpage-bold-literal.xsl \
61 manpage-links.xsl
62 XSL_SRC_FILES = $(addprefix $(srcdir)/xsl/,$(XSL_FILES))
63
64 # common dependencies
65 COMMON_DEPS = $(ASCIIDOC_CONF) $(COMMON_TXT)
66
67 # man pages destinations
68 MAN1 = $(addsuffix .1,$(MAN1_NAMES))
69 MAN3 = $(addsuffix .3,$(MAN3_NAMES))
70 MAN8 = $(addsuffix .8,$(MAN8_NAMES))
71 MAN1_NO_ASCIIDOC = $(addsuffix .1,$(MAN1_NO_ASCIIDOC_NAMES))
72 MAN3_NO_ASCIIDOC = $(addsuffix .3,$(MAN3_NO_ASCIIDOC_NAMES))
73 MAN8_NO_ASCIIDOC = $(addsuffix .8,$(MAN8_NO_ASCIIDOC_NAMES))
74 MAN = $(MAN1) $(MAN3) $(MAN8)
75
76 # initially empty
77 CLEANFILES =
78
79 if EMBED_HELP
80 MAN1_H = $(addsuffix .1.h,$(MAN1_NAMES))
81 MAN3_H = $(addsuffix .3.h,$(MAN3_NAMES))
82 MAN8_H = $(addsuffix .8.h,$(MAN8_NAMES))
83 MAN_H = $(MAN1_H) $(MAN3_H) $(MAN8_H)
84 MAN_H_RECIPE = \
85 MANWIDTH=80 @MANPROG@ --encoding=UTF-8 --no-hyphenation --no-justification --local-file $< > $@ ; \
86 $(SED) -i 's/\\/\\\\/g' $@ ; \
87 $(SED) -i 's/"/\\"/g' $@ ; \
88 $(SED) -i 's/^\(.*\)$$/"\1\\n"/' $@
89
90 %.1.h: %.1
91 $(MAN_H_RECIPE)
92
93 %.3.h: %.3
94 $(MAN_H_RECIPE)
95
96 %.8.h: %.8
97 $(MAN_H_RECIPE)
98
99 all-local: $(MAN_H)
100
101 CLEANFILES += $(MAN_H)
102 endif # EMBED_HELP
103
104 if MAN_PAGES_OPT
105 # at this point, we know the user asked to build the man pages
106 if HAVE_ASCIIDOC_XMLTO
107 # tools
108 ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -f $(ASCIIDOC_ATTRS_CONF) -d manpage
109 ADOC_DOCBOOK = $(ADOC) -b docbook
110 XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man
111
112 # only add this dependency if we can build the man pages because it's
113 # a file generated by the configure script, so it's more recent than
114 # the pregenerated man pages in a tarball
115 COMMON_DEPS += $(ASCIIDOC_ATTRS_CONF)
116
117 # recipes
118 %.1.xml: $(srcdir)/%.1.txt $(COMMON_DEPS)
119 $(ADOC_DOCBOOK) -o $@ $<
120
121 %.1: %.1.xml $(XSL_SRC_FILES)
122 $(XTO) $<
123
124 %.3.xml: $(srcdir)/%.3.txt $(COMMON_DEPS)
125 $(ADOC_DOCBOOK) -o $@ $<
126
127 %.3: %.3.xml $(XSL_SRC_FILES)
128 $(XTO) $<
129
130 %.8.xml: $(srcdir)/%.8.txt $(COMMON_DEPS)
131 $(ADOC_DOCBOOK) -o $@ $<
132
133 %.8: %.8.xml $(XSL_SRC_FILES)
134 $(XTO) $<
135
136 # only clean the generated files if we have the tools to generate them again
137 CLEANFILES += $(MAN_XML) $(MAN)
138 else # HAVE_ASCIIDOC_XMLTO
139 # create man page targets used to stop the build if we want to
140 # build the man pages, but we don't have the necessary tools to do so
141 ERR_MSG = "Error: Cannot build target because asciidoc or xmlto tool is missing."
142 ERR_MSG += "Make sure both tools are installed and run the configure script again."
143
144 %.1: $(srcdir)/%.1.txt $(COMMON_DEPS)
145 @echo $(ERR_MSG)
146 @false
147
148 %.3: $(srcdir)/%.3.txt $(COMMON_DEPS)
149 @echo $(ERR_MSG)
150 @false
151
152 %.8: $(srcdir)/%.8.txt $(COMMON_DEPS)
153 @echo $(ERR_MSG)
154 @false
155 endif # HAVE_ASCIIDOC_XMLTO
156 endif # MAN_PAGES_OPT
157
158 # those are always installed since they are directly written in troff
159 dist_man1_MANS = $(MAN1_NO_ASCIIDOC)
160 dist_man3_MANS = $(MAN3_NO_ASCIIDOC)
161 dist_man8_MANS = $(MAN8_NO_ASCIIDOC)
162
163 if MAN_PAGES_OPT
164 # building man pages: we can install and distribute them
165 dist_man1_MANS += $(MAN1)
166 dist_man3_MANS += $(MAN3)
167 dist_man8_MANS += $(MAN8)
168 endif # MAN_PAGES_OPT
169
170 if !MAN_PAGES_OPT
171 dist-hook:
172 @echo "Error: Please enable the man pages before creating a distribution tarball."
173 @false
174 endif # !MAN_PAGES_OPT
175
176 # always distribute the source files
177 EXTRA_DIST = $(MAN_TXT) $(COMMON_TXT) $(XSL_SRC_FILES) \
178 $(ASCIIDOC_CONF) $(ASCIIDOC_ATTRS_CONF).in
179
180 # keep generated man pages that can be considered intermediate files
181 .PRECIOUS: %.1 %.3 %.8
This page took 0.03313 seconds and 4 git commands to generate.