Re: [PATCH] configure: use AC_SEARCH_LIBS instead of AC_CHECK_LIB
- From
Brandon Casey <casey@nrlssc.navy.mil>
- Date
- Jul 21, 2009, 15:04 UTC
- Message-ID
- <6WnEB0at_uuAu9kicWjrHLsBbTv58WtCNOANkKzk-SqTgqjuWyh8WA@cipher.nrlssc.navy.mil>
- In-Reply-To
- <a52be8ba36206abc5ff5c91a759036a931e2658c.1248007036.git.nicolas.s.dev@gmx.fr>
After actually reading the autoconf documentation, don't some of the tests have the [action-if-found] and [action-if-not-found] actions backwards?
AC_CHECK_LIB has the form:
AC_CHECK_LIB (library, function, [action-if-found], [action-if-not-found], [other-libraries])
The test I added (which I blindly copied from the NEEDS_RESOLV test) looks like:
AC_CHECK_LIB([gen], [basename], [NEEDS_LIBGEN=], [NEEDS_LIBGEN=YesPlease]) AC_SUBST(NEEDS_LIBGEN) test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen"
Won't this check whether a program which calls basename() successfully links with -lgen? If it successfully links, then it will perform NEED_LIBGEN= and if not it will set NEEDS_LIBGEN=YesPlease, right? Isn't that the opposite of what should be done?
If that is correct, then the NEEDS_RESOLV and NEEDS_LIBGEN tests are wrong and they may still be wrong even if AC_SEARCH_LIBS is used instead of AC_CHECK_LIB.
A question about AC_SEARCH_LIBS:
With AC_SEARCH_LIBS, which of [action-if-found] or [action-if-not-found] is executed if the function is found in the standard c library i.e. "calling `AC_LINK_IFELSE([AC_LANG_CALL([], [function])])' first with no libraries"? Is the answer neither? If the answer is [action-if-found], won't the NEEDS_LIBGEN=YesPlease be set when the function is found in the c library? Assuming the NEEDS_LIBGEN test is made to look like this:
AC_SEARCH_LIBS([basename], [gen], [NEEDS_LIBGEN=YesPlease], [NEEDS_LIBGEN=])
Depending on the answer to that question, we either will want to use AC_SEARCH_LIBS, or stick with AC_CHECK_LIB but correct the [action] fields, or maybe even stick with AC_CHECK_LIB but rework the NEEDS_RESOLV and NEEDS_LIBGEN tests to look like the NEEDS_SOCKET test.
-brandon