]>
Commit | Line | Data |
---|---|---|
89409d33 AL |
1 | # -*- make -*- |
2 | ||
3 | # This will compile the gettext message catalogues. | |
4 | ||
5 | # The other make files drop file lists in build/po/domains/DOMAIN/* which | |
6 | # is then picked up by this make file to define all the domains and all the | |
7 | # source files that compose each domain. It then produces the POT files | |
8 | # and then filters the PO files through the per-domain POT file to create | |
9 | # the input to msgformat, which is then dumped into a locale directory. | |
10 | ||
11 | BASE=.. | |
12 | SUBDIR=po | |
13 | ||
14 | # Bring in the default rules | |
15 | include ../buildlib/defaults.mak | |
16 | ||
f026e89c | 17 | CATALOGS := $(addsuffix .gmo, $(shell sed -e '/^\#/ d' -e '/^$$/ d' LINGUAS | tr '\n' ' ')) |
ae76a57a | 18 | DOMAINS := $(sort $(notdir $(wildcard $(PO_DOMAINS)/*))) |
89409d33 AL |
19 | POTFILES := $(addsuffix .pot,$(addprefix $(PO)/,$(DOMAINS))) |
20 | ||
21 | # Construct a list of all mo files for all domains under $(PO_DOMAINS) | |
22 | MOFILES := $(patsubst %.gmo,%.mo,$(CATALOGS)) | |
23 | MOFILES := $(foreach D,$(DOMAINS),$(addprefix $(PO_DOMAINS)/$(D)/,$(MOFILES))) | |
24 | LANG_POFILES := $(patsubst %.mo,%.po,$(MOFILES)) | |
25 | LINGUAS := $(patsubst %.gmo,%,$(CATALOGS)) | |
26 | ||
827b733f AL |
27 | GETDOMAIN = $(word 1,$(subst /, ,$(1))) |
28 | ||
89409d33 AL |
29 | # Generate the list of files from the bits the other make files dropped |
30 | # and produce the .pot file. | |
827b733f | 31 | $(POTFILES) : $(PO)/%.pot : |
a11afb9d | 32 | echo "Generating POT file $@" |
57da1b4b DK |
33 | echo $@ : $(wildcard $(PO)/domains/$*/*.*list) $(addprefix $(BASE)/,$(shell cat $(wildcard $(PO)/domains/$*/*.srclist))) > $@.d.tmp |
34 | cmp --silent $@.d.tmp $@.d || mv $@.d.tmp $@.d | |
89409d33 | 35 | # From sh source |
57da1b4b DK |
36 | cat $(PO)/domains/$*/*.shlist 2> /dev/null | (cd $(BASE) && xargs -n1 bash --dump-po-strings) > $(PO)/domains/$*/sh.pot.tmp |
37 | cmp --silent $(PO)/domains/$*/sh.pot.tmp $(PO)/domains/$*/sh.pot || \ | |
38 | mv $(PO)/domains/$*/sh.pot.tmp $(PO)/domains/$*/sh.pot | |
89409d33 | 39 | # From C/C++ source |
0819e7f3 | 40 | cat $(PO)/domains/$*/*.srclist | sort > $(PO)/POTFILES_$*.in |
89409d33 AL |
41 | $(XGETTEXT) --default-domain=$* --directory=$(BASE) \ |
42 | --add-comments --foreign --keyword=_ --keyword=N_ \ | |
768a949c | 43 | --no-location \ |
f0f2f956 | 44 | --keyword=P_:1,2 \ |
57da1b4b DK |
45 | --files-from=$(PO)/POTFILES_$*.in -o $(PO)/domains/$*/c.pot.tmp |
46 | cmp --silent $(PO)/domains/$*/c.pot.tmp $(PO)/domains/$*/c.pot || \ | |
47 | mv $(PO)/domains/$*/c.pot.tmp $(PO)/domains/$*/c.pot | |
89409d33 | 48 | rm -f $(PO)/POTFILES_$*.in |
57da1b4b DK |
49 | $(MSGCOMM) --omit-header --more-than=0 $(PO)/domains/$*/c.pot $(PO)/domains/$*/sh.pot --output=$@.tmp |
50 | cmp --silent $@ $@.tmp || mv $@.tmp $@ | |
2913337f MV |
51 | # copy into the domain dirs to make rosetta happy |
52 | rm -f $(PO)/domains/$*/*.pot | |
53 | cp $@ $(PO)/domains/$* | |
89409d33 | 54 | |
89409d33 AL |
55 | # Filter the complete translation with the domain specific file to produce |
56 | # only the subtext needed for this domain | |
57 | # We cannot express the dependencies required for this directly with a pattern | |
58 | # rule, so we use the .d hack. | |
a11afb9d | 59 | $(LANG_POFILES) : $(PO_DOMAINS)/%.po : $(POTFILES) |
209836e2 | 60 | printf "%s " "Generating $@" |
89409d33 | 61 | echo $@ : $(notdir $@) $(PO)/$(call GETDOMAIN,$*).pot > $(PO)/$(call GETDOMAIN,$*)_$(notdir $@).d |
a11afb9d | 62 | $(MSGMERGE) --no-location $(notdir $@) $(PO)/$(call GETDOMAIN,$*).pot -o $@ |
89409d33 | 63 | |
827b733f | 64 | $(MOFILES) : $(PO_DOMAINS)/%.mo : $(PO_DOMAINS)/%.po |
209836e2 | 65 | printf "%s: " "Generating $(LOCALE)/$(notdir $*)/LC_MESSAGES/$(call GETDOMAIN,$*).mo" |
89409d33 AL |
66 | $(GMSGFMT) --statistics -o $@ $< |
67 | mkdir -p $(LOCALE)/$(notdir $*)/LC_MESSAGES/ | |
68 | cp $@ $(LOCALE)/$(notdir $*)/LC_MESSAGES/$(call GETDOMAIN,$*).mo | |
69 | ||
f026e89c | 70 | stats: all-linguas-enabled |
1c46aec4 | 71 | for i in *.pot *.po; do echo -n "$$i: "; msgfmt --output-file=/dev/null --statistics $$i; done |
1372a4a4 | 72 | |
f026e89c | 73 | binary: $(POTFILES) $(MOFILES) all-linguas-enabled |
a11afb9d DK |
74 | |
75 | $(PACKAGE)-all.pot: $(POTFILES) | |
76 | # we create our partial pot files without a header to avoid changing dates in *.mo files, | |
77 | # but we want a header for our master-pot file, so we use a dummy pot with nothing but the header | |
78 | $(XGETTEXT) --default-domain=$(PO)/$(PACKAGE)-dummy.pot --foreign --language=c \ | |
1c46aec4 DK |
79 | -o $(PO)/$(PACKAGE)-dummy.pot --force-po --package-name='$(PACKAGE)' \ |
80 | --package-version='$(PACKAGE_VERSION)' --msgid-bugs-address='$(PACKAGE_MAIL)' /dev/null | |
a11afb9d DK |
81 | $(MSGCOMM) --more-than=0 $(PO)/$(PACKAGE)-dummy.pot $(POTFILES) --output=$(PACKAGE)-all.pot |
82 | rm -f $(PO)/$(PACKAGE)-dummy.pot | |
89409d33 | 83 | |
f026e89c DK |
84 | .PHONY: update-po all-linguas-enabled |
85 | update-po: $(PACKAGE)-all.pot all-linguas-enabled | |
29628967 | 86 | for lang in ${LINGUAS}; do \ |
38112620 AL |
87 | echo "Updating $$lang.po"; \ |
88 | $(MSGMERGE) $$lang.po $(PACKAGE)-all.pot -o $$lang.new.po; \ | |
89 | cmp $$lang.new.po $$lang.po || cp $$lang.new.po $$lang.po; \ | |
90 | rm -f $$lang.new.po; \ | |
91 | done | |
92 | ||
f026e89c DK |
93 | all-linguas-enabled: LINGUAS |
94 | ifdef NOISY | |
95 | echo "Available Translations: $(shell ls *.po | cut -d'.' -f 1 | sort | tr '\n' ' ')" | |
96 | echo "Mentioned Translations: $(shell sed -e '/^\#\#/ d' -e '/^$$/ d' -e 's/# //' LINGUAS | tr ' ' '\n' | sort | tr '\n' ' ')" | |
97 | echo "Build Translations: $(shell echo "$(LINGUAS)" | tr ' ' '\n' | sort | tr '\n' ' ')" | |
98 | endif | |
99 | test "$(shell ls *.po | cut -d'.' -f 1 | sort | tr '\n' ' ')" = \ | |
100 | "$(shell sed -e '/^\#\#/ d' -e '/^$$/ d' -e 's/# //' LINGUAS | tr ' ' '\n' | sort | tr '\n' ' ')" || \ | |
101 | ( echo "ERROR: Not all available translations are mentioned in po/LINGUAS!"; exit 100) | |
102 | ||
89409d33 | 103 | clean: clean/local |
a11afb9d | 104 | clean/local: |
89409d33 AL |
105 | rm -f $(MOFILES) $(LANG_POFILES) $(PO)/*.d |
106 | ||
107 | # Include the dependencies that are available | |
108 | The_DFiles = $(wildcard $(PO)/*.d) | |
109 | ifneq ($(words $(The_DFiles)),0) | |
110 | include $(The_DFiles) | |
111 | endif | |
209836e2 | 112 | |
57da1b4b | 113 | # otherwise the output is completely screwed |
209836e2 | 114 | .NOTPARALLEL: |