Rev 11998: Allow using system python. in file:///home/jelmer/bzr.samba/python/

Jelmer Vernooij jelmer at samba.org
Tue Apr 24 10:53:15 GMT 2007


At file:///home/jelmer/bzr.samba/python/

------------------------------------------------------------
revno: 11998
revision-id: jelmer at samba.org-20070424105253-27pda62b1kn6bwbj
parent: jelmer at samba.org-20070423231935-oh9d9hbudrs8jfdh
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: python
timestamp: Tue 2007-04-24 12:52:53 +0200
message:
  Allow using system python.
removed:
  source/lib/python/Modules/linuxaudiodev.c linuxaudiodev.c-20070423105804-3mrp9flhlt8pjj8v-398
modified:
  source/build/m4/public.m4      svn-v2:7274 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fbuild%2fm4%2fpublic.m4
  source/build/smb_build/makefile.pm svn-v2:3690 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fbuild%2fsmb_build%2fmakefile.pm
  source/lib/ldb/libldb.m4       svn-v2:18109 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2flib%2fldb%2flibldb.m4
  source/lib/python/config.m4    configure.in-20070423105804-3mrp9flhlt8pjj8v-11
  source/lib/python/config.mk    makefile.pre.in-20070423105804-3mrp9flhlt8pjj8v-5
  source/lib/tdb/libtdb.m4       svn-v2:18108 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2flib%2ftdb%2flibtdb.m4
  source/libcli/config.m4        svn-v2:15395 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2flibcli%2fconfig.m4
  source/scripting/swig/config.m4 svn-v2:14906 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fscripting%2fswig%2fconfig.m4
