60
62
ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
61
63
[errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
63
ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
64
[AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
65
65
ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
66
66
[errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
68
define([gt_included_intl],
69
ifelse([$1], [external],
70
ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
72
define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
74
AM_GNU_GETTEXT_NEED([$2])
68
define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
69
define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
76
71
AC_REQUIRE([AM_PO_SUBDIRS])dnl
77
72
ifelse(gt_included_intl, yes, [
138
121
dnl to use. If GNU gettext is available we use this. Else we have
139
122
dnl to fall back to GNU NLS library.
141
if test $gt_api_version -ge 3; then
142
gt_revision_test_code='
143
#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
144
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
147
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
151
gt_revision_test_code=
153
if test $gt_api_version -ge 2; then
154
gt_expression_test_code=' + * ngettext ("", "", 0)'
156
gt_expression_test_code=
124
dnl Add a version number to the cache macros.
125
define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
126
define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
127
define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
159
AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
129
AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
160
130
[AC_TRY_LINK([#include <libintl.h>
161
$gt_revision_test_code
162
extern int _nl_msg_cat_cntr;
131
]ifelse([$2], [need-formatstring-macros],
132
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
133
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
136
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
138
], [])[extern int _nl_msg_cat_cntr;
163
139
extern int *_nl_domain_bindings;],
164
140
[bindtextdomain ("", "");
165
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings],
166
[eval "$gt_func_gnugettext_libc=yes"],
167
[eval "$gt_func_gnugettext_libc=no"])])
141
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
142
gt_cv_func_gnugettext_libc=yes,
143
gt_cv_func_gnugettext_libc=no)])
169
if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
145
if test "$gt_cv_func_gnugettext_libc" != "yes"; then
170
146
dnl Sometimes libintl requires libiconv, so first search for libiconv.
171
147
ifelse(gt_included_intl, yes, , [
177
153
dnl even if libiconv doesn't exist.
178
154
AC_LIB_LINKFLAGS_BODY([intl])
179
155
AC_CACHE_CHECK([for GNU gettext in libintl],
180
[$gt_func_gnugettext_libintl],
156
gt_cv_func_gnugettext_libintl,
181
157
[gt_save_CPPFLAGS="$CPPFLAGS"
182
158
CPPFLAGS="$CPPFLAGS $INCINTL"
183
159
gt_save_LIBS="$LIBS"
184
160
LIBS="$LIBS $LIBINTL"
185
161
dnl Now see whether libintl exists and does not depend on libiconv.
186
162
AC_TRY_LINK([#include <libintl.h>
187
$gt_revision_test_code
188
extern int _nl_msg_cat_cntr;
163
]ifelse([$2], [need-formatstring-macros],
164
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
165
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
168
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
170
], [])[extern int _nl_msg_cat_cntr;
190
172
#ifdef __cplusplus
193
const char *_nl_expand_alias (const char *);],
175
const char *_nl_expand_alias ();],
194
176
[bindtextdomain ("", "");
195
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
196
[eval "$gt_func_gnugettext_libintl=yes"],
197
[eval "$gt_func_gnugettext_libintl=no"])
177
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
178
gt_cv_func_gnugettext_libintl=yes,
179
gt_cv_func_gnugettext_libintl=no)
198
180
dnl Now see whether libintl exists and depends on libiconv.
199
if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
181
if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
200
182
LIBS="$LIBS $LIBICONV"
201
183
AC_TRY_LINK([#include <libintl.h>
202
$gt_revision_test_code
203
extern int _nl_msg_cat_cntr;
184
]ifelse([$2], [need-formatstring-macros],
185
[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
186
#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
189
typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
191
], [])[extern int _nl_msg_cat_cntr;
205
193
#ifdef __cplusplus
208
const char *_nl_expand_alias (const char *);],
196
const char *_nl_expand_alias ();],
209
197
[bindtextdomain ("", "");
210
return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
198
return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
211
199
[LIBINTL="$LIBINTL $LIBICONV"
212
200
LTLIBINTL="$LTLIBINTL $LTLIBICONV"
213
eval "$gt_func_gnugettext_libintl=yes"
201
gt_cv_func_gnugettext_libintl=yes
216
204
CPPFLAGS="$gt_save_CPPFLAGS"
332
310
dnl For backward compatibility. Some Makefiles may be using this.
333
311
DATADIRNAME=share
334
AC_SUBST([DATADIRNAME])
312
AC_SUBST(DATADIRNAME)
336
314
dnl For backward compatibility. Some Makefiles may be using this.
338
AC_SUBST([INSTOBJEXT])
340
318
dnl For backward compatibility. Some Makefiles may be using this.
344
322
dnl For backward compatibility. Some Makefiles may be using this.
346
323
if test "$USE_INCLUDED_LIBINTL" = yes; then
347
324
INTLOBJS="\$(GETTOBJS)"
351
328
dnl Enable libtool support if the surrounding package wishes it.
352
329
INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
353
AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
330
AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
356
333
dnl For backward compatibility. Some Makefiles may be using this.
357
334
INTLLIBS="$LIBINTL"
360
337
dnl Make all documented variables known to autoconf.
362
AC_SUBST([LTLIBINTL])
367
dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
368
m4_define([gt_NEEDS_INIT],
370
m4_divert_text([DEFAULTS], [gt_needs=])
371
m4_define([gt_NEEDS_INIT], [])
375
dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
376
AC_DEFUN([AM_GNU_GETTEXT_NEED],
378
m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
344
dnl Checks for all prerequisites of the intl subdirectory,
345
dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
346
dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
347
AC_DEFUN([AM_INTL_SUBDIR],
349
AC_REQUIRE([AC_PROG_INSTALL])dnl
350
AC_REQUIRE([AM_MKINSTALLDIRS])dnl
351
AC_REQUIRE([AC_PROG_CC])dnl
352
AC_REQUIRE([AC_CANONICAL_HOST])dnl
353
AC_REQUIRE([AC_PROG_RANLIB])dnl
354
AC_REQUIRE([AC_ISC_POSIX])dnl
355
AC_REQUIRE([AC_HEADER_STDC])dnl
356
AC_REQUIRE([AC_C_CONST])dnl
357
AC_REQUIRE([bh_C_SIGNED])dnl
358
AC_REQUIRE([AC_C_INLINE])dnl
359
AC_REQUIRE([AC_TYPE_OFF_T])dnl
360
AC_REQUIRE([AC_TYPE_SIZE_T])dnl
361
AC_REQUIRE([jm_AC_TYPE_LONG_LONG])dnl
362
AC_REQUIRE([gt_TYPE_LONGDOUBLE])dnl
363
AC_REQUIRE([gt_TYPE_WCHAR_T])dnl
364
AC_REQUIRE([gt_TYPE_WINT_T])dnl
365
AC_REQUIRE([jm_AC_HEADER_INTTYPES_H])
366
AC_REQUIRE([jm_AC_HEADER_STDINT_H])
367
AC_REQUIRE([gt_TYPE_INTMAX_T])
368
AC_REQUIRE([gt_PRINTF_POSIX])
369
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
370
AC_REQUIRE([AC_FUNC_MMAP])dnl
371
AC_REQUIRE([jm_GLIBC21])dnl
372
AC_REQUIRE([gt_INTDIV0])dnl
373
AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl
374
AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl
375
AC_REQUIRE([gt_INTTYPES_PRI])dnl
376
AC_REQUIRE([gl_XSIZE])dnl
378
AC_CHECK_TYPE([ptrdiff_t], ,
379
[AC_DEFINE([ptrdiff_t], [long],
380
[Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
382
AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
383
stdlib.h string.h unistd.h sys/param.h])
384
AC_CHECK_FUNCS([asprintf fwprintf getcwd getegid geteuid getgid getuid \
385
mempcpy munmap putenv setenv setlocale snprintf stpcpy strcasecmp strdup \
386
strtoul tsearch wcslen __argz_count __argz_stringify __argz_next \
389
dnl Use the _snprintf function only if it is declared (because on NetBSD it
390
dnl is defined as a weak alias of snprintf; we prefer to use the latter).
391
gt_CHECK_DECL(_snprintf, [#include <stdio.h>])
392
gt_CHECK_DECL(_snwprintf, [#include <stdio.h>])
394
dnl Use the *_unlocked functions only if they are declared.
395
dnl (because some of them were defined without being declared in Solaris
396
dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
397
dnl on Solaris 2.5.1 to run on Solaris 2.6).
398
dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
399
gt_CHECK_DECL(feof_unlocked, [#include <stdio.h>])
400
gt_CHECK_DECL(fgets_unlocked, [#include <stdio.h>])
401
gt_CHECK_DECL(getc_unlocked, [#include <stdio.h>])
403
case $gt_cv_func_printf_posix in
404
*yes) HAVE_POSIX_PRINTF=1 ;;
405
*) HAVE_POSIX_PRINTF=0 ;;
407
AC_SUBST([HAVE_POSIX_PRINTF])
408
if test "$ac_cv_func_asprintf" = yes; then
413
AC_SUBST([HAVE_ASPRINTF])
414
if test "$ac_cv_func_snprintf" = yes; then
419
AC_SUBST([HAVE_SNPRINTF])
420
if test "$ac_cv_func_wprintf" = yes; then
425
AC_SUBST([HAVE_WPRINTF])
429
if test $ac_cv_header_locale_h = yes; then
433
dnl intl/plural.c is generated from intl/plural.y. It requires bison,
434
dnl because plural.y uses bison specific features. It requires at least
435
dnl bison-1.26 because earlier versions generate a plural.c that doesn't
437
dnl bison is only needed for the maintainer (who touches plural.y). But in
438
dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
439
dnl the rule in general Makefile. Now, some people carelessly touch the
440
dnl files or have a broken "make" program, hence the plural.c rule will
441
dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
442
dnl present or too old.
443
AC_CHECK_PROGS([INTLBISON], [bison])
444
if test -z "$INTLBISON"; then
447
dnl Found it, now check the version.
448
AC_MSG_CHECKING([version of bison])
449
changequote(<<,>>)dnl
450
ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
451
case $ac_prog_version in
452
'') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
453
1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
455
ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
456
*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
458
AC_MSG_RESULT([$ac_prog_version])
460
if test $ac_verc_fail = yes; then
466
dnl gt_CHECK_DECL(FUNC, INCLUDES)
467
dnl Check whether a function is declared.
468
AC_DEFUN([gt_CHECK_DECL],
470
AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1,
471
[AC_TRY_COMPILE([$2], [
473
char *p = (char *) $1;
475
], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)])
476
if test $ac_cv_have_decl_$1 = yes; then
481
AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value],
482
[Define to 1 if you have the declaration of `$1', and to 0 if you don't.])