Received: from eggs.gnu.org ([208.118.235.92]:40456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfBMR-0006tV-Rw for qemu-devel@nongnu.org; Thu, 14 Jun 2012 10:49:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfBMM-00014P-Pc for qemu-devel@nongnu.org; Thu, 14 Jun 2012 10:49:23 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:53932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfBMM-00013l-Gl for qemu-devel@nongnu.org; Thu, 14 Jun 2012 10:49:18 -0400 Received: by eekd41 with SMTP id d41so783200eek.4 for ; Thu, 14 Jun 2012 07:49:15 -0700 (PDT) From: Natanael Copa Date: Thu, 14 Jun 2012 14:51:26 +0000 Message-Id: <1339685486-8247-1-git-send-email-ncopa@alpinelinux.org> Subject: [Qemu-devel] [PATCH] 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(). Signed-off-by: Natanael Copa --- Makefile | 4 ++-- Makefile.target | 4 +--- configure | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 32550cb..9dfa01a 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ configure: ; $(call set-vpath, $(SRC_PATH)) -LIBS+=-lz $(LIBS_TOOLS) +LIBS+=-lz $(LIBS_TOOLS) $(LIBM) $(LIBRT) HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF) @@ -172,7 +172,7 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $@") qapi-dir := $(BUILD_DIR)/qapi-generated -qemu-ga$(EXESUF): LIBS = $(LIBS_QGA) +qemu-ga$(EXESUF): LIBS = $(LIBS_QGA) $(LIBRT) $(LIBM) qemu-ga$(EXESUF): QEMU_CFLAGS += -I $(qapi-dir) gen-out-type = $(subst .,-,$(suffix $@)) diff --git a/Makefile.target b/Makefile.target index 2907aad..d214d2c 100644 --- a/Makefile.target +++ b/Makefile.target @@ -34,9 +34,7 @@ PROGS+=$(QEMU_PROGW) endif STPFILES= -ifndef CONFIG_HAIKU -LIBS+=-lm -endif +LIBS+=$(LIBM) $(LIBRT) config-target.h: config-target.h-timestamp config-target.h-timestamp: config-target.mak diff --git a/configure b/configure index c2366ee..f925973 100755 --- a/configure +++ b/configure @@ -102,6 +102,8 @@ audio_win_int="" cc_i386=i386-pc-linux-gnu-gcc libs_qga="" debug_info="yes" +libm="" +librt="" target_list="" @@ -2568,17 +2570,42 @@ fi ########################################## +# Do we need libm +cat > $TMPC << EOF +#include +int main(void) { return isnan(0.0); } +EOF +if compile_prog "" "" ; then + libm= +elif compile_prog "" "-lm" ; then + libm="-lm" +else + echo + echo "Error: libm check failed" + echo + exit 1 +fi + +########################################## # Do we need librt 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" + librt="-lrt" +else + echo + echo "Error: librt check failed" + echo + exit 1 fi if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \ @@ -3442,6 +3469,8 @@ echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak echo "EXESUF=$EXESUF" >> $config_host_mak echo "LIBS_QGA+=$libs_qga" >> $config_host_mak echo "POD2MAN=$POD2MAN" >> $config_host_mak +echo "LIBM=$libm" >> $config_host_mak +echo "LIBRT=$librt" >> $config_host_mak # generate list of library paths for linker script -- 1.7.10.4