Paolo Bonzini wrote: > * m4/libunistring.m4: Do not repeat twice "no, consider installing GNU > libunistring".
While testing the case that this code is meant for, I noticed that it did not work at all. How to reproduce: 0) Create an empty directory, used as --prefix for everything that follows. 1) Install libiconv with --disable-shared. 2) Install libunistring with --disable-shared. 3) Remove the installed libunistring.la file. 4) Configure a testdir created with "./gnulib-tool --create-testdir libunistring". The output is: checking for libunistring... no, consider installing GNU libunistring checking for libunistring... (cached) no, consider installing GNU libunistring First, a fix to libunistring.m4. Then the output is: checking for libunistring... no, consider installing GNU libunistring checking for libunistring... no, consider installing GNU libunistring This does not work because of the way LIBS is constructed. After a fix to lib-link.m4, the detection is finally right: checking for libunistring... no, consider installing GNU libunistring checking for libunistring... yes checking how to link with libunistring... /arch/x86-linux/gnu-inst-libunistring/0.9.2.1+libiconv-static/lib/libunistring.a 2010-04-11 Bruno Haible <br...@clisp.org> libunistring: Detect libunistring also when it depends on libiconv. * m4/libunistring.m4 (gl_LIBUNISTRING): Unset the cached result before the second AC_LIB_HAVE_LINKFLAGS invocation. --- m4/libunistring.m4.orig Sun Apr 11 17:55:20 2010 +++ m4/libunistring.m4 Sun Apr 11 17:55:16 2010 @@ -1,4 +1,4 @@ -# libunistring.m4 serial 2 +# libunistring.m4 serial 3 dnl Copyright (C) 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,6 +23,9 @@ dnl Second try, with -liconv. AC_REQUIRE([AM_ICONV]) if test -n "$LIBICONV"; then + dnl We have to erase the cached result of the first AC_LIB_HAVE_LINKFLAGS + dnl invocation, otherwise the second one will not be run. + unset ac_cv_libunistring glus_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_LIB_HAVE_LINKFLAGS([unistring], [], 2010-04-11 Bruno Haible <br...@clisp.org> havelib: Add static libraries to LIBS in the right order. * m4/lib-link.m4 (AC_LIB_HAVE_LINKFLAGS): When $LIB[]NAME contains no -l options, prepend it to $LIBS, instead of appending it to $LIBS. --- m4/lib-link.m4.orig Sun Apr 11 17:55:20 2010 +++ m4/lib-link.m4 Sun Apr 11 17:47:32 2010 @@ -1,4 +1,4 @@ -# lib-link.m4 serial 20 (gettext-0.18) +# lib-link.m4 serial 21 (gettext-0.18) dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -74,7 +74,17 @@ AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" - LIBS="$LIBS $LIB[]NAME" + dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, + dnl because these -l options might require -L options that are present in + dnl LIBS. -l options benefit only from the -L options listed before it. + dnl Otherwise, add it to the front of LIBS, because it may be a static + dnl library that depends on another static library that is present in LIBS. + dnl Static libraries benefit only from the static libraries listed after + dnl it. + case " $LIB[]NAME" in + *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; + *) LIBS="$LIB[]NAME $LIBS" ;; + esac AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])