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