]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New macro AM_GNU_GETTEXT_NEED.
authorBruno Haible <bruno@clisp.org>
Mon, 2 Oct 2006 12:24:24 +0000 (12:24 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:02 +0000 (12:14 +0200)
gettext-runtime/m4/ChangeLog
gettext-runtime/m4/gettext.m4
gettext-tools/doc/ChangeLog
gettext-tools/doc/gettext.texi

index e82aee91bf02892f56c4c1629b97833d6c8adbd7..d9bf3eae87ad7aa97f1092371cec87acd8ec06b9 100644 (file)
@@ -1,3 +1,10 @@
+2006-10-01  Bruno Haible  <bruno@clisp.org>
+
+       * gettext.m4 (gt_NEEDS_INIT, AM_GNU_GETTEXT_NEED): New macros.
+       (AM_GNU_GETTEXT): Invoke them. Convert gt_api_version,
+       gt_cv_func_gnugettext_libc, gt_cv_func_gnugettext_libintl from
+       m4-time variables to sh-time variables.
+
 2006-10-01  Bruno Haible  <bruno@clisp.org>
 
        * intldir.m4: New file.
index 17ab4185f9ebe3ae70df3822feb42162a09dc8a9..c15c093e114c75601eb1fdf47d478d73d73c7ba5 100644 (file)
@@ -1,4 +1,4 @@
-# gettext.m4 serial 56 (gettext-0.15.1)
+# gettext.m4 serial 57 (gettext-0.15.1)
 dnl Copyright (C) 1995-2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -68,6 +68,8 @@ AC_DEFUN([AM_GNU_GETTEXT],
       ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
       [yes]))
   define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
+  gt_NEEDS_INIT
+  AM_GNU_GETTEXT_NEED([$2])
 
   AC_REQUIRE([AM_PO_SUBDIRS])dnl
   ifelse(gt_included_intl, yes, [
@@ -81,7 +83,7 @@ AC_DEFUN([AM_GNU_GETTEXT],
   dnl Sometimes libintl requires libiconv, so first search for libiconv.
   dnl Ideally we would do this search only after the
   dnl      if test "$USE_NLS" = "yes"; then
-  dnl        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
+  dnl        if eval test "\$$gt_func_gnugettext_libc" != "yes"; then
   dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
   dnl the configure script would need to contain the same shell code
   dnl again, outside any 'if'. There are two solutions:
@@ -107,6 +109,15 @@ AC_DEFUN([AM_GNU_GETTEXT],
   LTLIBINTL=
   POSUB=
 
+  dnl Add a version number to the cache macros.
+  case " $gt_needs " in
+    *" need-formatstring-macros "*) gt_api_version=3 ;;
+    *" need-ngettext "*) gt_api_version=2 ;;
+    *) gt_api_version=1 ;;
+  esac
+  gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
+  gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
+
   dnl If we use NLS figure out what method
   if test "$USE_NLS" = "yes"; then
     gt_use_preinstalled_gnugettext=no
@@ -125,26 +136,33 @@ AC_DEFUN([AM_GNU_GETTEXT],
         dnl to use.  If GNU gettext is available we use this.  Else we have
         dnl to fall back to GNU NLS library.
 
-        dnl Add a version number to the cache macros.
-        define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
-        define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
-        define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
-
-        AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
-         [AC_TRY_LINK([#include <libintl.h>
-]ifelse([$2], [need-formatstring-macros],
-[[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
+        if test $gt_api_version -ge 3; then
+          gt_revision_test_code='[[
+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
 #endif
 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-]], [])[extern int _nl_msg_cat_cntr;
+]]'
+        else
+          gt_revision_test_code=
+        fi
+        if test $gt_api_version -ge 2; then
+          gt_expression_test_code=' + * ngettext ("", "", 0)'
+        else
+          gt_expression_test_code=
+        fi
+
+        AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
+         [AC_TRY_LINK([#include <libintl.h>
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
 extern int *_nl_domain_bindings;],
             [bindtextdomain ("", "");
-return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
-            gt_cv_func_gnugettext_libc=yes,
-            gt_cv_func_gnugettext_libc=no)])
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings],
+            [eval "$gt_func_gnugettext_libc=yes"],
+            [eval "$gt_func_gnugettext_libc=no"])])
 
