makefile 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # -*- make -*-
  2. # This will compile the gettext message catalogues.
  3. # The other make files drop file lists in build/po/domains/DOMAIN/* which
  4. # is then picked up by this make file to define all the domains and all the
  5. # source files that compose each domain. It then produces the POT files
  6. # and then filters the PO files through the per-domain POT file to create
  7. # the input to msgformat, which is then dumped into a locale directory.
  8. BASE=..
  9. SUBDIR=po
  10. # Bring in the default rules
  11. include ../buildlib/defaults.mak
  12. CATALOGS := $(addsuffix .gmo,$(shell cat LINGUAS))
  13. DOMAINS := $(notdir $(wildcard $(PO_DOMAINS)/*))
  14. POTFILES := $(addsuffix .pot,$(addprefix $(PO)/,$(DOMAINS)))
  15. # Construct a list of all mo files for all domains under $(PO_DOMAINS)
  16. MOFILES := $(patsubst %.gmo,%.mo,$(CATALOGS))
  17. MOFILES := $(foreach D,$(DOMAINS),$(addprefix $(PO_DOMAINS)/$(D)/,$(MOFILES)))
  18. LANG_POFILES := $(patsubst %.mo,%.po,$(MOFILES))
  19. LINGUAS := $(patsubst %.gmo,%,$(CATALOGS))
  20. GETDOMAIN = $(word 1,$(subst /, ,$(1)))
  21. # Generate the list of files from the bits the other make files dropped
  22. # and produce the .pot file.
  23. $(POTFILES) : $(PO)/%.pot :
  24. echo "Generating POT file $@"
  25. echo $@ : $(wildcard $(PO)/domains/$*/*.*list) $(addprefix $(BASE)/,$(shell cat $(wildcard $(PO)/domains/$*/*.srclist))) > $@.d
  26. # From sh source
  27. cat $(PO)/domains/$*/*.shlist 2> /dev/null | (cd $(BASE) && xargs -n1 bash --dump-po-strings) > $(PO)/domains/$*/sh.pot
  28. # From C/C++ source
  29. cat $(PO)/domains/$*/*.srclist > $(PO)/POTFILES_$*.in
  30. $(XGETTEXT) --default-domain=$* --directory=$(BASE) \
  31. --add-comments --foreign --keyword=_ --keyword=N_ \
  32. --keyword=P_:1,2 \
  33. --files-from=$(PO)/POTFILES_$*.in -o $(PO)/domains/$*/c.pot
  34. rm -f $(PO)/POTFILES_$*.in
  35. $(MSGCOMM) --omit-header --more-than=0 $(PO)/domains/$*/c.pot $(PO)/domains/$*/sh.pot --output=$@
  36. # copy into the domain dirs to make rosetta happy
  37. rm -f $(PO)/domains/$*/*.pot
  38. cp $@ $(PO)/domains/$*
  39. # Filter the complete translation with the domain specific file to produce
  40. # only the subtext needed for this domain
  41. # We cannot express the dependencies required for this directly with a pattern
  42. # rule, so we use the .d hack.
  43. $(LANG_POFILES) : $(PO_DOMAINS)/%.po : $(POTFILES)
  44. printf "%s " "Generating $@"
  45. echo $@ : $(notdir $@) $(PO)/$(call GETDOMAIN,$*).pot > $(PO)/$(call GETDOMAIN,$*)_$(notdir $@).d
  46. $(MSGMERGE) --no-location $(notdir $@) $(PO)/$(call GETDOMAIN,$*).pot -o $@
  47. $(MOFILES) : $(PO_DOMAINS)/%.mo : $(PO_DOMAINS)/%.po
  48. printf "%s: " "Generating $(LOCALE)/$(notdir $*)/LC_MESSAGES/$(call GETDOMAIN,$*).mo"
  49. $(GMSGFMT) --statistics -o $@ $<
  50. mkdir -p $(LOCALE)/$(notdir $*)/LC_MESSAGES/
  51. cp $@ $(LOCALE)/$(notdir $*)/LC_MESSAGES/$(call GETDOMAIN,$*).mo
  52. stats:
  53. for i in *.pot *.po; do echo -n "$$i: "; msgfmt --statistics $$i; done
  54. binary: $(POTFILES) $(MOFILES)
  55. $(PACKAGE)-all.pot: $(POTFILES)
  56. # we create our partial pot files without a header to avoid changing dates in *.mo files,
  57. # but we want a header for our master-pot file, so we use a dummy pot with nothing but the header
  58. $(XGETTEXT) --default-domain=$(PO)/$(PACKAGE)-dummy.pot --foreign --language=c \
  59. -o $(PO)/$(PACKAGE)-dummy.pot --force-po --package-name=$(PACKAGE) \
  60. --package-version=$(VERSION) --msgid-bugs-address=deity@lists.debian.org /dev/null
  61. $(MSGCOMM) --more-than=0 $(PO)/$(PACKAGE)-dummy.pot $(POTFILES) --output=$(PACKAGE)-all.pot
  62. rm -f $(PO)/$(PACKAGE)-dummy.pot
  63. .PHONY: update-po
  64. update-po: $(PACKAGE)-all.pot
  65. for lang in ${LINGUAS}; do \
  66. echo "Updating $$lang.po"; \
  67. $(MSGMERGE) $$lang.po $(PACKAGE)-all.pot -o $$lang.new.po; \
  68. cmp $$lang.new.po $$lang.po || cp $$lang.new.po $$lang.po; \
  69. rm -f $$lang.new.po; \
  70. done
  71. clean: clean/local
  72. clean/local:
  73. rm -f $(MOFILES) $(LANG_POFILES) $(PO)/*.d
  74. # Include the dependencies that are available
  75. The_DFiles = $(wildcard $(PO)/*.d)
  76. ifneq ($(words $(The_DFiles)),0)
  77. include $(The_DFiles)
  78. endif
  79. .NOTPARALLEL: