Received: from eggs.gnu.org ([208.118.235.92]:44963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3TYG-0002Oy-E9 for qemu-devel@nongnu.org; Mon, 20 Aug 2012 11:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3TYB-00005b-GG for qemu-devel@nongnu.org; Mon, 20 Aug 2012 11:06:00 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:53804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3TYB-00005U-99 for qemu-devel@nongnu.org; Mon, 20 Aug 2012 11:05:55 -0400 Received: by eaac13 with SMTP id c13so1930923eaa.4 for ; Mon, 20 Aug 2012 08:05:54 -0700 (PDT) From: Natanael Copa Date: Mon, 20 Aug 2012 15:05:39 +0000 Message-Id: <1345475139-11545-1-git-send-email-ncopa@alpinelinux.org> In-Reply-To: References: Subject: [Qemu-devel] [PATCH v3] configure: properly check if -lrt and -lm is needed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: 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 --- Changes v2->v3: - Check if -lpthread is needed with static -lrt configure | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/configure b/configure index edf9da4..3d7fe69 100755 --- a/configure +++ b/configure @@ -2624,17 +2624,52 @@ 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) { 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" +# we might need -lpthread in case static linking +elif compile_prog "" "-lrt -lpthread" ; then + LIBS="-lrt -lpthread $LIBS" + libs_qga="-lrt -lpthread $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.12