Skip to content

Commit

Permalink
Revert "buildsys: rewite man/Makefile.am"
Browse files Browse the repository at this point in the history
This reverts commit 0759cac.
  • Loading branch information
leleliu008 committed Apr 15, 2022
1 parent 0759cac commit d3af9c1
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 421 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/testing-alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
steps:
- run: apk add libc-dev gcc make automake autoconf pkgconf python3 file diffutils git

- run: git config --global --add safe.directory /__w/ctags/ctags

- uses: actions/checkout@v2

- run: cc --version
Expand Down
6 changes: 3 additions & 3 deletions makefiles/testing.mak
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ check-genfile:
fi
if HAVE_RST2MAN
# man/*.in : committed for man pages to be genrated without rst2man
# make clean-docs remove both man/*.rst and docs/man/*.rst
# make clean-docs remove both man/*.in and docs/man/*.rst
$(chkgen_verbose)$(MAKE) -C man clean-docs
$(chkgen_verbose)$(MAKE) -C man
$(chkgen_verbose)$(MAKE) -C man man-in
$(chkgen_verbose)if ! git diff --exit-code -- man; then \
echo "Files under man/ are not up to date." ; \
echo "Please execute 'make -C man' and commit them." ; \
echo "Please execute 'make -C man man-in' and commit them." ; \
exit 1 ; \
else \
echo "Files under man are up to date." ; \
Expand Down
194 changes: 141 additions & 53 deletions man/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# This is a Makefile.am read by the Autotools.
# GNU Make is needed.
#
# Copyright (c) 2017, Masatake YAMMATO
# Copyright (c) 2017, Red Hat, Inc.
Expand All @@ -9,63 +10,150 @@
# later version.
#

#SUFFIXES = .rst.in .rst .html .pdf
# 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 " $@";

VERBOSE = $(VERBOSE_@AM_V@)
VERBOSE_ = $(VERBOSE_@AM_DEFAULT_V@)
VERBOSE_0 = @

BUILD_OPTIONS = $(BUILD_OPTIONS_@AM_V@)
BUILD_OPTIONS_ = $(BUILD_OPTIONS_@AM_DEFAULT_V@)
BUILD_OPTIONS_1 = -v

#############################################################################

# https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Preset-Output-Variables.html
# in this document, we use `abs_srcdir`, this is an absolute dir of this file. to prevent: No such file or directory

rst:
$(VERBOSE)$(abs_srcdir)/build.sh $(BUILD_OPTIONS) gen-rst
#
# 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

man:
$(VERBOSE)$(abs_srcdir)/build.sh $(BUILD_OPTIONS) rst2man $(RST2MAN_OPTIONS)
%: %.in
$(sed_verbose)$(REPLACE_CONF_VARS) < $< > $@

pdf:
$(VERBOSE)$(abs_srcdir)/build.sh $(BUILD_OPTIONS) rst2pdf $(RST2PDF_OPTIONS)
#
# 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

html:
$(VERBOSE)$(abs_srcdir)/build.sh $(BUILD_OPTIONS) rst2html $(RST2HTML_OPTIONS)
#
# 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:
$(VERBOSE)$(abs_srcdir)/build.sh $(BUILD_OPTIONS) clean rst doc

update-docs:
$(VERBOSE)$(abs_srcdir)/build.sh $(BUILD_OPTIONS) update-docs

.PHONY: rst man pdf html clean-docs update-docs

#############################################################################

# this target will be automatically invoked when you run `make clean`
# https://www.gnu.org/software/automake/manual/html_node/Extending.html
clean-local:
$(VERBOSE)$(abs_srcdir)/build.sh $(BUILD_OPTIONS) clean rst man pdf html doc

# this target will be automatically invoked when you run `make maintainer-clean`
# https://www.gnu.org/software/automake/manual/html_node/Extending.html
maintainer-clean-local:
$(VERBOSE)$(abs_srcdir)/build.sh $(BUILD_OPTIONS) clean rst

# this target will be automatically invoked when you run `make dist`
# https://www.gnu.org/software/automake/manual/html_node/The-dist-Hook.html
dist-hook: rst
$(VERBOSE)for item in $$(cd $(abs_srcdir) && ls *.rst*) build.sh ; do cp -f $(BUILD_OPTIONS) $(abs_srcdir)/$$item $(distdir)/$$item; done

# this target will be automatically invoked when you run `make install`
# https://www.gnu.org/software/automake/manual/html_node/Extending.html
install-exec-hook:
$(VERBOSE)if $(abs_srcdir)/build.sh $(BUILD_OPTIONS) find-exec rst2man > /dev/null ; then \
$(abs_srcdir)/build.sh $(BUILD_OPTIONS) rst2man $(RST2MAN_OPTIONS) ; \
$(abs_srcdir)/build.sh $(BUILD_OPTIONS) install-mans $(mandir) ; else \
printf '%s\n' "NOTE: DO NOT INSTALL MAN-PAGES due to rst2man not found."; fi
$(rm_verbose)rm -f $(man_in_files) $(doc_files)
Loading

0 comments on commit d3af9c1

Please sign in to comment.