]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
po-man: rewrite autotools code
authorKarel Zak <kzak@redhat.com>
Wed, 22 Jan 2025 15:08:39 +0000 (16:08 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 12 Feb 2025 09:52:47 +0000 (10:52 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
Makefile.am
po-man/Makefile.am [deleted file]
po-man/Makemodule.am [new file with mode: 0644]

index b52e9aa0ee47af7d6777e8efa69ffbb3f09decc2..c1c0a54e4bb34624a61f26ed488d16db7719a4ba 100644 (file)
@@ -85,12 +85,6 @@ 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
 
@@ -125,6 +119,7 @@ include lsfd-cmd/Makemodule.am
 include pam_lastlog2/Makemodule.am
 include bash-completion/Makemodule.am
 include man-common/Makemodule.am
+include po-man/Makemodule.am
 
 include Documentation/Makemodule.am
 include tests/Makemodule.am
@@ -264,7 +259,6 @@ SUFFIXES = .1.adoc .3.adoc .5.adoc .8.adoc .1 .3 .5 .8
                $(MKDIR_P) $$(dirname $@) && \
                $(asciidoc_man_cmd) --base-dir=$(abs_srcdir) \
                                    --destination-dir $(abs_builddir)/$$(dirname $@) $<
-
 -include \
        $(abs_builddir)/**.1.deps \
        $(abs_builddir)/**.3.deps \
@@ -272,7 +266,7 @@ SUFFIXES = .1.adoc .3.adoc .5.adoc .8.adoc .1 .3 .5 .8
        $(abs_builddir)/**.8.deps
 
 $(MANLINKS): $(MANPAGES)
-gen-man: $(man_MANS)
+gen-man: $(man_MANS) gen-poman
 
 # Standard "make" follows BUILD_* macros from ./configure, and in this case, it
 # ignores man pages for disabled tools, but for distribution tarball, we need
diff --git a/po-man/Makefile.am b/po-man/Makefile.am
deleted file mode 100644 (file)
index dbfd100..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-
-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
-DISTCLEANFILES = util-linux-man.pot $(PO_FILES)
-
-if ENABLE_POMAN
-util-linux-man.pot: Makefile
-       $(AM_V_GEN) $(PO4A) --verbose --no-translations po4a.cfg
-
-po4a-gen.stamp: $(PO_FILES)
-       @echo 'po4a: generate man-pages translations'
-       $(AM_V_GEN) $(PO4A) --srcdir $(srcdir) $(srcdir)/po4a.cfg
-       @touch po4a-gen.stamp
-
-# We need to call po4a --force only on 'make dist', otherwise .po and .pot
-# files has to be unmodified. This update has to be done before 'make' copies
-# sources to the $distdir. $EXTRA_DIST (where is util-linux-man.pot) is used as
-# a dependence for 'distdir' automake target, so it's triggered by "make dist*"
-# only.
-util-linux-man.pot:
-       @echo 'po4a: force pot-update'
-       $(AM_V_GEN) $(PO4A) --force --srcdir $(srcdir) $(srcdir)/po4a.cfg
-
-gen-trans: $(PO_STAMPS)
-
-asciidoc_man_cmd = $(ASCIIDOCTOR) \
-       -b manpage \
-       -a 'release-version=$(VERSION)' \
-       -a 'package-docdir=$(docdir)' \
-       -a 'VERSION=$(VERSION)' \
-       -a 'ADJTIME_PATH=$(ADJTIME_PATH)' \
-       --load-path '$(top_srcdir)/tools' \
-       --require asciidoctor-unicodeconverter
-
-if HAVE_ASCIIDOCTOR_FAILURE_LEVEL
-asciidoc_man_cmd += --failure-level ERROR
-endif
-
-gen-mans: gen-trans
-       @set -e; \
-         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
-       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
-
-uninstall-local:
-       @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"; \
-             for file in $$installfiles; do \
-               manname=`echo $$file | sed -e 's|^.*/||'`;  \
-               echo "  Uninstalling " $$l ": " $$manname ; \
-               rm -f $${installdir}/$${manname}; \
-             done; \
-           fi; \
-         done; \
-       done
-
-else
-gen-trans:
-gen-mans:
-all:
-distclean-local:
-clean-local:
-endif
diff --git a/po-man/Makemodule.am b/po-man/Makemodule.am
new file mode 100644 (file)
index 0000000..88ba827
--- /dev/null
@@ -0,0 +1,52 @@
+if ENABLE_ASCIIDOC
+if ENABLE_POMAN
+
+PO_FILES = po-man/$(wildcard *.po)
+
+EXTRA_DIST += po-man/README.md \
+             po-man/po4a.cfg \
+             po-man/util-linux-man.pot \
+             $(PO_FILES)
+
+
+asciidoc_poman_translate_cmd = $(top_srcdir)/po-man/translate.sh \
+       --progress \
+       --srcdir '$(top_srcdir)/po-man' \
+       --destdir '$(top_builddir)/po-man/translations' \
+       --asciidoctor-load-path '$(top_srcdir)/tools' \
+       --docdir '$(docdir)' \
+       --po4acfg '$(top_srcdir)/po-man/po4a.cfg' \
+       --util-linux-version '$(VERSION)'
+
+asciidoc_poman_install_cmd = $(top_srcdir)/po-man/install-translations.sh \
+       --mandir '$(DESTDIR)/$(mandir)' \
+       --mansrcdir '$(top_builddir)/po-man/translations/man'
+
+
+ADOCFILES = $(MANPAGES:=.adoc)
+gen-poman: $(ADOCFILES_COMMON) $(ADOCFILES)
+       $(asciidoc_poman_translate_cmd) $(ADOCFILES)
+
+
+install-data-hook-poman:
+       $(asciidoc_poman_install_cmd) --install
+INSTALL_DATA_HOOKS += install-data-hook-poman
+
+
+uninstall-hook-poman:
+       $(asciidoc_poman_install_cmd) --uninstall
+UNINSTALL_HOOKS += uninstall-hook-poman
+
+
+clean-local-hook-poman:
+       rm -rf $(top_builddir)/po-man/translations
+CLEAN_LOCALS += clean-local-hook-poman
+
+
+# !ENABLE_POMAN
+else
+gen-poman:
+endif
+
+# ENABLE_ASCIIDOC
+endif