]> git.draconx.ca Git - dxcommon.git/blob - snippet/gettext.mk
Import gettext m4/automake bits from cdecl99.
[dxcommon.git] / snippet / gettext.mk
1 # Copyright © 2011-2012 Nick Bowler
2 #
3 # Automake fragment to distribute and install gettext .po/.mo files, intended
4 # for use in a non-recursive build setup.  This does not include rules to
5 # generate the .pot file.  Two variables must be defined:
6 #
7 #   POFILES: the complete list of .po files included with the package, and
8 #   MOFILES: the set of .mo files to be installed (a user-selected subset
9 #            of the available options).
10 #
11 # One way to define these variables is to use the DX_LINGUAS autoconf macro
12 # which normally accompanies this fragment.
13 #
14 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
15 # This is free software: you are free to do what the fuck you want to.
16 # There is NO WARRANTY, to the extent permitted by law.
17
18 ALL_MOFILES = $(POFILES:.po=.mo)
19 EXTRA_DIST += po/LINGUAS $(POFILES) $(ALL_MOFILES)
20 MAINTAINERCLEANFILES += $(ALL_MOFILES)
21
22 .po.mo:
23         $(AM_V_at) $(MKDIR_P) $(@D)
24         $(AM_V_GEN) $(MSGFMT) $(MSGFMTFLAGS) -c -o $@ $<
25
26 install-data-local: install-mofiles
27 install-mofiles: $(MOFILES)
28         for mo in $?; do \
29                 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
30                 test x"$$lang" = x"" && exit 1; \
31                 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
32                 (set -x; $(MKDIR_P) "$$inst") \
33                         || exit $$?; \
34                 (set -x; $(INSTALL_DATA) "$$mo" "$$inst/$(PACKAGE).mo") \
35                         || exit $$?; \
36         done
37 .PHONY: install-mofiles
38
39 installdirs-local: installdirs-mofiles
40 installdirs-mofiles:
41         for mo in $(MOFILES); do \
42                 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
43                 test x"$$lang" = x"" && exit 1; \
44                 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
45                 (set -x; $(MKDIR_P) "$$inst") || exit $$?; \
46         done
47 .PHONY: installdirs-mofiles
48
49 uninstall-local: uninstall-mofiles
50 uninstall-mofiles:
51         for mo in $(ALL_MOFILES); do \
52                 lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
53                 test x"$$lang" = x"" && exit 1; \
54                 inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
55                 (set -x; cd "$$inst" && rm -f '$(PACKAGE).mo'); \
56         done
57 .PHONY: uninstall-mofiles