[spice-common] configure.ac: Check for needed python modules for git builds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After the patch adding support for python 3 to the code generator,
python-six is required when building from git. Since I got 2 different
reports of SPICE build failures right after introducing it, it's
probably better to check for the needed python modules from configure,
and exit with an error if they are missing.
This commit adds a --enable-python-checks configure flag for that
though, since we only want to do that when building from git. It assumes
that people running from git will be running autogen.sh, while people
building from tarballs will run configure.
---
 autogen.sh             |  2 +-
 configure.ac           |  2 ++
 m4/ax_python_module.m4 | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 m4/spice-deps.m4       | 19 +++++++++++++++++++
 4 files changed, 71 insertions(+), 1 deletion(-)
 create mode 100644 m4/ax_python_module.m4

diff --git a/autogen.sh b/autogen.sh
index e4ada55..0a69542 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -15,5 +15,5 @@ autoreconf --verbose --force --install
 
 cd "$olddir"
 if [ -z "$NOCONFIGURE" ]; then
-    "$srcdir"/configure --enable-maintainer-mode ${1+"$@"}
+    "$srcdir"/configure --enable-maintainer-mode --enable-python-checks ${1+"$@"}
 fi
diff --git a/configure.ac b/configure.ac
index 73102c0..3a8c0e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,6 +36,8 @@ AC_CONFIG_SUBDIRS([spice-protocol])
 PROTOCOL_CFLAGS='-I ${top_srcdir}/spice-protocol'
 AC_SUBST(PROTOCOL_CFLAGS)
 
+SPICE_CHECK_PYTHON_MODULES()
+
 SPICE_CHECK_PIXMAN(SPICE_COMMON)
 SPICE_CHECK_SMARTCARD(SPICE_COMMON)
 SPICE_CHECK_CELT051(SPICE_COMMON)
diff --git a/m4/ax_python_module.m4 b/m4/ax_python_module.m4
new file mode 100644
index 0000000..3afc404
--- /dev/null
+++ b/m4/ax_python_module.m4
@@ -0,0 +1,49 @@
+# ===========================================================================
+#     http://www.gnu.org/software/autoconf-archive/ax_python_module.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_PYTHON_MODULE(modname[, fatal])
+#
+# DESCRIPTION
+#
+#   Checks for Python module.
+#
+#   If fatal is non-empty then absence of a module will trigger an error.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Andrew Collier
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 6
+
+AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE])
+AC_DEFUN([AX_PYTHON_MODULE],[
+    if test -z $PYTHON;
+    then
+        PYTHON="python"
+    fi
+    PYTHON_NAME=`basename $PYTHON`
+    AC_MSG_CHECKING($PYTHON_NAME module: $1)
+	$PYTHON -c "import $1" 2>/dev/null
+	if test $? -eq 0;
+	then
+		AC_MSG_RESULT(yes)
+		eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
+	else
+		AC_MSG_RESULT(no)
+		eval AS_TR_CPP(HAVE_PYMOD_$1)=no
+		#
+		if test -n "$2"
+		then
+			AC_MSG_ERROR(failed to find required module $1)
+			exit 1
+		fi
+	fi
+])
diff --git a/m4/spice-deps.m4 b/m4/spice-deps.m4
index 2477dbc..600dd98 100644
--- a/m4/spice-deps.m4
+++ b/m4/spice-deps.m4
@@ -154,3 +154,22 @@ AC_DEFUN([SPICE_CHECK_GLIB2], [
     AS_VAR_APPEND([$1_CFLAGS], [" $GLIB2_CFLAGS"])
     AS_VAR_APPEND([$1_LIBS], [" $GLIB2_LIBS"])
 ])
+
+# SPICE_CHECK_PYTHON_MODULES()
+# --------------------------
+# Adds a --enable-python-checks configure flags as well as checks for the
+# availability of the python modules needed by the python scripts generating
+# C code from spice.proto. These checks are not needed when building from
+# tarballs so they are disabled by default.
+#---------------------------
+AC_DEFUN([SPICE_CHECK_PYTHON_MODULES], [
+    AC_ARG_ENABLE([python-checks],
+        AS_HELP_STRING([--enable-python-checks=@<:@yes/no@:>@],
+                       [Enable checks for Python modules needed to build from git @<:@default=no@:>@]),
+                       [],
+                       [enable_python_checks="no"])
+    if test "x$enable_python_checks" != "xno"; then
+        AX_PYTHON_MODULE([six], [1])
+        AX_PYTHON_MODULE([pyparsing], [1])
+    fi
+])
-- 
2.3.5

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]