[Spice-devel] [vdagent-win PATCH] build: Check we can link libpng statically

Frediano Ziglio fziglio at redhat.com
Wed Feb 27 10:52:05 UTC 2019


Catch the problem during configure instead of having to wait the
build to fail.
On Fedora try for instance to remove mingw64-zlib-static package,
the missing dependency won't be detected during configure.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 configure.ac   | 10 ++++++++--
 m4/pushvars.m4 | 15 +++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)
 create mode 100644 m4/pushvars.m4

diff --git a/configure.ac b/configure.ac
index fbcb8da..e5d4b2c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,8 +103,14 @@ dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
 
-PKG_CHECK_MODULES(LIBPNG, [libpng])
-PKG_CHECK_MODULES(ZLIB, [zlib])
+PKG_CHECK_MODULES_STATIC(LIBPNG, [libpng])
+PKG_CHECK_MODULES_STATIC(ZLIB, [zlib])
+ACX_SET_VAR(CFLAGS, "$CFLAGS $LIBPNG_CFLAGS -Wall",
+ACX_SET_VAR(LDFLAGS, "$LDFLAGS -static",
+ACX_SET_VAR(LIBS, "$LIBS $LIBPNG_LIBS",
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <png.h>]], [[
+    return !!png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL)
+  ]])], [], AC_MSG_ERROR([static libpng not found])))))
 
 dnl ---------------------------------------------------------------------------
 dnl - Makefiles, etc.
diff --git a/m4/pushvars.m4 b/m4/pushvars.m4
new file mode 100644
index 0000000..86a27fc
--- /dev/null
+++ b/m4/pushvars.m4
@@ -0,0 +1,15 @@
+AC_DEFUN([ACX_PUSH_VAR],
+[m4_pushdef([SAVE$1],save_$1[_]__line__)dnl
+SAVE$1="$$1"
+$1=[$2]])
+
+AC_DEFUN([ACX_POP_VAR],
+[$1="$SAVE$1"
+unset SAVE$1 dnl
+m4_popdef([SAVE$1])dnl
+])
+
+AC_DEFUN([ACX_SET_VAR],
+[ACX_PUSH_VAR($1, [$2])
+[$3]
+ACX_POP_VAR($1)])
-- 
2.20.1



More information about the Spice-devel mailing list