[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Objections? Re: Checking for CXX libraries -- AC_CXX_CHECK_LIB ?
From: |
Allan Clark (Reply To List Only) |
Subject: |
Re: Objections? Re: Checking for CXX libraries -- AC_CXX_CHECK_LIB ? |
Date: |
Mon, 30 Sep 2002 08:46:45 -0400 |
Steve;
(whole cc: line is included to see how it fits your work)
I like your argument for simply using an arbitrary piece of code.
If/when I write this up, I should use it as an example.
action-if-found/action-if-not-found are direct copies of the non-CXX
version.
With allusion to my recent response to Sebastian for AC_CHECK_HEADER()
to check for header files, what about:
> AC_CXX_CHECK_LIB(library, code snippet, [action-if-found],
> [action-if-not-found], [other-libraries])
ie
> AC_CXX_CHECK_LIB(<lib>, [pipes::pipeCheck ((char *) "test", (int) 42);])
>
> ... generating:
>
> (void) pipes::pipeCheck ((char *) "test", (int) 42);
or
> AC_CHECK_HEADER( foo.h )
> AC_CXX_CHECK_LIB( <foo>, [pipes::pipeCheck("test", 42);] )
AC_CHECK_HEADER *should* cause AC_CXX_CHECK_LIB to have the #include
<foo.h> in the call, right? I'm only half-sure about that part). As
well, simply converting the function name to a code-snippet retains a
certain similarity with the AC_CHECK_LIB, one that I would prefer to
retain for an iteration of AC_CXX_CHECK_LIB if possible.
This almost argues for a change to a generic function in AC_CHECK_LIB.
Do we ever have a need for an AC_CHECK_LIB() to check C libraries using
a raw code snippet? AC_CHECK_LIB(<foo>,functioncall(),...) might have
some use, but I haven't seen it yet.
Allan
"Steve M. Robbins" wrote:
>
> On Sun, Sep 29, 2002 at 03:05:35PM -0400, Allan Clark (reply to list only)
> wrote:
> > I'm looking here for objections from the AutoConf list.
> >
> >
> > I could probably have a version tonight or tomorrow that ignores the
> > copied LANG(C)->LANG(C+) stuff and looks something like this:
> >
> > AC_CXX_CHECK_LIB(library, function, params, [action-if-found],
> > [action-if-not-found], [other-libraries])
> >
> > ... really adding "params" in there before the optionals. I could get
> > this together, test it myself, and have Sebastian Huber, jlm, and Ossama
> > Othman (recent requestors) test it out to see if it works for them.
> > Forgive me if I commit syntactical errors; I'm chronically looking
> > things up.
> >
> > The function above would generate a call something like:
> >
> > AC_CXX_CHECK_LIB(<lib>, pipes::pipeCheck, [(char *) "test", (int) 42])
> >
> > ... generating:
> >
> > (void) pipes::pipeCheck ((char *) "test", (int) 42)
>
> Separating the function name and the function parameters in this
> way strikes me as clumsy. It also doesn't allow checking
> for a particular class, as you noted later. Also, you need some
> way to specify headers to include for the library.
>
> I have for some time been using a macro that runs TRY_LINK on an arbitrary
> piece of code, so you'd write your example as
>
> AC_CXX_CHECK_LIB( <foo>,
> [#include <foo.h>],
> [pipes::pipeCheck("test", 42);])
>
> Since the third argument is arbitrary code, it could just as easily
> have been an object instantiation to check for a templated library.
>
> Actually, my macro assumes that the library is required for building
> and so uses MSG_ERROR if the lib is not found. This makes it a lot
> simpler, but your proposal with [action-if-found], [action-if-not-found],
> etc is better.
>
> dnl @synopsis mni_REQUIRE_LIB(LIBRARY,INCLUDES,BODY)
> dnl
> dnl @version $Id: mni_REQUIRE_LIB.m4,v 1.1 2001/08/20 16:51:50 stever Exp $
> dnl @author Steve M. Robbins <address@hidden>
>
> AC_DEFUN([mni_REQUIRE_LIB],
> [
> AC_MSG_CHECKING([for library $1])
> LIBS="-l$1 $LIBS"
> AC_TRY_LINK([$2],[$3],[mni_result=yes],[mni_result=no])
> AC_MSG_RESULT([$mni_result])
> if test "$mni_result" = "no"; then
> AC_MSG_ERROR([cannot find required library $1])
> fi
> ])
>
> So maybe I've missed the point entirely: it seems that all you want
> is something that sets the LIBS variable and then calls TRY_LINK?
>
> Regards,
> -Steve