With the Weblate adoption, we let it update the po files from the
catalog template. The po4a behaviour of extracting the template,
merging the existing translations, and creating the translated PODs at
once is problematic. Hence, split the extraction and the translated POD
generation in two.
Use po4a-gettextize to extract the catalog template only, not doing it
anymore automatically at each build. There is no more need for a
po4a.conf file.
Use po4a-translate to create translated PODs from the po files, keeping
the fixup of the generated files (to avoid spurious =encoding, etc).
Add a silent rule to hide the po4a-translate command lines by default.
These changes also allow us to get rid of the POD existance checks with
associated error message pointing to the update-po rule. Now each
translated POD file is generated because of make dependency, and it
depends only on its po file.
---
.gitignore | 1 -
m4/guestfs-progs.m4 | 5 +++--
po-docs/Makefile.am | 37 ++++++-------------------------------
po-docs/language.mk | 29 +++++++++++++++--------------
subdir-rules.mk | 3 +++
5 files changed, 27 insertions(+), 48 deletions(-)
diff --git a/.gitignore b/.gitignore
index 54423b1a..28ddd182 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,7 +83,6 @@ Makefile.in
/po-docs/*/*.3
/po-docs/*/*.5
/po-docs/*/*.8
-/po-docs/po4a.conf
/po-docs/*/*.pod
/podwrapper.1
/podwrapper.pl
diff --git a/m4/guestfs-progs.m4 b/m4/guestfs-progs.m4
index 1847e241..edb45cf9 100644
--- a/m4/guestfs-progs.m4
+++ b/m4/guestfs-progs.m4
@@ -45,8 +45,9 @@ AC_PATH_PROGS([GENISOIMAGE],[genisoimage mkisofs],[no],
test "x$GENISOIMAGE" = "xno" && AC_MSG_ERROR([genisoimage
must be installed])
dnl po4a for translating man pages and POD files (optional).
-AC_CHECK_PROG([PO4A],[po4a],[po4a],[no])
-AM_CONDITIONAL([HAVE_PO4A], [test "x$PO4A" != "xno"])
+AC_CHECK_PROG([PO4A_GETTEXTIZE],[po4a-gettextize],[po4a-gettextize],[no])
+AC_CHECK_PROG([PO4A_TRANSLATE],[po4a-translate],[po4a-translate],[no])
+AM_CONDITIONAL([HAVE_PO4A], [test "x$PO4A_GETTEXTIZE" != "xno"
&& test "x$PO4A_TRANSLATE" != "xno"])
dnl Check for db_load (optional).
GUESTFS_FIND_DB_TOOL([DB_LOAD], [load])
diff --git a/po-docs/Makefile.am b/po-docs/Makefile.am
index 0660eba0..0667b784 100644
--- a/po-docs/Makefile.am
+++ b/po-docs/Makefile.am
@@ -34,47 +34,22 @@ EXTRA_DIST = \
$(linguas:%=%.po) \
podfiles
-CLEANFILES += po4a.conf
-
# Build the final man pages from the translated POD files. Each
# language directory contains a Makefile.am that we need to keep up to
# date (note each $lang/Makefile.am should be identical).
# XXX Is there a better way?
SUBDIRS = $(linguas_translated)
-update-po: virt-v2v-docs.pot
-
-# Note: po4a puts the following junk at the top of every POD file it
-# generates:
-# - a warning
-# - a probably bogus =encoding line
-# Remove both.
-# XXX Fix po4a so it doesn't do this.
-virt-v2v-docs.pot: po4a.conf
- $(PO4A) \
- -M utf-8 -L utf-8 -A utf-8 \
- -v \
- -k 0 \
+virt-v2v-docs.pot:
+ $(PO4A_GETTEXTIZE) \
+ -f pod \
+ -M utf-8 -L utf-8 \
--package-name $(PACKAGE_NAME) \
--package-version $(PACKAGE_VERSION) \
--msgid-bugs-address libguestfs(a)redhat.com \
--copyright-holder "Red Hat Inc." \
- po4a.conf
- for f in `cd $(srcdir); find $(linguas_translated) -name '*.pod'`; do \
- $(SED) '0,/^=encoding/d' < $$f > $$f.new; \
- mv $$f.new $$f; \
- done
-
-po4a.conf: podfiles
- rm -f $@-t
- echo "[po_directory] $(srcdir)" >> $@-t
- echo >> $@-t
- for f in `cat podfiles`; do \
- out=`basename -- $$f .pod`.pod; \
- echo "[type: pod] $$f \$$lang:\$$lang/$$out" >> $@-t; \
- echo >> $@-t; \
- done;
- mv $@-t $@
+ -p $@ \
+ $(patsubst %,-m %,$(shell cat $(srcdir)/podfiles))
podfiles: Makefile
rm -f $@ $@-t
diff --git a/po-docs/language.mk b/po-docs/language.mk
index ab402c32..54f621b5 100644
--- a/po-docs/language.mk
+++ b/po-docs/language.mk
@@ -22,7 +22,7 @@ include $(top_srcdir)/subdir-rules.mk
LINGUA = $(shell basename -- `pwd`)
# Before 1.23.23, the old Perl tools were called *.pl.
-CLEANFILES += *.pl
+CLEANFILES += *.pl *.pod
MANPAGES = \
virt-v2v.1 \
@@ -54,19 +54,20 @@ virt-v2v.1: key-option.pod keys-from-stdin-option.pod
--man $@ \
$<
-# If a POD file is missing, the user needs to run make update-po.
-# This cannot be done automatically by make because it would be unsafe
-# to run po4a or update podfiles potentially in parallel. Therefore
-# tell the user what to do and stop.
-$(podfiles):
- @if ! test -f $@; then \
- echo "***"; \
- echo "*** You need to run the following commands:"; \
- echo "*** rm po-docs/podfiles; make -C po-docs update-po"; \
- echo "*** After that, rerun make."; \
- echo "***"; \
- exit 1; \
- fi
+# Note: po4a puts the following junk at the top of every POD file it
+# generates:
+# - a warning
+# - a probably bogus =encoding line
+# Remove both.
+# XXX Fix po4a so it doesn't do this.
+%.pod: $(srcdir)/../$(LINGUA).po
+ $(guestfs_am_v_po4a_translate)$(PO4A_TRANSLATE) \
+ -f pod \
+ -M utf-8 -L utf-8 \
+ -k 0 \
+ -m $(srcdir)/../$(shell grep '/$(notdir $@)$$' $(top_srcdir)/po-docs/podfiles)
\
+ -p $< \
+ | $(SED) '0,/^=encoding/d' > $@
# XXX Can automake do this properly?
install-data-hook:
diff --git a/subdir-rules.mk b/subdir-rules.mk
index 6c6f1e56..3547c750 100644
--- a/subdir-rules.mk
+++ b/subdir-rules.mk
@@ -76,6 +76,9 @@ guestfs_am_v_podwrapper_0 = @echo " POD " $@;
guestfs_am_v_jar = $(guestfs_am_v_jar_@AM_V@)
guestfs_am_v_jar_ = $(guestfs_am_v_jar_@AM_DEFAULT_V@)
guestfs_am_v_jar_0 = @echo " JAR " $@;
+guestfs_am_v_po4a_translate = $(guestfs_am_v_po4a_translate_@AM_V@)
+guestfs_am_v_po4a_translate_ = $(guestfs_am_v_po4a_translate_@AM_DEFAULT_V@)
+guestfs_am_v_po4a_translate_0 = @echo " PO4A-T " $@;
%.cmi: %.mli
$(guestfs_am_v_ocamlcmi)$(OCAMLFIND) ocamlc -package guestfs $(OCAMLFLAGS)
$(OCAMLPACKAGES) -c $< -o $@
--
2.26.2