po4a.mk 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #
  2. # You must set the $(lang) variable when you include this makefile.
  3. #
  4. #
  5. # This makefile deals with the manpages generated from POs with po4a, and
  6. # should be included in an automake Makefile.am.
  7. #
  8. # The po must be named:
  9. # <man>.$(lang).po
  10. # If a man page require an addendum, you must name it:
  11. # <man>.$(lang).po.addendum
  12. # Where <man> corresponds to a filename in the C directory (which contains
  13. # the English man pages).
  14. #
  15. # The POs suffix is $(lang).po to allow dl10n to detect the outdated POs.
  16. #
  17. #
  18. # If a man page cannot be generated (it is not sufficiently translated; the
  19. # threshold is 80%), it won't be distributed, and the build won't fail.
  20. #
  21. mandir = @mandir@/$(lang)
  22. # List of aliases for dpkg_source.1
  23. # If dpkg_source.1 can be generated, this aliases are also generated
  24. dpkg_source_aliases = \
  25. dpkg-buildpackage.1 \
  26. dpkg-distaddfile.1 \
  27. dpkg-genchanges.1 \
  28. dpkg-gencontrol.1 \
  29. dpkg-parsechangelog.1 \
  30. dpkg-shlibdeps.1
  31. # Inform automake that we want to install some man pages in section 1, 5
  32. # and 8.
  33. # We can't simply use:
  34. # dist_man_MANS = $(wildcard *.[1-9])
  35. # Because when Makefile.in is generated, dist_man_MANS is empty, and
  36. # automake do not generate the install-man targets.
  37. dist_man_MANS = fake-page.1 fake-page.5 fake-page.8
  38. # Do not fail if these man pages do not exist
  39. .PHONY: fake-page.1 fake-page.5 fake-page.8
  40. # Override the automake's install-man target.
  41. # And set dist_man_MANS according to the pages that could be generated
  42. # when this target is called.
  43. install-man: dist_man_MANS = $(wildcard *.[1-9])
  44. install-man: install-man1 install-man5 install-man8
  45. # For each .po, try to generate the man page
  46. all-local:
  47. for po in $(srcdir)/*.$(lang).po; do \
  48. $(MAKE) $$(basename $${po%.$(lang).po}); \
  49. done
  50. # If dpkg-source.1 was generated, create the symlink
  51. if [ -f dpkg-source.1 ]; then \
  52. for man in $(dpkg_source_aliases); do \
  53. echo ".so man1/dpkg-source.1" > $$man; \
  54. chmod 644 $$man; \
  55. done; \
  56. fi
  57. # Remove the man pages that were generated from a .po
  58. clean-local:
  59. for po in $(srcdir)/*.$(lang).po; do \
  60. rm -f $$(basename $${po%.$(lang).po}); \
  61. done
  62. rm -f $(dpkg_source_aliases)
  63. .PHONY: updatepo
  64. # Update the PO in srcdir, according to the POT in C.
  65. # Based on the gettext po/Makefile.in.in
  66. updatepo:
  67. tmpdir=`pwd`; \
  68. cd $(srcdir); \
  69. for po in *.$(lang).po; do \
  70. pot=../C/po/$${po%$(lang).po}pot; \
  71. echo "$(MSGMERGE) $$po $$pot -o $${po%po}new.po"; \
  72. if $(MSGMERGE) $$po $$pot -o $$tmpdir/$${po%po}new.po; then \
  73. if cmp $$po $$tmpdir/$${po%po}new.po >/dev/null 2>&1; then \
  74. rm -f $$tmpdir/$${po%po}new.po; \
  75. else \
  76. if mv -f $$tmpdir/$${po%po}new.po $$po; then \
  77. :; \
  78. else \
  79. echo "msgmerge for $$po failed: cannot move $$tmpdir/$${po%po}new.po to $$po" 1>&2; \
  80. exit 1; \
  81. fi; \
  82. fi; \
  83. else \
  84. echo "msgmerge for $$po failed!" 1>&2; \
  85. rm -f $$tmpdir/$${po%po}new.po; \
  86. fi; \
  87. msgfmt -o /dev/null --statistics $$po; \
  88. done
  89. dist-hook: updatepo
  90. # Build the pages with an addendum
  91. %: $(srcdir)/%.$(lang).po $(srcdir)/../C/% $(srcdir)/%.$(lang).po.addendum
  92. po4a-translate -f man -m $(srcdir)/../C/$@ -p $< -l $@ -a $(srcdir)/$@.$(lang).po.addendum
  93. # Build the pages without addendum
  94. %: $(srcdir)/%.$(lang).po $(srcdir)/../C/%
  95. po4a-translate -f man -m $(srcdir)/../C/$@ -p $< -l $@