=== removed file 'source/lib/python/Modules/linuxaudiodev.c'
--- a/source/lib/python/Modules/linuxaudiodev.c	2007-04-23 11:03:09 +0000
+++ b/source/lib/python/Modules/linuxaudiodev.c	1970-01-01 00:00:00 +0000
@@ -1,502 +0,0 @@
-/* Hey Emacs, this is -*-C-*- 
- ******************************************************************************
- * linuxaudiodev.c -- Linux audio device for python.
- * 
- * Author          : Peter Bosch
- * Created On      : Thu Mar  2 21:10:33 2000
- * Status          : Unknown, Use with caution!
- * 
- * Unless other notices are present in any part of this file
- * explicitly claiming copyrights for other people and/or 
- * organizations, the contents of this file is fully copyright 
- * (C) 2000 Peter Bosch, all rights reserved.
- ******************************************************************************
- */
-
-#include "Python.h"
-#include "structmember.h"
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#else
-#define O_RDONLY 00
-#define O_WRONLY 01
-#endif
-
-
-#include <sys/ioctl.h>
-#if defined(linux)
-#include <linux/soundcard.h>
-
-#ifndef HAVE_STDINT_H
-typedef unsigned long uint32_t;
-#endif
-
-#elif defined(__FreeBSD__)
-#include <machine/soundcard.h>
-
-#ifndef SNDCTL_DSP_CHANNELS
-#define SNDCTL_DSP_CHANNELS SOUND_PCM_WRITE_CHANNELS
-#endif
-
-#endif
-
-typedef struct {
-    PyObject_HEAD
-    int		x_fd;		/* The open file */
-    int         x_mode;           /* file mode */
-    int		x_icount;	/* Input count */
-    int		x_ocount;	/* Output count */
-    uint32_t	x_afmts;	/* Audio formats supported by hardware*/
-} lad_t;
-
-/* XXX several format defined in soundcard.h are not supported,
-   including _NE (native endian) options and S32 options
-*/
-
-static struct {
-    int		a_bps;
-    uint32_t	a_fmt;
-    char       *a_name;
-} audio_types[] = {
-    {  8, 	AFMT_MU_LAW, "logarithmic mu-law 8-bit audio" },
-    {  8, 	AFMT_A_LAW,  "logarithmic A-law 8-bit audio" },
-    {  8,	AFMT_U8,     "linear unsigned 8-bit audio" },
-    {  8, 	AFMT_S8,     "linear signed 8-bit audio" },
-    { 16, 	AFMT_U16_BE, "linear unsigned 16-bit big-endian audio" },
-    { 16, 	AFMT_U16_LE, "linear unsigned 16-bit little-endian audio" },
-    { 16, 	AFMT_S16_BE, "linear signed 16-bit big-endian audio" },
-    { 16, 	AFMT_S16_LE, "linear signed 16-bit little-endian audio" },
-    { 16, 	AFMT_S16_NE, "linear signed 16-bit native-endian audio" },
-};
-
-static int n_audio_types = sizeof(audio_types) / sizeof(audio_types[0]);
-
-static PyTypeObject Ladtype;
-
-static PyObject *LinuxAudioError;
-
-static lad_t *
-newladobject(PyObject *arg)
-{
-    lad_t *xp;
-    int fd, afmts, imode;
-    char *basedev = NULL;
-    char *mode = NULL;
-
-    /* Two ways to call linuxaudiodev.open():
-         open(device, mode) (for consistency with builtin open())
-         open(mode)         (for backwards compatibility)
-       because the *first* argument is optional, parsing args is
-       a wee bit tricky. */
-    if (!PyArg_ParseTuple(arg, "s|s:open", &basedev, &mode))
-       return NULL;
-    if (mode == NULL) {                 /* only one arg supplied */
-       mode = basedev;
-       basedev = NULL;
-    }
-
-    if (strcmp(mode, "r") == 0)
-        imode = O_RDONLY;
-    else if (strcmp(mode, "w") == 0)
-        imode = O_WRONLY;
-    else {
-        PyErr_SetString(LinuxAudioError, "mode should be 'r' or 'w'");
-        return NULL;
-    }
-
-    /* Open the correct device.  The base device name comes from the
-     * AUDIODEV environment variable first, then /dev/dsp.  The
-     * control device tacks "ctl" onto the base device name.
-     * 
-     * Note that the only difference between /dev/audio and /dev/dsp
-     * is that the former uses logarithmic mu-law encoding and the
-     * latter uses 8-bit unsigned encoding.
-     */
-
-    if (basedev == NULL) {              /* called with one arg */
-       basedev = getenv("AUDIODEV");
-       if (basedev == NULL)             /* $AUDIODEV not set */
-          basedev = "/dev/dsp";
-    }
-
-    if ((fd = open(basedev, imode)) == -1) {
-        PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
-        return NULL;
-    }
-    if (imode == O_WRONLY && ioctl(fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) {
-        PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
-        return NULL;
-    }
-    if (ioctl(fd, SNDCTL_DSP_GETFMTS, &afmts) == -1) {
-        PyErr_SetFromErrnoWithFilename(LinuxAudioError, basedev);
-        return NULL;
-    }
-    /* Create and initialize the object */
-    if ((xp = PyObject_New(lad_t, &Ladtype)) == NULL) {
-        close(fd);
-        return NULL;
-    }
-    xp->x_fd = fd;
-    xp->x_mode = imode;
-    xp->x_icount = xp->x_ocount = 0;
-    xp->x_afmts  = afmts;
-    return xp;
-}
-
-static void
-lad_dealloc(lad_t *xp)
-{
-    /* if already closed, don't reclose it */
-    if (xp->x_fd != -1)
-	close(xp->x_fd);
-    PyObject_Del(xp);
-}
-
-static PyObject *
-lad_read(lad_t *self, PyObject *args)
-{
-    int size, count;
-    char *cp;
-    PyObject *rv;
-	
-    if (!PyArg_ParseTuple(args, "i:read", &size))
-        return NULL;
-    rv = PyString_FromStringAndSize(NULL, size);
-    if (rv == NULL)
-        return NULL;
-    cp = PyString_AS_STRING(rv);
-    if ((count = read(self->x_fd, cp, size)) < 0) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        Py_DECREF(rv);
-        return NULL;
-    }
-    self->x_icount += count;
-    _PyString_Resize(&rv, count);
-    return rv;
-}
-
-static PyObject *
-lad_write(lad_t *self, PyObject *args)
-{
-    char *cp;
-    int rv, size;
-    fd_set write_set_fds;
-    struct timeval tv;
-    int select_retval;
-    
-    if (!PyArg_ParseTuple(args, "s#:write", &cp, &size)) 
-	return NULL;
-
-    /* use select to wait for audio device to be available */
-    FD_ZERO(&write_set_fds);
-    FD_SET(self->x_fd, &write_set_fds);
-    tv.tv_sec = 4; /* timeout values */
-    tv.tv_usec = 0; 
-
-    while (size > 0) {
-      select_retval = select(self->x_fd+1, NULL, &write_set_fds, NULL, &tv);
-      tv.tv_sec = 1; tv.tv_usec = 0; /* willing to wait this long next time*/
-      if (select_retval) {
-        if ((rv = write(self->x_fd, cp, size)) == -1) {
-	  if (errno != EAGAIN) {
-	    PyErr_SetFromErrno(LinuxAudioError);
-	    return NULL;
-	  } else {
-	    errno = 0; /* EAGAIN: buffer is full, try again */
-	  }
-        } else {
-	  self->x_ocount += rv;
-	  size -= rv;
-	  cp += rv;
-	}
-      } else {
-	/* printf("Not able to write to linux audio device within %ld seconds\n", tv.tv_sec); */
-	PyErr_SetFromErrno(LinuxAudioError);
-	return NULL;
-      }
-    }
-    Py_INCREF(Py_None);
-    return Py_None;
-}
-
-static PyObject *
-lad_close(lad_t *self, PyObject *unused)
-{
-    if (self->x_fd >= 0) {
-        close(self->x_fd);
-        self->x_fd = -1;
-    }
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-lad_fileno(lad_t *self, PyObject *unused)
-{
-    return PyInt_FromLong(self->x_fd);
-}
-
-static PyObject *
-lad_setparameters(lad_t *self, PyObject *args)
-{
-    int rate, ssize, nchannels, n, fmt, emulate=0;
-
-    if (!PyArg_ParseTuple(args, "iiii|i:setparameters",
-                          &rate, &ssize, &nchannels, &fmt, &emulate))
-        return NULL;
-  
-    if (rate < 0) {
-	PyErr_Format(PyExc_ValueError, "expected rate >= 0, not %d",
-		     rate); 
-	return NULL;
-    }
-    if (ssize < 0) {
-	PyErr_Format(PyExc_ValueError, "expected sample size >= 0, not %d",
-		     ssize);
-	return NULL;
-    }
-    if (nchannels != 1 && nchannels != 2) {
-	PyErr_Format(PyExc_ValueError, "nchannels must be 1 or 2, not %d",
-		     nchannels);
-	return NULL;
-    }
-
-    for (n = 0; n < n_audio_types; n++)
-        if (fmt == audio_types[n].a_fmt)
-            break;
-    if (n == n_audio_types) {
-	PyErr_Format(PyExc_ValueError, "unknown audio encoding: %d", fmt);
-	return NULL;
-    }
-    if (audio_types[n].a_bps != ssize) {
-	PyErr_Format(PyExc_ValueError, 
-		     "for %s, expected sample size %d, not %d",
-		     audio_types[n].a_name, audio_types[n].a_bps, ssize);
-	return NULL;
-    }
-
-    if (emulate == 0) {
-	if ((self->x_afmts & audio_types[n].a_fmt) == 0) {
-	    PyErr_Format(PyExc_ValueError, 
-			 "%s format not supported by device",
-			 audio_types[n].a_name);
-	    return NULL;
-	}
-    }
-    if (ioctl(self->x_fd, SNDCTL_DSP_SETFMT, 
-	      &audio_types[n].a_fmt) == -1) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    if (ioctl(self->x_fd, SNDCTL_DSP_SPEED, &rate) == -1) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-
-    Py_INCREF(Py_None);
-    return Py_None;
-}
-
-static int
-_ssize(lad_t *self, int *nchannels, int *ssize)
-{
-    int fmt;
-
-    fmt = 0;
-    if (ioctl(self->x_fd, SNDCTL_DSP_SETFMT, &fmt) < 0) 
-        return -errno;
-
-    switch (fmt) {
-    case AFMT_MU_LAW:
-    case AFMT_A_LAW:
-    case AFMT_U8:
-    case AFMT_S8:
-        *ssize = sizeof(char);
-        break;
-    case AFMT_S16_LE:
-    case AFMT_S16_BE:
-    case AFMT_U16_LE:
-    case AFMT_U16_BE:
-        *ssize = sizeof(short);
-        break;
-    case AFMT_MPEG:
-    case AFMT_IMA_ADPCM:
-    default:
-        return -EOPNOTSUPP;
-    }
-    if (ioctl(self->x_fd, SNDCTL_DSP_CHANNELS, nchannels) < 0)
-        return -errno;
-    return 0;
-}
-
-
-/* bufsize returns the size of the hardware audio buffer in number 
-   of samples */
-static PyObject *
-lad_bufsize(lad_t *self, PyObject *unused)
-{
-    audio_buf_info ai;
-    int nchannels=0, ssize=0;
-
-    if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize));
-}
-
-/* obufcount returns the number of samples that are available in the 
-   hardware for playing */
-static PyObject *
-lad_obufcount(lad_t *self, PyObject *unused)
-{
-    audio_buf_info ai;
-    int nchannels=0, ssize=0;
-
-    if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) / 
-                          (ssize * nchannels));
-}
-
-/* obufcount returns the number of samples that can be played without
-   blocking */
-static PyObject *
-lad_obuffree(lad_t *self, PyObject *unused)
-{
-    audio_buf_info ai;
-    int nchannels=0, ssize=0;
-
-    if (_ssize(self, &nchannels, &ssize) < 0 || !ssize || !nchannels) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    if (ioctl(self->x_fd, SNDCTL_DSP_GETOSPACE, &ai) < 0) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    return PyInt_FromLong(ai.bytes / (ssize * nchannels));
-}
-
-/* Flush the device */
-static PyObject *
-lad_flush(lad_t *self, PyObject *unused)
-{
-    if (ioctl(self->x_fd, SNDCTL_DSP_SYNC, NULL) == -1) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    Py_RETURN_NONE;
-}
-
-static PyObject *
-lad_getptr(lad_t *self, PyObject *unused)
-{
-    count_info info;
-    int req;
-
-    if (self->x_mode == O_RDONLY)
-	req = SNDCTL_DSP_GETIPTR;
-    else
-	req = SNDCTL_DSP_GETOPTR;
-    if (ioctl(self->x_fd, req, &info) == -1) {
-        PyErr_SetFromErrno(LinuxAudioError);
-        return NULL;
-    }
-    return Py_BuildValue("iii", info.bytes, info.blocks, info.ptr);
-}
-
-static PyMethodDef lad_methods[] = {
-    { "read",		(PyCFunction)lad_read, METH_VARARGS },
-    { "write",		(PyCFunction)lad_write, METH_VARARGS },
-    { "setparameters",	(PyCFunction)lad_setparameters, METH_VARARGS },
-    { "bufsize",	(PyCFunction)lad_bufsize, METH_VARARGS },
-    { "obufcount",	(PyCFunction)lad_obufcount, METH_NOARGS },
-    { "obuffree",	(PyCFunction)lad_obuffree, METH_NOARGS },
-    { "flush",		(PyCFunction)lad_flush, METH_NOARGS },
-    { "close",		(PyCFunction)lad_close, METH_NOARGS },
-    { "fileno",     	(PyCFunction)lad_fileno, METH_NOARGS },
-    { "getptr",         (PyCFunction)lad_getptr, METH_NOARGS },
-    { NULL,		NULL}		/* sentinel */
-};
-
-static PyObject *
-lad_getattr(lad_t *xp, char *name)
-{
-    return Py_FindMethod(lad_methods, (PyObject *)xp, name);
-}
-
-static PyTypeObject Ladtype = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,				/*ob_size*/
-    "linuxaudiodev.linux_audio_device", /*tp_name*/
-    sizeof(lad_t),		/*tp_size*/
-    0,				/*tp_itemsize*/
-    /* methods */
-    (destructor)lad_dealloc,	/*tp_dealloc*/
-    0,				/*tp_print*/
-    (getattrfunc)lad_getattr,	/*tp_getattr*/
-    0,				/*tp_setattr*/
-    0,				/*tp_compare*/
-    0,				/*tp_repr*/
-};
-
-static PyObject *
-ladopen(PyObject *self, PyObject *args)
-{
-    return (PyObject *)newladobject(args);
-}
-
-static PyMethodDef linuxaudiodev_methods[] = {
-    { "open", ladopen, METH_VARARGS },
-    { 0, 0 },
-};
-
-void
-initlinuxaudiodev(void)
-{
-    PyObject *m;
-  
-    m = Py_InitModule("linuxaudiodev", linuxaudiodev_methods);
-    if (m == NULL)
-	return;
-
-    LinuxAudioError = PyErr_NewException("linuxaudiodev.error", NULL, NULL);
-    if (LinuxAudioError)
-	PyModule_AddObject(m, "error", LinuxAudioError);
-
-    if (PyModule_AddIntConstant(m, "AFMT_MU_LAW", (long)AFMT_MU_LAW) == -1)
-	return;
-    if (PyModule_AddIntConstant(m, "AFMT_A_LAW", (long)AFMT_A_LAW) == -1)
-	return;
-    if (PyModule_AddIntConstant(m, "AFMT_U8", (long)AFMT_U8) == -1)
-	return;
-    if (PyModule_AddIntConstant(m, "AFMT_S8", (long)AFMT_S8) == -1)
-	return;
-    if (PyModule_AddIntConstant(m, "AFMT_U16_BE", (long)AFMT_U16_BE) == -1)
-	return;
-    if (PyModule_AddIntConstant(m, "AFMT_U16_LE", (long)AFMT_U16_LE) == -1)
-	return;
-    if (PyModule_AddIntConstant(m, "AFMT_S16_BE", (long)AFMT_S16_BE) == -1)
-	return;
-    if (PyModule_AddIntConstant(m, "AFMT_S16_LE", (long)AFMT_S16_LE) == -1)
-	return;
-    if (PyModule_AddIntConstant(m, "AFMT_S16_NE", (long)AFMT_S16_NE) == -1)
-	return;
-
-    return;
-}

