forked from universal-ctags/ctags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile.am
159 lines (135 loc) · 4.22 KB
/
GNUmakefile.am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#
# This is a Makefile.am read by the Autotools.
# GNU Make is needed.
#
# Copyright (c) 2017, Masatake YAMMATO
# Copyright (c) 2017, Red Hat, Inc.
#
# This source code is released for free distribution under the terms
# of the GNU General Public License version 2 or (at your option) any
# later version.
#
# Note: RST2MAN, RST2HTML, RST2PDF, and RST2MAN_OPTIONS are defined by configure.ac
RST2MAN_FLAGS = $(RST2MAN_OPTIONS)
RST2HTML_FLAGS =
RST2PDF_FLAGS =
DOCS_DIR = ../docs/man
SUFFIXES = .rst .html .pdf .in
# The man_MANS or dist_man_MANS requires conventional file names for man files.
# For example `$(basename $(files))` is not accepted.
GEN_IN_MAN_FILES = \
ctags.1 \
ctags-optlib.7 \
ctags-incompatibilities.7 \
ctags-client-tools.7 \
ctags-faq.7 \
\
ctags-lang-gdscript.7 \
ctags-lang-iPythonCell.7 \
ctags-lang-julia.7 \
ctags-lang-python.7 \
ctags-lang-tcl.7 \
ctags-lang-verilog.7 \
ctags-lang-inko.7 \
ctags-lang-r.7 \
ctags-lang-rmarkdown.7 \
ctags-lang-sql.7 \
ctags-lang-elm.7 \
\
readtags.1 \
tags.5 \
\
$(NULL)
man_pages = $(GEN_IN_MAN_FILES)
man_in_files = $(addsuffix .in,$(man_pages))
rst_files = $(addsuffix .rst,$(man_pages))
html_pages = $(addsuffix .html,$(man_pages))
pdf_pages = $(addsuffix .pdf,$(man_pages))
doc_files = $(addprefix $(DOCS_DIR)/,$(rst_files))
# for automake
# generate man pages only when rst2man is installed
if HAVE_RST2MAN
man_MANS = $(man_pages)
endif
EXTRA_DIST = README $(addsuffix .rst.in,$(GEN_IN_MAN_FILES)) $(man_in_files)
CLEANFILES = $(man_pages) $(addsuffix .rst,$(GEN_IN_MAN_FILES)) $(html_pages) $(pdf_pages)
MAINTAINERCLEANFILES = $(man_in_files)
.PHONY: man man-in html pdf update-docs clean-docs
all-am: update-docs
man: $(man_pages)
man-in: $(man_in_files)
html: $(html_pages)
pdf: $(pdf_pages)
# use `[@]` not to be replaced by automake
REPLACE_CONF_VARS = sed \
-e s/[@]CTAGS_NAME_EXECUTABLE[@]/ctags/g \
-e s/[@]ETAGS_NAME_EXECUTABLE[@]/etags/g \
-e s/[@]VERSION[@]/$(VERSION)/g
rst2man_verbose = $(rst2man_verbose_@AM_V@)
rst2man_verbose_ = $(rst2man_verbose_@AM_DEFAULT_V@)
rst2man_verbose_0 = @echo RST2MAN " $@";
rst2html_verbose = $(rst2html_verbose_@AM_V@)
rst2html_verbose_ = $(rst2html_verbose_@AM_DEFAULT_V@)
rst2html_verbose_0 = @echo RST2HTML " $@";
rst2pdf_verbose = $(rst2pdf_verbose_@AM_V@)
rst2pdf_verbose_ = $(rst2pdf_verbose_@AM_DEFAULT_V@)
rst2pdf_verbose_0 = @echo RST2MAN " $@";
sed_verbose = $(sed_verbose_@AM_V@)
sed_verbose_ = $(sed_verbose_@AM_DEFAULT_V@)
sed_verbose_0 = @echo SED " $@";
rm_verbose = $(rm_verbose_@AM_V@)
rm_verbose_ = $(rm_verbose_@AM_DEFAULT_V@)
rm_verbose_0 = @echo RM " $@";
#
# generate man
#
# generate *.in to be distributed
%.in: %.rst.in
if HAVE_RST2MAN
$(rst2man_verbose)$(RST2MAN) $(RST2MAN_FLAGS) $< > $@
else
$(error Cannot make $@: rst2man is not installed)
endif
%: %.in
$(sed_verbose)$(REPLACE_CONF_VARS) < $< > $@
#
# generate HTML and PDF
#
%.rst: %.rst.in
$(sed_verbose)$(REPLACE_CONF_VARS) < $< > $@
%.html: %.rst
if HAVE_RST2HTML
$(rst2html_verbose)$(RST2HTML) $(RST2HTML_FLAGS) $< > $@
else
$(error Cannot make $@: rst2html is not installed)
endif
%.pdf: %.rst
if HAVE_RST2PDF
$(rst2pdf_verbose)$(RST2PDF) $(RST2PDF_FLAGS) $< -o $@
else
$(error Cannot make $@: rst2pdf is not installed)
endif
#
# generate $(DOCS_DIR)/*.rst for Sphinx document
#
update-docs: $(doc_files)
# Convert the names of man page files (without suffix) to man page citations.
# ctags.1 tags.5 ... => ctags(1) tags(5) ...
cites := ${subst .,(,${addsuffix ),${man_pages}}}
# Convert the man page citations to sed patterns for making hyperlinks.
# ctags(1) tags(5) ...
# => -e 's/\<ctags(1)/:ref:`& <&>`/g' -e 's/\<ctags(5)/:ref:`& <&>`/g' ...
if HAS_GNU_SED
reppat := $(foreach m,$(cites),-e 's/\<$(m)/:ref:`& <&>`/g')
else
reppat := $(foreach m,$(cites),-e 's/[[:<:]]$(m)/:ref:`& <&>`/g')
endif
# Delete the line "------" in the first 10 lines of $(DOCS_DIR)/*.rst to
# suppress unnecessary section indices.
$(DOCS_DIR)/%.rst: %.rst
@$(MKDIR_P) $(DOCS_DIR)
$(sed_verbose)sed $(reppat) -e '1,10s/^-*$$//' < $< > $@
# remove generated files to be commited (used for `make checkgen`)
clean-local: clean-docs
clean-docs:
$(rm_verbose)rm -f $(man_in_files) $(doc_files)