po/Makefile.in.in: fix make -q problem
[gnulib.git] / build-aux / po / Makefile.in.in
1 # Makefile for PO directory in any package using GNU gettext.
2 # Copyright (C) 1995-1997, 2000-2007, 2009-2010 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
3 #
4 # This file can be copied and used freely without restrictions.  It can
5 # be used in projects which are not available under the GNU General Public
6 # License but which still want to provide support for the GNU gettext
7 # functionality.
8 # Please note that the actual code of GNU gettext is covered by the GNU
9 # General Public License and is *not* in the public domain.
10 #
11 # Origin: gettext-0.18
12 GETTEXT_MACRO_VERSION = 0.18
13
14 PACKAGE = @PACKAGE@
15 VERSION = @VERSION@
16 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
17
18 SHELL = /bin/sh
19 @SET_MAKE@
20
21 srcdir = @srcdir@
22 top_srcdir = @top_srcdir@
23 VPATH = @srcdir@
24
25 prefix = @prefix@
26 exec_prefix = @exec_prefix@
27 datarootdir = @datarootdir@
28 datadir = @datadir@
29 localedir = @localedir@
30 gettextsrcdir = $(datadir)/gettext/po
31
32 INSTALL = @INSTALL@
33 INSTALL_DATA = @INSTALL_DATA@
34
35 # We use $(mkdir_p).
36 # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
37 # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
38 # @install_sh@ does not start with $(SHELL), so we add it.
39 # In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined
40 # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
41 # versions, $(mkinstalldirs) and $(install_sh) are unused.
42 mkinstalldirs = $(SHELL) @install_sh@ -d
43 install_sh = $(SHELL) @install_sh@
44 MKDIR_P = @MKDIR_P@
45 mkdir_p = @mkdir_p@
46
47 GMSGFMT_ = @GMSGFMT@
48 GMSGFMT_no = @GMSGFMT@
49 GMSGFMT_yes = @GMSGFMT_015@
50 GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
51 MSGFMT_ = @MSGFMT@
52 MSGFMT_no = @MSGFMT@
53 MSGFMT_yes = @MSGFMT_015@
54 MSGFMT = $(MSGFMT_$(USE_MSGCTXT))
55 XGETTEXT_ = @XGETTEXT@
56 XGETTEXT_no = @XGETTEXT@
57 XGETTEXT_yes = @XGETTEXT_015@
58 XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
59 MSGMERGE = msgmerge
60 MSGMERGE_UPDATE = @MSGMERGE@ --update
61 MSGINIT = msginit
62 MSGCONV = msgconv
63 MSGFILTER = msgfilter
64
65 POFILES = @POFILES@
66 GMOFILES = @GMOFILES@
67 UPDATEPOFILES = @UPDATEPOFILES@
68 DUMMYPOFILES = @DUMMYPOFILES@
69 DISTFILES.common = Makefile.in.in remove-potcdate.sin \
70 $(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
71 DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
72 $(POFILES) $(GMOFILES) \
73 $(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
74
75 POTFILES = \
76
77 CATALOGS = @CATALOGS@
78
79 # Makevars gets inserted here. (Don't remove this line!)
80
81 .SUFFIXES:
82 .SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
83
84 .po.mo:
85         @echo "$(MSGFMT) -c -o $@ $<"; \
86         $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
87
88 .po.gmo:
89         @lang=`echo $* | sed -e 's,.*/,,'`; \
90         test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
91         echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \
92         cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
93
94 .sin.sed:
95         sed -e '/^#/d' $< > t-$@
96         mv t-$@ $@
97
98
99 all: all-@USE_NLS@
100
101 all-yes: stamp-po
102 all-no:
103
104 # Ensure that the gettext macros and this Makefile.in.in are in sync.
105 CHECK_MACRO_VERSION = \
106         test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \
107           || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \
108                exit 1; \
109              }
110
111 # $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
112 # internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
113 # we don't want to bother translators with empty POT files). We assume that
114 # LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
115 # In this case, stamp-po is a nop (i.e. a phony target).
116
117 # stamp-po is a timestamp denoting the last time at which the CATALOGS have
118 # been loosely updated. Its purpose is that when a developer or translator
119 # checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
120 # "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
121 # invocations of "make" will do nothing. This timestamp would not be necessary
122 # if updating the $(CATALOGS) would always touch them; however, the rule for
123 # $(POFILES) has been designed to not touch files that don't need to be
124 # changed.
125 stamp-po: $(srcdir)/$(DOMAIN).pot
126         @$(CHECK_MACRO_VERSION)
127         test ! -f $(srcdir)/$(DOMAIN).pot || \
128           test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
129         @test ! -f $(srcdir)/$(DOMAIN).pot || { \
130           echo "touch stamp-po" && \
131           echo timestamp > stamp-poT && \
132           mv stamp-poT stamp-po; \
133         }
134
135 # Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
136 # otherwise packages like GCC can not be built if only parts of the source
137 # have been downloaded.
138
139 # This target rebuilds $(DOMAIN).pot; it is an expensive operation.
140 # Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
141 $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
142         if LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \
143           package_gnu='GNU '; \
144         else \
145           package_gnu=''; \
146         fi; \
147         if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
148           msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
149         else \
150           msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
151         fi; \
152         case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
153           '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
154             $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
155               --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
156               --files-from=$(srcdir)/POTFILES.in \
157               --copyright-holder='$(COPYRIGHT_HOLDER)' \
158               --msgid-bugs-address="$$msgid_bugs_address" \
159             ;; \
160           *) \
161             $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
162               --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \
163               --files-from=$(srcdir)/POTFILES.in \
164               --copyright-holder='$(COPYRIGHT_HOLDER)' \
165               --package-name="$${package_gnu}@PACKAGE@" \
166               --package-version='@VERSION@' \
167               --msgid-bugs-address="$$msgid_bugs_address" \
168             ;; \
169         esac
170         test ! -f $(DOMAIN).po || { \
171           if test -f $(srcdir)/$(DOMAIN).pot; then \
172             sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
173             sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
174             if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
175               rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
176             else \
177               rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
178               mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
179             fi; \
180           else \
181             mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
182           fi; \
183         }
184
185 # This rule has no dependencies: we don't need to update $(DOMAIN).pot at
186 # every "make" invocation, only create it when it is missing.
187 # Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
188 $(srcdir)/$(DOMAIN).pot:
189         $(MAKE) $(DOMAIN).pot-update
190
191 # This target rebuilds a PO file if $(DOMAIN).pot has changed.
192 # Note that a PO file is not touched if it doesn't need to be changed.
193 $(POFILES): $(srcdir)/$(DOMAIN).pot
194         @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
195         if test -f "$(srcdir)/$${lang}.po"; then \
196           test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
197           echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \
198           cd $(srcdir) \
199             && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
200                    '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
201                      $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
202                    *) \
203                      $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \
204                  esac; \
205                }; \
206         else \
207           $(MAKE) $${lang}.po-create; \
208         fi
209
210
211 install: install-exec install-data
212 install-exec:
213 install-data: install-data-@USE_NLS@
214         if test "$(PACKAGE)" = "gettext-tools"; then \
215           $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
216           for file in $(DISTFILES.common) Makevars.template; do \
217             $(INSTALL_DATA) $(srcdir)/$$file \
218                             $(DESTDIR)$(gettextsrcdir)/$$file; \
219           done; \
220           for file in Makevars; do \
221             rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
222           done; \
223         else \
224           : ; \
225         fi
226 install-data-no: all
227 install-data-yes: all
228         @catalogs='$(CATALOGS)'; \
229         for cat in $$catalogs; do \
230           cat=`basename $$cat`; \
231           lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
232           dir=$(localedir)/$$lang/LC_MESSAGES; \
233           $(mkdir_p) $(DESTDIR)$$dir; \
234           if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
235           $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
236           echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
237           for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
238             if test -n "$$lc"; then \
239               if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
240                 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
241                 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
242                 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
243                 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
244                  for file in *; do \
245                    if test -f $$file; then \
246                      ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
247                    fi; \
248                  done); \
249                 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
250               else \
251                 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
252                   :; \
253                 else \
254                   rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
255                   mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
256                 fi; \
257               fi; \
258               rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
259               ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
260               ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
261               cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
262               echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
263             fi; \
264           done; \
265         done
266
267 install-strip: install
268
269 installdirs: installdirs-exec installdirs-data
270 installdirs-exec:
271 installdirs-data: installdirs-data-@USE_NLS@
272         if test "$(PACKAGE)" = "gettext-tools"; then \
273           $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
274         else \
275           : ; \
276         fi
277 installdirs-data-no:
278 installdirs-data-yes:
279         @catalogs='$(CATALOGS)'; \
280         for cat in $$catalogs; do \
281           cat=`basename $$cat`; \
282           lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
283           dir=$(localedir)/$$lang/LC_MESSAGES; \
284           $(mkdir_p) $(DESTDIR)$$dir; \
285           for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
286             if test -n "$$lc"; then \
287               if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
288                 link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
289                 mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
290                 mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
291                 (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
292                  for file in *; do \
293                    if test -f $$file; then \
294                      ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
295                    fi; \
296                  done); \
297                 rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
298               else \
299                 if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
300                   :; \
301                 else \
302                   rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
303                   mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
304                 fi; \
305               fi; \
306             fi; \
307           done; \
308         done
309
310 # Define this as empty until I found a useful application.
311 installcheck:
312
313 uninstall: uninstall-exec uninstall-data
314 uninstall-exec:
315 uninstall-data: uninstall-data-@USE_NLS@
316         if test "$(PACKAGE)" = "gettext-tools"; then \
317           for file in $(DISTFILES.common) Makevars.template; do \
318             rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
319           done; \
320         else \
321           : ; \
322         fi
323 uninstall-data-no:
324 uninstall-data-yes:
325         catalogs='$(CATALOGS)'; \
326         for cat in $$catalogs; do \
327           cat=`basename $$cat`; \
328           lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
329           for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
330             rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
331           done; \
332         done
333
334 check: all
335
336 info dvi ps pdf html tags TAGS ctags CTAGS ID:
337
338 mostlyclean:
339         rm -f remove-potcdate.sed
340         rm -f stamp-poT
341         rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
342         rm -fr *.o
343
344 clean: mostlyclean
345
346 distclean: clean
347         rm -f Makefile Makefile.in POTFILES *.mo
348
349 maintainer-clean: distclean
350         @echo "This command is intended for maintainers to use;"
351         @echo "it deletes files that may require special tools to rebuild."
352         rm -f stamp-po $(GMOFILES)
353
354 distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
355 dist distdir:
356         $(MAKE) update-po
357         @$(MAKE) dist2
358 # This is a separate target because 'update-po' must be executed before.
359 dist2: stamp-po $(DISTFILES)
360         dists="$(DISTFILES)"; \
361         if test "$(PACKAGE)" = "gettext-tools"; then \
362           dists="$$dists Makevars.template"; \
363         fi; \
364         if test -f $(srcdir)/$(DOMAIN).pot; then \
365           dists="$$dists $(DOMAIN).pot stamp-po"; \
366         fi; \
367         if test -f $(srcdir)/ChangeLog; then \
368           dists="$$dists ChangeLog"; \
369         fi; \
370         for i in 0 1 2 3 4 5 6 7 8 9; do \
371           if test -f $(srcdir)/ChangeLog.$$i; then \
372             dists="$$dists ChangeLog.$$i"; \
373           fi; \
374         done; \
375         if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
376         for file in $$dists; do \
377           if test -f $$file; then \
378             cp -p $$file $(distdir) || exit 1; \
379           else \
380             cp -p $(srcdir)/$$file $(distdir) || exit 1; \
381           fi; \
382         done
383
384 update-po: Makefile
385         $(MAKE) $(DOMAIN).pot-update
386         test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
387         $(MAKE) update-gmo
388
389 # General rule for creating PO files.
390
391 .nop.po-create:
392         @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
393         echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
394         exit 1
395
396 # General rule for updating PO files.
397
398 .nop.po-update:
399         @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
400         if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
401         tmpdir=`pwd`; \
402         echo "$$lang:"; \
403         test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
404         echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
405         cd $(srcdir); \
406         if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
407                '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
408                  $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
409                *) \
410                  $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
411              esac; \
412            }; then \
413           if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
414             rm -f $$tmpdir/$$lang.new.po; \
415           else \
416             if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
417               :; \
418             else \
419               echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
420               exit 1; \
421             fi; \
422           fi; \
423         else \
424           echo "msgmerge for $$lang.po failed!" 1>&2; \
425           rm -f $$tmpdir/$$lang.new.po; \
426         fi
427
428 $(DUMMYPOFILES):
429
430 update-gmo: Makefile $(GMOFILES)
431         @:
432
433 # Recreate Makefile by invoking config.status. Explicitly invoke the shell,
434 # because execution permission bits may not work on the current file system.
435 # Use @SHELL@, which is the shell determined by autoconf for the use by its
436 # scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient.
437 Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@
438         cd $(top_builddir) \
439           && @SHELL@ ./config.status $(subdir)/$@.in po-directories
440
441 force:
442
443 # Tell versions [3.59,3.63) of GNU make not to export all variables.
444 # Otherwise a system limit (for SysV at least) may be exceeded.
445 .NOEXPORT: