[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Proposal to make better use of 5th arg to AC_CHECK_LIB and AC_SEARCH
From: |
Erez Zadok |
Subject: |
Re: Proposal to make better use of 5th arg to AC_CHECK_LIB and AC_SEARCH_LIBS |
Date: |
Mon, 1 Oct 2001 17:10:31 -0400 (EDT) |
In message <address@hidden>, Paul Eggert writes:
[...]
> What if there were multiple -lxxx args, e.g.: AC_CHECK_LIB(hesiod,
> hes_init,,, -lresolv -lsocket) Would you want it to try all
> combinations ('', '-lresolv', '-lsocket', '-lresolve -lsocket')?
> Seems like that would be a win in some cases.
>
>
> My own impression is that there are a lot of possibilities here. I
> agree that AC_CHECK_LIB does not have good semantics. However, I
> think your proposal might be improved and/or generalized too. If it's
> an incompatible change, I'd rather see an improved/generalized
> proposal now rather than install one incompatible change now, and
> another one later.
Hi Paul, I wrote the original AC_CHECK_LIB2 for am-utils b/c it served an
important purpose for the am-utils package, exactly as Rainer stated. I do
not think that the current AC_CHECK_LIB behavior makes sense. I think
autoconf need to modify that behavior or provide a new, more powerful macro.
I like your idea of generalization of this macros. I would suggest against
a fancy macro that will test any permutation of N libraries: that would be
2^N checks and is just too costly, plus I don't think it's needed. Many
autoconf macros simply search in order, and that's probably what I'd
prefer to see. Here are two ideas for new/revised macros:
AC_CHECK_FOO(fxn, lib1, lib2, ..., libN)
Checks if function "fxn" can be satisfied without linking with any
libraries (other than those already appended to $LIBS). If not
possible, checks if "fxn" can be satisfied by linking only with
lib1. If not, try only lib2, and so on. This is a serial test for
a single library at a time. If no single library can satisfy fxn,
then try to link against lib1+lib2, then lib1+2+3, and so on until
all libraries are tried. This will require exactly 2N tests, much
less time than 2^N and will satisfy the most demanding applications
(like the crazy linking rules we have to put in am-utils,
specifically to avoid bad libraries).
AC_CHECK_BAR(fxn1, fxn2, ..., fxnN, -lib1, -lib2, ..., -lib3)
Same as above, but check if all of fxn1 through fxnN can be
satisfied by some of the libraries listed, in the same checking
order as AC_CHECK_FOO. This is useful IMHO b/c there are times
where I need a series of functions to be found, or not at all. That
is, checking for hes_init is not enough to tell me if hesiod is
fully working on a given system (there are different versions of
hesiod out there, Solaris 7 has a partially working LDAP system,
etc.) A macro like this would ensure that I will only use the
functions listed above if all of them can be found. Otherwise, I'd
rather not have a half-working implementation: it's better to have
none of it.
An alternative to this macro would check for any one of fxn1--fxnN
in a series of libraries. If the first idea checked for all of them
(logical AND), this one will check for at least one (logical OR).
This is useful b/c some times I need to figure out if a feature
exists (say, ldap) on a system, but I have to check for it in
various ways b/c of incompatible functions and different generations
of (ldap) libraries. I'm not sure if this OR alternative needs a
separate macro: we could just execute a series of AC_CHECK_BAR
macros with only one fxn in them, and the same series of libraries.
Thanks,
Erez.