From 61a95befd1830137b0d817da60869f23f63d9540 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Thu, 30 Oct 2008 01:21:08 +0000 Subject: [PATCH] Some minor cleanups in the Python build. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2806 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- configure.ac | 17 +++++++++++------ python/Makefile-files | 8 ++++---- python/_libvserver.c | 2 +- python/ctags-constants.awk | 4 ++++ 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 python/ctags-constants.awk diff --git a/configure.ac b/configure.ac index 5fd23e5..f480a23 100644 --- a/configure.ac +++ b/configure.ac @@ -454,26 +454,30 @@ dnl Check for Python AM_PATH_PYTHON(,, [:]) if test "x$PYTHON" != x:; then - ensc_have_python=true + ensc_have_python=yes else - ensc_have_python=false + 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=false;; + (no) ensc_have_python=no;; (yes) ;; (*) ensc_python_config="$withval";; esac]) -if $ensc_have_python && $ensc_python_config --cflags > /dev/null 2>&1; then +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` AC_SUBST(PYTHON_CFLAGS) AC_SUBST(PYTHON_LDFLAGS) else - ensc_have_python=false + ensc_have_python=no fi -AM_CONDITIONAL([HAVE_PYTHON], [$ensc_have_python]) +AC_PATH_PROG([CTAGS], [ctags], [no]) +if test "x$CTAGS" = xno; then + ensc_have_python=no +fi +AM_CONDITIONAL([HAVE_PYTHON], [test x$ensc_have_python = xyes]) dnl Python stuff ends here dnl ######################## @@ -522,6 +526,7 @@ Features: syscall(2) invocation: $with_syscall vserver(2) syscall#: $ensc_cv_value_syscall_vserver crypto api: $ensc_crypto_api + python bindings: $ensc_have_python Paths: prefix: $prefix diff --git a/python/Makefile-files b/python/Makefile-files index e504166..cb27731 100644 --- a/python/Makefile-files +++ b/python/Makefile-files @@ -24,11 +24,11 @@ python__libvserver_la_CFLAGS = $(AM_CFLAGS) $(PYTHON_CFLAGS) \ python__libvserver_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS) python__libvserver_la_LIBADD = $(LIBVSERVER_GLIBC) +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 - ctags -x $(top_srcdir)/lib/vserver.h | \ - awk '$$2 == "macro" || $$2 == "enumerator" { print $$1 }' | \ - egrep '^(vc|VC|CLONE)' | grep -v VC_ATTR_ | \ - awk '{ printf " PyModule_AddIntConstant(mod, \"%s\", %s);\n", $$1, $$1 }' \ + $(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 3404c9d..448e353 100644 --- a/python/_libvserver.c +++ b/python/_libvserver.c @@ -278,7 +278,7 @@ pyvserver_get_rlimit(PyObject UNUSED *self, PyObject *args) if (vc_get_rlimit(xid, resource, &limit) == -1) return PyErr_SetFromErrno(PyExc_OSError); - return Py_BuildValue("(KKK)", limit.min, limit.soft, limit.hard); + return Py_BuildValue("(LLL)", limit.min, limit.soft, limit.hard); } static PyObject * diff --git a/python/ctags-constants.awk b/python/ctags-constants.awk new file mode 100644 index 0000000..15c4bdb --- /dev/null +++ b/python/ctags-constants.awk @@ -0,0 +1,4 @@ +(($2 == "macro" || $2 == "enumerator") && $1 ~ /^(vc|VC|CLONE)/ && + $1 !~ /^VC_ATTR_/) { + printf " PyModule_AddIntConstant(mod, \"%s\", %s);\n", $1, $1 +} -- 1.8.1.5