[libdispatch-dev] [PATCH 2/4] check whether to add -lm for testing to compile

Robert Watson robert at fledge.watson.org
Wed Nov 18 07:28:00 PST 2009

On Wed, 18 Nov 2009, Mario Schwalbe wrote:

> Robert Watson schrieb:
>> On Wed, 18 Nov 2009, Mario Schwalbe wrote:
>>> Linux needs -lm in order to compile the testing directory due to fabs().
>> Could you confirm that this doesn't create an unnecessary libm
>> dependency for libdispatch itself?
> No, it does create a superfluous dependency.

Another possibility, since libm isn't required on FreeBSD or Mac OS X for 
fabs(), would be to use AC_CHECK_FUNC() to see if it's available without 
special linkage.  If it isn't, then as custom action, use AC_SEARCH_LIBS(), 
itself with a custom action that adds -lm only to FABS_LIBS, which can be used 
just with the binary that requires it.  This avoids picking up libm 
dependencies on the testing binaries as well; if we hit any interesting 
platforms that don't implement fabs() at all (are there any?) then we could 
also use it to trigger conditional building of the test.

Robert N M Watson
Computer Laboratory
University of Cambridge

More information about the libdispatch-dev mailing list