configure: check if -lm is needed for libm
PATCH 1/1 configure: check if -lm is needed for libm
Some systems, like uClibc, needs -lm linker flag. Check and add if needed.
This fixes building on Alpine Linux.
Signed-off-by Natanael Copa <[email protected]>
--- Makefile | 4 ++-- configure | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -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
configure +19 -0
@@ -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
Signature · 1 line
1.7.7.4