Fixes build against uClibc. uClibc provides 2 versions of clock_gettime(), one with realtime support and one without (this is so you can avoid linking in -lrt unless actually needed). This means that the clock_gettime() don't need -lrt. We still need it for timer_create() so we check for this function in addition.
We also need check if -lm is needed for isnan(). Both -lm and -lrt are needed for libs_qga. Signed-off-by: Natanael Copa <nc...@alpinelinux.org> --- The Xen people have nagged me to get this patch upstream so I have come up with a rebased v2 patch after consulting with pm215 on IRC. Please consider include this. Changes v1->v2: - Check for sin() in addition to isnan() - Add comment on why we also check for timer_create - Use $LIBS and $libs_qga instead of $libm and $librt, based on feedback from pm215 on IRC - Do not remove the explicit add of -lm unless Haiku. This was due to http://www.mail-archive.com/qemu-devel@nongnu.org/msg102965.html I am not sure if this is valid, though. configure | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/configure b/configure index edf9da4..a351f9b 100755 --- a/configure +++ b/configure @@ -2624,17 +2624,48 @@ fi ########################################## +# Do we need libm +cat > $TMPC << EOF +#include <math.h> +int main(void) { return isnan(sin(0.0)); } +EOF +if compile_prog "" "" ; then + : +elif compile_prog "" "-lm" ; then + LIBS="-lm $LIBS" + libs_qga="-lm $libs_qga" +else + echo + echo "Error: libm check failed" + echo + exit 1 +fi + +########################################## # Do we need librt +# uClibc provides 2 versions of clock_gettime(), one with realtime +# support and one without. This means that the clock_gettime() don't +# need -lrt. We still need it for timer_create() so we check for this +# function in addition. cat > $TMPC <<EOF #include <signal.h> #include <time.h> -int main(void) { return clock_gettime(CLOCK_REALTIME, NULL); } +int main(void) { + timer_create(CLOCK_REALTIME, NULL, NULL); + return clock_gettime(CLOCK_REALTIME, NULL); +} EOF if compile_prog "" "" ; then : elif compile_prog "" "-lrt" ; then LIBS="-lrt $LIBS" + libs_qga="-lrt $libs_qga" +else + echo + echo "Error: librt check failed" + echo + exit 1 fi if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \ -- 1.7.11.4