[fedora-classroom] Introductory workshop on GNU autotools

Siddhesh Poyarekar siddhesh.poyarekar at gmail.com
Mon May 3 13:25:51 UTC 2010


On Mon, May 3, 2010 at 6:48 PM, Bruno Wolff III <bruno at wolff.to> wrote:
> On Mon, May 03, 2010 at 08:15:20 -0500,
>  Bruno Wolff III <bruno at wolff.to> wrote:
>>
>> I'll be travelling from home to work during the meeting time, so probably
>> won't catch much of it live, but will read the logs after the fact.
>> One question I have is how to handle when you need the math library and/or
>> simple X stuff. I have been doing some DSO linking cleanup and have been
>> recommending adding -lm or -lX11 to the prog_ADD type variable in the
>> Makefile.am to fix these cases, but I am wondering if there is a better
>> way to do that?
>
> That should have been prog_LDADD.
>

If you want to be really generic (which is the point of autotools
anyway), you can use the AC_CHECK_LIB macro to check for presence of
the library in question (libm, libX11). So you will have:

AC_CHECK_LIB([m], [sin],,[AC_MSG_ERROR("No libm present")])
AC_CHECK_LIB([X11], [XOpenDisplay],,[AC_MSG_ERROR("No libX11 present")])

This does the check and adds the required flags to LDFLAGS if present.
If not, it returns an error.

-- 
Siddhesh Poyarekar
http://siddhesh.in


More information about the classroom mailing list