[Spice-devel] [PATCH 2/2] do not link spice with libcacard

Christophe Fergeau cfergeau at redhat.com
Fri Oct 9 06:36:55 PDT 2015


Hi,

Thanks for the 2 patches!

On Fri, Oct 09, 2015 at 01:04:12AM +0300, Michael Tokarev wrote:
> None of the libcacard symbols are actually used by the library,
> only the header files, so there's no need to link with libcacard.
> 
> Signed-off-by: Michael Tokarev <mjt at tls.msk.ru>
> ---
>  spice-common/m4/spice-deps.m4 | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/spice-common/m4/spice-deps.m4 b/spice-common/m4/spice-deps.m4
> index 64e7093..532472a 100644
> --- a/spice-common/m4/spice-deps.m4
> +++ b/spice-common/m4/spice-deps.m4
> @@ -58,7 +58,8 @@ AC_DEFUN([SPICE_CHECK_SMARTCARD], [
>        fi
>      fi
>      AS_VAR_APPEND([$1_CFLAGS], [' $(SMARTCARD_CFLAGS)'])
> -    AS_VAR_APPEND([$1_LIBS], [' $(SMARTCARD_LIBS)'])
> +dnl only headers are used, not the lib itself
> +dnl    AS_VAR_APPEND([$1_LIBS], [' $(SMARTCARD_LIBS)'])

This one is not going to work, spice-common does not need to link
with libcacard, but spice-gtk which is using the same macro needs it.
Now that these SPICE_CHECK_xxx macros are used by
spice-common/spice/spice-gtk, this AS_VAR_APPEND() work they are doing
is a bit out of place as only spice-common needs it. I'd suggest
removing it from the macros, and generating
SPICE_COMMON_CFLAGS/SPICE_COMMON_LIBS manually from
spice-common/configure.ac as in the attached patch. This would also
remove the issue fixed by your first patch.

Christophe


From 93756c00c8a08ee043236eeb3ac58a00ecc10c88 Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau at redhat.com>
Date: Fri, 9 Oct 2015 15:07:27 +0200
Subject: [spice-common] build-sys: Rework SPICE_CHECK_* m4 macros

These macros were automatically appending the needed CFLAGS/LIBS to
variables passed as arguments. This is how spice-common uses them, but
now how spice-gtk/spice want to use them, and is making the macros more
complicated than they could (in particular this makes them use
AS_VAR_APPEND).
This  is also not flexible enough as spice-gtk uses libcacard libraries,
while spice-common does not need them. If SPICE_CHECK_SMARTCARD
unconditionnally libcacard libraries to the variable spice-common passes
it as an argument, we'll end up linking with an unneeded library.

This commit removes this automatic appending from the SPICE_CHECK_*
macros and moves it to spice-common as it's the only one which needs it.
---
 configure.ac     | 14 +++++-----
 m4/spice-deps.m4 | 81 ++++++++++++++++++++++----------------------------------
 2 files changed, 39 insertions(+), 56 deletions(-)

diff --git a/configure.ac b/configure.ac
index 98311bf..4694fc0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,12 +34,14 @@ AC_SUBST([CODE_GENERATOR_BASEDIR])
 
 SPICE_CHECK_PYTHON_MODULES()
 
-SPICE_CHECK_PIXMAN(SPICE_COMMON)
-SPICE_CHECK_SMARTCARD(SPICE_COMMON)
-SPICE_CHECK_CELT051(SPICE_COMMON)
-SPICE_CHECK_GLIB2(SPICE_COMMON)
-SPICE_CHECK_OPUS(SPICE_COMMON)
-SPICE_CHECK_OPENGL(SPICE_COMMON)
+SPICE_CHECK_PIXMAN
+SPICE_CHECK_SMARTCARD
+SPICE_CHECK_CELT051
+SPICE_CHECK_GLIB2
+SPICE_CHECK_OPUS
+SPICE_CHECK_OPENGL
+SPICE_COMMON_CFLAGS="$PIXMAN_CFLAGS $SMARTCARD_CFLAGS $CELT051_CFLAGS $GLIB2_CFLAGS $OPUS_CFLAGS $GL_CFLAGS"
+SPICE_COMMON_LIBS="$PIXMAN_LIBS $CELT051_LIBS $GLIB2_LIBS $OPUS_LIBS $GL_LIBS"
 AC_SUBST(SPICE_COMMON_CFLAGS)
 AC_SUBST(SPICE_COMMON_LIBS)
 
diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index e4b2c8d..f56073f 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -1,8 +1,3 @@
-# For autoconf < 2.63
-m4_ifndef([AS_VAR_APPEND],
-          AC_DEFUN([AS_VAR_APPEND], $1=$$1$2))
-
-
 # SPICE_CHECK_SYSDEPS()
 # ---------------------
 # Checks for header files and library functions needed by spice-common.
@@ -33,13 +28,13 @@ AC_DEFUN([SPICE_CHECK_SYSDEPS], [
 ])
 
 
-# SPICE_CHECK_SMARTCARD(PREFIX)
-# -----------------------------
+# SPICE_CHECK_SMARTCARD
+# ---------------------
 # Adds a --enable-smartcard switch in order to enable/disable smartcard
 # support, and checks if the needed libraries are available. If found, it will
-# append the flags to use to the $PREFIX_CFLAGS and $PREFIX_LIBS variables, and
+# return the flags to use in the SMARTCARD_CFLAGS and SMARTCARD_LIBS variables, and
 # it will define a USE_SMARTCARD preprocessor symbol.
-#------------------------------
+#----------------------
 AC_DEFUN([SPICE_CHECK_SMARTCARD], [
     AC_ARG_ENABLE([smartcard],
       AS_HELP_STRING([--enable-smartcard=@<:@yes/no/auto@:>@],
@@ -57,19 +52,17 @@ AC_DEFUN([SPICE_CHECK_SMARTCARD], [
         AC_DEFINE(USE_SMARTCARD, [1], [Define if supporting smartcard proxying])
       fi
     fi
-    AS_VAR_APPEND([$1_CFLAGS], [" $SMARTCARD_CFLAGS"])
-    AS_VAR_APPEND([$1_LIBS], [" $SMARTCARD_LIBS"])
 ])
 
 
-# SPICE_CHECK_CELT051(PREFIX)
-# ---------------------------
+# SPICE_CHECK_CELT051
+# -------------------
 # Adds a --disable-celt051 switch in order to enable/disable CELT 0.5.1
 # support, and checks if the needed libraries are available. If found, it will
-# append the flags to use to the $PREFIX_CFLAGS and $PREFIX_LIBS variables, and
+# return the flags to use in the CELT051_CFLAGS and CELT051_LIBS variables, and
 # it will define a HAVE_CELT051 preprocessor symbol as well as a HAVE_CELT051
 # Makefile conditional.
-#----------------------------
+#--------------------
 AC_DEFUN([SPICE_CHECK_CELT051], [
     AC_ARG_ENABLE([celt051],
         [  --disable-celt051       Disable celt051 audio codec (enabled by default)],,
@@ -83,17 +76,15 @@ AC_DEFUN([SPICE_CHECK_CELT051], [
 
     AM_CONDITIONAL([HAVE_CELT051], [test "x$have_celt051" = "xyes"])
     AM_COND_IF([HAVE_CELT051], AC_DEFINE([HAVE_CELT051], 1, [Define if we have celt051 codec]))
-    AS_VAR_APPEND([$1_CFLAGS], [" $CELT051_CFLAGS"])
-    AS_VAR_APPEND([$1_LIBS], [" $CELT051_LIBS"])
 ])
 
 
-# SPICE_CHECK_OPUS(PREFIX)
-# ------------------------
-# Check for the availability of Opus. If found, it will append the flags to use
-# to the $PREFIX_CFLAGS and $PREFIX_LIBS variables, and it will define a
+# SPICE_CHECK_OPUS
+# ----------------
+# Check for the availability of Opus. If found, it will return the flags to use
+# in the OPUS_CFLAGS and OPUS_LIBS variables, and it will define a
 # HAVE_OPUS preprocessor symbol as well as a HAVE_OPUS Makefile conditional.
-#-------------------------
+# ----------------
 AC_DEFUN([SPICE_CHECK_OPUS], [
     PKG_CHECK_MODULES([OPUS], [opus >= 0.9.14], [have_opus=yes], [have_opus=no])
 
@@ -101,19 +92,17 @@ AC_DEFUN([SPICE_CHECK_OPUS], [
     if test "x$have_opus" = "xyes" ; then
       AC_DEFINE([HAVE_OPUS], [1], [Define if we have OPUS])
     fi
-    AS_VAR_APPEND([$1_CFLAGS], [" $OPUS_CFLAGS"])
-    AS_VAR_APPEND([$1_LIBS], [" $OPUS_LIBS"])
 ])
 
 
-# SPICE_CHECK_OPENGL(PREFIX)
-# --------------------------
+# SPICE_CHECK_OPENGL
+# ------------------
 # Adds a --disable-opengl switch in order to enable/disable OpenGL
 # support, and checks if the needed libraries are available. If found, it will
-# append the flags to use to the $PREFIX_CFLAGS and $PREFIX_LIBS variables, and
+# return the flags to use in the GL_CFLAGS and GL_LIBS variables, and
 # it will define USE_OPENGL and GL_GLEXT_PROTOTYPES preprocessor symbol as well
 # as a SUPPORT_GL Makefile conditional.
-#---------------------------
+# ------------------
 AC_DEFUN([SPICE_CHECK_OPENGL], [
     AC_ARG_ENABLE([opengl],
         AS_HELP_STRING([--enable-opengl=@<:@yes/no@:>@],
@@ -132,32 +121,26 @@ AC_DEFUN([SPICE_CHECK_OPENGL], [
             AC_MSG_ERROR([GL libraries not available])
         fi
     fi
-    AS_VAR_APPEND([$1_CFLAGS], [" $GL_CFLAGS"])
-    AS_VAR_APPEND([$1_LIBS], [" $GL_LIBS"])
 ])
 
 
-# SPICE_CHECK_PIXMAN(PREFIX)
-# --------------------------
-# Check for the availability of pixman. If found, it will append the flags to
-# use to the $PREFIX_CFLAGS and $PREFIX_LIBS variables.
-#---------------------------
+# SPICE_CHECK_PIXMAN
+# ------------------
+# Check for the availability of pixman. If found, it will return the flags to
+# use in the PIXMAN_CFLAGS and PIXMAN_LIBS variables.
+#-------------------
 AC_DEFUN([SPICE_CHECK_PIXMAN], [
     PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.17.7)
-    AS_VAR_APPEND([$1_CFLAGS], [" $PIXMAN_CFLAGS"])
-    AS_VAR_APPEND([$1_LIBS], [" $PIXMAN_LIBS"])
 ])
 
 
-# SPICE_CHECK_GLIB2(PREFIX)
-# --------------------------
-# Check for the availability of glib2. If found, it will append the flags to
-# use to the $PREFIX_CFLAGS and $PREFIX_LIBS variables.
-#---------------------------
+# SPICE_CHECK_GLIB2
+# -----------------
+# Check for the availability of glib2. If found, it will return the flags to
+# use in the GLIB2_CFLAGS and GLIB2_LIBS variables.
+#------------------
 AC_DEFUN([SPICE_CHECK_GLIB2], [
     PKG_CHECK_MODULES(GLIB2, glib-2.0)
-    AS_VAR_APPEND([$1_CFLAGS], [" $GLIB2_CFLAGS"])
-    AS_VAR_APPEND([$1_LIBS], [" $GLIB2_LIBS"])
 ])
 
 # SPICE_CHECK_PYTHON_MODULES()
@@ -181,14 +164,14 @@ AC_DEFUN([SPICE_CHECK_PYTHON_MODULES], [
 ])
 
 
-# SPICE_CHECK_LZ4(PREFIX)
-# -----------------------------
+# SPICE_CHECK_LZ4
+# ---------------
 # Adds a --enable-lz4 switch in order to enable/disable LZ4 compression
 # support, and checks if the needed libraries are available. If found, it will
-# append the flags to use to the $PREFIX_CFLAGS and $PREFIX_LIBS variables, and
+# return the flags to use in the LZ4_CFLAGS and LZ4_LIBS variables, and
 # it will define a USE_LZ4 preprocessor symbol as well as a SUPPORT_LZ4 Makefile
 # conditional.
-#------------------------------
+# ---------------
 AC_DEFUN([SPICE_CHECK_LZ4], [
     AC_ARG_ENABLE([lz4],
       AS_HELP_STRING([--enable-lz4=@<:@yes/no@:>@],
@@ -200,6 +183,4 @@ AC_DEFUN([SPICE_CHECK_LZ4], [
       PKG_CHECK_MODULES([LZ4], [liblz4])
       AC_DEFINE(USE_LZ4, [1], [Define to build with lz4 support])
     fi
-    AS_VAR_APPEND([$1_CFLAGS], [" $LZ4_CFLAGS"])
-    AS_VAR_APPEND([$1_LIBS], [" $LZ4_LIBS"])
 ])
-- 
2.5.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20151009/e78afac4/attachment.sig>


More information about the Spice-devel mailing list