[Spice-devel,common,03/11] build-sys: Add SPICE_CHECK_GSTREAMER_ELEMENTS()

Submitted by Francois Gouget on Nov. 3, 2015, 12:05 p.m.

Details

Message ID alpine.DEB.2.20.1511031253240.11833@amboise
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Francois Gouget Nov. 3, 2015, 12:05 p.m.
This makes it possible to warn the developer that the GStreamer elements
needed at runtime are missing and give him a hint on how to fix the
issue.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
---
 m4/spice-deps.m4 | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Patch hide | download patch | download mbox

diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index bb58d0f..e7190f6 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -216,14 +216,46 @@  AC_DEFUN([SPICE_CHECK_LZ4], [
 # ---------------------
 AC_DEFUN([SPICE_CHECK_GSTREAMER], [
     AS_VAR_PUSHDEF([have_gst],[have_]m4_tolower([$1]))dnl
+    AS_VAR_PUSHDEF([gst_inspect],[GST_INSPECT_$2])dnl
     PKG_CHECK_MODULES([$1], [$3],
         [have_gst="yes"
          AC_SUBST(AS_TR_SH([[$1]_CFLAGS]))
          AC_SUBST(AS_TR_SH([[$1]_LIBS]))
          AS_VAR_APPEND([SPICE_REQUIRES], [" $3"])
          AC_DEFINE(AS_TR_SH([HAVE_$1]), [1], [Define if supporting GStreamer $2])
+         AC_PATH_PROG(gst_inspect, gst-inspect-$2)
+         AS_IF([test "x$gst_inspect" = x],
+               SPICE_WARNING([Cannot verify that the required runtime GStreamer $2 elements are present because gst-inspect-$2 is missing]))
          $4],
         [have_gst="no"
          $5])
+    AS_VAR_POPDEF([gst_inspect])dnl
     AS_VAR_POPDEF([have_gst])dnl
 ])
+
+# SPICE_CHECK_GSTREAMER_ELEMENTS(gst-inspect, package, elements-to-check-for)
+# ---------------------
+# Checks that the specified GStreamer elements are installed. If not it
+# issues a warning and sets missing_gstreamer_elements.
+# ---------------------
+AC_DEFUN([SPICE_CHECK_GSTREAMER_ELEMENTS], [
+AS_IF([test "x$1" != x],
+      [missing=""
+       for element in $3
+       do
+           AS_VAR_PUSHDEF([cache_var],[spice_cv_prog_${1}_${element}])dnl
+           AC_CACHE_CHECK([for the $element GStreamer element], cache_var,
+                          [found=no
+                           "$1" $element >/dev/null 2>/dev/null && found=yes
+                           eval "cache_var=$found"])
+           AS_VAR_COPY(res, cache_var)
+           AS_IF([test "x$res" = "xno"], [missing="$missing $element"])
+           AS_VAR_POPDEF([cache_var])dnl
+       done
+       AS_IF([test "x$missing" != x],
+             [SPICE_WARNING([The$missing GStreamer element(s) are missing. You should be able to find them in the $2 package.])
+              missing_gstreamer_elements="yes"],
+             [test "x$missing_gstreamer_elements" = x],
+             [missing_gstreamer_elements="no"])
+      ])
+])

Comments

Hey,

On Tue, Nov 03, 2015 at 01:05:49PM +0100, Francois Gouget wrote:
> This makes it possible to warn the developer that the GStreamer elements
> needed at runtime are missing and give him a hint on how to fix the
> issue.
> 
> Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
> ---
>  m4/spice-deps.m4 | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
> index bb58d0f..e7190f6 100644
> --- a/m4/spice-deps.m4
> +++ b/m4/spice-deps.m4
> @@ -216,14 +216,46 @@ AC_DEFUN([SPICE_CHECK_LZ4], [
>  # ---------------------
>  AC_DEFUN([SPICE_CHECK_GSTREAMER], [
>      AS_VAR_PUSHDEF([have_gst],[have_]m4_tolower([$1]))dnl
> +    AS_VAR_PUSHDEF([gst_inspect],[GST_INSPECT_$2])dnl
>      PKG_CHECK_MODULES([$1], [$3],
>          [have_gst="yes"
>           AC_SUBST(AS_TR_SH([[$1]_CFLAGS]))
>           AC_SUBST(AS_TR_SH([[$1]_LIBS]))
>           AS_VAR_APPEND([SPICE_REQUIRES], [" $3"])
>           AC_DEFINE(AS_TR_SH([HAVE_$1]), [1], [Define if supporting GStreamer $2])
> +         AC_PATH_PROG(gst_inspect, gst-inspect-$2)
> +         AS_IF([test "x$gst_inspect" = x],
> +               SPICE_WARNING([Cannot verify that the required runtime GStreamer $2 elements are present because gst-inspect-$2 is missing]))
>           $4],
>          [have_gst="no"
>           $5])
> +    AS_VAR_POPDEF([gst_inspect])dnl
>      AS_VAR_POPDEF([have_gst])dnl
>  ])
> +
> +# SPICE_CHECK_GSTREAMER_ELEMENTS(gst-inspect, package, elements-to-check-for)
> +# ---------------------
> +# Checks that the specified GStreamer elements are installed. If not it
> +# issues a warning and sets missing_gstreamer_elements.
> +# ---------------------
> +AC_DEFUN([SPICE_CHECK_GSTREAMER_ELEMENTS], [
> +AS_IF([test "x$1" != x],
> +      [missing=""
> +       for element in $3
> +       do
> +           AS_VAR_PUSHDEF([cache_var],[spice_cv_prog_${1}_${element}])dnl
> +           AC_CACHE_CHECK([for the $element GStreamer element], cache_var,
> +                          [found=no
> +                           "$1" $element >/dev/null 2>/dev/null && found=yes
> +                           eval "cache_var=$found"])
> +           AS_VAR_COPY(res, cache_var)

On el6, this needs a fallback definition:
+m4_ifndef([AS_VAR_COPY],
+          [m4_define([AS_VAR_COPY],
+          [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])])

I can add that before pushing. Looks good otherwise (though my m4-foo is
weaker than what you are doing in this patch ;)

Christophe
On Wed, 4 Nov 2015, Christophe Fergeau wrote:
[...]
> > +AC_DEFUN([SPICE_CHECK_GSTREAMER_ELEMENTS], [
> > +AS_IF([test "x$1" != x],
> > +      [missing=""
> > +       for element in $3
> > +       do
> > +           AS_VAR_PUSHDEF([cache_var],[spice_cv_prog_${1}_${element}])dnl
> > +           AC_CACHE_CHECK([for the $element GStreamer element], cache_var,
> > +                          [found=no
> > +                           "$1" $element >/dev/null 2>/dev/null && found=yes
> > +                           eval "cache_var=$found"])
> > +           AS_VAR_COPY(res, cache_var)
> 
> On el6, this needs a fallback definition:
> +m4_ifndef([AS_VAR_COPY],
> +          [m4_define([AS_VAR_COPY],
> +          [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])])
> 
> I can add that before pushing. Looks good otherwise (though my m4-foo is
> weaker than what you are doing in this patch ;)

Thanks. That would be nice.