+
+if ENABLE_ASCIIDOC
+EXTRA_DIST += $(ADOCFILES_COMMON) $(MANPAGES) $(MANLINKS)
+man_MANS += $(MANPAGES) $(MANLINKS)
+
+$(MANPAGES): $(ADOCFILES_COMMON)
+
+asciidoc_man_cmd = $(ASCIIDOCTOR) \
+ -b manpage \
+ -a 'release-version=$(VERSION)' \
+ -a 'package-docdir=$(docdir)' \
+ -a 'VERSION=$(VERSION)' \
+ -a 'ADJTIME_PATH=$(ADJTIME_PATH)' \
+ --load-path '$(abs_srcdir)/tools' \
+ --require asciidoctor-includetracker
+
+if HAVE_ASCIIDOCTOR_FAILURE_LEVEL
+asciidoc_man_cmd += --failure-level ERROR
+endif
+
+SUFFIXES = .1.adoc .3.adoc .5.adoc .8.adoc .1 .3 .5 .8
+.1.adoc.1 .3.adoc.3 .5.adoc.5 .8.adoc.8:
+ $(AM_V_GEN) test -f ./$@ || \
+ $(MKDIR_P) $$(dirname $@) && \
+ $(asciidoc_man_cmd) --base-dir=$(abs_srcdir) \
+ --destination-dir $(abs_builddir)/$$(dirname $@) $<
+
+-include \
+ $(abs_builddir)/**.1.deps \
+ $(abs_builddir)/**.3.deps \
+ $(abs_builddir)/**.5.deps \
+ $(abs_builddir)/**.8.deps
+
+$(MANLINKS): $(MANPAGES)
+gen-man: $(man_MANS)
+
+# Standard "make" follows BUILD_* macros from ./configure, and in this case, it
+# ignores man pages for disabled tools, but for distribution tarball, we need
+# to generate all man-pages (to avoid dependence on asciidoc). [kzak Jan-2022]
+gen-man-dist:
+ @list=`find -name *.adoc -not -path "*/man-common/*" -not -path "*/po-man/*" | sed -e 's/\.adoc//g'`; \
+ missing=`for p in $$list; do test -f $$p || echo $$p; done`; \
+ if test -n "$$missing"; then \
+ $(MAKE) $(AM_MAKEFLAGS) $$missing; \
+ fi;
+
+
+# !ENABLE_ASCIIDOC
+else
+
+if HAVE_MANPAGES
+EXTRA_DIST += $(ADOCFILES_COMMON) $(MANPAGES) $(MANLINKS)
+man_MANS += $(MANPAGES) $(MANLINKS)
+endif
+
+gen-man:
+gen-man-dist:
+endif
+
+