~vcs-imports/scourge/trunk

« back to all changes in this revision

Viewing changes to m4/gettext.m4

  • Committer: gabortorok
  • Date: 2007-01-22 05:28:40 UTC
  • Revision ID: vcs-imports@canonical.com-20070122052840-6e9fe946aec15259
more gettext files

Show diffs side-by-side

added added

removed removed

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