This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: charset configury cleanup
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 25 Mar 2009 19:03:27 -0600
- Subject: FYI: charset configury cleanup
- Reply-to: tromey at redhat dot com
I'm checking this in.
I noticed a couple oddities in the iconv configure code. It wasn't
reliably detecting the in-tree libiconv, and it was adding too many
things to CPPFLAGS in some cases.
This patch cleans these up. I also added some comments to make it
simpler to figure out what is going on.
Built three ways on x86 F9. I also verified the generated
gdb/Makefile by hand in each case.
Tom
2009-03-25 Tom Tromey <tromey@redhat.com>
* configure: Rebuild.
* acinclude.m4 (AM_ICONV): Set am_cv_use_build_libiconv.
Rearrange flags setting. Add comments.
Index: acinclude.m4
===================================================================
RCS file: /cvs/src/src/gdb/acinclude.m4,v
retrieving revision 1.26
diff -u -r1.26 acinclude.m4
--- acinclude.m4 25 Mar 2009 00:58:34 -0000 1.26
+++ acinclude.m4 26 Mar 2009 00:36:51 -0000
@@ -177,8 +177,8 @@
AC_ARG_WITH([libiconv-prefix],
[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
for dir in `echo "$withval" | tr : ' '`; do
- if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
- if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; LDFLAGS="$LDFLAGS -L$dir/lib"; fi
+ if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; fi
+ if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; fi
done
])
@@ -189,14 +189,23 @@
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
am_cv_use_build_libiconv=no
+ # First, try to find iconv in libc.
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)
+
+ # If iconv was not in libc, try -liconv. In this case, arrange to
+ # look in the libiconv prefix, if it was specified by the user.
if test "$am_cv_func_iconv" != yes; then
+ am_save_CPPFLAGS="$CPPFLAGS"
am_save_LIBS="$LIBS"
+ if test -n "$LIBICONV_INCLUDE"; then
+ CPPFLAGS="$CPPFLAGS $LIBICONV_INCLUDE"
+ LIBS="$LIBS $LIBICONV_LIBDIR"
+ fi
LIBS="$LIBS -liconv"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
@@ -206,8 +215,10 @@
am_cv_lib_iconv=yes
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
+ CPPFLAGS="$am_save_CPPFLAGS"
fi
- # Look for libiconv in the build tree.
+
+ # If that didn't work, try to find libiconv in the build tree.
if test "$am_cv_func_iconv" != yes && test -d ../libiconv; then
am_save_LIBS="$LIBS"
am_save_CPPFLAGS="$CPPFLAGS"
@@ -218,15 +229,22 @@
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
+ am_cv_use_build_libiconv=yes
am_cv_lib_iconv=yes
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
CPPFLAGS="$am_save_CPPFLAGS"
fi
])
+
+ # Set the various flags based on the cache variables. We can't rely
+ # on the flags to remain set from the above code, due to caching.
LIBICONV=
if test "$am_cv_lib_iconv" = yes; then
LIBICONV="-liconv"
+ else
+ LIBICONV_LIBDIR=
+ LIBICONV_INCLUDE=
fi
if test "$am_cv_use_build_libiconv" = yes; then
LIBICONV_LIBDIR="$BUILD_LIBICONV_LIBDIR"
@@ -234,6 +252,7 @@
fi
CPPFLAGS="$CPPFLAGS $LIBICONV_INCLUDE"
LIBS="$LIBS $LIBICONV_LIBDIR $LIBICONV"
+
if test "$am_cv_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
AC_MSG_CHECKING([for iconv declaration])