makefile 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. DOMAINS = $(notdir $(wildcard $(PO_DOMAINS)/*))
  13. POTFILES := $(addsuffix .pot,$(addprefix $(PO)/,$(DOMAINS)))
  14. # Construct a list of all mo files for all domains under $(PO_DOMAINS)
  15. MOFILES := $(patsubst %.gmo,%.mo,$(CATALOGS))
  16. MOFILES := $(foreach D,$(DOMAINS),$(addprefix $(PO_DOMAINS)/$(D)/,$(MOFILES)))
  17. LANG_POFILES := $(patsubst %.mo,%.po,$(MOFILES))
  18. LINGUAS := $(patsubst %.gmo,%,$(CATALOGS))
  19. GETDOMAIN = $(filter $(DOMAINS),$(subst /, ,$(1)))
  20. # Generate the list of files from the bits the other make files dropped
  21. # and produce the .pot file.
  22. $(POTFILES) : $(PO)/%.pot :
  23. printf "%s " "Generating POT file $@"
  24. echo $@ : $(wildcard $(PO)/domains/$*/*.*list) $(addprefix $(BASE)/,$(shell cat $(wildcard $(PO)/domains/$*/*.srclist))) > $@.d
  25. # From sh source
  26. cat $(PO)/domains/$*/*.shlist 2> /dev/null | (cd $(BASE) && xargs -n1 bash --dump-po-strings) > $(PO)/domains/$*/sh.pot
  27. # From C/C++ source
  28. cat $(PO)/domains/$*/*.srclist > $(PO)/POTFILES_$*.in
  29. $(XGETTEXT) --default-domain=$* --directory=$(BASE) \
  30. --add-comments --foreign --keyword=_ --keyword=N_ \
  31. --files-from=$(PO)/POTFILES_$*.in -o $(PO)/domains/$*/c.pot
  32. rm -f $(PO)/POTFILES_$*.in
  33. $(MSGCOMM) --more-than=0 $(PO)/domains/$*/c.pot $(PO)/domains/$*/sh.pot --output=$@
  34. $(PO)/$(PACKAGE)-all.pot: $(POTFILES)
  35. $(MSGCOMM) --more-than=0 $(POTFILES) --output=$@
  36. # Filter the complete translation with the domain specific file to produce
  37. # only the subtext needed for this domain
  38. # We cannot express the dependencies required for this directly with a pattern
  39. # rule, so we use the .d hack.
  40. $(LANG_POFILES) : %.po : $(PO)/$(PACKAGE)-all.pot
  41. printf "%s " "Generating $@"
  42. echo $@ : $(notdir $@) $(PO)/$(call GETDOMAIN,$*).pot > $(PO)/$(call GETDOMAIN,$*)_$(notdir $@).d
  43. $(MSGMERGE) $(notdir $@) $(PO)/$(call GETDOMAIN,$*).pot -o $@
  44. $(MOFILES) : %.mo : %.po
  45. printf "%s: " "Generating $(LOCALE)/$(notdir $*)/LC_MESSAGES/$(call GETDOMAIN,$*).mo"
  46. $(GMSGFMT) --statistics -o $@ $<
  47. mkdir -p $(LOCALE)/$(notdir $*)/LC_MESSAGES/
  48. cp $@ $(LOCALE)/$(notdir $*)/LC_MESSAGES/$(call GETDOMAIN,$*).mo
  49. binary: $(POTFILES) $(PO)/$(PACKAGE)-all.pot $(MOFILES)
  50. clean: clean/local
  51. clean/local:
  52. rm -f $(MOFILES) $(LANG_POFILES) $(PO)/*.d
  53. # Include the dependencies that are available
  54. The_DFiles = $(wildcard $(PO)/*.d)
  55. ifneq ($(words $(The_DFiles)),0)
  56. include $(The_DFiles)
  57. endif
  58. .NOTPARALLEL: