jpayne@68: # gettext.m4 serial 78 (gettext-0.22.4) jpayne@68: dnl Copyright (C) 1995-2014, 2016, 2018-2023 Free Software Foundation, Inc. jpayne@68: dnl This file is free software; the Free Software Foundation jpayne@68: dnl gives unlimited permission to copy and/or distribute it, jpayne@68: dnl with or without modifications, as long as this notice is preserved. jpayne@68: dnl jpayne@68: dnl This file can be used in projects which are not available under jpayne@68: dnl the GNU General Public License or the GNU Lesser General Public jpayne@68: dnl License but which still want to provide support for the GNU gettext jpayne@68: dnl functionality. jpayne@68: dnl Please note that the actual code of the GNU gettext library is covered jpayne@68: dnl by the GNU Lesser General Public License, and the rest of the GNU jpayne@68: dnl gettext package is covered by the GNU General Public License. jpayne@68: dnl They are *not* in the public domain. jpayne@68: jpayne@68: dnl Authors: jpayne@68: dnl Ulrich Drepper , 1995-2000. jpayne@68: dnl Bruno Haible , 2000-2006, 2008-2010. jpayne@68: jpayne@68: dnl Macro to add for using GNU gettext. jpayne@68: jpayne@68: dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). jpayne@68: dnl INTLSYMBOL must be one of 'external', 'use-libtool', 'here'. jpayne@68: dnl INTLSYMBOL should be 'external' for packages other than GNU gettext. jpayne@68: dnl It should be 'use-libtool' for the packages 'gettext-runtime' and jpayne@68: dnl 'gettext-tools'. jpayne@68: dnl It should be 'here' for the package 'gettext-runtime/intl'. jpayne@68: dnl If INTLSYMBOL is 'here', then a libtool library jpayne@68: dnl $(top_builddir)/libintl.la will be created (shared and/or static, jpayne@68: dnl depending on --{enable,disable}-{shared,static} and on the presence of jpayne@68: dnl AM-DISABLE-SHARED). jpayne@68: dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext jpayne@68: dnl implementations (in libc or libintl) without the ngettext() function jpayne@68: dnl will be ignored. If NEEDSYMBOL is specified and is jpayne@68: dnl 'need-formatstring-macros', then GNU gettext implementations that don't jpayne@68: dnl support the ISO C 99 formatstring macros will be ignored. jpayne@68: dnl INTLDIR is used to find the intl libraries. If empty, jpayne@68: dnl the value '$(top_builddir)/intl/' is used. jpayne@68: dnl jpayne@68: dnl The result of the configuration is one of three cases: jpayne@68: dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled jpayne@68: dnl and used. jpayne@68: dnl Catalog format: GNU --> install in $(datadir) jpayne@68: dnl Catalog extension: .mo after installation, .gmo in source tree jpayne@68: dnl 2) GNU gettext has been found in the system's C library. jpayne@68: dnl Catalog format: GNU --> install in $(datadir) jpayne@68: dnl Catalog extension: .mo after installation, .gmo in source tree jpayne@68: dnl 3) No internationalization, always use English msgid. jpayne@68: dnl Catalog format: none jpayne@68: dnl Catalog extension: none jpayne@68: dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. jpayne@68: dnl The use of .gmo is historical (it was needed to avoid overwriting the jpayne@68: dnl GNU format catalogs when building on a platform with an X/Open gettext), jpayne@68: dnl but we keep it in order not to force irrelevant filename changes on the jpayne@68: dnl maintainers. jpayne@68: dnl jpayne@68: AC_DEFUN([AM_GNU_GETTEXT], jpayne@68: [ jpayne@68: dnl Argument checking. jpayne@68: m4_if([$1], [], , [m4_if([$1], [external], , [m4_if([$1], [use-libtool], , [m4_if([$1], [here], , jpayne@68: [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT jpayne@68: ])])])])]) jpayne@68: m4_if(m4_if([$1], [], [old])[]m4_if([$1], [no-libtool], [old]), [old], jpayne@68: [errprint([ERROR: Use of AM_GNU_GETTEXT without [external] argument is no longer supported. jpayne@68: ])]) jpayne@68: m4_if([$2], [], , [m4_if([$2], [need-ngettext], , [m4_if([$2], [need-formatstring-macros], , jpayne@68: [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT jpayne@68: ])])])]) jpayne@68: define([gt_building_libintl_in_same_build_tree], jpayne@68: m4_if([$1], [use-libtool], [yes], [m4_if([$1], [here], [yes], [no])])) jpayne@68: gt_NEEDS_INIT jpayne@68: AM_GNU_GETTEXT_NEED([$2]) jpayne@68: jpayne@68: AC_REQUIRE([AM_PO_SUBDIRS])dnl jpayne@68: jpayne@68: dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. jpayne@68: AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) jpayne@68: AC_REQUIRE([AC_LIB_RPATH]) jpayne@68: jpayne@68: dnl Sometimes libintl requires libiconv, so first search for libiconv. jpayne@68: dnl Ideally we would do this search only after the jpayne@68: dnl if test "$USE_NLS" = "yes"; then jpayne@68: dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then jpayne@68: dnl tests. But if configure.ac invokes AM_ICONV after AM_GNU_GETTEXT jpayne@68: dnl the configure script would need to contain the same shell code jpayne@68: dnl again, outside any 'if'. There are two solutions: jpayne@68: dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. jpayne@68: dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. jpayne@68: dnl Since AC_PROVIDE_IFELSE is not documented, we avoid it. jpayne@68: m4_if(gt_building_libintl_in_same_build_tree, yes, , [ jpayne@68: AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) jpayne@68: ]) jpayne@68: jpayne@68: dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation. jpayne@68: gt_INTL_MACOSX jpayne@68: jpayne@68: dnl Set USE_NLS. jpayne@68: AC_REQUIRE([AM_NLS]) jpayne@68: jpayne@68: m4_if(gt_building_libintl_in_same_build_tree, yes, [ jpayne@68: USE_INCLUDED_LIBINTL=no jpayne@68: ]) jpayne@68: LIBINTL= jpayne@68: LTLIBINTL= jpayne@68: POSUB= jpayne@68: jpayne@68: dnl Add a version number to the cache macros. jpayne@68: case " $gt_needs " in jpayne@68: *" need-formatstring-macros "*) gt_api_version=3 ;; jpayne@68: *" need-ngettext "*) gt_api_version=2 ;; jpayne@68: *) gt_api_version=1 ;; jpayne@68: esac jpayne@68: gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" jpayne@68: gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" jpayne@68: jpayne@68: dnl If we use NLS figure out what method jpayne@68: if test "$USE_NLS" = "yes"; then jpayne@68: gt_use_preinstalled_gnugettext=no jpayne@68: m4_if(gt_building_libintl_in_same_build_tree, yes, [ jpayne@68: AC_MSG_CHECKING([whether included gettext is requested]) jpayne@68: AC_ARG_WITH([included-gettext], jpayne@68: [ --with-included-gettext use the GNU gettext library included here], jpayne@68: nls_cv_force_use_gnu_gettext=$withval, jpayne@68: nls_cv_force_use_gnu_gettext=no) jpayne@68: AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) jpayne@68: jpayne@68: nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" jpayne@68: if test "$nls_cv_force_use_gnu_gettext" != "yes"; then jpayne@68: ]) jpayne@68: dnl User does not insist on using GNU NLS library. Figure out what jpayne@68: dnl to use. If GNU gettext is available we use this. Else we have jpayne@68: dnl to fall back to GNU NLS library. jpayne@68: jpayne@68: if test $gt_api_version -ge 3; then jpayne@68: gt_revision_test_code=' jpayne@68: #ifndef __GNU_GETTEXT_SUPPORTED_REVISION jpayne@68: #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) jpayne@68: #endif jpayne@68: changequote(,)dnl jpayne@68: typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; jpayne@68: changequote([,])dnl jpayne@68: ' jpayne@68: else jpayne@68: gt_revision_test_code= jpayne@68: fi jpayne@68: if test $gt_api_version -ge 2; then jpayne@68: gt_expression_test_code=' + * ngettext ("", "", 0)' jpayne@68: else jpayne@68: gt_expression_test_code= jpayne@68: fi jpayne@68: jpayne@68: AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], jpayne@68: [AC_LINK_IFELSE( jpayne@68: [AC_LANG_PROGRAM( jpayne@68: [[ jpayne@68: #include jpayne@68: #ifndef __GNU_GETTEXT_SUPPORTED_REVISION jpayne@68: extern int _nl_msg_cat_cntr; jpayne@68: extern int *_nl_domain_bindings; jpayne@68: #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) jpayne@68: #else jpayne@68: #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 jpayne@68: #endif jpayne@68: $gt_revision_test_code jpayne@68: ]], jpayne@68: [[ jpayne@68: bindtextdomain ("", ""); jpayne@68: return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION jpayne@68: ]])], jpayne@68: [eval "$gt_func_gnugettext_libc=yes"], jpayne@68: [eval "$gt_func_gnugettext_libc=no"])]) jpayne@68: jpayne@68: if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then jpayne@68: dnl Sometimes libintl requires libiconv, so first search for libiconv. jpayne@68: m4_if(gt_building_libintl_in_same_build_tree, yes, , [ jpayne@68: AM_ICONV_LINK jpayne@68: ]) jpayne@68: dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL jpayne@68: dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) jpayne@68: dnl because that would add "-liconv" to LIBINTL and LTLIBINTL jpayne@68: dnl even if libiconv doesn't exist. jpayne@68: AC_LIB_LINKFLAGS_BODY([intl]) jpayne@68: AC_CACHE_CHECK([for GNU gettext in libintl], jpayne@68: [$gt_func_gnugettext_libintl], jpayne@68: [gt_save_CPPFLAGS="$CPPFLAGS" jpayne@68: CPPFLAGS="$CPPFLAGS $INCINTL" jpayne@68: gt_save_LIBS="$LIBS" jpayne@68: LIBS="$LIBS $LIBINTL" jpayne@68: dnl Now see whether libintl exists and does not depend on libiconv. jpayne@68: AC_LINK_IFELSE( jpayne@68: [AC_LANG_PROGRAM( jpayne@68: [[ jpayne@68: #include jpayne@68: #ifndef __GNU_GETTEXT_SUPPORTED_REVISION jpayne@68: extern int _nl_msg_cat_cntr; jpayne@68: extern jpayne@68: #ifdef __cplusplus jpayne@68: "C" jpayne@68: #endif jpayne@68: const char *_nl_expand_alias (const char *); jpayne@68: #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) jpayne@68: #else jpayne@68: #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 jpayne@68: #endif jpayne@68: $gt_revision_test_code jpayne@68: ]], jpayne@68: [[ jpayne@68: bindtextdomain ("", ""); jpayne@68: return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION jpayne@68: ]])], jpayne@68: [eval "$gt_func_gnugettext_libintl=yes"], jpayne@68: [eval "$gt_func_gnugettext_libintl=no"]) jpayne@68: dnl Now see whether libintl exists and depends on libiconv or other jpayne@68: dnl OS dependent libraries, specifically on macOS and AIX. jpayne@68: gt_LIBINTL_EXTRA="$INTL_MACOSX_LIBS" jpayne@68: AC_REQUIRE([AC_CANONICAL_HOST]) jpayne@68: case "$host_os" in jpayne@68: aix*) gt_LIBINTL_EXTRA="-lpthread" ;; jpayne@68: esac jpayne@68: if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } \ jpayne@68: && { test -n "$LIBICONV" || test -n "$gt_LIBINTL_EXTRA"; }; then jpayne@68: LIBS="$LIBS $LIBICONV $gt_LIBINTL_EXTRA" jpayne@68: AC_LINK_IFELSE( jpayne@68: [AC_LANG_PROGRAM( jpayne@68: [[ jpayne@68: #include jpayne@68: #ifndef __GNU_GETTEXT_SUPPORTED_REVISION jpayne@68: extern int _nl_msg_cat_cntr; jpayne@68: extern jpayne@68: #ifdef __cplusplus jpayne@68: "C" jpayne@68: #endif jpayne@68: const char *_nl_expand_alias (const char *); jpayne@68: #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias ("")) jpayne@68: #else jpayne@68: #define __GNU_GETTEXT_SYMBOL_EXPRESSION 0 jpayne@68: #endif jpayne@68: $gt_revision_test_code jpayne@68: ]], jpayne@68: [[ jpayne@68: bindtextdomain ("", ""); jpayne@68: return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION jpayne@68: ]])], jpayne@68: [LIBINTL="$LIBINTL $LIBICONV $gt_LIBINTL_EXTRA" jpayne@68: LTLIBINTL="$LTLIBINTL $LTLIBICONV $gt_LIBINTL_EXTRA" jpayne@68: eval "$gt_func_gnugettext_libintl=yes" jpayne@68: ]) jpayne@68: fi jpayne@68: CPPFLAGS="$gt_save_CPPFLAGS" jpayne@68: LIBS="$gt_save_LIBS"]) jpayne@68: fi jpayne@68: jpayne@68: dnl If an already present or preinstalled GNU gettext() is found, jpayne@68: dnl use it. But if this macro is used in GNU gettext, and GNU jpayne@68: dnl gettext is already preinstalled in libintl, we update this jpayne@68: dnl libintl. (Cf. the install rule in intl/Makefile.in.) jpayne@68: if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ jpayne@68: || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ jpayne@68: && test "$PACKAGE" != gettext-runtime \ jpayne@68: && test "$PACKAGE" != gettext-tools \ jpayne@68: && test "$PACKAGE" != libintl; }; then jpayne@68: gt_use_preinstalled_gnugettext=yes jpayne@68: else jpayne@68: dnl Reset the values set by searching for libintl. jpayne@68: LIBINTL= jpayne@68: LTLIBINTL= jpayne@68: INCINTL= jpayne@68: fi jpayne@68: jpayne@68: m4_if(gt_building_libintl_in_same_build_tree, yes, [ jpayne@68: if test "$gt_use_preinstalled_gnugettext" != "yes"; then jpayne@68: dnl GNU gettext is not found in the C library. jpayne@68: dnl Fall back on included GNU gettext library. jpayne@68: nls_cv_use_gnu_gettext=yes jpayne@68: fi jpayne@68: fi jpayne@68: jpayne@68: if test "$nls_cv_use_gnu_gettext" = "yes"; then jpayne@68: dnl Mark actions used to generate GNU NLS library. jpayne@68: USE_INCLUDED_LIBINTL=yes jpayne@68: LIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LIBICONV $LIBTHREAD" jpayne@68: LTLIBINTL="m4_if([$3],[],\${top_builddir}/intl,[$3])/libintl.la $LTLIBICONV $LTLIBTHREAD" jpayne@68: LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` jpayne@68: fi jpayne@68: jpayne@68: CATOBJEXT= jpayne@68: if test "$gt_use_preinstalled_gnugettext" = "yes" \ jpayne@68: || test "$nls_cv_use_gnu_gettext" = "yes"; then jpayne@68: dnl Mark actions to use GNU gettext tools. jpayne@68: CATOBJEXT=.gmo jpayne@68: fi jpayne@68: ]) jpayne@68: jpayne@68: if test -n "$INTL_MACOSX_LIBS"; then jpayne@68: if test "$gt_use_preinstalled_gnugettext" = "yes" \ jpayne@68: || test "$nls_cv_use_gnu_gettext" = "yes"; then jpayne@68: dnl Some extra flags are needed during linking. jpayne@68: LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" jpayne@68: LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" jpayne@68: fi jpayne@68: fi jpayne@68: jpayne@68: if test "$gt_use_preinstalled_gnugettext" = "yes" \ jpayne@68: || test "$nls_cv_use_gnu_gettext" = "yes"; then jpayne@68: AC_DEFINE([ENABLE_NLS], [1], jpayne@68: [Define to 1 if translation of program messages to the user's native language jpayne@68: is requested.]) jpayne@68: else jpayne@68: USE_NLS=no jpayne@68: fi jpayne@68: fi jpayne@68: jpayne@68: AC_MSG_CHECKING([whether to use NLS]) jpayne@68: AC_MSG_RESULT([$USE_NLS]) jpayne@68: if test "$USE_NLS" = "yes"; then jpayne@68: AC_MSG_CHECKING([where the gettext function comes from]) jpayne@68: if test "$gt_use_preinstalled_gnugettext" = "yes"; then jpayne@68: if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then jpayne@68: gt_source="external libintl" jpayne@68: else jpayne@68: gt_source="libc" jpayne@68: fi jpayne@68: else jpayne@68: gt_source="included intl directory" jpayne@68: fi jpayne@68: AC_MSG_RESULT([$gt_source]) jpayne@68: fi jpayne@68: jpayne@68: if test "$USE_NLS" = "yes"; then jpayne@68: jpayne@68: if test "$gt_use_preinstalled_gnugettext" = "yes"; then jpayne@68: if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then jpayne@68: AC_MSG_CHECKING([how to link with libintl]) jpayne@68: AC_MSG_RESULT([$LIBINTL]) jpayne@68: AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) jpayne@68: fi jpayne@68: jpayne@68: dnl For backward compatibility. Some packages may be using this. jpayne@68: AC_DEFINE([HAVE_GETTEXT], [1], jpayne@68: [Define if the GNU gettext() function is already present or preinstalled.]) jpayne@68: AC_DEFINE([HAVE_DCGETTEXT], [1], jpayne@68: [Define if the GNU dcgettext() function is already present or preinstalled.]) jpayne@68: fi jpayne@68: jpayne@68: dnl We need to process the po/ directory. jpayne@68: POSUB=po jpayne@68: fi jpayne@68: jpayne@68: m4_if(gt_building_libintl_in_same_build_tree, yes, [ jpayne@68: dnl Make all variables we use known to autoconf. jpayne@68: AC_SUBST([USE_INCLUDED_LIBINTL]) jpayne@68: AC_SUBST([CATOBJEXT]) jpayne@68: ]) jpayne@68: jpayne@68: m4_if(gt_building_libintl_in_same_build_tree, yes, [], [ jpayne@68: dnl For backward compatibility. Some Makefiles may be using this. jpayne@68: INTLLIBS="$LIBINTL" jpayne@68: AC_SUBST([INTLLIBS]) jpayne@68: ]) jpayne@68: jpayne@68: dnl Make all documented variables known to autoconf. jpayne@68: AC_SUBST([LIBINTL]) jpayne@68: AC_SUBST([LTLIBINTL]) jpayne@68: AC_SUBST([POSUB]) jpayne@68: jpayne@68: dnl Define localedir_c and localedir_c_make. jpayne@68: dnl Find the final value of localedir. jpayne@68: gt_save_prefix="${prefix}" jpayne@68: gt_save_datarootdir="${datarootdir}" jpayne@68: gt_save_localedir="${localedir}" jpayne@68: dnl Unfortunately, prefix gets only finally determined at the end of jpayne@68: dnl configure. jpayne@68: if test "X$prefix" = "XNONE"; then jpayne@68: prefix="$ac_default_prefix" jpayne@68: fi jpayne@68: eval datarootdir="$datarootdir" jpayne@68: eval localedir="$localedir" jpayne@68: gl_BUILD_TO_HOST([localedir]) jpayne@68: localedir="${gt_save_localedir}" jpayne@68: datarootdir="${gt_save_datarootdir}" jpayne@68: prefix="${gt_save_prefix}" jpayne@68: ]) jpayne@68: jpayne@68: jpayne@68: dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. jpayne@68: m4_define([gt_NEEDS_INIT], jpayne@68: [ jpayne@68: m4_divert_text([DEFAULTS], [gt_needs=]) jpayne@68: m4_define([gt_NEEDS_INIT], []) jpayne@68: ]) jpayne@68: jpayne@68: jpayne@68: dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) jpayne@68: AC_DEFUN([AM_GNU_GETTEXT_NEED], jpayne@68: [ jpayne@68: m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) jpayne@68: ]) jpayne@68: jpayne@68: jpayne@68: dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) jpayne@68: AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) jpayne@68: jpayne@68: jpayne@68: dnl Usage: AM_GNU_GETTEXT_REQUIRE_VERSION([gettext-version]) jpayne@68: AC_DEFUN([AM_GNU_GETTEXT_REQUIRE_VERSION], [])