This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] config: fix AM_ICONV for in-tree libiconv


On Sat, 2015-08-22 at 18:04 +0100, Pedro Alves wrote:
> I noticed that regenerating binutils/configure or gdb/configure
> undoes the libiconv changes done here:
[snip] 
> However, that commit does not include any config/iconv.m4/AM_ICONV
> change.  Looks like you forgot to attach the config/iconv.m4 patch, and
> then only the regeneration bits were pushed (both binutils-gdb git
> and gcc svn)?

Looks like I forgot to repost that part of the patchset; attached.

-- 
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.

2015-07-01  Yaakov Selkowitz  <yselkowi@redhat.com>

	config/
	* iconv.m4 (AM_ICONV_LINK): Use in-tree libiconv when present.

Index: config/iconv.m4
===================================================================
--- config/iconv.m4	(revision 223875)
+++ config/iconv.m4	(working copy)
@@ -7,6 +7,7 @@
 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,16 +29,15 @@
   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("","");
@@ -44,8 +44,36 @@
        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 @@
          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_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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]