1# Makefile for program source directory in GNU NLS utilities package.
2# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
3#
4# This file file be copied and used freely without restrictions.  It can
5# be used in projects which are not available under the GNU Public License
6# but which still want to provide support for the GNU gettext functionality.
7# Please note that the actual code is *not* freely available.
8#
9# - Modified by Owen Taylor <otaylor@redhat.com> to use GETTEXT_PACKAGE
10#   instead of PACKAGE and to look for po2tbl in ./ not in intl/
11#
12# - Modified by jacob berkman <jacob@ximian.com> to install
13#   Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
14#
15# - Modified by Rodney Dawes <dobey@novell.com> for use with intltool
16#
17# We have the following line for use by intltoolize:
18# INTLTOOL_MAKEFILE
19
20GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
21XGETTEXT_KEYWORDS=--keyword=_ --keyword=N_ --keyword=Q_:1g --keyword=C_:1c,2 --keyword=NC_:1c,2
22
23PACKAGE = @PACKAGE@
24VERSION = @VERSION@
25
26SHELL = /bin/sh
27
28srcdir = @srcdir@
29top_srcdir = @top_srcdir@
30top_builddir = @top_builddir@
31VPATH = @srcdir@
32
33prefix = @prefix@
34exec_prefix = @exec_prefix@
35datadir = @datadir@
36datarootdir = @datarootdir@
37libdir = @libdir@
38DATADIRNAME = @DATADIRNAME@
39itlocaledir = $(prefix)/$(DATADIRNAME)/locale
40subdir = po
41install_sh = @install_sh@
42# Automake >= 1.8 provides @mkdir_p@.
43# Until it can be supposed, use the safe fallback:
44mkdir_p = $(install_sh) -d
45
46INSTALL = @INSTALL@
47INSTALL_DATA = @INSTALL_DATA@
48
49GMSGFMT = @GMSGFMT@
50MSGFMT = @MSGFMT@
51XGETTEXT = @XGETTEXT@
52INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
53INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
54MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
55GENPOT   = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
56
57ALL_LINGUAS = @ALL_LINGUAS@
58
59PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; fi)
60
61USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep ^$$lang$$ $(srcdir)/LINGUAS`" -o -n "`echo $$ALINGUAS|grep ' ?$$lang ?'`"; then printf "$$lang "; fi; done; fi)
62
63USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done)
64
65POFILES=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done)
66
67DISTFILES = Makefile.in.in POTFILES.in $(POFILES)
68EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS
69
70POTFILES = \
71# This comment gets stripped out
72
73CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done)
74
75.SUFFIXES:
76.SUFFIXES: .po .pox .gmo .mo .msg .cat
77
78.po.pox:
79	$(MAKE) $(GETTEXT_PACKAGE).pot
80	$(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox
81
82.po.mo:
83	$(MSGFMT) -o $@ $<
84
85.po.gmo:
86	file=`echo $* | sed 's,.*/,,'`.gmo \
87	  && rm -f $$file && $(GMSGFMT) -o $$file $<
88
89.po.cat:
90	sed -f ../intl/po2msg.sed < $< > $*.msg \
91	  && rm -f $@ && gencat $@ $*.msg
92
93
94all: all-@USE_NLS@
95
96all-yes: $(CATALOGS)
97all-no:
98
99$(GETTEXT_PACKAGE).pot: $(POTFILES)
100	@if test "x$(INTLTOOL_UPDATE)" = "x/bin/true"; then \
101		echo "Warning: pot generation deactivated on VPATH builds."; \
102		echo "         See commit c96006919."; \
103	fi
104	$(GENPOT)
105
106install: install-data
107install-data: install-data-@USE_NLS@
108install-data-no: all
109install-data-yes: all
110	$(mkdir_p) $(DESTDIR)$(itlocaledir)
111	linguas="$(USE_LINGUAS)"; \
112	for lang in $$linguas; do \
113	  dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \
114	  $(mkdir_p) $$dir; \
115	  if test -r $$lang.gmo; then \
116	    $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \
117	    echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \
118	  else \
119	    $(INSTALL_DATA) $(srcdir)/$$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \
120	    echo "installing $(srcdir)/$$lang.gmo as" \
121		 "$$dir/$(GETTEXT_PACKAGE).mo"; \
122	  fi; \
123	  if test -r $$lang.gmo.m; then \
124	    $(INSTALL_DATA) $$lang.gmo.m $$dir/$(GETTEXT_PACKAGE).mo.m; \
125	    echo "installing $$lang.gmo.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \
126	  else \
127	    if test -r $(srcdir)/$$lang.gmo.m ; then \
128	      $(INSTALL_DATA) $(srcdir)/$$lang.gmo.m \
129		$$dir/$(GETTEXT_PACKAGE).mo.m; \
130	      echo "installing $(srcdir)/$$lang.gmo.m as" \
131		   "$$dir/$(GETTEXT_PACKAGE).mo.m"; \
132	    else \
133	      true; \
134	    fi; \
135	  fi; \
136	done
137
138# Empty stubs to satisfy archaic automake needs
139dvi info tags TAGS ID:
140
141# Define this as empty until I found a useful application.
142install-exec installcheck:
143
144uninstall:
145	linguas="$(USE_LINGUAS)"; \
146	for lang in $$linguas; do \
147	  rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \
148	  rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \
149	done
150
151check: all $(GETTEXT_PACKAGE).pot
152	rm -f missing notexist
153	srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m
154	if [ -r missing -o -r notexist ]; then \
155	  exit 1; \
156	fi
157
158mostlyclean:
159	rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp
160	rm -f .intltool-merge-cache
161
162clean: mostlyclean
163
164distclean: clean
165	rm -f Makefile Makefile.in POTFILES stamp-it
166	rm -f *.mo *.msg *.cat *.cat.m *.gmo
167	# Around December of 2020, a possible change on intltool-merge or some
168	# other dependency in Debian testing broke the CI distcheck job, leaving
169	# some lock files. This CLEANFILES rule should be removed once this is
170	# fixed upstream.
171	rm -f .intltool-merge-cache.lock
172
173maintainer-clean: distclean
174	@echo "This command is intended for maintainers to use;"
175	@echo "it deletes files that may require special tools to rebuild."
176	rm -f Makefile.in.in
177
178distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
179dist distdir: $(DISTFILES)
180	dists="$(DISTFILES)"; \
181	extra_dists="$(EXTRA_DISTFILES)"; \
182	for file in $$extra_dists; do \
183	  test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \
184	done; \
185	for file in $$dists; do \
186	  test -f $$file || file="$(srcdir)/$$file"; \
187	  ln $$file $(distdir) 2> /dev/null \
188	    || cp -p $$file $(distdir); \
189	done
190
191update-po: Makefile
192	@if test "x$(INTLTOOL_UPDATE)" = "x/bin/true"; then \
193		echo "Error: po generation deactivated on VPATH builds."; \
194		echo "       See commit c96006919."; \
195		false; \
196	fi
197	$(MAKE) $(GETTEXT_PACKAGE).pot
198	tmpdir=`pwd`; \
199	linguas="$(USE_LINGUAS)"; \
200	for lang in $$linguas; do \
201	  echo "$$lang:"; \
202	  result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \
203	  if $$result; then \
204	    if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
205	      rm -f $$tmpdir/$$lang.new.po; \
206            else \
207	      if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
208	        :; \
209	      else \
210	        echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
211	        rm -f $$tmpdir/$$lang.new.po; \
212	        exit 1; \
213	      fi; \
214	    fi; \
215	  else \
216	    echo "msgmerge for $$lang.gmo failed!"; \
217	    rm -f $$tmpdir/$$lang.new.po; \
218	  fi; \
219	done
220
221Makefile POTFILES: stamp-it
222	@if test ! -f $@; then \
223	  rm -f stamp-it; \
224	  $(MAKE) stamp-it; \
225	fi
226
227stamp-it: Makefile.in.in $(top_builddir)/config.status POTFILES.in
228	cd $(top_builddir) \
229	  && CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \
230	       $(SHELL) ./config.status
231
232# Tell versions [3.59,3.63) of GNU make not to export all variables.
233# Otherwise a system limit (for SysV at least) may be exceeded.
234.NOEXPORT:
235