gcc/config
Yaakov Selkowitz d485982286 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
2015-08-24 10:24:52 +00:00
..
ChangeLog Missing parts of fixes for in-tree libiconv 2015-08-24 10:24:52 +00:00
acinclude.m4 config: sync with src 2008-07-30 14:57:07 +00:00
acx.m4 configure: Regenerate. 2011-12-18 09:58:37 +00:00
asmcfi.m4 libitm: Configure for gas cfi pseudo ops. 2011-11-09 10:09:53 -08:00
bitfields.m4 Improve the test in bitfields.m4 2015-05-05 03:41:53 +00:00
bootstrap-O1.mk re PR target/37137 (unrecognized command line option "-minterlink-mips16") 2009-05-12 05:49:28 +00:00
bootstrap-O3.mk re PR target/37137 (unrecognized command line option "-minterlink-mips16") 2009-05-12 05:49:28 +00:00
bootstrap-asan.mk Export "detect_leaks=0" 2014-11-17 14:12:55 -08:00
bootstrap-debug-big.mk configure.ac (--with-build-config): New. 2009-09-03 05:55:57 +00:00
bootstrap-debug-ckovw.mk invoke.texi (-fvar-tracking-assignments): New. 2009-09-02 02:42:21 +00:00
bootstrap-debug-lean.mk configure.ac (--with-build-config): New. 2009-09-03 05:55:57 +00:00
bootstrap-debug-lib.mk invoke.texi (-fvar-tracking-assignments): New. 2009-09-02 02:42:21 +00:00
bootstrap-debug.mk invoke.texi (-fvar-tracking-assignments): New. 2009-09-02 02:42:21 +00:00
bootstrap-lto-noplugin.mk re PR bootstrap/65537 (--with-build-config=bootstrap-lto fails on CentOS 5.11) 2015-03-25 17:01:36 +01:00
bootstrap-lto.mk Support slim LTO bootstrap 2014-09-01 16:41:28 +00:00
bootstrap-mpx.mk Add the missing file 2015-04-14 08:04:45 -07:00
bootstrap-time.mk invoke.texi (-fvar-tracking-assignments): New. 2009-09-02 02:42:21 +00:00
bootstrap-ubsan.mk bootstrap-ubsan.mk (POSTSTAGE1_LDFLAGS): Remove -lpthread -ldl. 2013-11-29 20:13:45 +00:00
codeset.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
depstand.m4 depstand.m4 (ZW_CREATE_DEPDIR): Use mkinstalldirs to make directory. 2007-01-27 19:50:38 +00:00
dfp.m4 IA MCU psABI support: changes to libraries 2015-06-30 09:42:07 -07:00
elf.m4 nvptx-none: Disable the lto-plugin. 2015-02-18 09:01:03 +01:00
enable.m4 enable.m4: New file. 2005-09-23 16:33:47 +00:00
extensions.m4 extensions.m4 (AC_USE_SYSTEM_EXTENSIONS): Do not expand for Autoconf 2.62 or newer. 2009-07-30 19:41:13 +00:00
futex.m4 configure.ac (--enable-linux-futex): Add new configure option. 2008-01-08 17:14:49 +01:00
gc++filt.m4 Missed in last commit. 2010-07-02 10:26:12 +00:00
gcc-plugin.m4 Let GDB reuse GCC's parser. 2014-10-27 17:21:42 +00:00
gettext-sister.m4 Richard Earnshaw <rearnsha@arm.com> 2006-06-13 08:00:45 +00:00
gettext.m4 re PR other/66259 (Combined gcc and binutils build from git-master fails, with gas/as-new not existing) 2015-07-24 12:20:44 -06:00
glibc21.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
gthr.m4 gthr.m4: New. 2012-10-15 13:10:30 +00:00
gxx-include-dir.m4 re PR libgcj/28426 (libgcj header files installed in wrong location in cross build) 2006-07-21 20:49:06 +00:00
iconv.m4 Missing parts of fixes for in-tree libiconv 2015-08-24 10:24:52 +00:00
intdiv0.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
inttypes-pri.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
inttypes.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
inttypes_h.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
isl.m4 isl.m4: Don't pass -DCLOOG_INT_GMP on islinc. 2014-12-04 08:45:33 +00:00
largefile.m4 largefile.m4 (ACX_LARGEFILE): Require AC_CANONICAL_HOST and AC_CANONICAL_TARGET. 2009-11-30 16:38:14 +00:00
lcmessage.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
ld-symbolic.m4 ld-symbolic.m4: New. 2007-01-14 07:38:18 -08:00
lead-dot.m4 Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception. 2009-04-09 17:00:19 +02:00
lib-ld.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
lib-link.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
lib-prefix.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
libstdc++-raw-cxx.m4 Remove "-I" from LIBSTDCXX_RAW_CXX_LDFLAGS 2013-01-07 10:23:42 -08:00
lthostflags.m4 re PR target/40125 (libgcc_s DLL installed in wrong directory in cross toolchain) 2010-12-06 00:50:04 +00:00
math.m4 math.m4 (GCC_CHECK_MATH_FUNC): Remove if-present argument. 2012-04-02 07:46:39 +00:00
mh-alpha-linux Install back PR target/47230 fix (Revert the revert). 2015-03-27 18:08:44 +01:00
mh-cygwin Makefile.def: Add dependency from termcap to gdb. 2011-03-24 17:11:26 +00:00
mh-darwin re PR target/65351 (libiberty's pic version contains non-pic code on m32 darwin; causes bootstrap fail building libcc1.) 2015-04-10 06:43:52 +00:00
mh-djgpp
mh-mingw mh-cygwin (LDFLAGS): Turn up stack allocation to 12MB. 2010-12-02 23:30:47 +00:00
mh-pa configure.ac: Add makefile fragments for hpux. 2008-07-30 12:17:17 +00:00
mh-pa-hpux10 configure.ac: Add makefile fragments for hpux. 2008-07-30 12:17:17 +00:00
mh-ppc-aix mh-ppc-aix (LDFLAGS): Quote $(CC). 2012-05-03 15:39:07 +00:00
mmap.m4 mmap.m4: Use *vms* instead of vms*. 2012-04-03 12:07:28 +00:00
mt-alphaieee mt-alphaieee (GOCFLAGS_FOR_TARGET): Add -mieee. 2011-07-06 19:48:43 +02:00
mt-d30v
mt-gnu re PR target/43538 (config/mt-gnu CXXFLAGS_FOR_TARGET) 2014-04-25 08:03:08 +00:00
mt-mips-elfoabi configure.ac (mips*-*-*linux*, [...]): Use mt-mips-gnu. 2008-08-09 19:08:15 +00:00
mt-mips-gnu configure.ac (mips*-*-*linux*, [...]): Use mt-mips-gnu. 2008-08-09 19:08:15 +00:00
mt-mips16-compat configure.ac (mips*-*-*linux*, [...]): Use mt-mips-gnu. 2008-08-09 19:08:15 +00:00
mt-nios2-elf configure.ac (target_makefile_frag): Set for nios2-*-elf*. 2014-05-14 19:20:59 -04:00
mt-ospace mt-ospace (CFLAGS_FOR_TARGET): Append -g -Os rather than overwriting. 2014-11-18 15:12:52 -07:00
mt-sde mt-sde: Change -mcode-xonly to -mcode-readable=pcrel. 2012-09-19 20:42:01 +00:00
mt-spu mt-spu (all-ld): Update for ld Makefile changes. 2008-08-03 13:07:55 +09:30
multi.m4 re PR target/37137 (unrecognized command line option "-minterlink-mips16") 2009-05-12 05:49:28 +00:00
nls.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
no-executables.m4 extensions.m4 (AC_USE_SYSTEM_EXTENSIONS): Do not expand for Autoconf 2.62 or newer. 2009-07-30 19:41:13 +00:00
override.m4 Guard against M4 versions with a buggy strstr. 2011-03-05 07:32:50 +00:00
picflag.m4 re PR target/65351 (libiberty's pic version contains non-pic code on m32 darwin; causes bootstrap fail building libcc1.) 2015-04-10 06:43:52 +00:00
plugins.m4 Merge the ./config directory between GCC and Binutils 2014-11-26 21:53:35 +00:00
po.m4 re PR other/66259 (Combined gcc and binutils build from git-master fails, with gas/as-new not existing) 2015-07-24 12:20:44 -06:00
proginstall.m4 configure.ac: m4_include config/proginstall.m4. 2008-03-16 08:19:08 +00:00
progtest.m4
sjlj.m4 sjlj.m4: New file. 2015-05-13 21:15:31 +00:00
stdint.m4 re PR other/66259 (Combined gcc and binutils build from git-master fails, with gas/as-new not existing) 2015-07-24 12:20:44 -06:00
stdint_h.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
target-posix [PATCH 2/4] OpenMP 4.0 offloading to Intel MIC: liboffloadmic. 2014-11-13 14:03:17 +00:00
tcl.m4 re PR other/66259 (Combined gcc and binutils build from git-master fails, with gas/as-new not existing) 2015-07-24 12:20:44 -06:00
tls.m4 re PR bootstrap/43170 (gcc 4.5 20100218 bootstrap compare fails on os x 10.6) 2010-06-09 09:27:04 +00:00
uintmax_t.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
ulonglong.m4 gettext-sister.m4: Renamed from gettext.m4 2004-09-22 23:53:59 +00:00
unwind_ipinfo.m4 Index... 2008-12-21 14:27:18 -08:00
warnings.m4 * warnings.m4: Fix comment. 2015-05-27 16:40:38 -04:00
weakref.m4 Remove obsolete Tru64 UNIX V5.1B support 2012-03-12 15:35:56 +00:00
zlib.m4 This patch syncs zlib.m4 with binutils-gdb and uses AM_ZLIB from zlib.m4 2015-07-14 07:25:35 -07:00