building: add python bindings
authorThibault Saunier <thibault.saunier@collabora.com>
Tue, 7 Jun 2011 23:18:27 +0000 (19:18 -0400)
committerThibault Saunier <thibault.saunier@collabora.com>
Wed, 10 Aug 2011 15:12:45 +0000 (17:12 +0200)
Makefile.am
acinclude.m4 [new file with mode: 0644]
bindings/makefile.am [new file with mode: 0644]
bindings/python/Makefile.am [new file with mode: 0644]
bindings/python/codegen/Makefile.am [new file with mode: 0644]
configure.ac

index f32edf7..c4d7ae0 100644 (file)
@@ -1,6 +1,6 @@
 DISTCHECK_CONFIGURE_FLAGS=--enable-gtk-doc
 
-SUBDIRS = ges tests tools common m4 pkgconfig docs
+SUBDIRS = ges tests tools common m4 pkgconfig docs bindings
 
 DIST_SUBDIRS = $(SUBDIRS)
 
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644 (file)
index 0000000..04a283b
--- /dev/null
@@ -0,0 +1,66 @@
+## this one is commonly used with AM_PATH_PYTHONDIR ...
+dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
+dnl Check if a module containing a given symbol is visible to python.
+AC_DEFUN([AM_CHECK_PYMOD],
+[AC_REQUIRE([AM_PATH_PYTHON])
+py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
+AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1)
+AC_CACHE_VAL(py_cv_mod_$py_mod_var, [
+ifelse([$2],[], [prog="
+import sys
+try:
+        import $1
+except ImportError:
+        sys.exit(1)
+except:
+        sys.exit(0)
+sys.exit(0)"], [prog="
+import $1
+$1.$2"])
+if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
+  then
+    eval "py_cv_mod_$py_mod_var=yes"
+  else
+    eval "py_cv_mod_$py_mod_var=no"
+  fi
+])
+py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"`
+if test "x$py_val" != xno; then
+  AC_MSG_RESULT(yes)
+  ifelse([$3], [],, [$3
+])dnl
+else
+  AC_MSG_RESULT(no)
+  ifelse([$4], [],, [$4
+])dnl
+fi
+])
+
+dnl a macro to check for ability to create python extensions
+dnl  AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
+dnl function also defines PYTHON_INCLUDES
+AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
+[AC_REQUIRE([AM_PATH_PYTHON])
+AC_MSG_CHECKING(for headers required to compile python extensions)
+dnl deduce PYTHON_INCLUDES
+py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
+py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
+if $PYTHON-config --help 2>/dev/null; then
+  PYTHON_INCLUDES=`$PYTHON-config --includes 2>/dev/null`
+else
+  PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
+  if test "$py_prefix" != "$py_exec_prefix"; then
+    PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
+  fi
+fi
+AC_SUBST(PYTHON_INCLUDES)
+dnl check if the headers exist:
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
+AC_TRY_CPP([#include <Python.h>],dnl
+[AC_MSG_RESULT(found)
+$1],dnl
+[AC_MSG_RESULT(not found)
+$2])
+CPPFLAGS="$save_CPPFLAGS"
+])
diff --git a/bindings/makefile.am b/bindings/makefile.am
new file mode 100644 (file)
index 0000000..96fcb3e
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = python
diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am
new file mode 100644 (file)
index 0000000..c731be0
--- /dev/null
@@ -0,0 +1,41 @@
+SUBDIRS = codegen
+pkgpyexecdir = $(pyexecdir)/gst-$(GST_MAJORMINOR)/gst
+
+# we install everything in pyexecdir; otherwise you end up with a mess for
+# multilib
+pygesdir = $(pkgpyexecdir)
+pyges_PYTHON =
+
+pygesexecdir = $(pkgpyexecdir)
+pygesexec_LTLIBRARIES = ges.la
+
+DEFS = $(srcdir)/ges-types.defs $(srcdir)/ges.defs
+defs_DATA = $(DEFS)
+defsdir = $(pkgdatadir)/$(GST_MAJORMINOR)/defs
+OVERRIDES = ges.override
+
+INCLUDES = -I$(top_srcdir) -I$(srcdir) $(PYTHON_INCLUDES)
+
+ges_la_CFLAGS = -I$(top_srcdir)\
+               $(PYGOBJECT_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) -Wno-write-strings
+ges_la_LDFLAGS = -export-symbols-regex "^(initges|_PyGObject_API).*" \
+       -module -avoid-version $(GST_PLUGIN_LDFLAGS)
+ges_la_LIBADD = $(top_builddir)/ges/libges-@GST_MAJORMINOR@.la \
+               $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
+               -lges-@GST_MAJORMINOR@ -lges-@GST_MAJORMINOR@ \
+               -lges-@GST_MAJORMINOR@ $(GST_LIBS) $(LIBM)
+ges_la_SOURCES = gesmodule.c
+nodist_ges_la_SOURCES = ges.c
+
+EXTRA_DIST = $(defs_DATA) $(OVERRIDES) arg-types.py
+
+CLEANFILES = ges.c
+
+.defs.c: 
+       ($(PYTHON) $(srcdir)/codegen/codegen.py \
+               --load-types $(srcdir)/codegen/argtypes.py \
+               --register $(srcdir)/ges-types.defs \
+               --override $(srcdir)/$*.override \
+               --prefix pyges $<) > gen-$*.c \
+       && cp gen-$*.c $*.c \
+       && rm -f gen-$*.c
diff --git a/bindings/python/codegen/Makefile.am b/bindings/python/codegen/Makefile.am
new file mode 100644 (file)
index 0000000..dd3eea0
--- /dev/null
@@ -0,0 +1,15 @@
+EXTRA_DIST = \
+       argtypes.py \
+       code-coverage.py \
+       codegen.py \
+       definitions.py \
+       defsparser.py \
+       docextract.py \
+       docgen.py \
+       h2def.py \
+       __init__.py \
+       mergedefs.py \
+       mkskel.py \
+       override.py \
+       reversewrapper.py \
+       scmexpr.py
index 4a415e4..cd17b89 100644 (file)
@@ -60,6 +60,7 @@ AS_AUTOTOOLS_ALTERNATE
 
 dnl Add parameters for aclocal
 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I common/m4")
+AC_CONFIG_MACRO_DIR([m4])
 
 dnl *** check for arguments to configure ***
 
@@ -117,6 +118,54 @@ GTK_DOC_CHECK([1.3])
 AS_PATH_PYTHON([2.1])
 AG_GST_PLUGIN_DOCS([1.3],[2.1])
 
+dnl check for python
+AM_PATH_PYTHON
+AC_MSG_CHECKING(for python >= 2.3)
+prog="
+import sys, string
+minver = (2,3,0,'final',0)
+if sys.version_info < minver:
+  sys.exit(1)
+sys.exit(0)"
+
+if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC
+then
+  HAVE_PYTHON=yes
+  AC_MSG_RESULT(okay)
+else
+  HAVE_PYTHON=no
+  AC_MSG_RESULT(no python)
+fi
+
+AM_CHECK_PYTHON_HEADERS([HAVE_PYTHON_HEADERS=yes],[HAVE_PYTHON_HEADERS=no])
+
+dnl check for pygobject (optional, used in the bindings)
+PYGOBJECT_REQ=2.11.2
+PKG_CHECK_MODULES(PYGOBJECT, pygobject-2.0 >= $PYGOBJECT_REQ,
+  [HAVE_PYGOBJECT="yes"], [HAVE_PYGOBJECT="no"])
+AC_SUBST(PYGOBJECT_CFLAGS)
+
+dnl check for gst-python
+PKG_CHECK_MODULES(PYGST, gst-python-0.10,
+  [HAVE_PYGST="yes"], [HAVE_PYGST="no"])
+
+if test "x$HAVE_PYGST" = "xyes"; then
+  PYGST_DEFSDIR=`pkg-config gst-python-0.10 --variable=defsdir`
+fi
+AC_SUBST(PYGST_DEFSDIR, $PYGST_DEFSDIR)
+
+if test \
+    "x$HAVE_PYTHON" = "xyes" -a \
+    "x$HAVE_PYTHON_HEADERS" = "xyes" -a \
+    "x$HAVE_PYGOBJECT" = "xyes" -a \
+    "x$HAVE_PYGST" = "xyes"; then
+  HAVE_PYTHON_BINDINGS="yes"
+else
+  HAVE_PYTHON_BINDINGS="no"
+fi
+
+AM_CONDITIONAL(WITH_PYTHON, [test "x$HAVE_PYTHON_BINDINGS" = "xyes"])
+
 dnl *** checks for libraries ***
 
 dnl check for libm, for sin() etc.
@@ -301,6 +350,9 @@ common/m4/Makefile
 gst-editing-services.spec
 m4/Makefile
 ges/Makefile
+bindings/makefile
+bindings/python/Makefile
+bindings/python/codegen/Makefile
 tests/Makefile
 tests/check/Makefile
 tests/examples/Makefile