-        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
+        if eval test "\$$gt_func_gnugettext_libc" != "yes"; then
           dnl Sometimes libintl requires libiconv, so first search for libiconv.
           ifelse(gt_included_intl, yes, , [
             AM_ICONV_LINK
@@ -155,48 +173,40 @@ return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)],
           dnl even if libiconv doesn't exist.
           AC_LIB_LINKFLAGS_BODY([intl])
           AC_CACHE_CHECK([for GNU gettext in libintl],
-            gt_cv_func_gnugettext_libintl,
+            [$gt_func_gnugettext_libintl],
            [gt_save_CPPFLAGS="$CPPFLAGS"
             CPPFLAGS="$CPPFLAGS $INCINTL"
             gt_save_LIBS="$LIBS"
             LIBS="$LIBS $LIBINTL"
             dnl Now see whether libintl exists and does not depend on libiconv.
             AC_TRY_LINK([#include <libintl.h>
-]ifelse([$2], [need-formatstring-macros],
-[[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
-#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
-#endif
-typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-]], [])[extern int _nl_msg_cat_cntr;
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
 extern
 #ifdef __cplusplus
 "C"
 #endif
 const char *_nl_expand_alias (const char *);],
               [bindtextdomain ("", "");
-return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
-              gt_cv_func_gnugettext_libintl=yes,
-              gt_cv_func_gnugettext_libintl=no)
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
+              [eval "$gt_func_gnugettext_libintl=yes"],
+              [eval "$gt_func_gnugettext_libintl=no"])
             dnl Now see whether libintl exists and depends on libiconv.
-            if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
+            if eval test "\$$gt_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
               LIBS="$LIBS $LIBICONV"
               AC_TRY_LINK([#include <libintl.h>
-]ifelse([$2], [need-formatstring-macros],
-[[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
-#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
-#endif
-typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
-]], [])[extern int _nl_msg_cat_cntr;
+$gt_revision_test_code
+extern int _nl_msg_cat_cntr;
 extern
 #ifdef __cplusplus
 "C"
 #endif
 const char *_nl_expand_alias (const char *);],
                 [bindtextdomain ("", "");
-return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
+return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
                [LIBINTL="$LIBINTL $LIBICONV"
                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
-                gt_cv_func_gnugettext_libintl=yes
+                eval "$gt_func_gnugettext_libintl=yes"
                ])
             fi
             CPPFLAGS="$gt_save_CPPFLAGS"
@@ -207,8 +217,8 @@ return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)],
         dnl use it.  But if this macro is used in GNU gettext, and GNU
         dnl gettext is already preinstalled in libintl, we update this
         dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
-        if test "$gt_cv_func_gnugettext_libc" = "yes" \
-           || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
+        if eval test "\$$gt_func_gnugettext_libc" = "yes" \
+           || { eval test "\$$gt_func_gnugettext_libintl" = "yes" \
                 && test "$PACKAGE" != gettext-runtime \
                 && test "$PACKAGE" != gettext-tools; }; then
           gt_use_preinstalled_gnugettext=yes
@@ -268,7 +278,7 @@ return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)],
   if test "$USE_NLS" = "yes"; then
     AC_MSG_CHECKING([where the gettext function comes from])
     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
-      if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
+      if eval test "\$$gt_func_gnugettext_libintl" = "yes"; then
         gt_source="external libintl"
       else
         gt_source="libc"
@@ -282,7 +292,7 @@ return * gettext ("")]ifelse([$2], [need-ngettext], [ + * ngettext ("", "", 0)],
   if test "$USE_NLS" = "yes"; then
 
     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
-      if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
+      if eval test "\$$gt_func_gnugettext_libintl" = "yes"; then
         AC_MSG_CHECKING([how to link with libintl])
         AC_MSG_RESULT([$LIBINTL])
         AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
@@ -388,5 +398,20 @@ AC_DEFUN([gt_INTL_MACOSX],
 ])
 
 
+dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
+m4_define([gt_NEEDS_INIT],
+[
+  m4_divert_text([DEFAULTS], [gt_needs=])
+  m4_define([gt_NEEDS_INIT], [])
+])
+
+
+dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
+AC_DEFUN([AM_GNU_GETTEXT_NEED],
+[
+  m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
+])
+
+
 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
index 31ff643fffa7b78fe37e2e02b69cc7e8dc92806b..e49085448c39488d0fb2bdb2b6082852c01bbb83 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-01  Bruno Haible  <bruno@clisp.org>
+
+       * gettext.texi (AM_GNU_GETTEXT): Mention the AM_GNU_GETTEXT_NEED
+       alternative.
+       (AM_GNU_GETTEXT_NEED): New subsection.
+
 2006-10-01  Bruno Haible  <bruno@clisp.org>
 
        * gettext.texi (aclocal): Mention intldir.m4.
index e4f7954f13f0ab945c74bf5442c55c5f5021aa41..25c85ce2d79e40db7e00ca2720a8ea5ea145e1ae 100644 (file)
@@ -336,6 +336,7 @@ Autoconf macros for use in @file{configure.in}
 
 * AM_GNU_GETTEXT::              AM_GNU_GETTEXT in @file{gettext.m4}
 * AM_GNU_GETTEXT_VERSION::      AM_GNU_GETTEXT_VERSION in @file{gettext.m4}
