[Spice-devel] [PATCH spice-common v2 1/2] build: Ensure we link with -lm if needed
Frediano Ziglio
fziglio at redhat.com
Mon Jun 4 14:59:47 UTC 2018
From: Christophe Fergeau <cfergeau at redhat.com>
lines.c uses hypot(), which is found in libm on some systems.
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
m4/spice-deps.m4 | 3 +++
meson.build | 10 ++++++++++
2 files changed, 13 insertions(+)
diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index 7c0cca4..3f6c056 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -64,6 +64,9 @@ AC_DEFUN([SPICE_CHECK_SYSDEPS], [
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_CHECK_FUNCS([dup2 floor inet_ntoa memmove memset pow sqrt])
+ AC_SEARCH_LIBS([hypot], [m], [], [
+ AC_MSG_ERROR([unable to find the hypot() function])
+ ])
])
diff --git a/meson.build b/meson.build
index de777db..4dd4610 100644
--- a/meson.build
+++ b/meson.build
@@ -87,6 +87,16 @@ foreach func : functions
endif
endforeach
+# check for hypot function
+#
+# Include math.h header to avoid problems with builtins.
+# In some systems the function is in libm.
+if not compiler.has_function('hypot', prefix : '#include <math.h>')
+ libm = compiler.find_library('m', required : false)
+ if compiler.has_function('hypot', prefix : '#include <math.h>', dependencies : libm)
+ spice_common_deps += libm
+ endif
+endif
#
# check for mandatory dependencies
--
2.17.1
More information about the Spice-devel
mailing list