[Xcb] first cut of python bindings for libxcb

Xavier Toth txtoth at gmail.com
Mon Mar 3 08:28:14 PST 2008


Changes to setting ACLOCAL_FLAGS in Makefile.am and a few other thigs
to help the examples.

diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/Makefile.am libxcb.new/bindings/Makefile.am
--- libxcb/bindings/Makefile.am	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/bindings/Makefile.am	2008-03-02 15:18:06.000000000 -0600
@@ -0,0 +1,3 @@
+if BUILD_PYTHON
+SUBDIRS=python
+endif
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/examples/hello.py
libxcb.new/bindings/python/examples/hello.py
--- libxcb/bindings/python/examples/hello.py	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/examples/hello.py	2008-03-03
09:40:23.000000000 -0600
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+
+# example helloworld.py
+
+import os
+import pygtk
+pygtk.require('2.0')
+import gtk
+import gtk.gdk
+
+import xcb
+import xcb.xselinux
+from gtk.gdk import *
+from gtk import *
+
+class HelloWorld:
+
+    # This is a callback function. The data arguments are ignored
+    # in this example. More on callbacks below.
+    def hello(self, widget, data=None):
+        print "Hello World"
+
+    def delete_event(self, widget, event, data=None):
+        # If you return FALSE in the "delete_event" signal handler,
+        # GTK will emit the "destroy" signal. Returning TRUE means
+        # you don't want the window to be destroyed.
+        # This is useful for popping up 'are you sure you want to quit?'
+        # type dialogs.
+        print "delete event occurred"
+
+        # Change FALSE to TRUE and the main window will not be destroyed
+        # with a "delete_event".
+        return False
+
+    def destroy(self, widget, data=None):
+        gtk.main_quit()
+
+    def __init__(self):
+        # create a new window
+        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+
+        # When the window is given the "delete_event" signal (this is given
+        # by the window manager, usually by the "close" option, or on the
+        # titlebar), we ask it to call the delete_event () function
+        # as defined above. The data passed to the callback
+        # function is NULL and is ignored in the callback function.
+        self.window.connect("delete_event", self.delete_event)
+
+        # Here we connect the "destroy" event to a signal handler.
+        # This event occurs when we call gtk_widget_destroy() on the window,
+        # or if we return FALSE in the "delete_event" callback.
+        self.window.connect("destroy", self.destroy)
+
+        # Sets the border width of the window.
+        self.window.set_border_width(10)
+
+        # Creates a new button with the label "Hello World".
+        self.button = gtk.Button("Hello World")
+
+        # When the button receives the "clicked" signal, it will call the
+        # function hello() passing it None as its argument.  The hello()
+        # function is defined above.
+#        self.button.connect("clicked", self.hello, None)
+
+        # This will cause the window to be destroyed by calling
+        # gtk_widget_destroy(window) when "clicked".  Again, the destroy
+        # signal could come from here, or the window manager.
+        self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
+
+        # This packs the button into the window (a GTK container).
+        self.window.add(self.button)
+
+        # The final step is to display this newly created widget.
+        self.button.show()
+
+        # and the window
+        self.window.show()
+
+#        display = gtk.gdk.x11_display_get_xdisplay
(gtk.gdk.display_get_default())
+#        window_id = gtk.gdk.x11_drawable_get_xid (GDK_DRAWABLE (self.window))
+
+
+
+    def main(self):
+        # All PyGTK applications must have a gtk.main(). Control ends here
+        # and waits for an event to occur (like a key press or mouse event).
+        try:
+            pid = os.fork()
+        except e:
+            print >>sys.stderr, _("Failed to fork new process: %d
(%s)") % (e.errno, e.strerror)
+            sys.exit(1)
+
+        if not pid:
+            gtk.main()
+        else:
+            screen_ptr = xcb.new_intp()
+            self.conn = xcb.xcb_connect(None,screen_ptr)
+            xcb.delete_intp(screen_ptr)
+            print "%x\n" % (self.window.window.xid)
+            win_cookie =
xcb.xselinux.xcb_selinux_get_window_context(self.conn,self.window.window.xid)
+            win_reply,error =
xcb.xselinux.xcb_selinux_get_window_context_reply(self.conn,
win_cookie)
+            if win_reply == None:
+                print "Error Code ", error
+            else:
+                print
xcb.xselinux.xcb_selinux_get_window_context_context(win_reply)
+
+# If the program is run directly or passed as an argument to the python
+# interpreter then create a HelloWorld instance and show it
+if __name__ == "__main__":
+    hello = HelloWorld()
+    hello.main()
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/examples/Makefile.am
libxcb.new/bindings/python/examples/Makefile.am
--- libxcb/bindings/python/examples/Makefile.am	1969-12-31
18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/examples/Makefile.am	2008-03-02
15:18:06.000000000 -0600
@@ -0,0 +1,3 @@
+EXTRA_DIST =                            \
+        hello.py                     \
+        swigtest.py
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/examples/swigtest.py
libxcb.new/bindings/python/examples/swigtest.py
--- libxcb/bindings/python/examples/swigtest.py	1969-12-31
18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/examples/swigtest.py	2008-03-03
09:22:47.000000000 -0600
@@ -0,0 +1,16 @@
+import xcb
+import xcb.xselinux
+
+screen_ptr = xcb.new_intp()
+conn = xcb.xcb_connect(None,screen_ptr)
+xcb.delete_intp(screen_ptr)
+win = xcb.xcb_generate_id(conn)
+print win
+print "%x" % (win)
+win_cookie = xcb.xselinux.xcb_selinux_get_window_context(conn,win)
+error_test = xcb.xcb_generic_error_t()
+
+win_reply,error =
xcb.xselinux.xcb_selinux_get_window_context_reply(conn, win_cookie)
+
+if win_reply == None:
+    print "Error Code ", error
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/__init__.py
libxcb.new/bindings/python/__init__.py
--- libxcb/bindings/python/__init__.py	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/__init__.py	2008-03-03 09:51:39.000000000 -0600
@@ -0,0 +1,7 @@
+"""XCB bindings
+
+The xcb module allows you to use xcb.
+
+"""
+import _xcb
+from xcb import *
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/Makefile.am
libxcb.new/bindings/python/Makefile.am
--- libxcb/bindings/python/Makefile.am	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/Makefile.am	2008-03-03 09:17:08.000000000 -0600
@@ -0,0 +1,56 @@
+SUBDIRS = # examples tests
+
+EXTRA_DIST =                \
+        README           \
+        __init__.py         \
+	xselinux.i	\
+        xcb.i
+
+CLEANFILES =                \
+        *.pyc               \
+        *.pyo               \
+        xcb.py             \
+        xcb_wrap.*	\
+        xselinux.py             \
+        xselinux_wrap.*
+
+DISTCLEANFILES =            \
+        README              \
+        xcb.i		\
+	xselinux.i
+
+
+if BUILD_PYTHON
+BUILT_SOURCES = xcb_wrap.c xselinux_wrap.c
+LIBXCB_CFLAGS =
+INCLUDES = -I$(top_srcdir)/src
+PYTHON_INCLUDES = -I/usr/include/python at PYTHON_VERSION@/
+
+pkgpython_xcbdir = $(pyexecdir)/xcb
+pkgpython_xcb_PYTHON =  __init__.py xcb.py
+pkgpython_xcb_LTLIBRARIES = _xcb.la
+nodist__xcb_la_SOURCES = xcb_wrap.c
+_xcb_la_CFLAGS = $(PYTHON_INCLUDES) $(LIBXCB_CFLAGS) $(INCLUDES)
+_xcb_la_LDFLAGS = -module -avoid-version
+_xcb_la_LIBADD = $(LIBXCB_LIBS) $(top_builddir)/src/.libs/libxcb.la
+
+if BUILD_SELINUX
+pkgpython_xcb_xselinuxdir = $(pyexecdir)/xcb/xselinux
+pkgpython_xcb_xselinux_PYTHON = xselinux/__init__.py xselinux.py
+pkgpython_xcb_xselinux_LTLIBRARIES = _xselinux.la
+nodist__xselinux_la_SOURCES = xselinux_wrap.c
+_xselinux_la_CFLAGS = $(PYTHON_INCLUDES) $(LIBXCB_CFLAGS) $(INCLUDES)
+_xselinux_la_LDFLAGS = -module -avoid-version
+_xselinux_la_LIBADD = $(LIBXCB_LIBS)
$(top_builddir)/src/.libs/libxcb-xselinux.la
+
+xselinux_wrap.c: xselinux.i
+	$(SWIG) -Wall $(SWIG_PYTHON_OPT) -I$(top_builddir)/src -o $@ $<
+endif
+
+xcb_wrap.c: xcb.i
+	$(SWIG) -Wall $(SWIG_PYTHON_OPT) -I$(top_builddir)/src -o $@ $<
+
+
+test:
+	$(MAKE) -C tests test
+endif
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/xcb.i libxcb.new/bindings/python/xcb.i
--- libxcb/bindings/python/xcb.i	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/xcb.i	2008-03-02 15:18:06.000000000 -0600
@@ -0,0 +1,23 @@
+/* File : xcb.i */
+%module xcb
+%include "cpointer.i"
+
+%{
+#include <xcbext.h>
+#include <xproto.h>
+%}
+/* Create some functions for working with "int *" */
+%pointer_functions(int, intp);
+
+%include xcb_typemaps.i
+
+%extend xcb_generic_error_t {
+   char *__str__() {
+       static char tmp[1024];
+       sprintf(tmp,"xcb_generic_error_t(%d)", $self->error_code);
+       return tmp;
+   }
+};
+
+%include xproto.h
+%include xcb.h
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/xcb_typemaps.i
libxcb.new/bindings/python/xcb_typemaps.i
--- libxcb/bindings/python/xcb_typemaps.i	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/xcb_typemaps.i	2008-03-02
15:18:06.000000000 -0600
@@ -0,0 +1,15 @@
+
+%typemap(in, numinputs=0) xcb_generic_error_t ** (xcb_generic_error_t
*temp=NULL) {
+        $1 = &temp;
+}
+
+%typemap(argout,noblock=1) xcb_generic_error_t ** {
+        if (*$1) {
+                Py_INCREF(Py_None);   	
+		$result = Py_BuildValue("(OO)",Py_None,SWIG_NewPointerObj(*$1,
$*1_descriptor, 0));
+        }
+        else {
+                Py_INCREF(Py_None);
+		$result =  Py_BuildValue("(OO)",$result, Py_None);
+        }
+}
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/xselinux/__init__.py
libxcb.new/bindings/python/xselinux/__init__.py
--- libxcb/bindings/python/xselinux/__init__.py	1969-12-31
18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/xselinux/__init__.py	2008-03-03
09:51:58.000000000 -0600
@@ -0,0 +1,8 @@
+"""XCB SELinux bindings
+
+The xcb xselinux module allows you to use xcb.
+
+"""
+import _xselinux
+from xselinux import *
+
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/bindings/python/xselinux.i
libxcb.new/bindings/python/xselinux.i
--- libxcb/bindings/python/xselinux.i	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/bindings/python/xselinux.i	2008-03-03 09:31:10.000000000 -0600
@@ -0,0 +1,14 @@
+/* File : xselinux.i */
+%module xselinux
+%{
+#include <xcbext.h>
+#include <xproto.h>
+#include <xselinux.h>
+%}
+%include xcb_typemaps.i
+
+typedef uint32_t xcb_window_t;
+typedef uint32_t xcb_visualid_t ;
+typedef long uint32_t;
+
+%include xselinux.h
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/configure.ac libxcb.new/configure.ac
--- libxcb/configure.ac	2008-03-03 10:04:32.000000000 -0600
+++ libxcb.new/configure.ac	2008-03-03 09:57:14.000000000 -0600
@@ -16,6 +16,7 @@
 AC_PROG_LIBTOOL
 AC_PROG_CC

+
 AC_PATH_PROG(XSLTPROC, xsltproc, no)
 if test "$XSLTPROC" = "no"; then
    AC_MSG_ERROR([XCB requires xsltproc.])
@@ -131,11 +132,23 @@
 AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--enable-xvmc], [Build XCB XvMC
Extension (default: yes)]), [BUILD_XVMC=$enableval], [BUILD_XVMC=yes])
 AM_CONDITIONAL(BUILD_XVMC, [test "x$BUILD_XVMC" = xyes])