=== modified file 'source/build/m4/public.m4'
--- a/source/build/m4/public.m4	2006-05-13 19:57:09 +0000
+++ b/source/build/m4/public.m4	2007-04-24 10:52:53 +0000
@@ -4,7 +4,7 @@
 dnl Copyright (C) 2004-2005 Jelmer Vernooij
 dnl Published under the GPL
 dnl
-dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems)
+dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems,cflags)
 dnl
 dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name)
 dnl

=== modified file 'source/build/smb_build/makefile.pm'
--- a/source/build/smb_build/makefile.pm	2007-04-22 10:33:59 +0000
+++ b/source/build/smb_build/makefile.pm	2007-04-24 10:52:53 +0000
@@ -179,6 +179,7 @@
 SHELL=$self->{config}->{SHELL}
 
 PERL=$self->{config}->{PERL}
+PYTHON=$self->{config}->{PYTHON}
 
 CPP=$self->{config}->{CPP}
 CPPFLAGS=$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $self->{config}->{CPPFLAGS}

=== modified file 'source/lib/ldb/libldb.m4'
--- a/source/lib/ldb/libldb.m4	2006-12-15 17:54:47 +0000
+++ b/source/lib/ldb/libldb.m4	2007-04-24 10:52:53 +0000
@@ -6,34 +6,4 @@
 	SMB_ENABLE(ldb_sqlite3, YES)
 fi
 
