Convert to using automake
[virt-top.git] / po / Makefile.am
1 # libguestfs
2 # Copyright (C) 2009-2020 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 DOMAIN = $(PACKAGE_NAME)
19 COPYRIGHT_HOLDER = Red Hat Inc.
20 MSGID_BUGS_ADDRESS = https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
21
22 # Languages.
23 # Don't use LINGUAS (uppercase) as Gentoo defines it (RHBZ#804464).
24 linguas     := $(shell cat $(srcdir)/LINGUAS)
25
26 POTFILES    := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES)
27 POTFILES_ML := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES-ml)
28 POFILES     := $(linguas:%=%.po)
29 GMOFILES    := $(linguas:%=%.gmo)
30
31 EXTRA_DIST = \
32         LINGUAS \
33         POTFILES POTFILES-ml \
34         $(DOMAIN).pot \
35         $(POFILES) \
36         $(GMOFILES) \
37         zanata-pull.sh \
38         zanata.xml
39
40 if HAVE_GNU_GETTEXT
41
42 XGETTEXT_ARGS = \
43         --default-domain=$(DOMAIN) \
44         --from-code=utf-8 \
45         --add-comments=TRANSLATORS: \
46         --keyword=_ --keyword=N_ --keyword=__ --keyword=__x \
47         --flag=error:3:c-format \
48         --flag=error_at_line:5:c-format \
49         --flag=asprintf:2:c-format \
50         --flag=vasprintf:2:c-format \
51         --flag=xasprintf:1:c-format \
52         --copyright-holder='$(COPYRIGHT_HOLDER)' \
53         --package-name="$(PACKAGE_NAME)" \
54         --package-version="$(PACKAGE_VERSION)" \
55         --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \
56         --directory=$(top_srcdir)
57
58 # For explanation, see
59 # http://mingw-users.1079350.n2.nabble.com/Getting-rid-of-xgettext-s-quot-CHARSET-quot-warning-td5620533.html
60 FIX_CHARSET = \
61         $(SED) -i 's|text/plain; charset=CHARSET|text/plain; charset=utf-8|g'
62
63 $(DOMAIN).pot: Makefile POTFILES $(POTFILES) POTFILES-ml $(POTFILES_ML)
64         rm -f $@-t
65         touch $@-t
66 if HAVE_OCAML_GETTEXT
67         cd $(top_srcdir) && $(OCAML_GETTEXT) --action extract --extract-pot $(abs_srcdir)/$@-t $(shell cat $(abs_srcdir)/POTFILES-ml)
68          \
69         $(FIX_CHARSET) $@-t
70 endif
71         $(XGETTEXT) -j -o $@-t $(XGETTEXT_ARGS) \
72           --files-from=$(abs_srcdir)/POTFILES
73         $(FIX_CHARSET) $@-t
74         mv $@-t $@
75
76 .po.gmo:
77         rm -f $@ $@-t
78         $(MSGFMT) -c -o $@-t $(srcdir)/$<
79         mv $@-t $@
80
81 # Install.
82 # Cannot use 'localedir' since this conflicts with autoconf.
83 langinstdir = $(datadir)/locale
84
85 install-data-hook: $(GMOFILES)
86         mkdir -p $(DESTDIR)$(langinstdir)
87         for lang in $(linguas); do \
88           d=$(DESTDIR)$(langinstdir)/$$lang/LC_MESSAGES; \
89           mkdir -p $$d; \
90           install -m 0644 $$lang.gmo $$d/$(DOMAIN).mo; \
91         done
92
93 .PRECIOUS: $(DOMAIN).pot $(POFILES)
94
95 endif