From 8f5fff5350f2b41ca960c37c165b525745552f57 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 21 Apr 2021 19:55:27 +0200 Subject: [PATCH] build-sys: add targets to generated translated man pages * add --enable-poman (disabled by default) * add po-man/Makefile.am for "make all" and "make install" * install man pages to $mandir/$lang/man{1,3,5,8} Signed-off-by: Karel Zak --- Makefile.am | 6 +++++ configure.ac | 11 ++++++++ po-man/Makefile.am | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 po-man/Makefile.am diff --git a/Makefile.am b/Makefile.am index 26ec138291..85f7ed605b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,6 +73,12 @@ CLEANFILES = SUBDIRS = po +if ENABLE_ASCIIDOC +if ENABLE_POMAN +SUBDIRS += po-man +endif +endif + RCS_FIND_IGNORE = \( -name SCCS -o -name BitKeeper -o -name .svn -o \ -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o diff --git a/configure.ac b/configure.ac index abb96e6280..6a610b854f 100644 --- a/configure.ac +++ b/configure.ac @@ -743,6 +743,15 @@ UL_REQUIRES_PROGRAM([asciidoc], [ASCIIDOCTOR], [asciidoctor], [man pages]) AM_CONDITIONAL([ENABLE_ASCIIDOC], [test "x$build_asciidoc" = xyes]) +AC_ARG_ENABLE([poman], + AS_HELP_STRING([--enable-poman], [generate translated man pages]), + [], [UL_DEFAULT_ENABLE([poman], [no])] +) +UL_BUILD_INIT([poman]) +UL_REQUIRES_PROGRAM([poman], [PO4A], [po4a], [translated man pages]) +AM_CONDITIONAL([ENABLE_POMAN], [test "x$uild_poman" = xyes]) + + AX_CHECK_TLS have_pty=no @@ -2612,6 +2621,7 @@ libsmartcols/docs/Makefile libsmartcols/docs/version.xml libsmartcols/src/libsmartcols.h po/Makefile.in +po-man/Makefile ]) AC_OUTPUT @@ -2656,6 +2666,7 @@ AC_MSG_RESULT([ Wide-char support: ${build_widechar} Manual pages: ${build_asciidoc} + Manual pages translated: ${build_poman} warnings: diff --git a/po-man/Makefile.am b/po-man/Makefile.am new file mode 100644 index 0000000000..20f5c0b31f --- /dev/null +++ b/po-man/Makefile.am @@ -0,0 +1,63 @@ + +PO_FILES = $(wildcard *.po) +PO_LANGS = $(PO_FILES:.po=) + +PO_STAMPS = po4a-gen.stamp +MAN_SECTIONS = 1 3 5 8 +CLEANFILES = $(PO_STAMPS) + +EXTRA_DIST = README.md $(PO_FILES) po4a.cfg util-linux-man.pot + +po4a-gen.stamp: $(PO_FILES) + @echo 'po4a: generate man-pages translations' + $(AM_V_GEN) $(PO4A) po4a.cfg + @touch po4a-gen.stamp + +gen-trans: $(PO_STAMPS) + +asciidoc_man_cmd = $(ASCIIDOCTOR) \ + -b manpage \ + -a 'VERSION=$(VERSION)' \ + -a 'ADJTIME_PATH=$(ADJTIME_PATH)' + +gen-mans: gen-trans + @for l in $(PO_LANGS); do \ + gendir="$(abs_builddir)/$$l"; \ + genfiles=`echo $${gendir}/*.adoc`; \ + if test "$$genfiles" != '$${gendir}/*.adoc'; then \ + for file in $${genfiles}; do \ + manname=`echo $$file | sed -e 's|^.*/||' -e 's|\.adoc||'`; \ + test -f $${gendir}/$${manname} || { \ + echo " GEN " $$l ": " $$manname && \ + $(asciidoc_man_cmd) \ + --base-dir=$${gendir} \ + --destination-dir $${gendir} $${file}; \ + }; \ + done; \ + fi; \ + done + +all: gen-mans + +clean-local: + rm -f *~ *.bak + +distclean-local: + rm -rf $(PO_LANGS) *.stamp + +install-data-local: gen-mans + @for l in $(PO_LANGS); do \ + mansrcdir="$(abs_builddir)/$$l"; \ + for s in $(MAN_SECTIONS); do \ + installfiles=`echo $${mansrcdir}/*.$$s`; \ + if test "$$installfiles" != '$${mansrcdir}/*.$$s'; then \ + installdir="$(DESTDIR)$(mandir)/$$l/man$$s"; \ + $(MKDIR_P) "$${installdir}" || exit 1; \ + for file in $$installfiles; do \ + manname=`echo $$file | sed -e 's|^.*/||'`; \ + echo " Installing " $$l ": " $$manname ; \ + $(INSTALL_DATA) $$file $${installdir}; \ + done; \ + fi; \ + done; \ + done -- 2.39.2