]>
Commit | Line | Data |
---|---|---|
50ffbc9d CR |
1 | # gettext.m4 serial 72 (gettext-0.21.1) |
2 | dnl Copyright (C) 1995-2014, 2016, 2018-2020 Free Software Foundation, Inc. | |
be4078d2 CR |
3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | |
5 | dnl with or without modifications, as long as this notice is preserved. | |
6 | dnl | |
7 | dnl This file can be used in projects which are not available under | |
50ffbc9d | 8 | dnl the GNU General Public License or the GNU Lesser General Public |
be4078d2 CR |
9 | dnl License but which still want to provide support for the GNU gettext |
10 | dnl functionality. | |
11 | dnl Please note that the actual code of the GNU gettext library is covered | |
50ffbc9d | 12 | dnl by the GNU Lesser General Public License, and the rest of the GNU |
be4078d2 CR |
13 | dnl gettext package is covered by the GNU General Public License. |
14 | dnl They are *not* in the public domain. | |
15 | ||
16 | dnl Authors: | |
17 | dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. | |
18 | dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010. | |
50ffbc9d CR |
19 | |
20 | dnl Modified for bash use by Chet Ramey <chet.ramey@case.edu>, 2023 | |
be4078d2 CR |
21 | |
22 | dnl Macro to add for using GNU gettext. | |
23 | ||
232f5919 | 24 | dnl Usage: BASH_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). |
50ffbc9d CR |
25 | dnl INTLSYMBOL must be one of 'external', 'use-libtool'. |
26 | dnl INTLSYMBOL should be 'external' for packages other than GNU gettext, and | |
27 | dnl 'use-libtool' for the packages 'gettext-runtime' and 'gettext-tools'. | |
be4078d2 CR |
28 | dnl If INTLSYMBOL is 'use-libtool', then a libtool library |
29 | dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, | |
30 | dnl depending on --{enable,disable}-{shared,static} and on the presence of | |
50ffbc9d | 31 | dnl AM-DISABLE-SHARED). |
be4078d2 CR |
32 | dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext |
33 | dnl implementations (in libc or libintl) without the ngettext() function | |
34 | dnl will be ignored. If NEEDSYMBOL is specified and is | |
35 | dnl 'need-formatstring-macros', then GNU gettext implementations that don't | |
36 | dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored. | |
37 | dnl INTLDIR is used to find the intl libraries. If empty, | |
38 | dnl the value '$(top_builddir)/intl/' is used. | |
39 | dnl | |
40 | dnl The result of the configuration is one of three cases: | |
41 | dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled | |
42 | dnl and used. | |
43 | dnl Catalog format: GNU --> install in $(datadir) | |
44 | dnl Catalog extension: .mo after installation, .gmo in source tree | |
45 | dnl 2) GNU gettext has been found in the system's C library. | |
46 | dnl Catalog format: GNU --> install in $(datadir) | |
47 | dnl Catalog extension: .mo after installation, .gmo in source tree | |
48 | dnl 3) No internationalization, always use English msgid. | |
49 | dnl Catalog format: none | |
50 | dnl Catalog extension: none | |
51 | dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. | |
52 | dnl The use of .gmo is historical (it was needed to avoid overwriting the | |
53 | dnl GNU format catalogs when building on a platform with an X/Open gettext), | |
54 | dnl but we keep it in order not to force irrelevant filename changes on the | |
55 | dnl maintainers. | |
56 | dnl | |
232f5919 | 57 | AC_DEFUN([BASH_GNU_GETTEXT], |
be4078d2 CR |
58 | [ |
59 | dnl Argument checking. | |
50ffbc9d | 60 | m4_if([$1], [], , [m4_if([$1], [external], , [m4_if([$1], [use-libtool], , |
be4078d2 | 61 | [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT |
50ffbc9d CR |
62 | ])])])]) |
63 | m4_if(m4_if([$1], [], [old])[]m4_if([$1], [no-libtool], [old]), [old], | |
64 | [errprint([ERROR: Use of AM_GNU_GETTEXT without [external] argument is no longer supported. | |
65 | ])]) | |
66 | m4_if([$2], [], , [m4_if([$2], [need-ngettext], , [m4_if([$2], [need-formatstring-macros], , | |
be4078d2 CR |
67 | [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT |
68 | ])])])]) | |
69 | define([gt_included_intl], | |
50ffbc9d | 70 | m4_if([$1], [external], [no], [yes])) |
be4078d2 CR |
71 | gt_NEEDS_INIT |
72 | AM_GNU_GETTEXT_NEED([$2]) | |
73 | ||
74 | AC_REQUIRE([AM_PO_SUBDIRS])dnl | |
50ffbc9d | 75 | m4_if(gt_included_intl, yes, [ |
be4078d2 CR |
76 | AC_REQUIRE([AM_INTL_SUBDIR])dnl |
77 | ]) | |
78 | ||
79 | dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. | |
80 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) | |
81 | AC_REQUIRE([AC_LIB_RPATH]) | |
82 | ||
83 | dnl Sometimes libintl requires libiconv, so first search for libiconv. | |
84 | dnl Ideally we would do this search only after the | |
85 | dnl if test "$USE_NLS" = "yes"; then | |
86 | dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then | |
87 | dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT | |
88 | dnl the configure script would need to contain the same shell code | |
89 | dnl again, outside any 'if'. There are two solutions: | |
90 | dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. | |
91 | dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. | |
92 | dnl Since AC_PROVIDE_IFELSE is not documented, we avoid it. | |
50ffbc9d | 93 | m4_if(gt_included_intl, yes, , [ |
be4078d2 CR |
94 | AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) |
95 | ]) | |
96 | ||
97 | dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation. | |
98 | gt_INTL_MACOSX | |
99 | ||
100 | dnl Set USE_NLS. | |
101 | AC_REQUIRE([AM_NLS]) | |
102 | ||
50ffbc9d | 103 | m4_if(gt_included_intl, yes, [ |
be4078d2 CR |
104 | BUILD_INCLUDED_LIBINTL=no |
105 | USE_INCLUDED_LIBINTL=no | |
106 | ]) | |
107 | LIBINTL= | |
108 | LTLIBINTL= | |
109 | POSUB= | |
110 | ||
111 | dnl Add a version number to the cache macros. | |
112 | case " $gt_needs " in | |
113 | *" need-formatstring-macros "*) gt_api_version=3 ;; | |
114 | *" need-ngettext "*) gt_api_version=2 ;; | |
115 | *) gt_api_version=1 ;; | |
116 | esac | |
117 | gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" | |
118 | gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" | |
119 | ||
120 | dnl If we use NLS figure out what method | |
121 | if test "$USE_NLS" = "yes"; then | |
122 | gt_use_preinstalled_gnugettext=no | |
50ffbc9d | 123 | m4_if(gt_included_intl, yes, [ |
be4078d2 CR |
124 | AC_MSG_CHECKING([whether included gettext is requested]) |
125 | AC_ARG_WITH([included-gettext], | |
126 | [ --with-included-gettext use the GNU gettext library included here], | |
127 | nls_cv_force_use_gnu_gettext=$withval, | |
128 | nls_cv_force_use_gnu_gettext=no) | |
129 | AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) | |
130 | ||
131 | nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" | |
132 | if test "$nls_cv_force_use_gnu_gettext" != "yes"; then | |
133 | ]) | |
134 | dnl User does not insist on using GNU NLS library. Figure out what | |
135 | dnl to use. If GNU gettext is available we use this. Else we have | |
136 | dnl to fall back to GNU NLS library. | |
137 | ||
138 | if test $gt_api_version -ge 3; then | |
139 | gt_revision_test_code=' | |
140 | #ifndef __GNU_GETTEXT_SUPPORTED_REVISION | |
141 | #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) | |
142 | #endif | |
143 | changequote(,)dnl | |
144 | typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; | |
145 | changequote([,])dnl | |
146 | ' | |
147 | else | |
148 | gt_revision_test_code= | |
149 | fi | |
150 | if test $gt_api_version -ge 2; then | |
151 | gt_expression_test_code=' + * ngettext ("", "", 0)' | |
152 | else | |
153 | gt_expression_test_code= | |
154 | fi | |
155 | ||
156 | AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], | |
157 | [AC_LINK_IFELSE( | |
158 | [AC_LANG_PROGRAM( | |
159 | [[ | |
160 | #include <libintl.h> | |
161 | #ifndef __GNU_GETTEXT_SUPPORTED_REVISION | |
162 | extern int _nl_msg_cat_cntr; | |
163 | extern int *_nl_domain_bindings; | |
164 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) | |
165 | #else | |
166 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 | |
167 | #endif | |
168 | $gt_revision_test_code | |
169 | ]], | |
170 | [[ | |
171 | bindtextdomain ("", ""); | |
172 | return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION | |
173 | ]])], | |
174 | [eval "$gt_func_gnugettext_libc=yes"], | |
175 | [eval "$gt_func_gnugettext_libc=no"])]) | |
176 | ||
177 | if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then | |
178 | dnl Sometimes libintl requires libiconv, so first search for libiconv. | |
50ffbc9d | 179 | m4_if(gt_included_intl, yes, , [ |
be4078d2 CR |
180 | AM_ICONV_LINK |
181 | ]) | |
182 | dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL | |
183 | dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) | |
184 | dnl because that would add "-liconv" to LIBINTL and LTLIBINTL | |
185 | dnl even if libiconv doesn't exist. | |
186 | AC_LIB_LINKFLAGS_BODY([intl]) | |
187 | AC_CACHE_CHECK([for GNU gettext in libintl], | |
188 | [$gt_func_gnugettext_libintl], | |
189 | [gt_save_CPPFLAGS="$CPPFLAGS" | |
190 | CPPFLAGS="$CPPFLAGS $INCINTL" | |
191 | gt_save_LIBS="$LIBS" | |
192 | LIBS="$LIBS $LIBINTL" | |
193 | dnl Now see whether libintl exists and does not depend on libiconv. | |
194 | AC_LINK_IFELSE( | |
195 | [AC_LANG_PROGRAM( | |
196 | [[ | |
197 | #include <libintl.h> | |
198 | #ifndef __GNU_GETTEXT_SUPPORTED_REVISION | |
199 | extern int _nl_msg_cat_cntr; | |
200 | extern | |
201 | #ifdef __cplusplus | |
202 | "C" | |
203 | #endif | |
204 | const char *_nl_expand_alias (const char *); | |
205 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) | |
206 | #else | |
207 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 | |
208 | #endif | |
209 | $gt_revision_test_code | |
210 | ]], | |
211 | [[ | |
212 | bindtextdomain ("", ""); | |
213 | return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION | |
214 | ]])], | |
215 | [eval "$gt_func_gnugettext_libintl=yes"], | |
216 | [eval "$gt_func_gnugettext_libintl=no"]) | |
217 | dnl Now see whether libintl exists and depends on libiconv. | |
218 | if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then | |
219 | LIBS="$LIBS $LIBICONV" | |
220 | AC_LINK_IFELSE( | |
221 | [AC_LANG_PROGRAM( | |
222 | [[ | |
223 | #include <libintl.h> | |
224 | #ifndef __GNU_GETTEXT_SUPPORTED_REVISION | |
225 | extern int _nl_msg_cat_cntr; | |
226 | extern | |
227 | #ifdef __cplusplus | |
228 | "C" | |
229 | #endif | |
230 | const char *_nl_expand_alias (const char *); | |
231 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) | |
232 | #else | |
233 | #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 | |
234 | #endif | |
235 | $gt_revision_test_code | |
236 | ]], | |
237 | [[ | |
238 | bindtextdomain ("", ""); | |
239 | return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION | |
240 | ]])], | |
241 | [LIBINTL="$LIBINTL $LIBICONV" | |
242 | LTLIBINTL="$LTLIBINTL $LTLIBICONV" | |
243 | eval "$gt_func_gnugettext_libintl=yes" | |
244 | ]) | |
245 | fi | |
246 | CPPFLAGS="$gt_save_CPPFLAGS" | |
247 | LIBS="$gt_save_LIBS"]) | |
248 | fi | |
249 | ||
250 | dnl If an already present or preinstalled GNU gettext() is found, | |
251 | dnl use it. But if this macro is used in GNU gettext, and GNU | |
252 | dnl gettext is already preinstalled in libintl, we update this | |
253 | dnl libintl. (Cf. the install rule in intl/Makefile.in.) | |
254 | if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ | |
255 | || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ | |
256 | && test "$PACKAGE" != gettext-runtime \ | |
257 | && test "$PACKAGE" != gettext-tools; }; then | |
258 | gt_use_preinstalled_gnugettext=yes | |
259 | else | |
260 | dnl Reset the values set by searching for libintl. | |
261 | LIBINTL= | |
262 | LTLIBINTL= | |
263 | INCINTL= | |
264 | fi | |
265 | ||
50ffbc9d | 266 | m4_if(gt_included_intl, yes, [ |
be4078d2 CR |
267 | if test "$gt_use_preinstalled_gnugettext" != "yes"; then |
268 | dnl GNU gettext is not found in the C library. | |
269 | dnl Fall back on included GNU gettext library. | |
270 | nls_cv_use_gnu_gettext=yes | |
271 | fi | |
272 | fi | |
273 | ||
274 | if test "$nls_cv_use_gnu_gettext" = "yes"; then | |
275 | dnl Mark actions used to generate GNU NLS library. | |
276 | BUILD_INCLUDED_LIBINTL=yes | |
277 | USE_INCLUDED_LIBINTL=yes | |
50ffbc9d CR |
278 | # LIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD" |
279 | # we don't build with libtool | |
280 | LIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.a $LIBICONV $LIBTHREAD" | |
281 | LTLIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD" | |
be4078d2 CR |
282 | LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` |
283 | fi | |
284 | ||
285 | CATOBJEXT= | |
286 | if test "$gt_use_preinstalled_gnugettext" = "yes" \ | |
287 | || test "$nls_cv_use_gnu_gettext" = "yes"; then | |
288 | dnl Mark actions to use GNU gettext tools. | |
289 | CATOBJEXT=.gmo | |
290 | fi | |
291 | ]) | |
292 | ||
293 | if test -n "$INTL_MACOSX_LIBS"; then | |
294 | if test "$gt_use_preinstalled_gnugettext" = "yes" \ | |
295 | || test "$nls_cv_use_gnu_gettext" = "yes"; then | |
296 | dnl Some extra flags are needed during linking. | |
297 | LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" | |
298 | LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" | |
299 | fi | |
300 | fi | |
301 | ||
302 | if test "$gt_use_preinstalled_gnugettext" = "yes" \ | |
303 | || test "$nls_cv_use_gnu_gettext" = "yes"; then | |
304 | AC_DEFINE([ENABLE_NLS], [1], | |
305 | [Define to 1 if translation of program messages to the user's native language | |
306 | is requested.]) | |
307 | else | |
308 | USE_NLS=no | |
309 | fi | |
310 | fi | |
311 | ||
312 | AC_MSG_CHECKING([whether to use NLS]) | |
313 | AC_MSG_RESULT([$USE_NLS]) | |
314 | if test "$USE_NLS" = "yes"; then | |
315 | AC_MSG_CHECKING([where the gettext function comes from]) | |
316 | if test "$gt_use_preinstalled_gnugettext" = "yes"; then | |
317 | if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then | |
318 | gt_source="external libintl" | |
319 | else | |
320 | gt_source="libc" | |
321 | fi | |
322 | else | |
323 | gt_source="included intl directory" | |
324 | fi | |
325 | AC_MSG_RESULT([$gt_source]) | |
326 | fi | |
327 | ||
328 | if test "$USE_NLS" = "yes"; then | |
329 | ||
330 | if test "$gt_use_preinstalled_gnugettext" = "yes"; then | |
331 | if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then | |
332 | AC_MSG_CHECKING([how to link with libintl]) | |
333 | AC_MSG_RESULT([$LIBINTL]) | |
334 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) | |
335 | fi | |
336 | ||
337 | dnl For backward compatibility. Some packages may be using this. | |
338 | AC_DEFINE([HAVE_GETTEXT], [1], | |
339 | [Define if the GNU gettext() function is already present or preinstalled.]) | |
340 | AC_DEFINE([HAVE_DCGETTEXT], [1], | |
341 | [Define if the GNU dcgettext() function is already present or preinstalled.]) | |
342 | fi | |
343 | ||
344 | dnl We need to process the po/ directory. | |
345 | POSUB=po | |
346 | fi | |
347 | ||
50ffbc9d CR |
348 | m4_if(gt_included_intl, yes, [ |
349 | dnl In GNU gettext we have to set BUILD_INCLUDED_LIBINTL to 'yes' | |
350 | dnl because some of the testsuite requires it. | |
351 | BUILD_INCLUDED_LIBINTL=yes | |
be4078d2 CR |
352 | |
353 | dnl Make all variables we use known to autoconf. | |
354 | AC_SUBST([BUILD_INCLUDED_LIBINTL]) | |
355 | AC_SUBST([USE_INCLUDED_LIBINTL]) | |
356 | AC_SUBST([CATOBJEXT]) | |
be4078d2 CR |
357 | ]) |
358 | ||
359 | dnl For backward compatibility. Some Makefiles may be using this. | |
360 | INTLLIBS="$LIBINTL" | |
361 | AC_SUBST([INTLLIBS]) | |
362 | ||
363 | dnl Make all documented variables known to autoconf. | |
364 | AC_SUBST([LIBINTL]) | |
365 | AC_SUBST([LTLIBINTL]) | |
366 | AC_SUBST([POSUB]) | |
367 | ]) | |
368 | ||
369 | ||
370 | dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. | |
371 | m4_define([gt_NEEDS_INIT], | |
372 | [ | |
373 | m4_divert_text([DEFAULTS], [gt_needs=]) | |
374 | m4_define([gt_NEEDS_INIT], []) | |
375 | ]) | |
376 | ||
377 | ||
378 | dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) | |
379 | AC_DEFUN([AM_GNU_GETTEXT_NEED], | |
380 | [ | |
381 | m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) | |
382 | ]) | |
383 | ||
384 | ||
385 | dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) | |
386 | AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) | |
387 | ||
388 | ||
389 | dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version]) | |
390 | AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], []) |