From a846846ae79ceef4531ccd0495c7cdb076b9dc92 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Thu, 30 Oct 2008 02:33:25 +0000 Subject: [PATCH] 32-bit and Python 2.4 support. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2809 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- configure.ac | 18 +++++------------- python/Makefile-files | 3 ++- python/_libvserver.c | 9 +++++++++ python/ctags-constants.awk | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index f480a23..2da8aa9 100644 --- a/configure.ac +++ b/configure.ac @@ -452,22 +452,14 @@ AM_CONDITIONAL(HAVE_SYSV_INIT, test x"$ensc_with_init" = xsysv) dnl ######################## dnl Check for Python +ensc_have_python=yes AM_PATH_PYTHON(,, [:]) -if test "x$PYTHON" != x:; then - ensc_have_python=yes -else +if test "x$PYTHON" = x:; then ensc_have_python=no fi -ensc_python_config=python-config -AC_ARG_WITH(python, AC_HELP_STRING([--with-python=FILE], [use FILE to query Python build details (default: python-config)]), [ - case "$withval" in - (no) ensc_have_python=no;; - (yes) ;; - (*) ensc_python_config="$withval";; - esac]) -if test x$ensc_have_python = xyes && $ensc_python_config --cflags > /dev/null 2>&1; then - PYTHON_CFLAGS=`$ensc_python_config --cflags` - PYTHON_LDFLAGS=`$ensc_python_config --ldflags` +if test x$ensc_have_python = xyes; then + PYTHON_CFLAGS=-I`$PYTHON -c 'from distutils.sysconfig import get_python_inc; print get_python_inc(1)'` + PYTHON_LDFLAGS=-L`$PYTHON -c 'from distutils.sysconfig import get_python_lib; print get_python_lib(1)'` AC_SUBST(PYTHON_CFLAGS) AC_SUBST(PYTHON_LDFLAGS) else diff --git a/python/Makefile-files b/python/Makefile-files index cb27731..9f6a164 100644 --- a/python/Makefile-files +++ b/python/Makefile-files @@ -28,7 +28,8 @@ EXTRA_DIST += python/ctags-constants.awk # FIXME: Dude, this is ugly. python/_libvserver.c: $(top_builddir)/python/_libvserver-constants.c -$(top_builddir)/python/_libvserver-constants.c: lib/vserver.h +$(top_builddir)/python/_libvserver-constants.c: lib/vserver.h \ + $(top_srcdir)/python/ctags-constants.awk $(CTAGS) -x $(top_srcdir)/lib/vserver.h | \ $(AWK) -f $(top_srcdir)/python/ctags-constants.awk \ > $(top_builddir)/python/_libvserver-constants.c diff --git a/python/_libvserver.c b/python/_libvserver.c index 448e353..bb7a3b2 100644 --- a/python/_libvserver.c +++ b/python/_libvserver.c @@ -1126,6 +1126,15 @@ static PyMethodDef methods[] = { { NULL, NULL, 0, NULL } }; +static void +PyModule_AddLongLongConstant(PyObject *mod, const char *str, long long val) +{ + PyObject *o = PyLong_FromLongLong(val); + if (!o || PyModule_AddObject(mod, str, o) == -1) + /* This ought to be reported somehow... */ + return; +} + PyMODINIT_FUNC init_libvserver(void) { PyObject *mod; diff --git a/python/ctags-constants.awk b/python/ctags-constants.awk index 15c4bdb..02486aa 100644 --- a/python/ctags-constants.awk +++ b/python/ctags-constants.awk @@ -1,4 +1,4 @@ (($2 == "macro" || $2 == "enumerator") && $1 ~ /^(vc|VC|CLONE)/ && $1 !~ /^VC_ATTR_/) { - printf " PyModule_AddIntConstant(mod, \"%s\", %s);\n", $1, $1 + printf " PyModule_AddLongLongConstant(mod, \"%s\", %s);\n", $1, $1 } -- 1.8.1.5