[Spice-devel,spice-common,v3] spice-deps: Make LZ4 check depending on function

Submitted by Pavel Grunt on Nov. 25, 2016, 12:17 p.m.

Details

Message ID 20161125121749.11767-1-pgrunt@redhat.com
State Accepted
Commit 48da2c6654f37fcf02711aa86a08d6404dd6d215
Headers show
Series "spice-deps: Make LZ4 check depending on function" ( rev: 3 ) in Spice

Not browsing as part of any series.

Commit Message

Pavel Grunt Nov. 25, 2016, 12:17 p.m.
LZ4 changed versioning scheme from r131 to v1.7.3 making our configure
fail with (1.7.3 < 129).

Switch from version checking to checking that the necessary function
is available.
---
 m4/spice-deps.m4 | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index 54e0d82..3b22422 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -184,12 +184,26 @@  AC_DEFUN([SPICE_CHECK_LZ4], [
 
     have_lz4="no"
     if test "x$enable_lz4" != "xno"; then
-      PKG_CHECK_MODULES([LZ4], [liblz4 >= 129], [have_lz4="yes"], [have_lz4="no"])
+      # LZ4_compress_default is available in liblz4 >= 129, however liblz has changed
+      # versioning scheme making the check failing. Rather check for function definition
+      PKG_CHECK_MODULES([LZ4], [liblz4], [have_lz4="yes"], [have_lz4="no"])
 
       if test "x$have_lz4" = "xyes"; then
-        AC_DEFINE(USE_LZ4, [1], [Define to build with lz4 support])
-      elif test "x$enable_lz4" = "xyes"; then
-        AC_MSG_ERROR([lz4 support requested but liblz4 could not be found])
+        # It is necessary to set LIBS and CFLAGS before AC_CHECK_FUNC
+        old_LIBS="$LIBS"
+        old_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $LZ4_CFLAGS"
+        LIBS="$LIBS $LZ4_LIBS"
+
+        AC_CHECK_FUNC([LZ4_compress_default], [
+            AC_DEFINE(USE_LZ4, [1], [Define to build with lz4 support])],
+            [have_lz4="no"])
+
+        LIBS="$old_LIBS"
+        CFLAGS="$old_CFLAGS"
+      fi
+      if test "x$enable_lz4" = "xyes" && test "x$have_lz4" = "xno"; then
+        AC_MSG_ERROR([lz4 support requested but liblz4 >= 129 could not be found])
       fi
     fi
     AM_CONDITIONAL(HAVE_LZ4, test "x$have_lz4" = "xyes")

Comments

> 
> LZ4 changed versioning scheme from r131 to v1.7.3 making our configure
> fail with (1.7.3 < 129).
> 
> Switch from version checking to checking that the necessary function
> is available.
> ---
>  m4/spice-deps.m4 | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 

Acked-by: Frediano Ziglio <fziglio@redhat.com>

Frediano

> diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
> index 54e0d82..3b22422 100644
> --- a/m4/spice-deps.m4
> +++ b/m4/spice-deps.m4
> @@ -184,12 +184,26 @@ AC_DEFUN([SPICE_CHECK_LZ4], [
>  
>      have_lz4="no"
>      if test "x$enable_lz4" != "xno"; then
> -      PKG_CHECK_MODULES([LZ4], [liblz4 >= 129], [have_lz4="yes"],
> [have_lz4="no"])
> +      # LZ4_compress_default is available in liblz4 >= 129, however liblz
> has changed
> +      # versioning scheme making the check failing. Rather check for
> function definition
> +      PKG_CHECK_MODULES([LZ4], [liblz4], [have_lz4="yes"], [have_lz4="no"])
>  
>        if test "x$have_lz4" = "xyes"; then
> -        AC_DEFINE(USE_LZ4, [1], [Define to build with lz4 support])
> -      elif test "x$enable_lz4" = "xyes"; then
> -        AC_MSG_ERROR([lz4 support requested but liblz4 could not be found])
> +        # It is necessary to set LIBS and CFLAGS before AC_CHECK_FUNC
> +        old_LIBS="$LIBS"
> +        old_CFLAGS="$CFLAGS"
> +        CFLAGS="$CFLAGS $LZ4_CFLAGS"
> +        LIBS="$LIBS $LZ4_LIBS"
> +
> +        AC_CHECK_FUNC([LZ4_compress_default], [
> +            AC_DEFINE(USE_LZ4, [1], [Define to build with lz4 support])],
> +            [have_lz4="no"])
> +
> +        LIBS="$old_LIBS"
> +        CFLAGS="$old_CFLAGS"
> +      fi
> +      if test "x$enable_lz4" = "xyes" && test "x$have_lz4" = "xno"; then
> +        AC_MSG_ERROR([lz4 support requested but liblz4 >= 129 could not be
> found])
>        fi
>      fi
>      AM_CONDITIONAL(HAVE_LZ4, test "x$have_lz4" = "xyes")