Remove inttypes-h.m4 and its gl_HEADER_INTTYES_H macro.
[gnulib.git] / m4 / gettext.m4
1 # gettext.m4 serial 53.1
2 dnl Copyright (C) 1995-2006 Free Software Foundation, Inc.
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 can be used in projects which are not available under
8 dnl the GNU General Public License or the GNU Library General Public
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
12 dnl by the GNU Library General Public License, and the rest of the GNU
13 dnl gettext package 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-2005.
19
20 AC_PREREQ(2.52)
21
22 dnl Macro to add for using GNU gettext.
23
24 dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
25 dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
26 dnl    default (if it is not specified or empty) is 'no-libtool'.
27 dnl    INTLSYMBOL should be 'external' for packages with no intl directory,
28 dnl    and 'no-libtool' or 'use-libtool' for packages with an intl directory.
29 dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
30 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
31 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
32 dnl    AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
33 dnl    $(top_builddir)/intl/libintl.a will be created.
34 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
35 dnl    implementations (in libc or libintl) without the ngettext() function
36 dnl    will be ignored.  If NEEDSYMBOL is specified and is
37 dnl    'need-formatstring-macros', then GNU gettext implementations that don't
38 dnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
39 dnl INTLDIR is used to find the intl libraries.  If empty,
40 dnl    the value `$(top_builddir)/intl/' is used.
41 dnl
42 dnl The result of the configuration is one of three cases:
43 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
44 dnl    and used.
45 dnl    Catalog format: GNU --> install in $(datadir)
46 dnl    Catalog extension: .mo after installation, .gmo in source tree
47 dnl 2) GNU gettext has been found in the system's C library.
48 dnl    Catalog format: GNU --> install in $(datadir)
49 dnl    Catalog extension: .mo after installation, .gmo in source tree
50 dnl 3) No internationalization, always use English msgid.
51 dnl    Catalog format: none
52 dnl    Catalog extension: none
53 dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
54 dnl The use of .gmo is historical (it was needed to avoid overwriting the
55 dnl GNU format catalogs when building on a platform with an X/Open gettext),
56 dnl but we keep it in order not to force irrelevant filename changes on the
57 dnl maintainers.
58 dnl
59 AC_DEFUN([AM_GNU_GETTEXT],
60 [
61   dnl Argument checking.
62   ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
63     [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
64 ])])])])])
65   ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
66     [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
67 ])])])])
68   define([gt_included_intl], ifelse([$1], [external], [no], [yes]))
69   define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
70
71   AC_REQUIRE([AM_PO_SUBDIRS])dnl
72   ifelse(gt_included_intl, yes, [
73     AC_REQUIRE([AM_INTL_SUBDIR])dnl
74   ])
75
76   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
77   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
78   AC_REQUIRE([AC_LIB_RPATH])
79
80   dnl Sometimes libintl requires libiconv, so first search for libiconv.
81   dnl Ideally we would do this search only after the
82   dnl      if test "$USE_NLS" = "yes"; then
83   dnl        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
84   dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
85   dnl the configure script would need to contain the same shell code
86   dnl again, outside any 'if'. There are two solutions:
87   dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
88   dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
89   dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
90   dnl documented, we avoid it.
91   ifelse(gt_included_intl, yes, , [
92     AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
93   ])
94
95   dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation.
96   gt_INTL_MACOSX
97
98   dnl Set USE_NLS.
99   AC_REQUIRE([AM_NLS])
100
101   ifelse(gt_included_intl, yes, [
102     BUILD_INCLUDED_LIBINTL=no
103     USE_INCLUDED_LIBINTL=no
104   ])
105   LIBINTL=
106   LTLIBINTL=
107   POSUB=
108
109   dnl If we use NLS figure out what method
110   if test "$USE_NLS" = "yes"; then
111     gt_use_preinstalled_gnugettext=no
112     ifelse(gt_included_intl, yes, [
113       AC_MSG_CHECKING([whether included gettext is requested])
114       AC_ARG_WITH(included-gettext,
115         [  --with-included-gettext use the GNU gettext library included here],
116         nls_cv_force_use_gnu_gettext=$withval,
117         nls_cv_force_use_gnu_gettext=no)
118       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
119
120       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
121       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
122     ])
123         dnl User does not insist on using GNU NLS library.  Figure out what
124         dnl to use.  If GNU gettext is available we use this.  Else we have
125         dnl to fall back to GNU NLS library.
126
127         dnl Add a version number to the cache macros.
128         define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
129         define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
130         define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
131
132         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
133          [AC_TRY_LINK([#include <libintl.h>
134 ]ifelse([$2], [need-formatstring-macros],
135 [[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
136 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
137 #endif
138 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
139 ]], [])[extern int _nl_msg_cat_cntr;
140 extern int *_nl_domain_bindings;],
141             [bindtextdomain ("", "");
142 return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
143             gt_cv_func_gnugettext_libc=yes,
144             gt_cv_func_gnugettext_libc=no)])
145
146         if test "$gt_cv_func_gnugettext_libc" != "yes"; then
147           dnl Sometimes libintl requires libiconv, so first search for libiconv.
148           ifelse(gt_included_intl, yes, , [
149             AM_ICONV_LINK
150           ])
151           dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
152           dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
153           dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
154           dnl even if libiconv doesn't exist.
155           AC_LIB_LINKFLAGS_BODY([intl])
156           AC_CACHE_CHECK([for GNU gettext in libintl],
157             gt_cv_func_gnugettext_libintl,
158            [gt_save_CPPFLAGS="$CPPFLAGS"
159             CPPFLAGS="$CPPFLAGS $INCINTL"
160             gt_save_LIBS="$LIBS"
161             LIBS="$LIBS $LIBINTL"
162             dnl Now see whether libintl exists and does not depend on libiconv.
163             AC_TRY_LINK([#include <libintl.h>
164 ]ifelse([$2], [need-formatstring-macros],
165 [[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
166 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
167 #endif
168 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
169 ]], [])[extern int _nl_msg_cat_cntr;
170 extern
171 #ifdef __cplusplus
172 "C"
173 #endif
174 const char *_nl_expand_alias (const char *);],
175               [bindtextdomain ("", "");
176 return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
177               gt_cv_func_gnugettext_libintl=yes,
178               gt_cv_func_gnugettext_libintl=no)
179             dnl Now see whether libintl exists and depends on libiconv.
180             if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
181               LIBS="$LIBS $LIBICONV"
182               AC_TRY_LINK([#include <libintl.h>
183 ]ifelse([$2], [need-formatstring-macros],
184 [[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
185 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
186 #endif
187 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
188 ]], [])[extern int _nl_msg_cat_cntr;
189 extern
190 #ifdef __cplusplus
191 "C"
192 #endif
193 const char *_nl_expand_alias (const char *);],
194                 [bindtextdomain ("", "");
195 return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
196                [LIBINTL="$LIBINTL $LIBICONV"
197                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
198                 gt_cv_func_gnugettext_libintl=yes
199                ])
200             fi
201             CPPFLAGS="$gt_save_CPPFLAGS"
202             LIBS="$gt_save_LIBS"])
203         fi
204
205         dnl If an already present or preinstalled GNU gettext() is found,
206         dnl use it.  But if this macro is used in GNU gettext, and GNU
207         dnl gettext is already preinstalled in libintl, we update this
208         dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
209         if test "$gt_cv_func_gnugettext_libc" = "yes" \
210            || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
211                 && test "$PACKAGE" != gettext-runtime \
212                 && test "$PACKAGE" != gettext-tools; }; then
213           gt_use_preinstalled_gnugettext=yes
214         else
215           dnl Reset the values set by searching for libintl.
216           LIBINTL=
217           LTLIBINTL=
218           INCINTL=
219         fi
220
221     ifelse(gt_included_intl, yes, [
222         if test "$gt_use_preinstalled_gnugettext" != "yes"; then
223           dnl GNU gettext is not found in the C library.
224           dnl Fall back on included GNU gettext library.
225           nls_cv_use_gnu_gettext=yes
226         fi
227       fi
228
229       if test "$nls_cv_use_gnu_gettext" = "yes"; then
230         dnl Mark actions used to generate GNU NLS library.
231         BUILD_INCLUDED_LIBINTL=yes
232         USE_INCLUDED_LIBINTL=yes
233         LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
234         LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
235         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
236       fi
237
238       CATOBJEXT=
239       if test "$gt_use_preinstalled_gnugettext" = "yes" \
240          || test "$nls_cv_use_gnu_gettext" = "yes"; then
241         dnl Mark actions to use GNU gettext tools.
242         CATOBJEXT=.gmo
243       fi
244     ])
245
246     if test -n "$INTL_MACOSX_LIBS"; then
247       if test "$gt_use_preinstalled_gnugettext" = "yes" \
248          || test "$nls_cv_use_gnu_gettext" = "yes"; then
249         dnl Some extra flags are needed during linking.
250         LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
251         LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
252       fi
253     fi
254
255     if test "$gt_use_preinstalled_gnugettext" = "yes" \
256        || test "$nls_cv_use_gnu_gettext" = "yes"; then
257       AC_DEFINE(ENABLE_NLS, 1,
258         [Define to 1 if translation of program messages to the user's native language
259    is requested.])
260     else
261       USE_NLS=no
262     fi
263   fi
264
265   AC_MSG_CHECKING([whether to use NLS])
266   AC_MSG_RESULT([$USE_NLS])
267   if test "$USE_NLS" = "yes"; then
268     AC_MSG_CHECKING([where the gettext function comes from])
269     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
270       if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
271         gt_source="external libintl"
272       else
273         gt_source="libc"
274       fi
275     else
276       gt_source="included intl directory"
277     fi
278     AC_MSG_RESULT([$gt_source])
279   fi
280
281   if test "$USE_NLS" = "yes"; then
282
283     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
284       if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
285         AC_MSG_CHECKING([how to link with libintl])
286         AC_MSG_RESULT([$LIBINTL])
287         AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
288       fi
289
290       dnl For backward compatibility. Some packages may be using this.
291       AC_DEFINE(HAVE_GETTEXT, 1,
292        [Define if the GNU gettext() function is already present or preinstalled.])
293       AC_DEFINE(HAVE_DCGETTEXT, 1,
294        [Define if the GNU dcgettext() function is already present or preinstalled.])
295     fi
296
297     dnl We need to process the po/ directory.
298     POSUB=po
299   fi
300
301   ifelse(gt_included_intl, yes, [
302     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
303     dnl to 'yes' because some of the testsuite requires it.
304     if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
305       BUILD_INCLUDED_LIBINTL=yes
306     fi
307
308     dnl Make all variables we use known to autoconf.
309     AC_SUBST(BUILD_INCLUDED_LIBINTL)
310     AC_SUBST(USE_INCLUDED_LIBINTL)
311     AC_SUBST(CATOBJEXT)
312
313     dnl For backward compatibility. Some configure.ins may be using this.
314     nls_cv_header_intl=
315     nls_cv_header_libgt=
316
317     dnl For backward compatibility. Some Makefiles may be using this.
318     DATADIRNAME=share
319     AC_SUBST(DATADIRNAME)
320
321     dnl For backward compatibility. Some Makefiles may be using this.
322     INSTOBJEXT=.mo
323     AC_SUBST(INSTOBJEXT)
324
325     dnl For backward compatibility. Some Makefiles may be using this.
326     GENCAT=gencat
327     AC_SUBST(GENCAT)
328
329     dnl For backward compatibility. Some Makefiles may be using this.
330     INTLOBJS=
331     if test "$USE_INCLUDED_LIBINTL" = yes; then
332       INTLOBJS="\$(GETTOBJS)"
333     fi
334     AC_SUBST(INTLOBJS)
335
336     dnl Enable libtool support if the surrounding package wishes it.
337     INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
338     AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
339   ])
340
341   dnl For backward compatibility. Some Makefiles may be using this.
342   INTLLIBS="$LIBINTL"
343   AC_SUBST(INTLLIBS)
344
345   dnl Make all documented variables known to autoconf.
346   AC_SUBST(LIBINTL)
347   AC_SUBST(LTLIBINTL)
348   AC_SUBST(POSUB)
349 ])
350
351
352 dnl Checks for all prerequisites of the intl subdirectory,
353 dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
354 dnl            USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
355 AC_DEFUN([AM_INTL_SUBDIR],
356 [
357   AC_REQUIRE([AC_PROG_INSTALL])dnl
358   AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
359   AC_REQUIRE([AC_PROG_CC])dnl
360   AC_REQUIRE([AC_CANONICAL_HOST])dnl
361   AC_REQUIRE([gt_GLIBC2])dnl
362   AC_REQUIRE([AC_PROG_RANLIB])dnl
363   AC_REQUIRE([gl_VISIBILITY])dnl
364   AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl
365   AC_REQUIRE([bh_C_SIGNED])dnl
366   AC_REQUIRE([gl_AC_TYPE_LONG_LONG])dnl
367   AC_REQUIRE([gt_TYPE_LONGDOUBLE])dnl
368   AC_REQUIRE([gt_TYPE_WCHAR_T])dnl
369   AC_REQUIRE([gt_TYPE_WINT_T])dnl
370   AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
371   AC_REQUIRE([gt_TYPE_INTMAX_T])
372   AC_REQUIRE([gt_PRINTF_POSIX])
373   AC_REQUIRE([gl_GLIBC21])dnl
374   AC_REQUIRE([gl_XSIZE])dnl
375   AC_REQUIRE([gt_INTL_MACOSX])dnl
376
377   AC_CHECK_TYPE([ptrdiff_t], ,
378     [AC_DEFINE([ptrdiff_t], [long],
379        [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
380     ])
381   AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
382   AC_CHECK_FUNCS([asprintf fwprintf putenv setenv setlocale snprintf wcslen])
383
384   dnl Use the _snprintf function only if it is declared (because on NetBSD it
385   dnl is defined as a weak alias of snprintf; we prefer to use the latter).
386   gt_CHECK_DECL(_snprintf, [#include <stdio.h>])
387   gt_CHECK_DECL(_snwprintf, [#include <stdio.h>])
388
389   dnl Use the *_unlocked functions only if they are declared.
390   dnl (because some of them were defined without being declared in Solaris
391   dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
392   dnl on Solaris 2.5.1 to run on Solaris 2.6).
393   dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
394   gt_CHECK_DECL(getc_unlocked, [#include <stdio.h>])
395
396   case $gt_cv_func_printf_posix in
397     *yes) HAVE_POSIX_PRINTF=1 ;;
398     *) HAVE_POSIX_PRINTF=0 ;;
399   esac
400   AC_SUBST([HAVE_POSIX_PRINTF])
401   if test "$ac_cv_func_asprintf" = yes; then
402     HAVE_ASPRINTF=1
403   else
404     HAVE_ASPRINTF=0
405   fi
406   AC_SUBST([HAVE_ASPRINTF])
407   if test "$ac_cv_func_snprintf" = yes; then
408     HAVE_SNPRINTF=1
409   else
410     HAVE_SNPRINTF=0
411   fi
412   AC_SUBST([HAVE_SNPRINTF])
413   if test "$ac_cv_func_wprintf" = yes; then
414     HAVE_WPRINTF=1
415   else
416     HAVE_WPRINTF=0
417   fi
418   AC_SUBST([HAVE_WPRINTF])
419
420   AM_LANGINFO_CODESET
421   gt_LC_MESSAGES
422
423   dnl Compilation on mingw and Cygwin needs special Makefile rules, because
424   dnl 1. when we install a shared library, we must arrange to export
425   dnl    auxiliary pointer variables for every exported variable,
426   dnl 2. when we install a shared library and a static library simultaneously,
427   dnl    the include file specifies __declspec(dllimport) and therefore we
428   dnl    must arrange to define the auxiliary pointer variables for the
429   dnl    exported variables _also_ in the static library.
430   if test "$enable_shared" = yes; then
431     case "$host_os" in
432       cygwin*) is_woe32dll=yes ;;
433       *) is_woe32dll=no ;;
434     esac
435   else
436     is_woe32dll=no
437   fi
438   WOE32DLL=$is_woe32dll
439   AC_SUBST([WOE32DLL])
440
441   dnl Rename some macros and functions used for locking.
442   AH_BOTTOM([
443 #define __libc_lock_t                   gl_lock_t
444 #define __libc_lock_define              gl_lock_define
445 #define __libc_lock_define_initialized  gl_lock_define_initialized
446 #define __libc_lock_init                gl_lock_init
447 #define __libc_lock_lock                gl_lock_lock
448 #define __libc_lock_unlock              gl_lock_unlock
449 #define __libc_lock_recursive_t                   gl_recursive_lock_t
450 #define __libc_lock_define_recursive              gl_recursive_lock_define
451 #define __libc_lock_define_initialized_recursive  gl_recursive_lock_define_initialized
452 #define __libc_lock_init_recursive                gl_recursive_lock_init
453 #define __libc_lock_lock_recursive                gl_recursive_lock_lock
454 #define __libc_lock_unlock_recursive              gl_recursive_lock_unlock
455 #define glthread_in_use  libintl_thread_in_use
456 #define glthread_lock_init     libintl_lock_init
457 #define glthread_lock_lock     libintl_lock_lock
458 #define glthread_lock_unlock   libintl_lock_unlock
459 #define glthread_lock_destroy  libintl_lock_destroy
460 #define glthread_rwlock_init     libintl_rwlock_init
461 #define glthread_rwlock_rdlock   libintl_rwlock_rdlock
462 #define glthread_rwlock_wrlock   libintl_rwlock_wrlock
463 #define glthread_rwlock_unlock   libintl_rwlock_unlock
464 #define glthread_rwlock_destroy  libintl_rwlock_destroy
465 #define glthread_recursive_lock_init     libintl_recursive_lock_init
466 #define glthread_recursive_lock_lock     libintl_recursive_lock_lock
467 #define glthread_recursive_lock_unlock   libintl_recursive_lock_unlock
468 #define glthread_recursive_lock_destroy  libintl_recursive_lock_destroy
469 #define glthread_once                 libintl_once
470 #define glthread_once_call            libintl_once_call
471 #define glthread_once_singlethreaded  libintl_once_singlethreaded
472 ])
473 ])
474
475
476 dnl Checks for the core files of the intl subdirectory:
477 dnl   dcigettext.c
478 dnl   eval-plural.h
479 dnl   explodename.c
480 dnl   finddomain.c
481 dnl   gettextP.h
482 dnl   gmo.h
483 dnl   hash-string.h hash-string.c
484 dnl   l10nflist.c
485 dnl   libgnuintl.h.in (except the *printf stuff)
486 dnl   loadinfo.h
487 dnl   loadmsgcat.c
488 dnl   localealias.c
489 dnl   log.c
490 dnl   plural-exp.h plural-exp.c
491 dnl   plural.y
492 dnl Used by libglocale.
493 AC_DEFUN([gt_INTL_SUBDIR_CORE],
494 [
495   AC_REQUIRE([AC_C_INLINE])dnl
496   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
497   AC_REQUIRE([gl_AC_HEADER_STDINT_H])
498   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
499   AC_REQUIRE([AC_FUNC_MMAP])dnl
500   AC_REQUIRE([gt_INTDIV0])dnl
501   AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl
502   AC_REQUIRE([gt_INTTYPES_PRI])dnl
503   AC_REQUIRE([gl_LOCK])dnl
504
505   AC_TRY_LINK(
506     [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }],
507     [],
508     [AC_DEFINE([HAVE_BUILTIN_EXPECT], 1,
509        [Define to 1 if the compiler understands __builtin_expect.])])
510
511   AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h])
512   AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
513     stpcpy strcasecmp strdup strtoul tsearch argz_count argz_stringify \
514     argz_next __fsetlocking])
515
516   dnl Use the *_unlocked functions only if they are declared.
517   dnl (because some of them were defined without being declared in Solaris
518   dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
519   dnl on Solaris 2.5.1 to run on Solaris 2.6).
520   dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
521   gt_CHECK_DECL(feof_unlocked, [#include <stdio.h>])
522   gt_CHECK_DECL(fgets_unlocked, [#include <stdio.h>])
523
524   AM_ICONV
525
526   dnl glibc >= 2.4 has a NL_LOCALE_NAME macro when _GNU_SOURCE is defined,
527   dnl and a _NL_LOCALE_NAME macro always.
528   AC_CACHE_CHECK([for NL_LOCALE_NAME macro], gt_cv_nl_locale_name,
529     [AC_TRY_LINK([#include <langinfo.h>
530 #include <locale.h>],
531       [char* cs = nl_langinfo(_NL_LOCALE_NAME(LC_MESSAGES));],
532       gt_cv_nl_locale_name=yes,
533       gt_cv_nl_locale_name=no)
534     ])
535   if test $gt_cv_nl_locale_name = yes; then
536     AC_DEFINE(HAVE_NL_LOCALE_NAME, 1,
537       [Define if you have <langinfo.h> and it defines the NL_LOCALE_NAME macro if _GNU_SOURCE is defined.])
538   fi
539
540   dnl intl/plural.c is generated from intl/plural.y. It requires bison,
541   dnl because plural.y uses bison specific features. It requires at least
542   dnl bison-1.26 because earlier versions generate a plural.c that doesn't
543   dnl compile.
544   dnl bison is only needed for the maintainer (who touches plural.y). But in
545   dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
546   dnl the rule in general Makefile. Now, some people carelessly touch the
547   dnl files or have a broken "make" program, hence the plural.c rule will
548   dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
549   dnl present or too old.
550   AC_CHECK_PROGS([INTLBISON], [bison])
551   if test -z "$INTLBISON"; then
552     ac_verc_fail=yes
553   else
554     dnl Found it, now check the version.
555     AC_MSG_CHECKING([version of bison])
556 changequote(<<,>>)dnl
557     ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
558     case $ac_prog_version in
559       '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
560       1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
561 changequote([,])dnl
562          ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
563       *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
564     esac
565     AC_MSG_RESULT([$ac_prog_version])
566   fi
567   if test $ac_verc_fail = yes; then
568     INTLBISON=:
569   fi
570 ])
571
572
573 dnl Checks for special options needed on MacOS X.
574 dnl Defines INTL_MACOSX_LIBS.
575 AC_DEFUN([gt_INTL_MACOSX],
576 [
577   dnl Check for API introduced in MacOS X 10.2.
578   AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
579     gt_cv_func_CFPreferencesCopyAppValue,
580     [gt_save_LIBS="$LIBS"
581      LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
582      AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>],
583        [CFPreferencesCopyAppValue(NULL, NULL)],
584        [gt_cv_func_CFPreferencesCopyAppValue=yes],
585        [gt_cv_func_CFPreferencesCopyAppValue=no])
586      LIBS="$gt_save_LIBS"])
587   if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
588     AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1,
589       [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
590   fi
591   dnl Check for API introduced in MacOS X 10.3.
592   AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent,
593     [gt_save_LIBS="$LIBS"
594      LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
595      AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();],
596        [gt_cv_func_CFLocaleCopyCurrent=yes],
597        [gt_cv_func_CFLocaleCopyCurrent=no])
598      LIBS="$gt_save_LIBS"])
599   if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
600     AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1,
601       [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
602   fi
603   INTL_MACOSX_LIBS=
604   if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
605     INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
606   fi
607   AC_SUBST([INTL_MACOSX_LIBS])
608 ])
609
610
611 dnl gt_CHECK_DECL(FUNC, INCLUDES)
612 dnl Check whether a function is declared.
613 AC_DEFUN([gt_CHECK_DECL],
614 [
615   AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1,
616     [AC_TRY_COMPILE([$2], [
617 #ifndef $1
618   char *p = (char *) $1;
619 #endif
620 ], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)])
621   if test $ac_cv_have_decl_$1 = yes; then
622     gt_value=1
623   else
624     gt_value=0
625   fi
626   AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value],
627     [Define to 1 if you have the declaration of `$1', and to 0 if you don't.])
628 ])
629
630
631 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
632 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])