Commit d4859822 by Yaakov Selkowitz Committed by Pedro Alves

Missing parts of fixes for in-tree libiconv

(The previous iconv-related commit missed the config/iconv.m4 change.)

Original description:

This is the second in a series of patches to make a build with an
in-tree GNU libiconv work as designed.

Currently GDB is the only toolchain component which actually uses an
in-tree libiconv.  This patch modifies the common AM_ICONV to use an
in-tree libiconv when present and not already provided by libc.
(GDB's workaround uses an in-tree libiconv even when libc provides
iconv(3); I'm not sure when or why that would be desirable.)

config/ChangeLog:
2015-08-24  Yaakov Selkowitz  <yselkowi@redhat.com>

	* iconv.m4 (AM_ICONV_LINK): Use in-tree libiconv when present.
---
 config/ChangeLog   |  4 +++
 config/iconv.m4    | 47 +++++++++++++++++++++------
 4 files changed, 112 insertions(+), 36 deletions(-)

diff --git a/config/iconv.m4 b/config/iconv.m4
index c5f3579..5f9304a 100644
--- a/config/iconv.m4
+++ b/config/iconv.m4
@@ -7,6 +7,7 @@ dnl that contains a configuration script generated by Autoconf, under
 dnl the same distribution terms as the rest of that program.
 
 dnl From Bruno Haible.
+dnl with modifications to support building with in-tree libiconv
 
 AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
 [
@@ -28,24 +29,51 @@ AC_DEFUN([AM_ICONV_LINK],
   dnl accordingly.
   AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
 
-  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
-  dnl because if the user has installed libiconv and not disabled its use
-  dnl via --without-libiconv-prefix, he wants to use it. The first
-  dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
-  am_save_CPPFLAGS="$CPPFLAGS"
-  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
-
   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
+    dnl Add $INCICONV to CPPFLAGS before performing the first check,
+    dnl because if the user has installed libiconv and not disabled its use
+    dnl via --without-libiconv-prefix, he wants to use it. This first
+    dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
+    am_save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $INCICONV"
     AC_TRY_LINK([#include <stdlib.h>
 #include <iconv.h>],
       [iconv_t cd = iconv_open("","");
        iconv(cd,NULL,NULL,NULL,NULL);
        iconv_close(cd);],
       am_cv_func_iconv=yes)
+    CPPFLAGS="$am_save_CPPFLAGS"
+
+    if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
+      for _libs in .libs _libs; do
+        am_save_CPPFLAGS="$CPPFLAGS"
+        am_save_LIBS="$LIBS"
+        CPPFLAGS="$CPPFLAGS -I../libiconv/include"
+        LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
+        AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+          [iconv_t cd = iconv_open("","");
+           iconv(cd,NULL,NULL,NULL,NULL);
+           iconv_close(cd);],
+          INCICONV="-I../libiconv/include"
+          LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a
+          LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
+          am_cv_lib_iconv=yes
+          am_cv_func_iconv=yes)
+        CPPFLAGS="$am_save_CPPFLAGS"
+        LIBS="$am_save_LIBS"
+        if test "$am_cv_func_iconv" = "yes"; then
+          break
+        fi
+      done
+    fi
+
     if test "$am_cv_func_iconv" != yes; then
+      am_save_CPPFLAGS="$CPPFLAGS"
       am_save_LIBS="$LIBS"
+      CPPFLAGS="$LIBS $INCICONV"
       LIBS="$LIBS $LIBICONV"
       AC_TRY_LINK([#include <stdlib.h>
 #include <iconv.h>],
@@ -54,6 +82,7 @@ AC_DEFUN([AM_ICONV_LINK],
          iconv_close(cd);],
         am_cv_lib_iconv=yes
         am_cv_func_iconv=yes)
+      CPPFLAGS="$am_save_CPPFLAGS"
       LIBS="$am_save_LIBS"
     fi
   ])
@@ -61,12 +90,10 @@ AC_DEFUN([AM_ICONV_LINK],
     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
   fi
   if test "$am_cv_lib_iconv" = yes; then
+    AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
     AC_MSG_CHECKING([how to link with libiconv])
     AC_MSG_RESULT([$LIBICONV])
   else
-    dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
-    dnl either.
-    CPPFLAGS="$am_save_CPPFLAGS"
     LIBICONV=
     LTLIBICONV=
   fi
-- 
1.9.3

From-SVN: r227118
parent a339a01c
2015-08-24 Yaakov Selkowitz <yselkowi@redhat.com>
* iconv.m4 (AM_ICONV_LINK): Use in-tree libiconv when present.
2015-07-24 Micahel Darling <darlingm@gmail.com> 2015-07-24 Micahel Darling <darlingm@gmail.com>
PR other/66259 PR other/66259
......
...@@ -7,6 +7,7 @@ dnl that contains a configuration script generated by Autoconf, under ...@@ -7,6 +7,7 @@ dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program. dnl the same distribution terms as the rest of that program.
dnl From Bruno Haible. dnl From Bruno Haible.
dnl with modifications to support building with in-tree libiconv
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
[ [
...@@ -28,24 +29,51 @@ AC_DEFUN([AM_ICONV_LINK], ...@@ -28,24 +29,51 @@ AC_DEFUN([AM_ICONV_LINK],
dnl accordingly. dnl accordingly.
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
dnl Add $INCICONV to CPPFLAGS before performing the following checks, AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
dnl Add $INCICONV to CPPFLAGS before performing the first check,
dnl because if the user has installed libiconv and not disabled its use dnl because if the user has installed libiconv and not disabled its use
dnl via --without-libiconv-prefix, he wants to use it. The first dnl via --without-libiconv-prefix, he wants to use it. This first
dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
am_save_CPPFLAGS="$CPPFLAGS" am_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) CPPFLAGS="$CPPFLAGS $INCICONV"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_func_iconv=yes)
CPPFLAGS="$am_save_CPPFLAGS"
AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
am_cv_func_iconv="no, consider installing GNU libiconv" for _libs in .libs _libs; do
am_cv_lib_iconv=no am_save_CPPFLAGS="$CPPFLAGS"
am_save_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS -I../libiconv/include"
LIBS="$LIBS ../libiconv/lib/$_libs/libiconv.a"
AC_TRY_LINK([#include <stdlib.h> AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>], #include <iconv.h>],
[iconv_t cd = iconv_open("",""); [iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL); iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);], iconv_close(cd);],
INCICONV="-I../libiconv/include"
LIBICONV='${top_builddir}'/../libiconv/lib/$_libs/libiconv.a
LTLIBICONV='${top_builddir}'/../libiconv/lib/libiconv.la
am_cv_lib_iconv=yes
am_cv_func_iconv=yes) am_cv_func_iconv=yes)
CPPFLAGS="$am_save_CPPFLAGS"
LIBS="$am_save_LIBS"
if test "$am_cv_func_iconv" = "yes"; then
break
fi
done
fi
if test "$am_cv_func_iconv" != yes; then if test "$am_cv_func_iconv" != yes; then
am_save_CPPFLAGS="$CPPFLAGS"
am_save_LIBS="$LIBS" am_save_LIBS="$LIBS"
CPPFLAGS="$LIBS $INCICONV"
LIBS="$LIBS $LIBICONV" LIBS="$LIBS $LIBICONV"
AC_TRY_LINK([#include <stdlib.h> AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>], #include <iconv.h>],
...@@ -54,6 +82,7 @@ AC_DEFUN([AM_ICONV_LINK], ...@@ -54,6 +82,7 @@ AC_DEFUN([AM_ICONV_LINK],
iconv_close(cd);], iconv_close(cd);],
am_cv_lib_iconv=yes am_cv_lib_iconv=yes
am_cv_func_iconv=yes) am_cv_func_iconv=yes)
CPPFLAGS="$am_save_CPPFLAGS"
LIBS="$am_save_LIBS" LIBS="$am_save_LIBS"
fi fi
]) ])
...@@ -61,12 +90,10 @@ AC_DEFUN([AM_ICONV_LINK], ...@@ -61,12 +90,10 @@ AC_DEFUN([AM_ICONV_LINK],
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
fi fi
if test "$am_cv_lib_iconv" = yes; then if test "$am_cv_lib_iconv" = yes; then
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
AC_MSG_CHECKING([how to link with libiconv]) AC_MSG_CHECKING([how to link with libiconv])
AC_MSG_RESULT([$LIBICONV]) AC_MSG_RESULT([$LIBICONV])
else else
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
dnl either.
CPPFLAGS="$am_save_CPPFLAGS"
LIBICONV= LIBICONV=
LTLIBICONV= LTLIBICONV=
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment