[crossfire] python version check (was: some bugs)

Andreas Kirschbaum kirschbaum at myrealbox.com
Sun Feb 20 13:52:35 CST 2005


To check for a suitable python version, I added some checks to the
autoconf script. I have tested it with Python versions from 2.1 to 2.4
but only under debian.

Can someone review or check this patch before I commit it?
-------------- next part --------------
? ANK-TODO
? DIFF
Index: acinclude.m4
===================================================================
RCS file: /cvsroot/crossfire/crossfire/acinclude.m4,v
retrieving revision 1.5
diff -w -c -5 -r1.5 acinclude.m4
*** acinclude.m4	16 May 2004 06:13:20 -0000	1.5
--- acinclude.m4	20 Feb 2005 19:49:08 -0000
***************
*** 43,54 ****
  			fi
  		fi
  		if test "x$PYTHON_LIB" != "x"  ; then
  			AC_CHECK_LIB(pthread, main,  PY_LIBS="$PY_LIBS -lpthread", , $PY_LIBS )
  			AC_CHECK_LIB(util, main,  PY_LIBS="$PY_LIBS -lutil", , $PY_LIBS )
! 			$1
  		fi
  	fi
  
  	AC_SUBST(PYTHON_LIB)
  	AC_SUBST(PY_LIBS)
  	AC_SUBST(PY_INCLUDES)
--- 43,105 ----
  			fi
  		fi
  		if test "x$PYTHON_LIB" != "x"  ; then
  			AC_CHECK_LIB(pthread, main,  PY_LIBS="$PY_LIBS -lpthread", , $PY_LIBS )
  			AC_CHECK_LIB(util, main,  PY_LIBS="$PY_LIBS -lutil", , $PY_LIBS )
! 
! 			AC_MSG_CHECKING([whether python supports the "L" format specifier])
! 			saved_LIBS="$LIBS"
! 			LIBS="$LIBS $PYTHON_LIB $PY_LIBS"
! 			saved_CFLAGS="$CFLAGS"
! 			CFLAGS="$CFLAGS $PY_INCLUDES"
! 			AC_TRY_RUN([
! #include <Python.h>
! #include <stdlib.h>
! 
! static PyObject *callback(PyObject *self, PyObject *args)
! {
!     long long val;
! 
!     if (!PyArg_ParseTuple(args, "L", &val))
! 	return NULL;
!     if (val != 1)
! 	exit(1);
!     Py_INCREF(Py_None);
!     return Py_None;
! }
! 
! static PyMethodDef methods[] = {
!     {"callback", callback, METH_VARARGS},
!     {NULL, NULL, 0, NULL},
! };
! 
! int main()
! {
!     Py_Initialize();
!     Py_InitModule("test", methods);
!     return(PyRun_SimpleString("import test\ntest.callback(1)\n") != 0);
! }
! 				], [
! 				AC_MSG_RESULT([yes])
! 				], [
! 				AC_MSG_RESULT([no])
! 				PYTHON_LIB=""
! 				PYLIBS=""
! 				PY_INCLUDE=""
! 				],
! 				[
! 				AC_MSG_RESULT([skipped because cross compiling])
! 				])
! 			LIBS="$saved_LIBS"
! 			CFLAGS="$saved_CFLAGS"
! 		fi
  	fi
+ 
+ 	if test "x$PYTHON_LIB" = "x"  ; then
+ 		$2
+ 	else
+ 		$1
  	fi
  
  	AC_SUBST(PYTHON_LIB)
  	AC_SUBST(PY_LIBS)
  	AC_SUBST(PY_INCLUDES)
    
    


More information about the crossfire mailing list