-AC_MSG_CHECKING([for Python])
-
-PYTHON=
- 
-AC_ARG_WITH(python,
-[  --with-python=PYTHONNAME  build Python libraries],
-[ case "${withval-python}" in
-  yes)
-        PYTHON=python
-        ;;
-  no)
-        PYTHON=
-        ;;
-  *)
-        PYTHON=${withval-python}
-        ;;
-  esac ])
-
-if test x"$PYTHON" != "x"; then
-	incdir=`python -c 'import sys; print "%s/include/python%d.%d" % (sys.prefix, sys.version_info[[0]], sys.version_info[[1]])'`
-	CPPFLAGS="$CPPFLAGS -I $incdir"
-fi
-
-if test x"$PYTHON" != "x"; then
-	AC_MSG_RESULT([${withval-python}])
-else
-	AC_MSG_RESULT(no)
-	SMB_ENABLE(swig_ldb, NO)
-fi
-
-AC_SUBST(PYTHON)
+SMB_ENABLE(swig_ldb, NO)

=== modified file 'source/lib/python/config.m4'
--- a/source/lib/python/config.m4	2007-04-23 23:19:35 +0000
+++ b/source/lib/python/config.m4	2007-04-24 10:52:53 +0000
@@ -1,4 +1,66 @@
-dnl Process this file with autoconf 2.0 or later to make a configure script.
+case $INTERNAL_PYTHON in
+	yes|no|auto) ;;
+	*) INTERNAL_PYTHON=auto ;;
+esac
+AC_ARG_VAR(INTERNAL_PYTHON,
+[Whether the bundled python should be used (auto,yes,no)])
+
+ac_have_python=yes
+
+#
+# Allow the use of a (user set) custom python version
+#
+AC_ARG_VAR([PYTHON_VERSION],[The installed Python
+	version to use, for example '2.3'. This string 
+	will be appended to the Python interpreter
+	canonical name.])
+
+AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
+if test -z "$PYTHON"; then
+	ac_have_python=no
+fi
+
+AC_SUBST(PYTHON)
+
+#
+# Check for a version of Python >= 2.1.0
+#
+AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
+ac_supports_python_ver=`$PYTHON -c "import sys, string; \
+	ver = string.split(sys.version)[[0]]; \
+	print ver >= '2.1.0'"`
+if test "$ac_supports_python_ver" != "True"; then
+	ac_have_python=no
+	AC_MSG_RESULT([no])
+else 
+	AC_MSG_RESULT([yes])
+fi
+
+#
+# Check if you have distutils, else fail
+#
+AC_MSG_CHECKING([for the distutils Python package])
+ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
+if test -z "$ac_distutils_result"; then
+	AC_MSG_RESULT([yes])
+else
+	ac_have_python=no
+	AC_MSG_RESULT([no])
+fi
+
+if test x$INTERNAL_PYTHON = xauto
+then
+	if test x$ac_have_python = xyes; then		
+		INTERNAL_PYTHON=no
+	else
+		INTERNAL_PYTHON=yes
+	fi
+fi
+
+AC_MSG_CHECKING([whether to use internal python])
+AC_MSG_RESULT($INTERNAL_PYTHON)
+
+if test x$INTERNAL_PYTHON = xyes; then
 
 # Set VERSION so we only need to edit in one place (i.e., here)
 m4_define(PYTHON_VERSION, 2.6)
