[PATCH] configure.ac: Include math.h when checking for sqrt/cbrt

Mark Kettenis mark.kettenis at xs4all.nl
Mon Jul 26 09:03:36 PDT 2010


> Date: Mon, 26 Jul 2010 16:55:20 +0100
> From: Daniel Stone <daniel at fooishbar.org>
> 
> On Mon, Jul 26, 2010 at 05:48:10PM +0200, Mark Kettenis wrote:
> > > From: Daniel Stone <daniel at fooishbar.org>
> > > Date: Mon, 26 Jul 2010 16:31:15 +0100
> > >=20
> > > sqrt and cbrt are only defined in math.h, so we have to include that
> > > when checking for them, lest we miss it, and then some other header
> > > pulling in math.h causes build failures due to multiple definitions.
> >=20
> > Eh, why?  AC_CHECK_LIB is supposed to check whether these symbols are
> > available in the given library in a way that doesn't depend on a
> > prototype for them being in scope.  So I don't see what you diff
> > achieves, other than adding more clutter to the configure scripts.
> 
> Well, it does depend on a prototype for them being in scope.  It
> constructs a basic int main(...) { foo(); } bit of source with
> AC_LANG_CALL and then attempts to link it:
> 
> AC_DEFUN([AC_CHECK_LIB],
> [m4_ifval([$3], , [AH_CHECK_LIB([$1])])dnl
> AS_LITERAL_IF([$1],
>               [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2])],
>               [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1''_$2])])dnl
> AC_CACHE_CHECK([for $2 in -l$1], [ac_Lib],
> [ac_check_lib_save_LIBS=3D$LIBS
> LIBS=3D"-l$1 $5 $LIBS"
> AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
>                [AS_VAR_SET([ac_Lib], [yes])],
>                [AS_VAR_SET([ac_Lib], [no])])
> LIBS=3D$ac_check_lib_save_LIBS])
> AS_VAR_IF([ac_Lib], [yes],
>       [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
>   LIBS=3D"-l$1 $LIBS"
> ])],
>       [$4])
> AS_VAR_POPDEF([ac_Lib])dnl
> ])# AC_CHECK_LIB

Well, that fragment is supposed to compile fine even without a
prototype for foo(), so there must be something else going on.


More information about the xorg-devel mailing list