diff options
author | Tom Tromey <tromey@redhat.com> | 2009-03-26 01:18:35 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2009-03-26 01:18:35 +0000 |
commit | 94ae1714190d492723cc34ff51d6f45eb8beb4cc (patch) | |
tree | 61f2b290041d1994a3f16484fafe1ab7a2152624 /gdb/acinclude.m4 | |
parent | 2bc57ae31d16179dbe6b7401d497b071c8ce4459 (diff) | |
download | gdb-94ae1714190d492723cc34ff51d6f45eb8beb4cc.zip gdb-94ae1714190d492723cc34ff51d6f45eb8beb4cc.tar.gz gdb-94ae1714190d492723cc34ff51d6f45eb8beb4cc.tar.bz2 |
* configure: Rebuild.
* acinclude.m4 (AM_ICONV): Set am_cv_use_build_libiconv.
Rearrange flags setting. Add comments.
Diffstat (limited to 'gdb/acinclude.m4')
-rw-r--r-- | gdb/acinclude.m4 | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 1897045..5e77230 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -177,8 +177,8 @@ AC_DEFUN([AM_ICONV], 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 @@ AC_DEFUN([AM_ICONV], 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 @@ AC_DEFUN([AM_ICONV], 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 @@ AC_DEFUN([AM_ICONV], [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 @@ AC_DEFUN([AM_ICONV], 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]) |