inserted the python wrappers build, I hope this won't be too unportable
* python/Makefile.am python/libxml.c configure.in Makefile.am:
inserted the python wrappers build, I hope this won't be too
unportable
Daniel
diff --git a/ChangeLog b/ChangeLog
index 40d43f1..ce2be47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Feb 1 00:40:48 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+ * python/Makefile.am python/libxml.c configure.in Makefile.am:
+ inserted the python wrappers build, I hope this won't be too
+ unportable
+
Thu Jan 31 21:27:37 CET 2002 Daniel Veillard <daniel@veillard.com>
* xpath.c: minor optimization
diff --git a/Makefile.am b/Makefile.am
index b81584a..9869997 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
#AUTOMAKE_OPTIONS=no-dependencies
-SUBDIRS = include . doc example
+SUBDIRS = include . doc example python
INCLUDES = -I@srcdir@/include -I$(top_builddir)/include @THREAD_CFLAGS@ @Z_CFLAGS@
diff --git a/configure.in b/configure.in
index 8fe4d48..491ba18 100644
--- a/configure.in
+++ b/configure.in
@@ -185,6 +185,49 @@
esac
+dnl
+dnl check for python
+dnl
+
+PYTHON=
+PYTHON_VERSION=
+PYTHON_INCLUDES=
+AC_ARG_WITH(python, [ --with-python[=DIR] Build Python bindings if found])
+if test "$with_python" != "no" ; then
+ if test -x "$with_python/bin/python"
+ then
+ echo Found python in $with_python/bin/python
+ PYTHON="$with_python/bin/python"
+ else
+ AC_PATH_PROG(PYTHON, python python2.2 python2.1 python2.0 python1.6 python1.5)
+ fi
+ if test "$PYTHON" != ""
+ then
+ PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[[0:3]]"`
+ echo Found Python version $PYTHON_VERSION
+ fi
+ if test "$PYTHON_VERSION" != ""
+ then
+ if test -r $with_python/include/python$PYTHON_VERSION/Python.h
+ then
+ PYTHON_INCLUDES=$with_python/include/python$PYTHON_VERSION
+ else
+ if test -r $prefix/include/python$PYTHON_VERSION/Python.h
+ then
+ PYTHON_INCLUDES=$prefix/include/python$PYTHON_VERSION
+ else
+ if test -r /usr/include/python$PYTHON_VERSION/Python.h
+ then
+ PYTHON_INCLUDES=/usr/include/python$PYTHON_VERSION
+ else
+ echo could not find python$PYTHON_VERSION/Python.h
+ fi
+ fi
+ fi
+ fi
+fi
+AM_CONDITIONAL(WITH_PYTHON, test "$PYTHON_INCLUDES" != "")
+
dnl
dnl Use buffers for content
@@ -482,9 +525,12 @@
AC_SUBST(HTML_DIR)
AC_SUBST(HAVE_ISNAN)
AC_SUBST(HAVE_ISINF)
+AC_SUBST(PYTHON)
+AC_SUBST(PYTHON_VERSION)
+AC_SUBST(PYTHON_INCLUDES)
AC_SUBST(M_LIBS)
AC_SUBST(RDL_LIBS)
-AC_OUTPUT(libxml.spec Makefile include/Makefile include/libxml/Makefile doc/Makefile example/Makefile include/libxml/xmlversion.h include/libxml/xmlwin32version.h xml2-config libxml-2.0.pc xml2Conf.sh)
+AC_OUTPUT(libxml.spec Makefile include/Makefile include/libxml/Makefile doc/Makefile example/Makefile python/Makefile include/libxml/xmlversion.h include/libxml/xmlwin32version.h xml2-config libxml-2.0.pc xml2Conf.sh)
diff --git a/python/Makefile.am b/python/Makefile.am
new file mode 100644
index 0000000..22fe8f8
--- /dev/null
+++ b/python/Makefile.am
@@ -0,0 +1,31 @@
+LIBS=-L../.libs -L..
+INCLUDES=-I$(PYTHON_INCLUDES) -I$(top_srcdir)/include
+SHCFLAGS=$(INCLUDES) -Wall -fPIC
+LINK_FLAGS= $(LIBS) -shared -lxml2
+if WITH_PYTHON
+all: _libxml.so
+
+_libxml.so: libxml.o libxml2-py.o
+ $(CC) $(LINK_FLAGS) libxml2-py.o libxml.o -o _libxml.so
+else
+all:
+endif
+
+libxml.o: libxml.c libxml2-export.c libxml_wrap.h
+ $(CC) $(SHCFLAGS) -c -o libxml.o $(srcdir)/libxml.c
+
+libxml2-py.o: libxml2-py.c libxml2-py.h libxml_wrap.h
+ $(CC) $(SHCFLAGS) -c -o libxml2-py.o $(srcdir)/libxml2-py.c
+
+GENERATE = generator.py
+API_DESC = $(top_srcdir)/doc/libxml2-api.xml
+GENERATED= $(srcdir)/libxml2class.py \
+ $(srcdir)/libxml2-export.c \
+ $(srcdir)/libxml2-py.c \
+ $(srcdir)/libxml2-py.h
+
+$(GENERATED): $(srcdir)/$(GENERATE) $(API_DESC)
+ cd $(srcdir) && $(PYTHON) $(GENERATE)
+
+clean:
+ rm -f $(GENERATED) *.o _libxml.so
diff --git a/python/libxml.c b/python/libxml.c
index 6964975..9bee70a 100644
--- a/python/libxml.c
+++ b/python/libxml.c
@@ -1,5 +1,7 @@
#include <Python.h>
+#include <libxml/xmlversion.h>
+#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "libxml_wrap.h"