@@ -18,9 +80,6 @@
 #endif /*Py_PYCONFIG_H*/
 ])
 
-AC_SUBST(SOVERSION)
-SOVERSION=1.0
-
 # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
 # certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
 # them.
@@ -47,15 +106,6 @@
   CFLAGS=$save_CFLAGS
 fi
 
-dnl # check for ANSI or K&R ("traditional") preprocessor
-dnl AC_MSG_CHECKING(for C preprocessor type)
-dnl AC_TRY_COMPILE([
-dnl #define spam(name, doc) {#name, &name, #name "() -- " doc}
-dnl int foo;
-dnl struct {char *name; int *addr; char *doc;} desc = spam(foo, "something");
-dnl ], [;], cpp_type=ansi, AC_DEFINE(HAVE_OLD_CPP) cpp_type=traditional)
-dnl AC_MSG_RESULT($cpp_type)
-
 # checks for header files
 AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \
 fcntl.h grp.h \
@@ -69,7 +119,6 @@
 sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \
 sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \
 bluetooth/bluetooth.h)
-AC_HEADER_DIRENT
 AC_HEADER_MAJOR
 
 # On Solaris, term.h requires curses.h
@@ -390,25 +439,6 @@
 fi
 AC_MSG_RESULT($with_pymalloc)
 
