From patchwork Thu Aug 16 13:22:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Natanael Copa X-Patchwork-Id: 177989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 223212C009F for ; Thu, 16 Aug 2012 23:23:07 +1000 (EST) Received: from localhost ([::1]:40764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T202T-0007lG-7x for incoming@patchwork.ozlabs.org; Thu, 16 Aug 2012 09:23:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T202H-0007l3-8R for qemu-devel@nongnu.org; Thu, 16 Aug 2012 09:22:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T202B-0005Oy-7x for qemu-devel@nongnu.org; Thu, 16 Aug 2012 09:22:53 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:46273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T202B-0005Ol-0P for qemu-devel@nongnu.org; Thu, 16 Aug 2012 09:22:47 -0400 Received: by weyz53 with SMTP id z53so1719786wey.4 for ; Thu, 16 Aug 2012 06:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=MdH7gujr+gUCtpgPydrjPHpn2csrI4BYoi+PHa1pARs=; b=wZu/YFOBC4WlYSHGFmhYg5Hte1MMzZzitlXurz+NO6UUPAivqNBhldKOV5jnHBmlYD Hao0x2M1VxUTg0bzMNQys6gh4bwHsTMRItI1UEwtMIPhRQVIY7DhKIX1eFe8xrB8zOYN bYWCtdUHYvZGiPa0ArouelgX3iAXGJwF8xTNfA3ETOOYNyBNx2Cm5taf3uEA8zrlb1Gb 7jieWNT/v+PmukZaa01TdS8yf1d50LRf69XV4SpGtbchuXTY+EesDOwr+JRcXV9++5Zg 519k+PXPwpUdzhYOftpc4QPWkrtXsKB+aE1yD1T9qMksKQpp6wVv2mI//6nLHUv3ft4W Q/cA== Received: by 10.216.227.205 with SMTP id d55mr708305weq.23.1345123365593; Thu, 16 Aug 2012 06:22:45 -0700 (PDT) Received: from ncdev.alpinelinux.org (ncdev.alpinelinux.org. [91.220.88.21]) by mx.google.com with ESMTPS id ep14sm3948679wid.0.2012.08.16.06.22.45 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 16 Aug 2012 06:22:45 -0700 (PDT) From: Natanael Copa To: qemu-devel@nongnu.org Date: Thu, 16 Aug 2012 13:22:36 +0000 Message-Id: <1345123356-6673-1-git-send-email-ncopa@alpinelinux.org> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1339685486-8247-1-git-send-email-ncopa@alpinelinux.org> References: <1339685486-8247-1-git-send-email-ncopa@alpinelinux.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.82.173 Cc: Natanael Copa Subject: [Qemu-devel] [PATCH v2] configure: properly check if -lrt and -lm is needed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Juan Quintela --- 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 +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" +else + echo + echo "Error: librt check failed" + echo + exit 1 fi if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \