1 # Macro to add for using GNU gettext.
2 # Ulrich Drepper <drepper@cygnus.com>, 1995.
5 # Slightly modified by Thomas Roessler <roessler@does-not-exist.org>
6 # Updated to gettext-0.10.38 by Edmund Grimley Evans <edmundo@rano.org>
7 # Updated to gettext-0.10.40 by Andrew W. Nosenko <awn@bcs.zp.ua>
10 # This file can be copied and used freely without restrictions. It can
11 # be used in projects which are not available under the GNU General Public
12 # License or the GNU Library General Public License but which still want
13 # to provide support for the GNU gettext functionality.
14 # Please note that the actual code of the GNU gettext library is covered
15 # by the GNU Library General Public License, and the rest of the GNU
16 # gettext package package is covered by the GNU General Public License.
17 # They are *not* in the public domain.
21 dnl Usage: MUTT_AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR]).
22 dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
23 dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
24 dnl depending on --{enable,disable}-{shared,static} and on the presence of
25 dnl AM-DISABLE-SHARED). Otherwise, a static library
26 dnl $(top_builddir)/intl/libintl.a will be created.
27 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
28 dnl implementations (in libc or libintl) without the ngettext() function
30 dnl LIBDIR is used to find the intl libraries. If empty,
31 dnl the value `$(top_builddir)/intl/' is used.
33 dnl The result of the configuration is one of three cases:
34 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
36 dnl Catalog format: GNU --> install in $(datadir)
37 dnl Catalog extension: .mo after installation, .gmo in source tree
38 dnl 2) GNU gettext has been found in the system's C library.
39 dnl Catalog format: GNU --> install in $(datadir)
40 dnl Catalog extension: .mo after installation, .gmo in source tree
41 dnl 3) No internationalization, always use English msgid.
42 dnl Catalog format: none
43 dnl Catalog extension: none
44 dnl The use of .gmo is historical (it was needed to avoid overwriting the
45 dnl GNU format catalogs when building on a platform with an X/Open gettext),
46 dnl but we keep it in order not to force irrelevant filename changes on the
49 AC_DEFUN([MUTT_AM_WITH_NLS],
50 [AC_MSG_CHECKING([whether NLS is requested])
51 dnl Default is enabled NLS
53 AC_HELP_STRING([--disable-nls], [Do not use Native Language Support]),
54 USE_NLS=$enableval, USE_NLS=yes)
55 AC_MSG_RESULT($USE_NLS)
58 BUILD_INCLUDED_LIBINTL=no
59 USE_INCLUDED_LIBINTL=no
62 dnl If we use NLS figure out what method
63 if test "$USE_NLS" = "yes"; then
64 AC_DEFINE(ENABLE_NLS, 1,
65 [Define to 1 if translation of program messages to the user's native language
67 AC_MSG_CHECKING([whether included gettext is requested])
68 AC_ARG_WITH(included-gettext,
69 AC_HELP_STRING([--with-included-gettext], [Use the GNU gettext library included here]),
70 nls_cv_force_use_gnu_gettext=$withval,
71 nls_cv_force_use_gnu_gettext=no)
72 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
74 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
75 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
76 dnl User does not insist on using GNU NLS library. Figure out what
77 dnl to use. If GNU gettext is available we use this. Else we have
78 dnl to fall back to GNU NLS library.
81 dnl Add a version number to the cache macros.
82 define(gt_cv_func_gnugettext_libc, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libc])
83 define(gt_cv_func_gnugettext_libintl, [gt_cv_func_gnugettext]ifelse([$2], need-ngettext, 2, 1)[_libintl])
85 AC_CHECK_HEADER(libintl.h,
86 [AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
87 [AC_TRY_LINK([#include <libintl.h>
88 extern int _nl_msg_cat_cntr;],
89 [bindtextdomain ("", "");
90 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
91 gt_cv_func_gnugettext_libc=yes,
92 gt_cv_func_gnugettext_libc=no)])
94 if test "$gt_cv_func_gnugettext_libc" != "yes"; then
95 AC_CACHE_CHECK([for GNU gettext in libintl],
96 gt_cv_func_gnugettext_libintl,
98 LIBS="$LIBS -lintl $LIBICONV"
99 AC_TRY_LINK([#include <libintl.h>
100 extern int _nl_msg_cat_cntr;],
101 [bindtextdomain ("", "");
102 return (int) gettext ("")]ifelse([$2], need-ngettext, [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr],
103 gt_cv_func_gnugettext_libintl=yes,
104 gt_cv_func_gnugettext_libintl=no)
105 LIBS="$gt_save_LIBS"])
108 dnl If an already present or preinstalled GNU gettext() is found,
109 dnl use it. But if this macro is used in GNU gettext, and GNU
110 dnl gettext is already preinstalled in libintl, we update this
111 dnl libintl. (Cf. the install rule in intl/Makefile.in.)
112 if test "$gt_cv_func_gnugettext_libc" = "yes" \
113 || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
114 && test "$PACKAGE" != gettext; }; then
115 AC_DEFINE(HAVE_GETTEXT, 1,
116 [Define if the GNU gettext() function is already present or preinstalled.])
118 if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
119 dnl If iconv() is in a separate libiconv library, then anyone
120 dnl linking with libintl{.a,.so} also needs to link with
122 INTLLIBS="-lintl $LIBICONV"
126 LIBS="$LIBS $INTLLIBS"
127 AC_CHECK_FUNCS(dcgettext)
130 dnl Search for GNU msgfmt in the PATH.
131 MUTT_AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
132 [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
133 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
135 dnl Search for GNU xgettext in the PATH.
136 MUTT_AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
137 [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
143 if test "$CATOBJEXT" = "NONE"; then
144 dnl GNU gettext is not found in the C library.
145 dnl Fall back on GNU gettext library.
146 nls_cv_use_gnu_gettext=yes
150 if test "$nls_cv_use_gnu_gettext" = "yes"; then
151 dnl Mark actions used to generate GNU NLS library.
152 INTLOBJS="\$(GETTOBJS)"
153 MUTT_AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
154 [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
155 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
156 MUTT_AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
157 [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
159 BUILD_INCLUDED_LIBINTL=yes
160 USE_INCLUDED_LIBINTL=yes
162 INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
163 LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
166 dnl This could go away some day; the MUTT_PATH_PROG_WITH_TEST already does it.
167 dnl Test whether we really found GNU msgfmt.
168 if test "$GMSGFMT" != ":"; then
169 dnl If it is no GNU msgfmt we define it as : so that the
170 dnl Makefiles still can work.
171 if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
175 [found msgfmt program is not GNU msgfmt; ignore it])
180 dnl This could go away some day; the MUTT_PATH_PROG_WITH_TEST already does it.
181 dnl Test whether we really found GNU xgettext.
182 if test "$XGETTEXT" != ":"; then
183 dnl If it is no GNU xgettext we define it as : so that the
184 dnl Makefiles still can work.
185 if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
189 [found xgettext program is not GNU xgettext; ignore it])
194 dnl We need to process the po/ directory.
198 [for ac_file in $CONFIG_FILES; do
199 # Support "outfile[:infile[:infile...]]"
201 *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
203 # PO directories have a Makefile.in generated from Makefile.in.in.
204 case "$ac_file" in */Makefile.in)
205 # Adjust a relative srcdir.
206 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
207 ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
208 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
209 # In autoconf-2.13 it is called $ac_given_srcdir.
210 # In autoconf-2.50 it is called $srcdir.
211 test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
212 case "$ac_given_srcdir" in
213 .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
214 /*) top_srcdir="$ac_given_srcdir" ;;
215 *) top_srcdir="$ac_dots$ac_given_srcdir" ;;
217 if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
218 rm -f "$ac_dir/POTFILES"
219 test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
220 sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
221 test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
222 sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
229 dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
230 dnl to 'yes' because some of the testsuite requires it.
231 if test "$PACKAGE" = gettext; then
232 BUILD_INCLUDED_LIBINTL=yes
235 dnl intl/plural.c is generated from intl/plural.y. It requires bison,
236 dnl because plural.y uses bison specific features. It requires at least
237 dnl bison-1.26 because earlier versions generate a plural.c that doesn't
239 dnl bison is only needed for the maintainer (who touches plural.y). But in
240 dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
241 dnl the rule in general Makefile. Now, some people carelessly touch the
242 dnl files or have a broken "make" program, hence the plural.c rule will
243 dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
244 dnl present or too old.
245 AC_CHECK_PROGS([INTLBISON], [bison])
246 if test -z "$INTLBISON"; then
249 dnl Found it, now check the version.
250 AC_MSG_CHECKING([version of bison])
251 changequote(<<,>>)dnl
252 ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
253 case $ac_prog_version in
254 '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
255 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
257 ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
258 *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
260 AC_MSG_RESULT([$ac_prog_version])
262 if test $ac_verc_fail = yes; then
266 dnl These rules are solely for the distribution goal. While doing this
267 dnl we only have to keep exactly one list of the available catalogs
269 for lang in $ALL_LINGUAS; do
270 GMOFILES="$GMOFILES $lang.gmo"
271 POFILES="$POFILES $lang.po"
274 dnl Make all variables we use known to autoconf.
275 AC_SUBST(BUILD_INCLUDED_LIBINTL)
276 AC_SUBST(USE_INCLUDED_LIBINTL)
285 dnl For backward compatibility. Some configure.ins may be using this.
289 dnl For backward compatibility. Some Makefiles may be using this.
291 AC_SUBST(DATADIRNAME)
293 dnl For backward compatibility. Some Makefiles may be using this.
297 dnl For backward compatibility. Some Makefiles may be using this.
302 dnl Usage: Just like MUTT_AM_WITH_NLS, which see.
303 AC_DEFUN([MUTT_AM_GNU_GETTEXT],
304 [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
305 AC_REQUIRE([AC_PROG_CC])dnl
306 AC_REQUIRE([AC_CANONICAL_HOST])dnl
307 AC_REQUIRE([AC_PROG_RANLIB])dnl
308 AC_REQUIRE([AC_ISC_POSIX])dnl
309 AC_REQUIRE([AC_HEADER_STDC])dnl
310 AC_REQUIRE([AC_C_CONST])dnl
311 AC_REQUIRE([AC_C_INLINE])dnl
312 AC_REQUIRE([AC_TYPE_OFF_T])dnl
313 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
314 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
315 AC_REQUIRE([AC_FUNC_MMAP])dnl
316 AC_REQUIRE([MUTT_jm_GLIBC21])dnl
318 AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
319 stdlib.h string.h unistd.h sys/param.h])
320 AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
321 getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
322 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
325 MUTT_AM_LANGINFO_CODESET
327 MUTT_AM_WITH_NLS([$1],[$2],[$3])
329 if test "x$CATOBJEXT" != "x"; then
330 if test "x$ALL_LINGUAS" = "x"; then
333 AC_MSG_CHECKING(for catalogs to be installed)
335 for presentlang in $ALL_LINGUAS; do
337 for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
338 # Use the presentlang catalog if desiredlang is
339 # a. equal to presentlang, or
340 # b. a variant of presentlang (because in this case,
341 # presentlang can be used as a fallback for messages
342 # which are not translated in the desiredlang catalog).
343 case "$desiredlang" in
344 "$presentlang"*) useit=yes;;
347 if test $useit = yes; then
348 NEW_LINGUAS="$NEW_LINGUAS $presentlang"
352 AC_MSG_RESULT($LINGUAS)
355 dnl Construct list of names of catalog files to be constructed.
356 if test -n "$LINGUAS"; then
357 for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
361 dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
362 dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
363 dnl Try to locate is.
365 if test -n "$ac_aux_dir"; then
366 MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
368 if test -z "$MKINSTALLDIRS"; then
369 MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
371 AC_SUBST(MKINSTALLDIRS)
373 dnl Enable libtool support if the surrounding package wishes it.
374 INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
375 AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)