build-sys: make man pages optional, add --disable-asciidoc

* don't use dist_noinst_DATA= for generated man pages (use man_MANS=)

* make asciidoctor optional

* add --disable-asciidoc to explicitly disable man pages

Addresses: https://github.com/karelzak/util-linux/issues/1257
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2021-04-06 17:17:42 +02:00
parent 53b37016c3
commit 236421a491
3 changed files with 33 additions and 16 deletions

View File

@ -28,12 +28,6 @@ LDADD = $(LTLIBINTL)
LIB_FUZZING_ENGINE ?= -fsanitize=fuzzer
# Automake (at least up to 1.10) mishandles dist_man_MANS inside conditionals.
# Unlike with other dist primaries, the files are not distributed if the
# conditional is false.
# Work the bug around until it is fixed:
dist_noinst_DATA = $(dist_man_MANS)
# Paths to in-tree libraries (use ul_ prefix to avoid possible collisions) Note
# that blkid.h, libmount.h, libfdisk.h and libsmartcols.h are generated and
# stored in build dirs.
@ -52,7 +46,6 @@ noinst_PROGRAMS =
EXTRA_LTLIBRARIES =
usrbin_exec_PROGRAMS =
usrsbin_exec_PROGRAMS =
dist_man_MANS =
man_MANS =
pkgconfig_DATA =
usrlib_exec_LTLIBRARIES =
@ -196,18 +189,19 @@ $(PATHFILES): Makefile
@ mv $@.tmp $@
CLEANFILES += $(MANPAGES) $(MANLINKS)
EXTRA_DIST += $(MANPAGES:=.adoc) $(MANPAGES_EXTRA)
if ENABLE_ASCIIDOC
man_MANS += $(MANPAGES) $(MANLINKS)
$(MANPAGES): $(MANPAGES_EXTRA) Makefile
asciidoc_man_cmd = $(ASCIIDOCTOR) \
-b manpage \
-a 'VERSION=$(VERSION)' \
-a 'ADJTIME_PATH=$(ADJTIME_PATH)'
dist_man_MANS += $(MANPAGES) $(MANLINKS)
CLEANFILES += $(dist_man_MANS)
EXTRA_DIST += $(MANPAGES:=.adoc) $(MANPAGES_EXTRA)
$(MANPAGES): $(MANPAGES_EXTRA) Makefile
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 ./$@ || \
@ -216,8 +210,11 @@ SUFFIXES = .1.adoc .3.adoc .5.adoc .8.adoc .1 .3 .5 .8
--destination-dir $(abs_builddir)/$$(dirname $@) $<
$(MANLINKS): $(MANPAGES)
gen-man: $(man_MANS)
gen-man: $(dist_man_MANS)
else
gen-man:
endif
# Arrange so that .tarball-version appears only in the distribution
@ -283,6 +280,7 @@ DISTCHECK_CONFIGURE_FLAGS = \
--with-bashcompletiondir=$$dc_install_base/$(bashcompletiondir) \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
BUILT_SOURCES = .version
.version:
echo $(VERSION) > $@-t && mv $@-t $@

View File

@ -232,7 +232,23 @@ PKG_INSTALLDIR(['${usrlib_execdir}/pkgconfig'])
GTK_DOC_CHECK([1.10])
AC_PATH_PROG([XSLTPROC], [xsltproc])
AC_PATH_PROG([ASCIIDOCTOR], [asciidoctor])
AC_ARG_ENABLE([asciidoc],
AS_HELP_STRING([--disable-asciidoc], [do not generate man pages from asciidoc]),
[], [enable_asciidoc=check]
)
AS_IF([test "x$enable_asciidoc" = xno], [
AM_CONDITIONAL([ENABLE_ASCIIDOC], [false])
], [
AC_PATH_PROG([ASCIIDOCTOR], [asciidoctor])
AS_IF([test "x$enable_asciidoc" = xyes && "x$ASCIIDOCTOR" = x], [
AC_MSG_ERROR([AsciiDoc requested but asciidoctor not found])
])
AM_CONDITIONAL([ENABLE_ASCIIDOC], [test "x$ASCIIDOCTOR" != x])
])
linux_os=no
bsd_os=no

View File

@ -222,7 +222,10 @@ if ARCH_HPPA
SETARCH_LINKS += parisc parisc64 parisc32
endif
if ENABLE_ASCIIDOC
SETARCH_MAN_LINKS = $(addprefix sys-utils/,$(SETARCH_LINKS:=.8))
endif
man_MANS += $(SETARCH_MAN_LINKS)
CLEANFILES += $(SETARCH_MAN_LINKS)