+* AM_GNU_GETTEXT_NEED::         AM_GNU_GETTEXT_NEED in @file{gettext.m4}
 * AM_GNU_GETTEXT_INTL_SUBDIR::  AM_GNU_GETTEXT_INTL_SUBDIR in @file{intldir.m4}
 * AM_PO_SUBDIRS::               AM_PO_SUBDIRS in @file{po.m4}
 * AM_ICONV::                    AM_ICONV in @file{iconv.m4}
@@ -7342,6 +7343,7 @@ The primary macro is, of course, @code{AM_GNU_GETTEXT}.
 @menu
 * AM_GNU_GETTEXT::              AM_GNU_GETTEXT in @file{gettext.m4}
 * AM_GNU_GETTEXT_VERSION::      AM_GNU_GETTEXT_VERSION in @file{gettext.m4}
+* AM_GNU_GETTEXT_NEED::         AM_GNU_GETTEXT_NEED in @file{gettext.m4}
 * AM_GNU_GETTEXT_INTL_SUBDIR::  AM_GNU_GETTEXT_INTL_SUBDIR in @file{intldir.m4}
 * AM_PO_SUBDIRS::               AM_PO_SUBDIRS in @file{po.m4}
 * AM_ICONV::                    AM_ICONV in @file{iconv.m4}
@@ -7383,9 +7385,11 @@ gettext implementations (in libc or libintl) without the @code{ngettext()}
 function will be ignored.  If @var{needsymbol} is specified and is
 @samp{need-formatstring-macros}, then GNU gettext implementations that don't
 support the ISO C 99 @file{<inttypes.h>} formatstring macros will be ignored.
-Only one @var{needsymbol} can be specified.  To specify more than one
-requirement, just specify the strongest one among them.  The hierarchy among
-the various alternatives is as follows: @samp{need-formatstring-macros}
+Only one @var{needsymbol} can be specified.  These requirements can also be
+specified by using the macro @code{AM_GNU_GETTEXT_NEED} elsewhere.  To specify
+more than one requirement, just specify the strongest one among them, or
+invoke the @code{AM_GNU_GETTEXT_NEED} macro several times.  The hierarchy
+among the various alternatives is as follows: @samp{need-formatstring-macros}
 implies @samp{need-ngettext}.
 
 @var{intldir} is used to find the intl libraries.  If empty, the value
@@ -7436,7 +7440,7 @@ linker options needed to use iconv and appends them to the @code{LIBINTL}
 and @code{LTLIBINTL} variables.
 @end itemize
 
-@node AM_GNU_GETTEXT_VERSION, AM_GNU_GETTEXT_INTL_SUBDIR, AM_GNU_GETTEXT, autoconf macros
+@node AM_GNU_GETTEXT_VERSION, AM_GNU_GETTEXT_NEED, AM_GNU_GETTEXT, autoconf macros
 @subsection AM_GNU_GETTEXT_VERSION in @file{gettext.m4}
 
 @amindex AM_GNU_GETTEXT_VERSION
@@ -7446,7 +7450,31 @@ the GNU gettext infrastructure that is used by the package.
 The use of this macro is optional; only the @code{autopoint} program makes
 use of it (@pxref{CVS Issues}).
 
-@node AM_GNU_GETTEXT_INTL_SUBDIR, AM_PO_SUBDIRS, AM_GNU_GETTEXT_VERSION, autoconf macros
+
+@node AM_GNU_GETTEXT_NEED, AM_GNU_GETTEXT_INTL_SUBDIR, AM_GNU_GETTEXT_VERSION, autoconf macros
+@subsection AM_GNU_GETTEXT_NEED in @file{gettext.m4}
+
+@amindex AM_GNU_GETTEXT_NEED
+The @code{AM_GNU_GETTEXT_NEED} macro declares a constraint regarding the
+GNU gettext implementation.  The syntax is
+
+@example
+AM_GNU_GETTEXT_NEED([@var{needsymbol}])
+@end example
+
+If @var{needsymbol} is @samp{need-ngettext}, then GNU gettext implementations
+(in libc or libintl) without the @code{ngettext()} function will be ignored.
+If @var{needsymbol} is @samp{need-formatstring-macros}, then GNU gettext
+implementations that don't support the ISO C 99 @file{<inttypes.h>}
+formatstring macros will be ignored.
+
+The optional second argument of @code{AM_GNU_GETTEXT} is also taken into
+account.
+
+The @code{AM_GNU_GETTEXT_NEED} invocations can occur before or after
+the @code{AM_GNU_GETTEXT} invocation; the order doesn't matter.
+
+@node AM_GNU_GETTEXT_INTL_SUBDIR, AM_PO_SUBDIRS, AM_GNU_GETTEXT_NEED, autoconf macros
 @subsection AM_GNU_GETTEXT_INTL_SUBDIR in @file{intldir.m4}
 
 @amindex AM_GNU_GETTEXT_INTL_SUBDIR