From 236421a49103ea510bcba1e7ef90b57d24aeab76 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 6 Apr 2021 17:17:42 +0200 Subject: [PATCH] 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 --- Makefile.am | 28 +++++++++++++--------------- configure.ac | 18 +++++++++++++++++- sys-utils/Makemodule.am | 3 +++ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/Makefile.am b/Makefile.am index 48e89559b9..aa2041f2cc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 $@ diff --git a/configure.ac b/configure.ac index 946222676e..909be6dbcb 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am index baad296ecf..b96e006305 100644 --- a/sys-utils/Makemodule.am +++ b/sys-utils/Makemodule.am @@ -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) -- 2.47.2