]> git.draconx.ca Git - dxcommon.git/blob - snippet/gettext.mk
8f6865b8fb5c0e319e8ea4be361099cb26e44fd7
[dxcommon.git] / snippet / gettext.mk
1 # Copyright © 2011-2012, 2023 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         mos='$?'; for mo in $$mos; 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") || exit; \
33           (set -x; $(INSTALL_DATA) "$$mo" "$$inst/$(PACKAGE).mo") || exit; \
34         done
35 .PHONY: install-mofiles
36
37 installdirs-local: installdirs-mofiles
38 installdirs-mofiles:
39         mos='$(MOFILES)'; for mo in $$mos; do \
40           lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
41           test x"$$lang" = x"" && exit 1; \
42           inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
43           (set -x; $(MKDIR_P) "$$inst") || exit; \
44         done
45 .PHONY: installdirs-mofiles
46
47 uninstall-local: uninstall-mofiles
48 uninstall-mofiles:
49         mos='$(ALL_MOFILES)'; for mo in $$mos; do \
50           lang=`expr "$$mo" : '.*/\(.*\)\.mo' \| "$$mo" : '\(.*\)\.mo'`; \
51           test x"$$lang" = x"" && exit 1; \
52           inst="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
53           (set -x; cd "$$inst" && rm -f '$(PACKAGE).mo'); \
54         done
55 .PHONY: uninstall-mofiles