1 # po.m4 serial 32 (gettext-0.21.1)
2 dnl Copyright (C) 1995-2014, 2016, 2018-2022, 2024 Free Software Foundation,
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 dnl This file can be used in projects which are not available under
9 dnl the GNU General Public License or the GNU Lesser General Public
10 dnl License but which still want to provide support for the GNU gettext
12 dnl Please note that the actual code of the GNU gettext library is covered
13 dnl by the GNU Lesser General Public License, and the rest of the GNU
14 dnl gettext package is covered by the GNU General Public License.
15 dnl They are *not* in the public domain.
18 dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
19 dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
23 dnl Checks for all prerequisites of the po subdirectory.
24 AC_DEFUN([AM_PO_SUBDIRS],
26 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
27 AC_REQUIRE([AC_PROG_INSTALL])dnl
28 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
29 AC_REQUIRE([AC_PROG_SED])dnl
30 AC_REQUIRE([AM_NLS])dnl
32 dnl Release version of the gettext macros. This is used to ensure that
33 dnl the gettext macros and po/Makefile.in.in are in sync.
34 AC_SUBST([GETTEXT_MACRO_VERSION], [0.20])
36 dnl Perform the following tests also if --disable-nls has been given,
37 dnl because they are needed for "make dist" to work.
39 dnl Search for GNU msgfmt in the PATH.
40 dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
41 dnl The second test excludes FreeBSD msgfmt.
42 AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
43 [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
44 (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
46 AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
48 dnl Test whether it is GNU msgfmt >= 0.15.
50 case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
51 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;
52 *) GMSGFMT_015=$GMSGFMT ;;
55 AC_SUBST([GMSGFMT_015])
57 dnl Search for GNU xgettext 0.12 or newer in the PATH.
58 dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
59 dnl The second test excludes FreeBSD xgettext.
60 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
61 [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
62 (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
64 dnl Remove leftover from FreeBSD xgettext call.
67 dnl Test whether it is GNU xgettext >= 0.15.
69 case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in
70 '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;
71 *) XGETTEXT_015=$XGETTEXT ;;
74 AC_SUBST([XGETTEXT_015])
76 dnl Search for GNU msgmerge 0.11 or newer in the PATH.
77 AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
78 [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :)
80 dnl Test whether it is GNU msgmerge >= 0.20.
81 if LC_ALL=C $MSGMERGE --help | grep ' --for-msgfmt ' >/dev/null; then
82 MSGMERGE_FOR_MSGFMT_OPTION='--for-msgfmt'
84 dnl Test whether it is GNU msgmerge >= 0.12.
85 if LC_ALL=C $MSGMERGE --help | grep ' --no-fuzzy-matching ' >/dev/null; then
86 MSGMERGE_FOR_MSGFMT_OPTION='--no-fuzzy-matching --no-location --quiet'
88 dnl With these old versions, $(MSGMERGE) $(MSGMERGE_FOR_MSGFMT_OPTION) is
89 dnl slow. But this is not a big problem, as such old gettext versions are
90 dnl hardly in use any more.
91 MSGMERGE_FOR_MSGFMT_OPTION='--no-location --quiet'
94 AC_SUBST([MSGMERGE_FOR_MSGFMT_OPTION])
96 dnl Support for AM_XGETTEXT_OPTION.
97 test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=
98 AC_SUBST([XGETTEXT_EXTRA_OPTIONS])
100 AC_CONFIG_COMMANDS([po-directories], [[
101 for ac_file in $CONFIG_FILES; do
102 # Support "outfile[:infile[:infile...]]"
104 *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
106 # PO directories have a Makefile.in generated from Makefile.in.in.
107 case "$ac_file" in */Makefile.in)
108 # Adjust a relative srcdir.
109 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
110 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
111 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
112 # In autoconf-2.13 it is called $ac_given_srcdir.
113 # In autoconf-2.50 it is called $srcdir.
114 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
115 case "$ac_given_srcdir" in
116 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
117 /*) top_srcdir="$ac_given_srcdir" ;;
118 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
120 # Treat a directory as a PO directory if and only if it has a
121 # POTFILES.in file. This allows packages to have multiple PO
122 # directories under different names or in different locations.
123 if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
124 rm -f "$ac_dir/POTFILES"
125 test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
127 cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
128 POMAKEFILEDEPS="POTFILES.in"
129 # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
130 # on $ac_dir but don't depend on user-specified configuration
132 if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
133 # The LINGUAS file contains the set of available languages.
134 if test -n "$OBSOLETE_ALL_LINGUAS"; then
135 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
137 ALL_LINGUAS=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
138 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
140 # The set of available languages was given in configure.in.
141 ALL_LINGUAS=$OBSOLETE_ALL_LINGUAS
144 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
145 # Compute UPDATEPOFILES
146 # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
147 # Compute DUMMYPOFILES
148 # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
150 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
151 case "$ac_given_srcdir" in
153 *) srcdirpre='$(srcdir)/' ;;
159 for lang in $ALL_LINGUAS; do
160 POFILES="$POFILES $srcdirpre$lang.po"
161 UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
162 DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
163 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
165 # CATALOGS depends on both $ac_dir and the user's LINGUAS
166 # environment variable.
168 if test -n "$ALL_LINGUAS"; then
169 for presentlang in $ALL_LINGUAS; do
171 if test "%UNSET%" != "$LINGUAS"; then
172 desiredlanguages="$LINGUAS"
174 desiredlanguages="$ALL_LINGUAS"
176 for desiredlang in $desiredlanguages; do
177 # Use the presentlang catalog if desiredlang is
178 # a. equal to presentlang, or
179 # b. a variant of presentlang (because in this case,
180 # presentlang can be used as a fallback for messages
181 # which are not translated in the desiredlang catalog).
182 case "$desiredlang" in
183 "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*)
188 if test $useit = yes; then
189 INST_LINGUAS="$INST_LINGUAS $presentlang"
194 if test -n "$INST_LINGUAS"; then
195 for lang in $INST_LINGUAS; do
196 CATALOGS="$CATALOGS $lang.gmo"
199 test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
200 sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
201 for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
202 if test -f "$f"; then
204 *.orig | *.bak | *~) ;;
205 *) cat "$f" >> "$ac_dir/Makefile" ;;
213 [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
214 # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS.
215 OBSOLETE_ALL_LINGUAS="$ALL_LINGUAS"
216 # Capture the value of LINGUAS because we need it to compute CATALOGS.
217 LINGUAS="${LINGUAS-%UNSET%}"
221 dnl Postprocesses a Makefile in a directory containing PO files.
222 AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
224 # When this code is run, in config.status, two variables have already been
226 # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in,
227 # - LINGUAS is the value of the environment variable LINGUAS at configure
231 # Adjust a relative srcdir.
232 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
233 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
234 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
235 # In autoconf-2.13 it is called $ac_given_srcdir.
236 # In autoconf-2.50 it is called $srcdir.
237 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
238 case "$ac_given_srcdir" in
239 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
240 /*) top_srcdir="$ac_given_srcdir" ;;
241 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
244 # Find a way to echo strings without interpreting backslash.
245 if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then
248 if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then
249 gt_echo='printf %s\n'
260 # A sed script that extracts the value of VARIABLE from a Makefile.
263 # Test if the hold space is empty.
268 # Yes it was empty. Look if we have the expected variable definition.
269 /^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=/{
270 # Seen the first line of the variable definition.
271 s/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=//
276 # Here we are processing a line from the variable definition.
277 # Remove comment, more precisely replace it with a space.
279 # See if the line ends in a backslash.
283 # Print the line, without the trailing backslash.
286 # There was no trailing backslash. The end of the variable definition is
287 # reached. Clear the hold space.
292 # A trailing backslash means that the variable definition continues in the
293 # next line. Put a nonempty string into the hold space to indicate this.
300 # Set POTFILES to the value of the Makefile variable POTFILES.
301 sed_x_POTFILES=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/POTFILES/g'`
302 POTFILES=`sed -n -e "$sed_x_POTFILES" < "$ac_file"`
303 # Compute POTFILES_DEPS as
304 # $(foreach file, $(POTFILES), $(top_srcdir)/$(file))
306 for file in $POTFILES; do
307 POTFILES_DEPS="$POTFILES_DEPS "'$(top_srcdir)/'"$file"
311 if test -n "$OBSOLETE_ALL_LINGUAS"; then
312 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
314 if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
315 # The LINGUAS file contains the set of available languages.
316 ALL_LINGUAS=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
317 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
319 # Set ALL_LINGUAS to the value of the Makefile variable LINGUAS.
320 sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
321 ALL_LINGUAS=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
324 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
325 # Compute UPDATEPOFILES
326 # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)
327 # Compute DUMMYPOFILES
328 # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)
330 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)
331 # Compute PROPERTIESFILES
332 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(DOMAIN)_$(lang).properties)
334 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(DOMAIN)_$(lang).class)
336 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).qm)
338 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang)).msg)
339 # Compute RESOURCESDLLFILES
340 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(frob $(lang))/$(DOMAIN).resources.dll)
341 case "$ac_given_srcdir" in
343 *) srcdirpre='$(srcdir)/' ;;
354 for lang in $ALL_LINGUAS; do
355 POFILES="$POFILES $srcdirpre$lang.po"
356 UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
357 DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
358 GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
359 PROPERTIESFILES="$PROPERTIESFILES \$(srcdir)/\$(DOMAIN)_$lang.properties"
360 CLASSFILES="$CLASSFILES \$(srcdir)/\$(DOMAIN)_$lang.class"
361 QMFILES="$QMFILES $srcdirpre$lang.qm"
362 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
363 MSGFILES="$MSGFILES $srcdirpre$frobbedlang.msg"
364 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
365 RESOURCESDLLFILES="$RESOURCESDLLFILES $srcdirpre$frobbedlang/\$(DOMAIN).resources.dll"
367 # CATALOGS depends on both $ac_dir and the user's LINGUAS
368 # environment variable.
370 if test -n "$ALL_LINGUAS"; then
371 for presentlang in $ALL_LINGUAS; do
373 if test "%UNSET%" != "$LINGUAS"; then
374 desiredlanguages="$LINGUAS"
376 desiredlanguages="$ALL_LINGUAS"
378 for desiredlang in $desiredlanguages; do
379 # Use the presentlang catalog if desiredlang is
380 # a. equal to presentlang, or
381 # b. a variant of presentlang (because in this case,
382 # presentlang can be used as a fallback for messages
383 # which are not translated in the desiredlang catalog).
384 case "$desiredlang" in
385 "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*)
390 if test $useit = yes; then
391 INST_LINGUAS="$INST_LINGUAS $presentlang"
400 if test -n "$INST_LINGUAS"; then
401 for lang in $INST_LINGUAS; do
402 CATALOGS="$CATALOGS $lang.gmo"
403 JAVACATALOGS="$JAVACATALOGS \$(DOMAIN)_$lang.properties"
404 QTCATALOGS="$QTCATALOGS $lang.qm"
405 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
406 TCLCATALOGS="$TCLCATALOGS $frobbedlang.msg"
407 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
408 CSHARPCATALOGS="$CSHARPCATALOGS $frobbedlang/\$(DOMAIN).resources.dll"
412 sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
414 if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
415 # Add dependencies that cannot be formulated as a simple suffix rule.
416 for lang in $ALL_LINGUAS; do
417 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
418 cat >> "$ac_file.tmp" <<EOF
419 $frobbedlang.msg: $lang.po
420 ${tab}@echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
421 ${tab}\$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
425 if grep -l '@CSHARPCATALOGS@' "$ac_file" > /dev/null; then
426 # Add dependencies that cannot be formulated as a simple suffix rule.
427 for lang in $ALL_LINGUAS; do
428 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
429 cat >> "$ac_file.tmp" <<EOF
430 $frobbedlang/\$(DOMAIN).resources.dll: $lang.po
431 ${tab}@echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
432 ${tab}\$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
436 if test -n "$POMAKEFILEDEPS"; then
437 cat >> "$ac_file.tmp" <<EOF
438 Makefile: $POMAKEFILEDEPS
441 mv "$ac_file.tmp" "$ac_file"
444 dnl Initializes the accumulator used by AM_XGETTEXT_OPTION.
445 AC_DEFUN([AM_XGETTEXT_OPTION_INIT],
447 XGETTEXT_EXTRA_OPTIONS=
450 dnl Registers an option to be passed to xgettext in the po subdirectory.
451 AC_DEFUN([AM_XGETTEXT_OPTION],
453 AC_REQUIRE([AM_XGETTEXT_OPTION_INIT])
454 XGETTEXT_EXTRA_OPTIONS="$XGETTEXT_EXTRA_OPTIONS $1"