-# Check for --with-wctype-functions
-AC_MSG_CHECKING(for --with-wctype-functions)
-AC_ARG_WITH(wctype-functions, 
-            AC_HELP_STRING(--with-wctype-functions, use wctype.h functions),
-[
-if test "$withval" != no
-then 
-  AC_DEFINE(WANT_WCTYPE_FUNCTIONS, 1,
-  [Define if you want wctype.h functions to be used instead of the
-   one supplied by Python itself. (see Include/unicodectype.h).]) 
-  AC_MSG_RESULT(yes)
-else AC_MSG_RESULT(no)
-fi],
-[AC_MSG_RESULT(no)])
-
-# -I${DLINCLDIR} is added to the compile rule for importdl.o
-AC_SUBST(DLINCLDIR)
-DLINCLDIR=.
-
 # checks for library functions
 AC_CHECK_FUNCS(alarm bind_textdomain_codeset chflags chown clock confstr \
  ctermid execv fork fpathconf ftime ftruncate \
@@ -499,34 +529,6 @@
 )
 
 dnl check for true
-AC_CHECK_PROGS(TRUE, true, /bin/true)
-
-dnl On some systems (e.g. Solaris 9), hstrerror and inet_aton are in -lresolv
-dnl On others, they are in the C library, so we to take no action
-AC_CHECK_LIB(c, inet_aton, [$ac_cv_prog_TRUE],
-  AC_CHECK_LIB(resolv, inet_aton)
-)
-
-dnl Check if system zlib has *Copy() functions
-dnl
-dnl On MacOSX the linker will search for dylibs on the entire linker path
-dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
-dnl to revert to a more traditional unix behaviour and make it possible to
-dnl override the system libz with a local static library of libz. Temporarily
-dnl add that flag to our CFLAGS as well to ensure that we check the version
-dnl of libz that will be used by setup.py. 
-dnl The -L/usr/local/lib is needed as wel to get the same compilation 
-dnl environment as setup.py (and leaving it out can cause configure to use the
-dnl wrong version of the library)
-case $ac_sys_system/$ac_sys_release in
-Darwin/*) 
-	_CUR_CFLAGS="${CFLAGS}"
-	_CUR_LDFLAGS="${LDFLAGS}"
-	CFLAGS="${CFLAGS} -Wl,-search_paths_first"
-	LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
-	;;
-esac
-
 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
 
 case $ac_sys_system/$ac_sys_release in
@@ -1517,3 +1519,89 @@
 fi
 
 AC_DEFINE_UNQUOTED(PLATFORM, $MACHDEP, [Platforms])
+SMB_SUBSYSTEM(LIBPYTHON, [], [INTERNAL_PYTHON])
+SMB_ENABLE(python)
+SMB_ENABLE(pgen)
+PYTHON="$builddir/bin/python"
+
+else
+#
+# Check for Python include path
+#
+	AC_MSG_CHECKING([for Python include path])
+	if test -z "$PYTHON_CPPFLAGS"; then
+		python_path=`$PYTHON -c "import distutils.sysconfig; \
+				print distutils.sysconfig.get_python_inc();"`
+		if test -n "${python_path}"; then
+			python_path="-I$python_path"
+		fi
+		PYTHON_CPPFLAGS=$python_path
+	fi
+	AC_MSG_RESULT([$PYTHON_CPPFLAGS])
+	AC_SUBST([PYTHON_CPPFLAGS])
+
+#
+# Check for Python library path
+#
+	AC_MSG_CHECKING([for Python library path])
+	if test -z "$PYTHON_LDFLAGS"; then
+		# (makes two attempts to ensure we've got a version number
+		# from the interpreter)
+		py_version=`$PYTHON -c "from distutils.sysconfig import *; \
+			from string import join; \
+			print join(get_config_vars('VERSION'))"`
+		if test "$py_version" == "[None]"; then
+			if test -n "$PYTHON_VERSION"; then
+				py_version=$PYTHON_VERSION
+			else
+				py_version=`$PYTHON -c "import sys; \
+					print sys.version[[:3]]"`
+			fi
+		fi
+
+		PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
+			from string import join; \
+			print '-L' + get_python_lib(0,1), \
+				'-lpython';"`$py_version
+	fi		
+	AC_MSG_RESULT([$PYTHON_LDFLAGS])
+	AC_SUBST([PYTHON_LDFLAGS])
+
+#
+# Check for site packages
+#
+	AC_MSG_CHECKING([for Python site-packages path])
+	if test -z "$PYTHON_SITE_PKG"; then
+		PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
+				print distutils.sysconfig.get_python_lib(0,0);"`
+	fi
+	AC_MSG_RESULT([$PYTHON_SITE_PKG])
+	AC_SUBST([PYTHON_SITE_PKG])
+
+#
+# libraries which must be linked in when embedding
+#
+	AC_MSG_CHECKING(python extra libraries)
+	if test -z "$PYTHON_EXTRA_LIBS"; then
+	   PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
+				conf = distutils.sysconfig.get_config_var; \
+				print conf('LOCALMODLIBS'), conf('LIBS')"`
+	fi
+	AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
+	AC_SUBST(PYTHON_EXTRA_LIBS)
+
+#
+# linking flags needed when embedding
+#
+	AC_MSG_CHECKING(python extra linking flags)
+	if test -z "$PYTHON_EXTRA_LDFLAGS"; then
+		PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
+			conf = distutils.sysconfig.get_config_var; \
+			print conf('LINKFORSHARED')"`
+	fi
+	AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
+	AC_SUBST(PYTHON_EXTRA_LDFLAGS)
+
+    SMB_EXT_LIB(LIBPYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CPPFLAGS])
+	SMB_ENABLE(LIBPYTHON)
+fi

=== modified file 'source/lib/python/config.mk'
--- a/source/lib/python/config.mk	2007-04-23 22:48:27 +0000
+++ b/source/lib/python/config.mk	2007-04-24 10:52:53 +0000
@@ -35,7 +35,7 @@
 # XXX Note that a build now requires Python exist before the build starts
 ASDLGEN=	$(srcdir)/lib/python/Parser/asdl_c.py
 
-[LIBRARY::PYTHON]
+[LIBRARY::INTERNAL_PYTHON]
 LDFLAGS = -lm -lutil
 CFLAGS = -DPy_BUILD_CORE -Ilib/python/Include -Ilib/python -DPYTHONPATH=":plat-linux2" -DVERSION="2.6" -DPLATFORM="linux2"
 OBJ_FILES =	\
@@ -122,6 +122,7 @@
 		Modules/_sre.o  \
 		Modules/_codecsmodule.o  \
 		Modules/zipimport.o  \
+		Modules/socketmodule.o \
 		Modules/symtablemodule.o  \
 		Modules/xxsubtype.o \
 		Parser/acceler.o \
@@ -147,7 +148,8 @@
 
 # Build the interpreter
 [BINARY::python]
-PRIVATE_DEPENDENCIES = PYTHON
+ENABLE = NO
+PRIVATE_DEPENDENCIES = INTERNAL_PYTHON
 CFLAGS = -DPy_BUILD_CORE -Ilib/python/Include -Ilib/python
 OBJ_FILES = \
 			Modules/python.o
@@ -156,6 +158,7 @@
 		-bin/pgen $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
 
 [BINARY::pgen]
+ENABLE = NO
 CFLAGS = -DPy_BUILD_CORE -Ilib/python/Include -Ilib/python
 PRIVATE_DEPENDENCIES = PYTHON_PARSER_HOST
 OBJ_FILES = \

=== modified file 'source/lib/tdb/libtdb.m4'
--- a/source/lib/tdb/libtdb.m4	2006-11-30 03:25:07 +0000
+++ b/source/lib/tdb/libtdb.m4	2007-04-24 10:52:53 +0000
@@ -23,34 +23,4 @@
 AC_HAVE_DECL(pread, [#include <unistd.h>])
 AC_HAVE_DECL(pwrite, [#include <unistd.h>])
 
-AC_MSG_CHECKING([for Python])
-
-PYTHON=
- 
-AC_ARG_WITH(python,
-[  --with-python=PYTHONNAME  build Python libraries],
-[ case "${withval-python}" in
-  yes)
-        PYTHON=python
-        ;;
-  no)
-        PYTHON=
-        ;;
-  *)
-        PYTHON=${withval-python}
-        ;;
-  esac ])
-
-if test x"$PYTHON" != "x"; then
-	incdir=`python -c 'import sys; print "%s/include/python%d.%d" % (sys.prefix, sys.version_info[[0]], sys.version_info[[1]])'`
-	CPPFLAGS="$CPPFLAGS -I $incdir"
-fi
-
-if test x"$PYTHON" != "x"; then
-	AC_MSG_RESULT([${withval-python}])
-else
-	SMB_ENABLE(swig_tdb, NO)
-	AC_MSG_RESULT(no)
-fi
-
-AC_SUBST(PYTHON)
+SMB_ENABLE(swig_tdb, NO)

=== modified file 'source/libcli/config.m4'
--- a/source/libcli/config.m4	2006-05-02 19:20:49 +0000
+++ b/source/libcli/config.m4	2007-04-24 10:52:53 +0000
@@ -1,31 +1,3 @@
 AC_MSG_CHECKING([for Python (libcli_nbt)])
 
-PYTHON=
- 
-AC_ARG_WITH(python,
-[  --with-python=PYTHONNAME  build Python libraries],
-[ case "${withval-python}" in
-  yes)
-        PYTHON=python
-        ;;
-  no)
-        PYTHON=
-        ;;
-  *)
-        PYTHON=${withval-python}
-        ;;
-  esac ])
-
-if test x"$PYTHON" != "x"; then
-	incdir=`python -c 'import sys; print "%s/include/python%d.%d" % (sys.prefix, sys.version_info[[0]], sys.version_info[[1]])'`
-	CPPFLAGS="$CPPFLAGS -I $incdir"
-fi
-
-if test x"$PYTHON" != "x"; then
-	AC_MSG_RESULT([${withval-python}])
-else
-	AC_MSG_RESULT(no)
-	SMB_ENABLE(swig_libcli_nbt, NO)
-fi
-
-AC_SUBST(PYTHON)
+SMB_ENABLE(swig_libcli_nbt, NO)

=== modified file 'source/scripting/swig/config.m4'
--- a/source/scripting/swig/config.m4	2006-04-27 20:55:26 +0000
+++ b/source/scripting/swig/config.m4	2007-04-24 10:52:53 +0000
@@ -2,28 +2,5 @@
 
 # Check for python support
 
-PYTHON=
- 
-AC_ARG_WITH(python,
-[  --with-python=PYTHONNAME  build Python libraries],
-[ case "${withval-python}" in
-  yes)
-        PYTHON=python
-        ;;
-  no)
-        PYTHON=
-        ;;
-  *)
-        PYTHON=${withval-python}
-        ;;
-  esac ])
-
-if test x"$PYTHON" != "x"; then
-	incdir=`python -c 'import sys; print "%s/include/python%d.%d" % (sys.prefix, sys.version_info[[0]], sys.version_info[[1]])'`
-	CPPFLAGS="$CPPFLAGS -I $incdir"
-else
-	SMB_ENABLE(swig_dcerpc, NO)
-fi
-
-AC_SUBST(PYTHON)
+SMB_ENABLE(swig_dcerpc, NO)
 



More information about the samba-cvs mailing list