+AC_ARG_ENABLE(python, AS_HELP_STRING([--enable-python], [Build XCB
Python wrappers (EXPERIMENTAL) (default: no)]),
[BUILD_PYTHON=$enableval], [BUILD_PYTHON=no])
+AM_CONDITIONAL(BUILD_PYTHON, [test "x$BUILD_PYTHON" = xyes])

-AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile
m4/Makefile bindings/Makefile bindings/python/Makefile])
 AC_CONFIG_FILES([xcb.pc xcb-xlib.pc xcb-composite.pc xcb-damage.pc
xcb-dpms.pc xcb-glx.pc xcb-randr.pc xcb-record.pc xcb-render.pc
xcb-res.pc xcb-screensaver.pc xcb-shape.pc xcb-shm.pc xcb-sync.pc
xcb-xevie.pc xcb-xf86dri.pc xcb-xfixes.pc xcb-xinerama.pc
xcb-xinput.pc xcb-xprint.pc xcb-xselinux.pc xcb-xtest.pc xcb-xv.pc
xcb-xvmc.pc])
 AC_CONFIG_FILES([doc/xcb.doxygen])

+dnl **************************************************
+dnl * optional python bindings
+dnl **************************************************
+
+if [ test "x$BUILD_PYTHON" = xyes ]; then
+   AM_PATH_PYTHON(2.5)
+   AC_PROG_SWIG(1.3.33)
+   SWIG_PYTHON
+fi
+
 AC_OUTPUT

 dnl Configuration output
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/m4/ac_pkg_swig.m4 libxcb.new/m4/ac_pkg_swig.m4
--- libxcb/m4/ac_pkg_swig.m4	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/m4/ac_pkg_swig.m4	2008-03-02 15:18:06.000000000 -0600
@@ -0,0 +1,155 @@
+dnl @synopsis AC_PROG_SWIG([major.minor.micro])
+dnl
+dnl This macro searches for a SWIG installation on your system. If
+dnl found you should call SWIG via $(SWIG). You can use the optional
+dnl first argument to check if the version of the available SWIG is
+dnl greater than or equal to the value of the argument. It should have
+dnl the format: N[.N[.N]] (N is a number between 0 and 999. Only the
+dnl first N is mandatory.)
+dnl
+dnl If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks
+dnl that the swig package is this version number or higher.
+dnl
+dnl In configure.in, use as:
+dnl
+dnl             AC_PROG_SWIG(1.3.17)
+dnl             SWIG_ENABLE_CXX
+dnl             SWIG_MULTI_MODULE_SUPPORT
+dnl             SWIG_PYTHON
+dnl
+dnl @category InstalledPackages
+dnl @author Sebastian Huber <sebastian-huber at web.de>
+dnl @author Alan W. Irwin <irwin at beluga.phys.uvic.ca>
+dnl @author Rafael Laboissiere <rafael at laboissiere.net>
+dnl @author Andrew Collier <abcollier at yahoo.com>
+dnl @version 2004-09-20
+dnl @license GPLWithACException
+
+AC_DEFUN([AC_PROG_SWIG],[
+        AC_PATH_PROG([SWIG],[swig])
+        if test -z "$SWIG" ; then
+                AC_MSG_WARN([cannot find 'swig' program. You should
look at http://www.swig.org])
+                SWIG='echo "Error: SWIG is not installed. You should
look at http://www.swig.org" ; false'
+        elif test -n "$1" ; then
+                AC_MSG_CHECKING([for SWIG version])
+                [swig_version=`$SWIG -version 2>&1 | grep 'SWIG
Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
+                AC_MSG_RESULT([$swig_version])
+                if test -n "$swig_version" ; then
+                        # Calculate the required version number components
+                        [required=$1]
+                        [required_major=`echo $required | sed 's/[^0-9].*//'`]
+                        if test -z "$required_major" ; then
+                                [required_major=0]
+                        fi
+                        [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
+                        [required_minor=`echo $required | sed 's/[^0-9].*//'`]
+                        if test -z "$required_minor" ; then
+                                [required_minor=0]
+                        fi
+                        [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
+                        [required_patch=`echo $required | sed 's/[^0-9].*//'`]
+                        if test -z "$required_patch" ; then
+                                [required_patch=0]
+                        fi
+                        # Calculate the available version number components
+                        [available=$swig_version]
+                        [available_major=`echo $available | sed
's/[^0-9].*//'`]
+                        if test -z "$available_major" ; then
+                                [available_major=0]
+                        fi
+                        [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
+                        [available_minor=`echo $available | sed
's/[^0-9].*//'`]
+                        if test -z "$available_minor" ; then
+                                [available_minor=0]
+                        fi
+                        [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
+                        [available_patch=`echo $available | sed
's/[^0-9].*//'`]
+                        if test -z "$available_patch" ; then
+                                [available_patch=0]
+                        fi
+                        if test $available_major -ne $required_major \
+                                -o $available_minor -ne $required_minor \
+                                -o $available_patch -lt $required_patch ; then
+                                AC_MSG_WARN([SWIG version >= $1 is
required.  You have $swig_version.  You should look at
http://www.swig.org])
+                                SWIG='echo "Error: SWIG version >= $1
is required.  You have '"$swig_version"'.  You should look at
http://www.swig.org" ; false'
+                        else
+                                AC_MSG_NOTICE([SWIG executable is '$SWIG'])
+                                SWIG_LIB=`$SWIG -swiglib`
+                                AC_MSG_NOTICE([SWIG library directory
is '$SWIG_LIB'])
+                        fi
+                else
+                        AC_MSG_WARN([cannot determine SWIG version])
+                        SWIG='echo "Error: Cannot determine SWIG
version.  You should look at http://www.swig.org" ; false'
+                fi
+        fi
+        AC_SUBST([SWIG_LIB])
+])
+
+# SWIG_ENABLE_CXX()
+#
+# Enable SWIG C++ support.  This affects all invocations of $(SWIG).
+AC_DEFUN([SWIG_ENABLE_CXX],[
+        AC_REQUIRE([AC_PROG_SWIG])
+        AC_REQUIRE([AC_PROG_CXX])
+        SWIG="$SWIG -c++"
+])
+
+# SWIG_MULTI_MODULE_SUPPORT()
+#
+# Enable support for multiple modules.  This effects all invocations
+# of $(SWIG).  You have to link all generated modules against the
+# appropriate SWIG runtime library.  If you want to build Python
+# modules for example, use the SWIG_PYTHON() macro and link the
+# modules against $(SWIG_PYTHON_LIBS).
+#
+AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[
+        AC_REQUIRE([AC_PROG_SWIG])
+        SWIG="$SWIG -noruntime"
+])
+
+# SWIG_PYTHON([use-shadow-classes = {no, yes}])
+#
+# Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS),
+# and $(SWIG_PYTHON_OPT) output variables.
+#
+# $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate
+# code for Python.  Shadow classes are enabled unless the value of the
+# optional first argument is exactly 'no'.  If you need multi module
+# support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use
+# $(SWIG_PYTHON_LIBS) to link against the appropriate library.  It
+# contains the SWIG Python runtime library that is needed by the type
+# check system for example.
+AC_DEFUN([SWIG_PYTHON],[
+        AC_REQUIRE([AC_PROG_SWIG])
+        AC_REQUIRE([AC_PYTHON_DEVEL])
+        test "x$1" != "xno" || swig_shadow=" -noproxy"
+        AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow])
+        AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS])
+])
+
+
+dnl @synopsis AC_LIB_WAD
+dnl
+dnl This macro searches for installed WAD library.
+dnl
+AC_DEFUN([AC_LIB_WAD],
+[
+        AC_REQUIRE([AC_PYTHON_DEVEL])
+        AC_ARG_ENABLE(wad,
+        AC_HELP_STRING([--enable-wad], [enable wad module]),
+        [
+                case "${enableval}" in
+                        no)     ;;
+                        *)      if test "x${enableval}" = xyes;
+                                then
+                                        check_wad="yes"
+                                fi ;;
+                esac
+        ], [])
+
+        if test -n "$check_wad";
+        then
+                AC_CHECK_LIB(wadpy, _init, [WADPY=-lwadpy], [],
$PYTHON_LDFLAGS $PYTHON_EXTRA_LIBS)
+                AC_SUBST(WADPY)
+        fi
+])
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/m4/ac_python_devel.m4 libxcb.new/m4/ac_python_devel.m4
--- libxcb/m4/ac_python_devel.m4	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/m4/ac_python_devel.m4	2008-03-02 15:18:06.000000000 -0600
@@ -0,0 +1,64 @@
+dnl @synopsis AC_PYTHON_DEVEL
+dnl
+dnl Checks for Python and tries to get the include path to 'Python.h'.
+dnl It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output
+dnl variable.
+dnl
+dnl @category InstalledPackages
+dnl @author Sebastian Huber <sebastian-huber at web.de>
+dnl @author Alan W. Irwin <irwin at beluga.phys.uvic.ca>
+dnl @author Rafael Laboissiere <laboissiere at psy.mpg.de>
+dnl @author Andrew Collier <colliera at nu.ac.za>
+dnl @version 2004-07-14
+dnl @license GPLWithACException
+
+AC_DEFUN([AC_PYTHON_DEVEL],[
+	#
+	# should allow for checking of python version here...
+	#
+	AC_REQUIRE([AM_PATH_PYTHON])
+
+	# Check for Python include path
+	AC_MSG_CHECKING([for Python include path])
+	python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
+	for i in "$python_path/include/python$PYTHON_VERSION/"
"$python_path/include/python/" "$python_path/" ; do
+		python_path=`find $i -type f -name Python.h -print | sed "1q"`
+		if test -n "$python_path" ; then
+			break
+		fi
+	done
+	python_path=`echo $python_path | sed "s,/Python.h$,,"`
+	AC_MSG_RESULT([$python_path])
+	if test -z "$python_path" ; then
+		AC_MSG_ERROR([cannot find Python include path])
+	fi
+	AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
+
+	# Check for Python library path
+	AC_MSG_CHECKING([for Python library path])
+	python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
+	for i in "$python_path/lib/python$PYTHON_VERSION/config/"
"$python_path/lib/python$PYTHON_VERSION/"
"$python_path/lib/python/config/" "$python_path/lib/python/"
"$python_path/" ; do
+		python_path=`find $i -type f -name libpython$PYTHON_VERSION.*
-print | sed "1q"`
+		if test -n "$python_path" ; then
+			break
+		fi
+	done
+	python_path=`echo $python_path | sed "s,/libpython.*$,,"`
+	AC_MSG_RESULT([$python_path])
+	if test -z "$python_path" ; then
+		AC_MSG_ERROR([cannot find Python library path])
+	fi
+	AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
+	#
+	python_site=`echo $python_path | sed "s/config/site-packages/"`
+	AC_SUBST([PYTHON_SITE_PKG],[$python_site])
+	#
+	# libraries which must be linked in when embedding
+	#
+	AC_MSG_CHECKING(python extra libraries)
+	PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
+                conf = distutils.sysconfig.get_config_var; \
+                print conf('LOCALMODLIBS')+' '+conf('LIBS')"
+	AC_MSG_RESULT($PYTHON_EXTRA_LIBS)`
+	AC_SUBST(PYTHON_EXTRA_LIBS)
+])
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/m4/Makefile.am libxcb.new/m4/Makefile.am
--- libxcb/m4/Makefile.am	1969-12-31 18:00:00.000000000 -0600
+++ libxcb.new/m4/Makefile.am	2008-03-02 15:18:06.000000000 -0600
@@ -0,0 +1 @@
+EXTRA_DIST = ac_python_devel.m4 ac_pkg_swig.m4 python.m4
diff -ruN --exclude=.git --exclude='*.pc' --exclude=Makefile
--exclude=Makefile.in --exclude=.deps --exclude=doc --exclude=src
libxcb/Makefile.am libxcb.new/Makefile.am
--- libxcb/Makefile.am	2008-03-03 10:04:32.000000000 -0600
+++ libxcb.new/Makefile.am	2008-03-03 09:59:26.000000000 -0600
@@ -1,5 +1,10 @@
 SUBDIRS=src tests doc

+if BUILD_PYTHON
+ACLOCAL_FLAGS = -I m4
+SUBDIRS += m4 bindings
+endif
+
 pkgconfigdir = $(libdir)/pkgconfig

 pkgconfig_DATA = \


On Mon, Mar 3, 2008 at 8:32 AM, Xavier Toth <txtoth at gmail.com> wrote:
> I added a --enable-python flag to the build. One curious thing about
>  the build that occurs even without this patch is that two compiles are
>  run for each source file. I noticed this mostly because the swig
>  generated wrapper code takes a while to compile :)
>
>
>  diff -ruN --exclude=.git --exclude='*.pc' xcb/libxcb/autogen.sh
>  xcb.new/libxcb/autogen.sh
>  --- xcb/libxcb/autogen.sh       2008-03-01 17:07:53.000000000 -0600
>  +++ xcb.new/libxcb/autogen.sh   2008-03-01 12:49:48.000000000 -0600
>  @@ -1,7 +1,7 @@
>   ORIGDIR=`pwd`
>   cd $srcdir
>
>  -autoreconf -v --install || exit 1
>  +env ACLOCAL="aclocal -I m4" autoreconf -v --install || exit 1
>   cd $ORIGDIR || exit $?
>
>   $srcdir/configure --enable-maintainer-mode "$@"
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/Makefile.am xcb.new/libxcb/bindings/Makefile.am
>  --- xcb/libxcb/bindings/Makefile.am     1969-12-31 18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/Makefile.am 2008-03-01 10:41:08.000000000 -0600
>  @@ -0,0 +1,3 @@
>  +if BUILD_PYTHON
>  +SUBDIRS=python
>  +endif
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/python/examples/hello.py
>  xcb.new/libxcb/bindings/python/examples/hello.py
>  --- xcb/libxcb/bindings/python/examples/hello.py        1969-12-31
>  18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/python/examples/hello.py    2008-03-01
>  17:02:04.000000000 -0600
>  @@ -0,0 +1,108 @@
>  +#!/usr/bin/env python
>  +
>  +# example helloworld.py
>  +
>  +import os
>  +import pygtk
>  +pygtk.require('2.0')
>  +import gtk
>  +import gtk.gdk
>  +
>  +import _xcb
>  +import _xselinux
>  +import xcb
>  +import xselinux
>  +from xcb import *
>  +from xselinux import *
>  +from _xcb import *
>  +from _xselinux import *
>  +from gtk.gdk import *
>  +from gtk import *
>  +
>  +class HelloWorld:
>  +
>  +    # This is a callback function. The data arguments are ignored
>  +    # in this example. More on callbacks below.
>  +    def hello(self, widget, data=None):
>  +        print "Hello World"
>  +
>  +    def delete_event(self, widget, event, data=None):
>  +        # If you return FALSE in the "delete_event" signal handler,
>  +        # GTK will emit the "destroy" signal. Returning TRUE means
>  +        # you don't want the window to be destroyed.
>  +        # This is useful for popping up 'are you sure you want to quit?'
>  +        # type dialogs.
>  +        print "delete event occurred"
>  +
>  +        # Change FALSE to TRUE and the main window will not be destroyed
>  +        # with a "delete_event".
>  +        return False
>  +
>  +    def destroy(self, widget, data=None):
>  +        print "destroy signal occurred"
>  +        gtk.main_quit()
>  +
>  +    def __init__(self):
>  +        # create a new window
>  +        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
>  +
>  +        # When the window is given the "delete_event" signal (this is given
>  +        # by the window manager, usually by the "close" option, or on the
>  +        # titlebar), we ask it to call the delete_event () function
>  +        # as defined above. The data passed to the callback
>  +        # function is NULL and is ignored in the callback function.
>  +        self.window.connect("delete_event", self.delete_event)
>  +
>  +        # Here we connect the "destroy" event to a signal handler.
>  +        # This event occurs when we call gtk_widget_destroy() on the window,
>  +        # or if we return FALSE in the "delete_event" callback.
>  +        self.window.connect("destroy", self.destroy)
>  +
>  +        # Sets the border width of the window.
>  +        self.window.set_border_width(10)
>  +
>  +        # Creates a new button with the label "Hello World".
>  +        self.button = gtk.Button("Hello World")
>  +
>  +        # When the button receives the "clicked" signal, it will call the
>  +        # function hello() passing it None as its argument.  The hello()
>  +        # function is defined above.
>  +        self.button.connect("clicked", self.hello, None)
>  +
>  +        # This will cause the window to be destroyed by calling
>  +        # gtk_widget_destroy(window) when "clicked".  Again, the destroy
>  +        # signal could come from here, or the window manager.
>  +        self.button.connect_object("clicked", gtk.Widget.destroy, self.window)
>  +
>  +        # This packs the button into the window (a GTK container).
>  +        self.window.add(self.button)
>  +
>  +        # The final step is to display this newly created widget.
>  +        self.button.show()
>  +
>  +        # and the window
>  +        self.window.show()
>  +
>  +        display = gtk.gdk.x11_display_get_xdisplay
>  (gtk.gdk.display_get_default())
>  +        window_id = gtk.gdk.x11_drawable_get_xid (GDK_DRAWABLE (self.window))
>  +
>  +        screen_ptr = new_intp()
>  +        self.conn = xcb_connect(None,screen_ptr)
>  +        delete_intp(screen_ptr)
>  +        print "%x\n" % (self.window.window.xid)
>  +        win_cookie =
>  xcb_selinux_get_window_context(self.conn,self.window.window.xid)
>  +        win_reply,error =
>  xcb_selinux_get_window_context_reply(self.conn, win_cookie)
>  +        if win_reply == None:
>  +            print "Error Code ", error
>  +
>  +
>  +    def main(self):
>  +        # All PyGTK applications must have a gtk.main(). Control ends here
>  +        # and waits for an event to occur (like a key press or mouse event).
>  +        gtk.main()
>  +
>  +# If the program is run directly or passed as an argument to the python
>  +# interpreter then create a HelloWorld instance and show it
>  +if __name__ == "__main__":
>  +    hello = HelloWorld()
>  +    hello.main()
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/python/examples/Makefile.am
>  xcb.new/libxcb/bindings/python/examples/Makefile.am
>  --- xcb/libxcb/bindings/python/examples/Makefile.am     1969-12-31
>  18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/python/examples/Makefile.am 2008-03-01
>  17:23:26.000000000 -0600
>  @@ -0,0 +1,3 @@
>  +EXTRA_DIST =                            \
>  +        hello.py                     \
>  +        swigtest.py
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/python/examples/swigtest.py
>  xcb.new/libxcb/bindings/python/examples/swigtest.py
>  --- xcb/libxcb/bindings/python/examples/swigtest.py     1969-12-31
>  18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/python/examples/swigtest.py 2008-03-01
>  17:01:55.000000000 -0600
>  @@ -0,0 +1,22 @@
>  +import _xcb
>  +import _xselinux
>  +import xcb
>  +import xselinux
>  +from xcb import *
>  +from xselinux import *
>  +from _xcb import *
>  +from _xselinux import *
>  +
>  +screen_ptr = new_intp()
>  +conn = xcb_connect(None,screen_ptr)
>  +delete_intp(screen_ptr)
>  +win = xcb_generate_id(conn)
>  +print win
>  +print "%x" % (win)
>  +win_cookie = xcb_selinux_get_window_context(conn,win)
>  +error_test = xcb_generic_error_t()
>  +
>  +win_reply,error = xcb_selinux_get_window_context_reply(conn, win_cookie)
>  +
>  +if win_reply == None:
>  +    print "Error Code ", error
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/python/__init__.py
>  xcb.new/libxcb/bindings/python/__init__.py
>  --- xcb/libxcb/bindings/python/__init__.py      1969-12-31 18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/python/__init__.py  2008-03-01
>  10:56:32.000000000 -0600
>  @@ -0,0 +1,10 @@
>  +"""XCB bindings
>  +
>  +The xcb module allows you to use xcb.
>  +
>  +"""
>  +
>  +from xcb import *
>  +from xselinux import *
>  +
>  +__all__ = []
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/python/Makefile.am
>  xcb.new/libxcb/bindings/python/Makefile.am
>  --- xcb/libxcb/bindings/python/Makefile.am      1969-12-31 18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/python/Makefile.am  2008-03-01
>  16:26:47.000000000 -0600
>  @@ -0,0 +1,59 @@
>  +SUBDIRS = # examples tests
>  +
>  +EXTRA_DIST =                \
>  +        README           \
>  +        __init__.py         \
>  +       xselinux.i      \
>  +        xcb.i
>  +
>  +CLEANFILES =                \
>  +        *.pyc               \
>  +        *.pyo               \
>  +        xcb.py             \
>  +        xcb_wrap.*     \
>  +        xselinux.py             \
>  +        xselinux_wrap.*
>  +
>  +DISTCLEANFILES =            \
>  +        README              \
>  +        xcb.i          \
>  +       xselinux.i
>  +
>  +
>  +if BUILD_PYTHON
>  +BUILT_SOURCES = xcb_wrap.c xselinux_wrap.c
>  +LIBXCB_CFLAGS =
>  +INCLUDES = -I$(top_srcdir)/src
>  +PYTHON_INCLUDES = -I/usr/include/python at PYTHON_VERSION@/
>  +
>  +xcbdir = $(pyexecdir)/xcb
>  +xcb_PYTHON =  __init__.py
>  +nodist_xcb_PYTHON = xcb.py
>  +lib_LTLIBRARIES = _xcb.la
>  +nodist__xcb_la_SOURCES = xcb_wrap.c
>  +#_xcb_la_SOURCES = xcb.i
>  +_xcb_la_CFLAGS = $(PYTHON_INCLUDES) $(LIBXCB_CFLAGS) $(INCLUDES)
>  +_xcb_la_LDFLAGS = -module -avoid-version
>  +_xcb_la_LIBADD = $(LIBXCB_LIBS) $(top_builddir)/src/.libs/libxcb.la
>  +
>  +if BUILD_SELINUX
>  +nodist_xcb_PYTHON += xselinux.py
>  +lib_LTLIBRARIES += _xselinux.la
>  +nodist__xselinux_la_SOURCES = xselinux_wrap.c
>  +#_xselinux_la_SOURCES = xselinux.i
>  +_xselinux_la_CFLAGS = $(PYTHON_INCLUDES) $(LIBXCB_CFLAGS) $(INCLUDES)
>  +_xselinux_la_LDFLAGS = -module -avoid-version
>  +_xselinux_la_LIBADD = $(LIBXCB_LIBS)
>  $(top_builddir)/src/.libs/libxcb-xselinux.la
>  +
>  +xselinux_wrap.c: xselinux.i
>  +       $(SWIG) -Wall $(SWIG_PYTHON_OPT) -I$(top_builddir)/src -o $@ $<
>  +endif
>  +
>  +xcb_wrap.c: xcb.i
>  +       $(SWIG) -Wall $(SWIG_PYTHON_OPT) -I$(top_builddir)/src -o $@ $<
>  +
>  +
>  +
>  +test:
>  +       $(MAKE) -C tests test
>  +endif
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/python/xcb.i xcb.new/libxcb/bindings/python/xcb.i
>  --- xcb/libxcb/bindings/python/xcb.i    1969-12-31 18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/python/xcb.i        2008-03-01 14:20:00.000000000 -0600
>  @@ -0,0 +1,23 @@
>  +/* File : xcb.i */
>  +%module xcb
>  +%include "cpointer.i"
>  +
>  +%{
>  +#include <xcbext.h>
>  +#include <xproto.h>
>  +%}
>  +/* Create some functions for working with "int *" */
>  +%pointer_functions(int, intp);
>  +
>  +%include xcb_typemaps.i
>  +
>  +%extend xcb_generic_error_t {
>  +   char *__str__() {
>  +       static char tmp[1024];
>  +       sprintf(tmp,"xcb_generic_error_t(%d)", $self->error_code);
>  +       return tmp;
>  +   }
>  +};
>  +
>  +%include xproto.h
>  +%include xcb.h
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/python/xcb_typemaps.i
>  xcb.new/libxcb/bindings/python/xcb_typemaps.i
>  --- xcb/libxcb/bindings/python/xcb_typemaps.i   1969-12-31
>  18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/python/xcb_typemaps.i       2008-03-01
>  10:57:58.000000000 -0600
>  @@ -0,0 +1,15 @@
>  +
>  +%typemap(in, numinputs=0) xcb_generic_error_t ** (xcb_generic_error_t
>  *temp=NULL) {
>  +        $1 = &temp;
>  +}
>  +
>  +%typemap(argout,noblock=1) xcb_generic_error_t ** {
>  +        if (*$1) {
>  +                Py_INCREF(Py_None);
>  +               $result = Py_BuildValue("(OO)",Py_None,SWIG_NewPointerObj(*$1,
>  $*1_descriptor, 0));
>  +        }
>  +        else {
>  +                Py_INCREF(Py_None);
>  +               $result =  Py_BuildValue("(OO)",$result, Py_None);
>  +        }
>  +}
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/bindings/python/xselinux.i
>  xcb.new/libxcb/bindings/python/xselinux.i
>  --- xcb/libxcb/bindings/python/xselinux.i       1969-12-31 18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/bindings/python/xselinux.i   2008-03-01
>  16:12:52.000000000 -0600
>  @@ -0,0 +1,14 @@
>  +/* File : xselinux.i */
>  +%module xselinux
>  +%{
>  +#include <xcbext.h>
>  +#include <xproto.h>
>  +#include <xselinux.h>
>  +%}
>  +%include xcb_typemaps.i
>  +
>  +typedef uint32_t xcb_window_t;
>  +typedef xcb_window_t xcb_visualid_t ;
>  +typedef long uint32_t;
>  +
>  +%include xselinux.h
>  diff -ruN --exclude=.git --exclude='*.pc' xcb/libxcb/configure.ac
>  xcb.new/libxcb/configure.ac
>  --- xcb/libxcb/configure.ac     2008-03-01 17:07:53.000000000 -0600
>  +++ xcb.new/libxcb/configure.ac 2008-03-01 14:35:36.000000000 -0600
>  @@ -131,11 +133,23 @@
>   AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--enable-xvmc], [Build XCB XvMC
>  Extension (default: yes)]), [BUILD_XVMC=$enableval], [BUILD_XVMC=yes])
>   AM_CONDITIONAL(BUILD_XVMC, [test "x$BUILD_XVMC" = xyes])
>
>  +AC_ARG_ENABLE(python, AS_HELP_STRING([--enable-python], [Build XCB
>  Python wrappers (EXPERIMENTAL) (default: no)]),
>  [BUILD_PYTHON=$enableval], [BUILD_PYTHON=no])
>  +AM_CONDITIONAL(BUILD_PYTHON, [test "x$BUILD_PYTHON" = xyes])
>
>  -AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile])
>  +AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile doc/Makefile
>  m4/Makefile bindings/Makefile bindings/python/Makefile])
>   AC_CONFIG_FILES([xcb.pc xcb-xlib.pc xcb-composite.pc xcb-damage.pc
>  xcb-dpms.pc xcb-glx.pc xcb-randr.pc xcb-record.pc xcb-render.pc
>  xcb-res.pc xcb-screensaver.pc xcb-shape.pc xcb-shm.pc xcb-sync.pc
>  xcb-xevie.pc xcb-xf86dri.pc xcb-xfixes.pc xcb-xinerama.pc
>  xcb-xinput.pc xcb-xprint.pc xcb-xselinux.pc xcb-xtest.pc xcb-xv.pc
>  xcb-xvmc.pc])
>   AC_CONFIG_FILES([doc/xcb.doxygen])
>
>  +dnl **************************************************
>  +dnl * optional python bindings
>  +dnl **************************************************
>  +
>  +if [ test "x$BUILD_PYTHON" = xyes ]; then
>  +   AM_PATH_PYTHON(2.5)
>  +   AC_PROG_SWIG(1.3.33)
>  +   SWIG_PYTHON
>  +fi
>  +
>   AC_OUTPUT
>
>   dnl Configuration output
>  diff -ruN --exclude=.git --exclude='*.pc' xcb/libxcb/m4/ac_pkg_swig.m4
>  xcb.new/libxcb/m4/ac_pkg_swig.m4
>  --- xcb/libxcb/m4/ac_pkg_swig.m4        1969-12-31 18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/m4/ac_pkg_swig.m4    2008-03-01 12:00:09.000000000 -0600
>  @@ -0,0 +1,155 @@
>  +dnl @synopsis AC_PROG_SWIG([major.minor.micro])
>  +dnl
>  +dnl This macro searches for a SWIG installation on your system. If
>  +dnl found you should call SWIG via $(SWIG). You can use the optional
>  +dnl first argument to check if the version of the available SWIG is
>  +dnl greater than or equal to the value of the argument. It should have
>  +dnl the format: N[.N[.N]] (N is a number between 0 and 999. Only the
>  +dnl first N is mandatory.)
>  +dnl
>  +dnl If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks
>  +dnl that the swig package is this version number or higher.
>  +dnl
>  +dnl In configure.in, use as:
>  +dnl
>  +dnl             AC_PROG_SWIG(1.3.17)
>  +dnl             SWIG_ENABLE_CXX
>  +dnl             SWIG_MULTI_MODULE_SUPPORT
>  +dnl             SWIG_PYTHON
>  +dnl
>  +dnl @category InstalledPackages
>  +dnl @author Sebastian Huber <sebastian-huber at web.de>
>  +dnl @author Alan W. Irwin <irwin at beluga.phys.uvic.ca>
>  +dnl @author Rafael Laboissiere <rafael at laboissiere.net>
>  +dnl @author Andrew Collier <abcollier at yahoo.com>
>  +dnl @version 2004-09-20
>  +dnl @license GPLWithACException
>  +
>  +AC_DEFUN([AC_PROG_SWIG],[
>  +        AC_PATH_PROG([SWIG],[swig])
>  +        if test -z "$SWIG" ; then
>  +                AC_MSG_WARN([cannot find 'swig' program. You should
>  look at http://www.swig.org])
>  +                SWIG='echo "Error: SWIG is not installed. You should
>  look at http://www.swig.org" ; false'
>  +        elif test -n "$1" ; then
>  +                AC_MSG_CHECKING([for SWIG version])
>  +                [swig_version=`$SWIG -version 2>&1 | grep 'SWIG
>  Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`]
>  +                AC_MSG_RESULT([$swig_version])
>  +                if test -n "$swig_version" ; then
>  +                        # Calculate the required version number components
>  +                        [required=$1]
>  +                        [required_major=`echo $required | sed 's/[^0-9].*//'`]
>  +                        if test -z "$required_major" ; then
>  +                                [required_major=0]
>  +                        fi
>  +                        [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
>  +                        [required_minor=`echo $required | sed 's/[^0-9].*//'`]
>  +                        if test -z "$required_minor" ; then
>  +                                [required_minor=0]
>  +                        fi
>  +                        [required=`echo $required | sed 's/[0-9]*[^0-9]//'`]
>  +                        [required_patch=`echo $required | sed 's/[^0-9].*//'`]
>  +                        if test -z "$required_patch" ; then
>  +                                [required_patch=0]
>  +                        fi
>  +                        # Calculate the available version number components
>  +                        [available=$swig_version]
>  +                        [available_major=`echo $available | sed
>  's/[^0-9].*//'`]
>  +                        if test -z "$available_major" ; then
>  +                                [available_major=0]
>  +                        fi
>  +                        [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
>  +                        [available_minor=`echo $available | sed
>  's/[^0-9].*//'`]
>  +                        if test -z "$available_minor" ; then
>  +                                [available_minor=0]
>  +                        fi
>  +                        [available=`echo $available | sed 's/[0-9]*[^0-9]//'`]
>  +                        [available_patch=`echo $available | sed
>  's/[^0-9].*//'`]
>  +                        if test -z "$available_patch" ; then
>  +                                [available_patch=0]
>  +                        fi
>  +                        if test $available_major -ne $required_major \
>  +                                -o $available_minor -ne $required_minor \
>  +                                -o $available_patch -lt $required_patch ; then
>  +                                AC_MSG_WARN([SWIG version >= $1 is
>  required.  You have $swig_version.  You should look at
>  http://www.swig.org])
>  +                                SWIG='echo "Error: SWIG version >= $1
>  is required.  You have '"$swig_version"'.  You should look at
>  http://www.swig.org" ; false'
>  +                        else
>  +                                AC_MSG_NOTICE([SWIG executable is '$SWIG'])
>  +                                SWIG_LIB=`$SWIG -swiglib`
>  +                                AC_MSG_NOTICE([SWIG library directory
>  is '$SWIG_LIB'])
>  +                        fi
>  +                else
>  +                        AC_MSG_WARN([cannot determine SWIG version])
>  +                        SWIG='echo "Error: Cannot determine SWIG
>  version.  You should look at http://www.swig.org" ; false'
>  +                fi
>  +        fi
>  +        AC_SUBST([SWIG_LIB])
>  +])
>  +
>  +# SWIG_ENABLE_CXX()
>  +#
>  +# Enable SWIG C++ support.  This affects all invocations of $(SWIG).
>  +AC_DEFUN([SWIG_ENABLE_CXX],[
>  +        AC_REQUIRE([AC_PROG_SWIG])
>  +        AC_REQUIRE([AC_PROG_CXX])
>  +        SWIG="$SWIG -c++"
>  +])
>  +
>  +# SWIG_MULTI_MODULE_SUPPORT()
>  +#
>  +# Enable support for multiple modules.  This effects all invocations
>  +# of $(SWIG).  You have to link all generated modules against the
>  +# appropriate SWIG runtime library.  If you want to build Python
>  +# modules for example, use the SWIG_PYTHON() macro and link the
>  +# modules against $(SWIG_PYTHON_LIBS).
>  +#
>  +AC_DEFUN([SWIG_MULTI_MODULE_SUPPORT],[
>  +        AC_REQUIRE([AC_PROG_SWIG])
>  +        SWIG="$SWIG -noruntime"
>  +])
>  +
>  +# SWIG_PYTHON([use-shadow-classes = {no, yes}])
>  +#
>  +# Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS),
>  +# and $(SWIG_PYTHON_OPT) output variables.
>  +#
>  +# $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate
>  +# code for Python.  Shadow classes are enabled unless the value of the
>  +# optional first argument is exactly 'no'.  If you need multi module
>  +# support (provided by the SWIG_MULTI_MODULE_SUPPORT() macro) use
>  +# $(SWIG_PYTHON_LIBS) to link against the appropriate library.  It
>  +# contains the SWIG Python runtime library that is needed by the type
>  +# check system for example.
>  +AC_DEFUN([SWIG_PYTHON],[
>  +        AC_REQUIRE([AC_PROG_SWIG])
>  +        AC_REQUIRE([AC_PYTHON_DEVEL])
>  +        test "x$1" != "xno" || swig_shadow=" -noproxy"
>  +        AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow])
>  +        AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS])
>  +])
>  +
>  +
>  +dnl @synopsis AC_LIB_WAD
>  +dnl
>  +dnl This macro searches for installed WAD library.
>  +dnl
>  +AC_DEFUN([AC_LIB_WAD],
>  +[
>  +        AC_REQUIRE([AC_PYTHON_DEVEL])
>  +        AC_ARG_ENABLE(wad,
>  +        AC_HELP_STRING([--enable-wad], [enable wad module]),
>  +        [
>  +                case "${enableval}" in
>  +                        no)     ;;
>  +                        *)      if test "x${enableval}" = xyes;
>  +                                then
>  +                                        check_wad="yes"
>  +                                fi ;;
>  +                esac
>  +        ], [])
>  +
>  +        if test -n "$check_wad";
>  +        then
>  +                AC_CHECK_LIB(wadpy, _init, [WADPY=-lwadpy], [],
>  $PYTHON_LDFLAGS $PYTHON_EXTRA_LIBS)
>  +                AC_SUBST(WADPY)
>  +        fi
>  +])
>  diff -ruN --exclude=.git --exclude='*.pc'
>  xcb/libxcb/m4/ac_python_devel.m4 xcb.new/libxcb/m4/ac_python_devel.m4
>  --- xcb/libxcb/m4/ac_python_devel.m4    1969-12-31 18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/m4/ac_python_devel.m4        2008-03-01 12:00:09.000000000 -0600
>  @@ -0,0 +1,64 @@
>  +dnl @synopsis AC_PYTHON_DEVEL
>  +dnl
>  +dnl Checks for Python and tries to get the include path to 'Python.h'.
>  +dnl It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) output
>  +dnl variable.
>  +dnl
>  +dnl @category InstalledPackages
>  +dnl @author Sebastian Huber <sebastian-huber at web.de>
>  +dnl @author Alan W. Irwin <irwin at beluga.phys.uvic.ca>
>  +dnl @author Rafael Laboissiere <laboissiere at psy.mpg.de>
>  +dnl @author Andrew Collier <colliera at nu.ac.za>
>  +dnl @version 2004-07-14
>  +dnl @license GPLWithACException
>  +
>  +AC_DEFUN([AC_PYTHON_DEVEL],[
>  +       #
>  +       # should allow for checking of python version here...
>  +       #
>  +       AC_REQUIRE([AM_PATH_PYTHON])
>  +
>  +       # Check for Python include path
>  +       AC_MSG_CHECKING([for Python include path])
>  +       python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
>  +       for i in "$python_path/include/python$PYTHON_VERSION/"
>  "$python_path/include/python/" "$python_path/" ; do
>  +               python_path=`find $i -type f -name Python.h -print | sed "1q"`
>  +               if test -n "$python_path" ; then
>  +                       break
>  +               fi
>  +       done
>  +       python_path=`echo $python_path | sed "s,/Python.h$,,"`
>  +       AC_MSG_RESULT([$python_path])
>  +       if test -z "$python_path" ; then
>  +               AC_MSG_ERROR([cannot find Python include path])
>  +       fi
>  +       AC_SUBST([PYTHON_CPPFLAGS],[-I$python_path])
>  +
>  +       # Check for Python library path
>  +       AC_MSG_CHECKING([for Python library path])
>  +       python_path=`echo $PYTHON | sed "s,/bin.*$,,"`
>  +       for i in "$python_path/lib/python$PYTHON_VERSION/config/"
>  "$python_path/lib/python$PYTHON_VERSION/"
>  "$python_path/lib/python/config/" "$python_path/lib/python/"
>  "$python_path/" ; do
>  +               python_path=`find $i -type f -name libpython$PYTHON_VERSION.*
>  -print | sed "1q"`
>  +               if test -n "$python_path" ; then
>  +                       break
>  +               fi
>  +       done
>  +       python_path=`echo $python_path | sed "s,/libpython.*$,,"`
>  +       AC_MSG_RESULT([$python_path])
>  +       if test -z "$python_path" ; then
>  +               AC_MSG_ERROR([cannot find Python library path])
>  +       fi
>  +       AC_SUBST([PYTHON_LDFLAGS],["-L$python_path -lpython$PYTHON_VERSION"])
>  +       #
>  +       python_site=`echo $python_path | sed "s/config/site-packages/"`
>  +       AC_SUBST([PYTHON_SITE_PKG],[$python_site])
>  +       #
>  +       # libraries which must be linked in when embedding
>  +       #
>  +       AC_MSG_CHECKING(python extra libraries)
>  +       PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
>  +                conf = distutils.sysconfig.get_config_var; \
>  +                print conf('LOCALMODLIBS')+' '+conf('LIBS')"
>  +       AC_MSG_RESULT($PYTHON_EXTRA_LIBS)`
>  +       AC_SUBST(PYTHON_EXTRA_LIBS)
>  +])
>  diff -ruN --exclude=.git --exclude='*.pc' xcb/libxcb/m4/Makefile.am
>  xcb.new/libxcb/m4/Makefile.am
>  --- xcb/libxcb/m4/Makefile.am   1969-12-31 18:00:00.000000000 -0600
>  +++ xcb.new/libxcb/m4/Makefile.am       2008-03-01 12:20:38.000000000 -0600
>  @@ -0,0 +1 @@
>  +EXTRA_DIST = ac_python_devel.m4 ac_pkg_swig.m4
>  diff -ruN --exclude=.git --exclude='*.pc' xcb/libxcb/Makefile.am
>  xcb.new/libxcb/Makefile.am
>  --- xcb/libxcb/Makefile.am      2008-03-01 17:07:53.000000000 -0600
>  +++ xcb.new/libxcb/Makefile.am  2008-03-01 14:40:17.000000000 -0600
>  @@ -1,4 +1,4 @@
>  -SUBDIRS=src tests doc
>  +SUBDIRS=src tests doc m4 bindings
>
>   pkgconfigdir = $(libdir)/pkgconfig
>


More information about the Xcb mailing list