[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iconv.m4: provide useful am_func_iconv 'no' string

From: Bruno Haible
Subject: Re: iconv.m4: provide useful am_func_iconv 'no' string
Date: Sun, 10 Jul 2022 17:31:21 +0200

Hi Simon,

> In libidn and libidn2 we (used to) print this during ./configure:
>   Libiconv:          $am_cv_func_iconv $LTLIBICONV
> It prints the right thing in most cases, that is, one of these:
>   Libiconv:          yes -liconv ...
>   Libiconv:          no, consider installing GNU libiconv
> However on platforms that have iconv but it is broken, and thus ends up
> not being used by iconv.m4, it will print this:
>   Libiconv:          yes

The root of the problem is that the AM_ICONV macro does several tests,
and prints a result for each, whereas you want to have a summary result
that fits in a single line. Such a summary result does not exist so far.

> Reading iconv.m4 suggests to me that I probably should have been using
> the am_func_iconv variable instead

Nope; this variable is undocumented.

> I can't find any uses of am_func_iconv in any M4 files in gnulib, so I'm
> hoping that nobody is testing it for == 'no' strings but only uses !=
> 'yes' comparisons.

It's too dangerous to change the value of this variable. This macro is
in the wild for more than 20 years. There are surely packages that use
this variable, although it's undocumented. (E.g. GnuPG.)

Let me introduce a variable 'am_func_iconv_summary'. Meant to be used
   echo "iconv:    $am_func_iconv_summary"
Not 'libiconv', since that just the implementation. 'iconv' is the POSIX
facility's name.

2022-07-10  Bruno Haible  <bruno@clisp.org>

        iconv: Define a summary result.
        Reported by Simon Josefsson in
        * m4/iconv.m4 (AM_ICONV): Define also am_cv_func_iconv_summary.

diff --git a/m4/iconv.m4 b/m4/iconv.m4
index 6f1ae2b13d..2065c9772a 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -1,4 +1,4 @@
-# iconv.m4 serial 25
+# iconv.m4 serial 26
 dnl Copyright (C) 2000-2002, 2007-2014, 2016-2022 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -274,4 +274,20 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t 
*inbytesleft, char * *outbuf, si
+  dnl A summary result, for those packages which want to print a summary at the
+  dnl end of the configuration.
+  if test "$am_func_iconv" = yes; then
+    if test -n "$LIBICONV"; then
+      am_cv_func_iconv_summary='yes, in libiconv'
+    else
+      am_cv_func_iconv_summary='yes, in libc'
+    fi
+  else
+    if test "$am_cv_func_iconv" = yes; then
+      am_cv_func_iconv_summary='not working, consider installing GNU libiconv'
+    else
+      am_cv_func_iconv_summary='no, consider installing GNU libiconv'
+    fi
+  fi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]