* buildlib/podomain.mak:
[ntk/apt.git] / po / makefile
CommitLineData
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
11BASE=..
12SUBDIR=po
13
14# Bring in the default rules
15include ../buildlib/defaults.mak
16
ec2f559a 17CATALOGS := $(addsuffix .gmo,$(shell cat LINGUAS))
827b733f 18DOMAINS := $(notdir $(wildcard $(PO_DOMAINS)/*))
89409d33
AL
19POTFILES := $(addsuffix .pot,$(addprefix $(PO)/,$(DOMAINS)))
20
21# Construct a list of all mo files for all domains under $(PO_DOMAINS)
22MOFILES := $(patsubst %.gmo,%.mo,$(CATALOGS))
23MOFILES := $(foreach D,$(DOMAINS),$(addprefix $(PO_DOMAINS)/$(D)/,$(MOFILES)))
24LANG_POFILES := $(patsubst %.mo,%.po,$(MOFILES))
25LINGUAS := $(patsubst %.gmo,%,$(CATALOGS))
26
827b733f
AL
27GETDOMAIN = $(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 $@"
89409d33
AL
33 echo $@ : $(wildcard $(PO)/domains/$*/*.*list) $(addprefix $(BASE)/,$(shell cat $(wildcard $(PO)/domains/$*/*.srclist))) > $@.d
34# From sh source
35 cat $(PO)/domains/$*/*.shlist 2> /dev/null | (cd $(BASE) && xargs -n1 bash --dump-po-strings) > $(PO)/domains/$*/sh.pot
36# From C/C++ source
37 cat $(PO)/domains/$*/*.srclist > $(PO)/POTFILES_$*.in
38 $(XGETTEXT) --default-domain=$* --directory=$(BASE) \
39 --add-comments --foreign --keyword=_ --keyword=N_ \
f0f2f956 40 --keyword=P_:1,2 \
89409d33
AL
41 --files-from=$(PO)/POTFILES_$*.in -o $(PO)/domains/$*/c.pot
42 rm -f $(PO)/POTFILES_$*.in
a11afb9d 43 $(MSGCOMM) --omit-header --more-than=0 $(PO)/domains/$*/c.pot $(PO)/domains/$*/sh.pot --output=$@
2913337f
MV
44 # copy into the domain dirs to make rosetta happy
45 rm -f $(PO)/domains/$*/*.pot
46 cp $@ $(PO)/domains/$*
89409d33 47
89409d33
AL
48# Filter the complete translation with the domain specific file to produce
49# only the subtext needed for this domain
50# We cannot express the dependencies required for this directly with a pattern
51# rule, so we use the .d hack.
a11afb9d 52$(LANG_POFILES) : $(PO_DOMAINS)/%.po : $(POTFILES)
209836e2 53 printf "%s " "Generating $@"
89409d33 54 echo $@ : $(notdir $@) $(PO)/$(call GETDOMAIN,$*).pot > $(PO)/$(call GETDOMAIN,$*)_$(notdir $@).d
a11afb9d 55 $(MSGMERGE) --no-location $(notdir $@) $(PO)/$(call GETDOMAIN,$*).pot -o $@
89409d33 56
827b733f 57$(MOFILES) : $(PO_DOMAINS)/%.mo : $(PO_DOMAINS)/%.po
209836e2 58 printf "%s: " "Generating $(LOCALE)/$(notdir $*)/LC_MESSAGES/$(call GETDOMAIN,$*).mo"
89409d33
AL
59 $(GMSGFMT) --statistics -o $@ $<
60 mkdir -p $(LOCALE)/$(notdir $*)/LC_MESSAGES/
61 cp $@ $(LOCALE)/$(notdir $*)/LC_MESSAGES/$(call GETDOMAIN,$*).mo
62
1372a4a4 63stats:
dc738e7a 64 for i in *.pot *.po; do echo -n "$$i: "; msgfmt --statistics $$i; done
1372a4a4 65
a11afb9d
DK
66binary: $(POTFILES) $(MOFILES)
67
68$(PACKAGE)-all.pot: $(POTFILES)
69 # we create our partial pot files without a header to avoid changing dates in *.mo files,
70 # but we want a header for our master-pot file, so we use a dummy pot with nothing but the header
71 $(XGETTEXT) --default-domain=$(PO)/$(PACKAGE)-dummy.pot --foreign --language=c \
72 -o $(PO)/$(PACKAGE)-dummy.pot --force-po --package-name=$(PACKAGE) \
9179f697 73 --package-version=$(PACKAGE_VERSION) --msgid-bugs-address=deity@lists.debian.org /dev/null
a11afb9d
DK
74 $(MSGCOMM) --more-than=0 $(PO)/$(PACKAGE)-dummy.pot $(POTFILES) --output=$(PACKAGE)-all.pot
75 rm -f $(PO)/$(PACKAGE)-dummy.pot
89409d33 76
38112620
AL
77.PHONY: update-po
78update-po: $(PACKAGE)-all.pot
29628967 79 for lang in ${LINGUAS}; do \
38112620
AL
80 echo "Updating $$lang.po"; \
81 $(MSGMERGE) $$lang.po $(PACKAGE)-all.pot -o $$lang.new.po; \
82 cmp $$lang.new.po $$lang.po || cp $$lang.new.po $$lang.po; \
83 rm -f $$lang.new.po; \
84 done
85
89409d33 86clean: clean/local
a11afb9d 87clean/local:
89409d33
AL
88 rm -f $(MOFILES) $(LANG_POFILES) $(PO)/*.d
89
90# Include the dependencies that are available
91The_DFiles = $(wildcard $(PO)/*.d)
92ifneq ($(words $(The_DFiles)),0)
93include $(The_DFiles)
94endif
209836e2
AL
95
96.NOTPARALLEL: