Some minor cleanups in the Python build.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Thu, 30 Oct 2008 01:21:08 +0000 (01:21 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Thu, 30 Oct 2008 01:21:08 +0000 (01:21 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2806 94cd875c-1c1d-0410-91d2-eb244daf1a30

configure.ac
python/Makefile-files
python/_libvserver.c
python/ctags-constants.awk [new file with mode: 0644]

index 5fd23e5..f480a23 100644 (file)
@@ -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
index e504166..cb27731 100644 (file)
@@ -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
index 3404c9d..448e353 100644 (file)
@@ -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 (file)
index 0000000..15c4bdb
--- /dev/null
@@ -0,0 +1,4 @@
+(($2 == "macro" || $2 == "enumerator") && $1 ~ /^(vc|VC|CLONE)/ &&
+       $1 !~ /^VC_ATTR_/) {
+       printf "  PyModule_AddIntConstant(mod, \"%s\", %s);\n", $1, $1
+}