FACTOR: Don't try to perform analysis if there are no variables.
[pspp] / po / automake.mk
1 include $(top_srcdir)/po/Makevars
2
3 XGETTEXT=xgettext
4 MSGMERGE=msgmerge
5 MSGFMT=msgfmt
6
7 POFILES = \
8         po/ca.po \
9         po/de.po \
10         po/el.po \
11         po/es.po \
12         po/fr.po \
13         po/gl.po \
14         po/hu.po \
15         po/ja.po \
16         po/lt.po \
17         po/nl.po \
18         po/pl.po \
19         po/pt_BR.po \
20         po/ru.po \
21         po/sl.po \
22         po/tr.po \
23         po/uk.po \
24         po/zh_CN.po
25
26 LOCALPOFILES = po/cs.po po/en_GB.po
27
28 POTFILE=po/$(DOMAIN).pot
29
30 TRANSLATABLE_FILES = $(DIST_SOURCES) $(all_q_sources)
31
32 XGETTEXT_OPTIONS = \
33         --copyright-holder="$(COPYRIGHT_HOLDER)" \
34         --package-name=$(PACKAGE) \
35         --package-version=$(VERSION) \
36         --msgid-bugs-address=$(MSGID_BUGS_ADDRESS) \
37         --from-code=UTF-8 \
38         --add-comments='TRANSLATORS:'
39
40 $(POTFILE): $(TRANSLATABLE_FILES) $(UI_FILES) src/ui/gui/gen-dot-desktop.sh
41         @$(MKDIR_P) po
42         $(AM_V_GEN)$(XGETTEXT) --directory=$(top_srcdir) $(XGETTEXT_OPTIONS)    $(TRANSLATABLE_FILES) --language=C --keyword=_ --keyword=N_ -o $@,tmp
43         $(AM_V_at)$(XGETTEXT) --directory=$(top_srcdir) $(XGETTEXT_OPTIONS) -j $(UI_FILES) --language=glade -o $@,tmp
44         $(AM_V_at)$(XGETTEXT) --directory=$(top_srcdir) $(XGETTEXT_OPTIONS) -j src/ui/gui/gen-dot-desktop.sh --language=shell --keyword=TRANSLATE -o $@,tmp
45         $(AM_V_at)$(SED) -e '/^"POT-Creation-Date: .*/d' $@,tmp > $@
46
47 $(LOCALPOFILED) $(POFILES): $(POTFILE)
48         $(AM_V_GEN)$(MSGMERGE) --quiet $(top_srcdir)/$@ $? -o $@,tmp
49         $(AM_V_at)if test -e $(top_srcdir)/$@,aux ; then \
50                  touch $@,tmp ; \
51                  msgcat --use-first $(top_srcdir)/$@,aux $@,tmp -o $@,tmp; \
52         fi ;
53         $(AM_V_at)$(SED) -e '/^"POT-Creation-Date: /d' $@,tmp > $@,tmp2
54         $(RM) $@,tmp
55         mv $@,tmp2 $@
56
57 SUFFIXES += .po .gmo
58 .po.gmo:
59         @$(MKDIR_P) `dirname $@`
60         $(AM_V_GEN)$(MSGFMT) $< -o $@
61
62
63 GMOFILES = $(LOCALPOFILES:.po=.gmo) $(POFILES:.po=.gmo)
64
65 ALL_LOCAL += $(GMOFILES)
66
67 install-data-hook: $(GMOFILES)
68         for f in $(GMOFILES); do \
69           lang=`echo $$f | $(SED) -e 's%po/\(.*\)\.gmo%\1%' ` ; \
70           $(MKDIR_P) $(DESTDIR)$(prefix)/share/locale/$$lang/LC_MESSAGES; \
71           $(INSTALL_DATA) $$f $(DESTDIR)$(prefix)/share/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo ; \
72         done
73
74 uninstall-hook:
75         for f in $(GMOFILES); do \
76           lang=`echo $$f | $(SED) -e 's%po/\(.*\)\.gmo%\1%' ` ; \
77           rm -f $(DESTDIR)$(prefix)/share/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo ; \
78         done
79
80
81 EXTRA_DIST += \
82         $(LOCALPOFILES) \
83         $(POFILES) \
84         $(POTFILE) \
85         po/ChangeLog \
86         po/cs.po,aux
87
88 CLEANFILES += $(GMOFILES) $(POTFILE)
89
90 # Clean $(POFILES) from build directory but not if that's the same as
91 # the source directory.
92 po_CLEAN:
93         @if test "$(srcdir)" != .; then \
94                 echo rm -f $(LOCALPOFILES) $(POFILES); \
95                 rm -f $(LOCALPOFILES) $(POFILES); \
96         fi
97 CLEAN_LOCAL += po_CLEAN
98
99 WGET = wget
100 po-update:
101         cd $(srcdir) && rm -f $(POFILES)
102         cd $(srcdir)/po && \
103         for po in `echo '$(POFILES)' | sed 's,po/,,g'`; do \
104            $(WGET) https://translationproject.org/latest/pspp/$$po; \
105         done