forked from universal-ctags/ctags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
129 lines (112 loc) · 3.62 KB
/
Makefile
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
#
# This is a stand-alone Makefile for Universal-ctags maintainers.
# GNU Make is needed.
#
# This doesn't work with Makefile.am at the top of source tree.
#
# 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.
#
# rst2man and rst2html are part of python-docutils, and if not found
# can be installed using pip ("pip install docutils"). On some
# systems, rst2man and rst2html are actually installed as rst2man.py
# and rst2html.py - create a symlink of that's the case.
#
# rst2pdf is a separate tool and can also be installed via pip (e.g.,
# "pip install rst2pdf")
RST2MAN = $(shell command -v rst2man || command -v rst2man.py || command -v rst2man-3 || command -v rst2man-3.6 || command -v rst2man-3.7 || command -v rst2man-3.8 || command -v rst2man-3.9 || echo rst2man)
RST2HTML = $(shell command -v rst2html || command -v rst2html.py || command -v rst2html-3 || command -v rst2html-3.6 || command -v rst2html-3.7 || command -v rst2html-3.8 || command -v rst2html-3.9 || echo rst2html)
RST2PDF = rst2pdf
# rst2man had a bug about code-block:: handling.
# https://sourceforge.net/p/docutils/patches/141
RST2MAN_FLAGS = $(shell if $(RST2MAN) --help | grep -q -e --syntax-highlight; then \
echo --syntax-highlight=none; \
fi)
RST2HTML_FLAGS =
RST2PDF_FLAGS =
# To avoid running configure for quick previewing do:
#
# $ make QUICK=1
#
QUICK =
CONFIGURE_FLAGS =
.SUFFIXES: .rst .html .pdf .in
IN_SOURCE_FILES = \
ctags.1.rst.in \
ctags-optlib.7.rst.in \
ctags-incompatibilities.7.rst.in \
ctags-client-tools.7.rst.in \
ctags-faq.7.rst.in \
\
ctags-lang-iPythonCell.7.rst.in \
ctags-lang-julia.7.rst.in \
ctags-lang-python.7.rst.in \
ctags-lang-verilog.7.rst.in \
ctags-lang-inko.7.rst.in \
ctags-lang-r.7.rst.in \
ctags-lang-sql.7.rst.in \
\
readtags.1.rst.in \
\
$(NULL)
SOURCE_FILES = \
tags.5.rst \
\
$(NULL)
gen_rst_files = $(basename $(IN_SOURCE_FILES))
rst_files = $(gen_rst_files) $(SOURCE_FILES)
man_pages = $(basename $(rst_files))
html_pages = $(addsuffix .html,$(man_pages))
pdf_pages = $(addsuffix .pdf,$(man_pages))
doc_files = $(addprefix ../docs/man/,$(rst_files))
all: man html pdf
man: $(man_pages)
html: $(html_pages)
pdf: $(pdf_pages)
#
# 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' ...
#
is_gnu_sed := $(shell sed --version 2>/dev/null | grep -q GNU && echo 1)
ifeq ($(is_gnu_sed),1)
reppat := $(foreach m,$(cites),-e 's/\<$(m)/:ref:`& <&>`/g')
else
reppat := $(foreach m,$(cites),-e 's/[[:<:]]$(m)/:ref:`& <&>`/g')
endif
update-docs: $(doc_files)
# Delete the line "------" in the first 10 lines of ../docs/man/*.rst to
# suppress unnecessary section indices.
../docs/man/%.rst: %.rst
sed $(reppat) -e '1,10s/^-*$$//' < $< > $@
%.rst: %.rst.in
ifeq ($(QUICK),)
(cd ..; ./configure $(CONFIGURE_FLAGS))
else
version=`sed -n -e 's/AC_INIT(.*, *\[\(.*\)\])/\1/p' ../configure.ac`; \
sed \
-e s/@CTAGS_NAME_EXECUTABLE@/ctags/g \
-e s/@ETAGS_NAME_EXECUTABLE@/etags/g \
-e s/@VERSION@/$$version/g \
< $< > $@
endif
%: %.rst
$(RST2MAN) $(RST2MAN_FLAGS) $< > $@
%.html: %.rst
$(RST2HTML) $(RST2HTML_FLAGS) $< > $@
%.pdf: %.rst
$(RST2PDF) $(RST2PDF_FLAGS) $< -o $@
clean:
rm -f $(gen_rst_files) $(man_pages) $(html_pages) $(pdf_pages)