# gettext.m4
-# serial 81 (gettext-0.23)
-dnl Copyright (C) 1995-2014, 2016, 2018-2026 Free Software Foundation, Inc.
+# serial 86 (gettext-1.0)
+dnl Copyright (C) 1995-2026 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl gettext package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
-dnl Authors:
-dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
-dnl Bruno Haible <bruno@clisp.org>, 2000-2024.
+dnl From Ulrich Drepper, Bruno Haible, Daiku Ueno.
dnl Macro to add for using GNU gettext.
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
])
- dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation.
+ dnl On Mac OS X, libintl requires linking with CoreFoundation.
gt_INTL_MACOSX
+ dnl On native Windows, libintl requires linking with advapi32,
+ dnl because langprefs.c (_nl_language_preferences_win32_95) uses functions
+ dnl from advapi32.dll.
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ INTL_WINDOWS_LIBS=
+ case "$host_os" in
+ mingw* | windows*) INTL_WINDOWS_LIBS='-ladvapi32' ;;
+ esac
+
dnl Set USE_NLS.
AC_REQUIRE([AM_NLS])
if test "$USE_NLS" = "yes"; then
gt_use_preinstalled_gnugettext=no
m4_if(gt_building_libintl_in_same_build_tree, yes, [
- AC_MSG_CHECKING([whether included gettext is requested])
- AC_ARG_WITH([included-gettext],
- [ --with-included-gettext use the GNU gettext library included here],
- nls_cv_force_use_gnu_gettext=$withval,
- nls_cv_force_use_gnu_gettext=no)
- AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
-
- nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
- if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
+ AC_MSG_CHECKING([whether included libintl is requested])
+ AC_ARG_WITH([included-libintl],
+ [ --with-included-libintl use the GNU libintl library included here],
+ gt_cv_force_use_gnu_libintl=$withval,
+ gt_cv_force_use_gnu_libintl=no)
+ AC_MSG_RESULT([$gt_cv_force_use_gnu_libintl])
+
+ gt_cv_use_gnu_libintl="$gt_cv_force_use_gnu_libintl"
+ if test "$gt_cv_force_use_gnu_libintl" != "yes"; then
])
dnl User does not insist on using GNU NLS library. Figure out what
dnl to use. If GNU gettext is available we use this. Else we have
gt_expression_test_code=
fi
+ dnl In the test code below:
+ dnl * We test for the presence of _nl_msg_cat_cntr because GNU libc and
+ dnl libintl define this variable, whereas Solaris 10 libc/libintl
+ dnl (which we don't want to use, as it does not support GNU .mo files)
+ dnl does not define it.
+ dnl * We don't test for _nl_msg_cat_cntr on MSVC, because the use of a
+ dnl variable under MSVC depends on whether it is exported by a shared
+ dnl library or a static library: If libintl is a shared library, we
+ dnl would have to declare it with __declspec(dllimport), whereas if it
+ dnl is a static library, we would have to declare it without such a
+ dnl __declspec. But libintl comes with just one header file,
+ dnl <libintl.h>, that does not declare _nl_msg_cat_cntr and that does
+ dnl not tell us whether the library was built shared or static.
+ dnl * We test for the presence of _nl_domain_bindings because GNU libc
+ dnl defines this variable, whereas NetBSD libc (which we don't want to
+ dnl use, as it was broken at least in 2002) does not define it.
+ dnl * We test for the presence of _nl_expand_alias because GNU libintl
+ dnl defines this function, whereas NetBSD libintl (which we don't want
+ dnl to use, as it was broken at least in 2002) does not define it.
+
AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <libintl.h>
#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+#if defined _MSC_VER
+#define _nl_msg_cat_cntr 0
+#else
extern int _nl_msg_cat_cntr;
+#endif
extern int *_nl_domain_bindings;
#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings)
#else
bindtextdomain ("", "");
return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION
]])],
- [eval "$gt_func_gnugettext_libc=yes"],
+ [dnl Solaris 11.[0-3] doesn't strip the CODESET part from the locale name,
+ dnl when looking for a message catalog. E.g. when the locale is fr_FR.UTF-8,
+ dnl on Solaris 11.[0-3] it looks for
+ dnl <LOCALEDIR>/fr_FR.UTF-8/LC_MESSAGES/<domain>.mo
+ dnl <LOCALEDIR>/fr.UTF-8/LC_MESSAGES/<domain>.mo
+ dnl Similarly, on Solaris 11 OpenIndiana and Solaris 11 OmniOS it looks only for
+ dnl <LOCALEDIR>/fr_FR.UTF-8/LC_MESSAGES/<domain>.mo
+ dnl Reported at <https://www.illumos.org/issues/13423>.
+ dnl On Solaris 11.4 this is fixed: it looks for
+ dnl <LOCALEDIR>/fr_FR.UTF-8/LC_MESSAGES/<domain>.mo
+ dnl <LOCALEDIR>/fr.UTF-8/LC_MESSAGES/<domain>.mo
+ dnl <LOCALEDIR>/fr_FR/LC_MESSAGES/<domain>.mo
+ dnl <LOCALEDIR>/fr/LC_MESSAGES/<domain>.mo
+ if test "`uname -sr`" = 'SunOS 5.11'; then
+ case `uname -v` in
+ 11.4 | 11.4.*) eval "$gt_func_gnugettext_libc=yes" ;;
+ *) eval "$gt_func_gnugettext_libc=no" ;;
+ esac
+ else
+ eval "$gt_func_gnugettext_libc=yes"
+ fi
+ ],
[eval "$gt_func_gnugettext_libc=no"])])
if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
[[
#include <libintl.h>
#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+#if defined _MSC_VER
+#define _nl_msg_cat_cntr 0
+#else
extern int _nl_msg_cat_cntr;
+#endif
extern
#ifdef __cplusplus
"C"
[eval "$gt_func_gnugettext_libintl=yes"],
[eval "$gt_func_gnugettext_libintl=no"])
dnl Now see whether libintl exists and depends on libiconv or other
- dnl OS dependent libraries, specifically on macOS and AIX.
- gt_LIBINTL_EXTRA="$INTL_MACOSX_LIBS"
- AC_REQUIRE([AC_CANONICAL_HOST])
+ dnl OS dependent libraries, specifically on macOS, AIX, and native
+ dnl Windows.
+ gt_LIBINTL_EXTRA=
case "$host_os" in
- aix*) gt_LIBINTL_EXTRA="-lpthread" ;;
+ darwin*) gt_LIBINTL_EXTRA="$INTL_MACOSX_LIBS" ;;
+ aix*) gt_LIBINTL_EXTRA="-lpthread" ;;
+ mingw* | windows*) gt_LIBINTL_EXTRA="$INTL_WINDOWS_LIBS" ;;
esac
if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } \
&& { test -n "$LIBICONV" || test -n "$gt_LIBINTL_EXTRA"; }; then
[[
#include <libintl.h>
#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+#if defined _MSC_VER
+#define _nl_msg_cat_cntr 0
+#else
extern int _nl_msg_cat_cntr;
+#endif
extern
#ifdef __cplusplus
"C"
if test "$gt_use_preinstalled_gnugettext" != "yes"; then
dnl GNU gettext is not found in the C library.
dnl Fall back on included GNU gettext library.
- nls_cv_use_gnu_gettext=yes
+ gt_cv_use_gnu_libintl=yes
fi
fi
- if test "$nls_cv_use_gnu_gettext" = "yes"; then
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ if test "$gt_cv_use_gnu_libintl" = "yes" \
+ || case "$host_os" in cygwin*) true;; *) false;; esac; then
+ dnl GNU gettext is not found in the C library or is,
+ dnl like on Cygwin, a component of the C library.
dnl Mark actions used to generate GNU NLS library.
USE_INCLUDED_LIBINTL=yes
LIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD"
CATOBJEXT=
if test "$gt_use_preinstalled_gnugettext" = "yes" \
- || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ || test "$gt_cv_use_gnu_libintl" = "yes"; then
dnl Mark actions to use GNU gettext tools.
CATOBJEXT=.gmo
fi
if test -n "$INTL_MACOSX_LIBS"; then
if test "$gt_use_preinstalled_gnugettext" = "yes" \
- || test "$nls_cv_use_gnu_gettext" = "yes"; then
- dnl Some extra flags are needed during linking.
+ || test "$gt_cv_use_gnu_libintl" = "yes"; then
+ dnl Some extra options are needed during linking.
LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
fi
fi
+ if test -n "$INTL_WINDOWS_LIBS"; then
+ if test "$gt_use_preinstalled_gnugettext" = "yes" \
+ || test "$gt_cv_use_gnu_libintl" = "yes"; then
+ dnl Some extra options are needed during linking.
+ LIBINTL="$LIBINTL $INTL_WINDOWS_LIBS"
+ LTLIBINTL="$LTLIBINTL $INTL_WINDOWS_LIBS"
+ fi
+ fi
+
if test "$gt_use_preinstalled_gnugettext" = "yes" \
- || test "$nls_cv_use_gnu_gettext" = "yes"; then
+ || test "$gt_cv_use_gnu_libintl" = "yes"; then
AC_DEFINE([ENABLE_NLS], [1],
[Define to 1 if translation of program messages to the user's native language
is requested.])