]> git.draconx.ca Git - dxcommon.git/blob - snippet/gettext.mk
DX_C_ALIGNAS: Work around bash-5 parsing bug.
[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='$(MOFILES)'; for mo in $$mos; do \
29           save_IFS=$$IFS; IFS=/.; \
30           set x $$mo; shift; eval 'set x $$mo; lang=$$'$$#; \
31           IFS=$$save_IFS; \
32           d="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
33           echo "$(MKDIR_P) $$d"; $(MKDIR_P) "$$d" || exit; \
34           test -f "$$mo" && s="$$mo" || s="$(srcdir)/$$mo"; \
35           d="$$d/$(PACKAGE).mo"; \
36           echo "$(INSTALL_DATA) $$s $$d"; $(INSTALL_DATA) "$$s" "$$d" || exit; \
37         done
38 .PHONY: install-mofiles
39
40 installdirs-local: installdirs-mofiles
41 installdirs-mofiles:
42         d= mos='$(MOFILES)'; for mo in $$mos; do \
43           save_IFS=$$IFS; IFS=/.; \
44           set x $$mo; shift; eval 'set x $$mo; lang=$$'$$#; \
45           IFS=$$save_IFS; \
46           d="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
47           echo "$(MKDIR_P) $$d"; $(MKDIR_P) "$$d" || exit; \
48         done;
49 .PHONY: installdirs-mofiles
50
51 uninstall-local: uninstall-mofiles
52 uninstall-mofiles:
53         mos='$(ALL_MOFILES)'; for mo in $$mos; do \
54           save_IFS=$$IFS; IFS=/.; \
55           set x $$mo; shift; eval 'set x $$mo; lang=$$'$$#; \
56           IFS=$$save_IFS; \
57           d="$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(PACKAGE).mo"; \
58           echo "rm -f $$d"; rm -f "$$d"; :; \
59         done
60 .PHONY: uninstall-mofiles