autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: checking twice the same library with AC_CHECK_LIB


From: Vincent Torri
Subject: Re: checking twice the same library with AC_CHECK_LIB
Date: Fri, 18 Mar 2011 17:16:02 +0100 (CET)


On Fri, 18 Mar 2011, Eric Blake wrote:

On 03/18/2011 08:50 AM, Vincent Torri wrote:
It's not what I want. The test I want is:

1) checking if libbfd can be used without libintl. If yes, then setting
bfd_libs to "-lbfd"

2) If no, then checking if libbfd can be used with libintl. If yes, then
setting bfd_libs to "-lbfd -lintl". If not, I exit.

I want to set bfd_libs like that (because of static linking and .pc files)

Then I would suggest not using AC_CHECK_LIB, but writing lower-level
functions that don't commit a value to cache that affects a later test.

Looking at the source code, you might be able to get away with this
alternative instead (okay, so it's not really documented, and happens to
be exploiting internals of AC_SEARCH_LIBS, but if this works, it argues
that we should enhance AC_SEARCH_LIBS to accept multi-library arguments
and properly auto-append -l only when it is not already present):

AC_SEARCH_LIBS([bfd_openr], [bfd 'bfd -lintl'], [...], [...])

After all, the body of AC_SEARCH_LIBS is doing this (after temporarily
saving the original value of $LIBS):

for ac_lib in '' $2; do
 if test -z "$ac_lib"; then
   ac_res="none required"
 else
   ac_res=-l$ac_lib
   LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
 fi
...

which ends up testing no extra libraries, then -lbfd, then -lbfd -lintl,
until the link succeeds, and only then writing the cache.

Thank you both, Eric and Peter. I used AC_LINK_IFELSE.

Vincent Torri



reply via email to

[Prev in Thread] Current Thread [Next in Thread]