From 96b3e393d62fb56ca7e66cea92c14751ce35f561 Mon Sep 17 00:00:00 2001 Message-Id: <96b3e393d62fb56ca7e66cea92c14751ce35f561.1429739396.git.jen@redhat.com> In-Reply-To: <933ebfcd0e18f4ed2c68553cf4bc257652872678.1429739396.git.jen@redhat.com> References: <933ebfcd0e18f4ed2c68553cf4bc257652872678.1429739396.git.jen@redhat.com> From: John Snow Date: Mon, 6 Apr 2015 18:46:18 -0500 Subject: [CHANGE 05/11] configure: properly check if -lrt and -lm is needed To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: John Snow Message-id: <1428345980-16249-4-git-send-email-jsnow@redhat.com> Patchwork-id: 64721 O-Subject: [RHEL-6.7 qemu-kvm PATCH 3/5] configure: properly check if -lrt and -lm is needed Bugzilla: 1208605 RH-Acked-by: Fam Zheng RH-Acked-by: Kevin Wolf RH-Acked-by: Bandan Das From: Natanael Copa 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 Signed-off-by: Blue Swirl (cherry picked from commit 8bacde8d86a09699207d85d4bab06162aed18dc4) Signed-off-by: John Snow Signed-off-by: Jeff E. Nelson Conflicts: configure - Conflicts in context, - Existing -lrt probe sample program was slightly different. Signed-off-by: John Snow --- configure | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) Signed-off-by: Jeff E. Nelson --- configure | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/configure b/configure index d09786a..dfcb906 100755 --- a/configure +++ b/configure @@ -2079,17 +2079,44 @@ if compile_prog "" "" ; then fi ########################################## +# Do we need libm +cat > $TMPC << EOF +#include +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 < #include -int main(void) { clockid_t id; return clock_gettime(id, 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 +# we need pthread for static linking. use previous pthread test result +elif compile_prog "" "-lrt $pthread_lib" ; then LIBS="-lrt $LIBS" + libs_qga="-lrt $libs_qga" fi if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \ -- 2.1.0