qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-trivial] [PATCH] configure: check if -lm is needed for libm


From: Natanael Copa
Subject: [Qemu-trivial] [PATCH] configure: check if -lm is needed for libm
Date: Fri, 2 Dec 2011 09:45:47 +0000

Some systems, like uClibc, needs -lm linker flag. Check and add if
needed.

This fixes building on Alpine Linux.

Signed-off-by: Natanael Copa <address@hidden>
---
 Makefile  |    4 ++--
 configure |   19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 301c75e..f3a291a 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ configure: ;
 
 $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw)
 
-LIBS+=-lz $(LIBS_TOOLS)
+LIBS+=-lz $(LIBS_TOOLS) $(LIBM)
 
 ifdef BUILD_DOCS
 DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 
QMP/qmp-commands.txt
@@ -170,7 +170,7 @@ test-coroutine: test-coroutine.o qemu-timer-common.o 
async.o $(coroutine-obj-y)
 $(qapi-obj-y): $(GENERATED_HEADERS)
 qapi-dir := $(BUILD_DIR)/qapi-generated
 test-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS += -I 
$(qapi-dir)
-qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
+qemu-ga$(EXESUF): LIBS = $(LIBS_QGA) $(LIBM)
 
 $(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\
 $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
diff --git a/configure b/configure
index ac4840d..faa64bd 100755
--- a/configure
+++ b/configure
@@ -1287,6 +1287,24 @@ EOF
 fi
 
 ##########################################
+# libm check
+
+cat > $TMPC << EOF
+#include <math.h>
+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
+
+##########################################
 # zlib check
 
 if test "$zlib" != "no" ; then
@@ -3264,6 +3282,7 @@ echo "LIBS+=$LIBS" >> $config_host_mak
 echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 echo "LIBS_QGA+=$libs_qga" >> $config_host_mak
+echo "LIBM=$LIBM" >> $config_host_mak
 
 # generate list of library paths for linker script
 
-- 
1.7.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]