2005-10-30 13:16:22 -08:00
|
|
|
##############################################################################
|
|
|
|
# _MOO_AC_CHECK_PYTHON_MINGW(version,action-if-found,action-if-not-found)
|
|
|
|
# checks python stuff when building for mingw. it's broken
|
|
|
|
#
|
|
|
|
AC_DEFUN([_MOO_AC_CHECK_PYTHON_MINGW],[
|
|
|
|
no_dot_version=`echo $1 | sed "s/\.//"`
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
if test -z "$PYTHON_PARENT_DIR"; then
|
2005-10-30 13:16:22 -08:00
|
|
|
PYTHON_PARENT_DIR=/usr/local/win
|
|
|
|
fi
|
2006-08-04 02:17:32 -07:00
|
|
|
if test -z "$PYTHON_PREFIX"; then
|
2005-10-30 13:16:22 -08:00
|
|
|
PYTHON_PREFIX=$PYTHON_PARENT_DIR/Python$no_dot_version
|
|
|
|
fi
|
2006-08-04 02:17:32 -07:00
|
|
|
if test -z "$PYTHON_CFLAGS"; then
|
|
|
|
PYTHON_CFLAGS="-I$PYTHON_PREFIX/include -mno-cygwin"
|
2005-10-30 13:16:22 -08:00
|
|
|
fi
|
2006-08-04 02:17:32 -07:00
|
|
|
if test -z "$PYTHON_LIBS"; then
|
|
|
|
PYTHON_LIBS="-L$PYTHON_PREFIX/libs -lpython$no_dot_version -mno-cygwin"
|
2005-10-30 13:16:22 -08:00
|
|
|
fi
|
2006-08-04 02:17:32 -07:00
|
|
|
if test -z "$PYTHON"; then
|
2006-04-30 18:54:05 -07:00
|
|
|
PYTHON="python"
|
|
|
|
fi
|
2005-10-30 13:16:22 -08:00
|
|
|
|
|
|
|
# check whether Python.h and library exists
|
|
|
|
|
|
|
|
save_CPPFLAGS="$CPPFLAGS"
|
2006-08-04 02:17:32 -07:00
|
|
|
CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
|
2005-10-30 13:16:22 -08:00
|
|
|
save_CFLAGS="$CFLAGS"
|
2006-08-04 02:17:32 -07:00
|
|
|
CFLAGS="$CFLAGS $PYTHON_CFLAGS"
|
2005-10-30 13:16:22 -08:00
|
|
|
save_LDFLAGS="$LDFLAGS"
|
2006-08-04 02:17:32 -07:00
|
|
|
LDFLAGS="$LDFLAGS $PYTHON_LIBS"
|
2005-10-30 13:16:22 -08:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
AC_MSG_CHECKING([PYTHON_CFLAGS])
|
2005-10-30 13:16:22 -08:00
|
|
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
|
|
|
#include <Python.h>
|
|
|
|
int main ()
|
|
|
|
{
|
|
|
|
Py_Initialize();
|
|
|
|
PyRun_SimpleString("from time import time,ctime\n"
|
|
|
|
"print 'Today is',ctime(time())\n");
|
|
|
|
Py_Finalize();
|
|
|
|
return 0;
|
|
|
|
}]])],[
|
2006-08-04 02:17:32 -07:00
|
|
|
AC_MSG_RESULT([$PYTHON_CFLAGS])
|
|
|
|
AC_MSG_CHECKING([PYTHON_LIBS])
|
|
|
|
AC_MSG_RESULT([$PYTHON_LIBS])
|
2005-10-30 13:16:22 -08:00
|
|
|
AC_MSG_NOTICE([Did not do real linking])
|
2006-08-04 02:17:32 -07:00
|
|
|
AC_SUBST(PYTHON_CFLAGS)
|
|
|
|
AC_SUBST(PYTHON_LIBS)
|
2005-10-30 13:16:22 -08:00
|
|
|
pyexecdir=$PYTHON_PREFIX/Lib/site-packages
|
|
|
|
$2
|
|
|
|
],[
|
|
|
|
AC_MSG_RESULT([Not found])
|
2006-08-04 02:17:32 -07:00
|
|
|
PYTHON_CFLAGS=""
|
|
|
|
PYTHON_LIBS=""
|
2005-10-30 13:16:22 -08:00
|
|
|
PYTHON_EXTRA_LIBS=""
|
2005-11-03 20:30:47 -08:00
|
|
|
$3
|
2005-10-30 13:16:22 -08:00
|
|
|
])
|
|
|
|
|
|
|
|
LDFLAGS="$save_LDFLAGS"
|
|
|
|
CFLAGS="$save_CFLAGS"
|
|
|
|
CPPFLAGS="$save_CPPFLAGS"
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# _MOO_AC_PYTHON_DEVEL(action-if-found,action-if-not-found)
|
|
|
|
# checks python headers and libs. it's
|
|
|
|
# http://www.gnu.org/software/ac-archive/htmldoc/ac_python_devel.html,
|
2006-08-04 02:17:32 -07:00
|
|
|
# modified to allow actions if-found/if-not-found
|
2005-10-30 13:16:22 -08:00
|
|
|
#
|
|
|
|
AC_DEFUN([_MOO_AC_PYTHON_DEVEL],[
|
2006-08-04 02:17:32 -07:00
|
|
|
# Check for distutils first
|
|
|
|
AC_MSG_CHECKING([for the distutils Python package])
|
|
|
|
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
|
|
|
|
if test -z "$ac_distutils_result"; then
|
2005-10-30 13:16:22 -08:00
|
|
|
python_found=yes
|
2006-08-04 02:17:32 -07:00
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
else
|
|
|
|
python_found=no
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
AC_MSG_ERROR([cannot import Python module "distutils".
|
|
|
|
Please check your Python installation. The error was:
|
|
|
|
$ac_distutils_result])
|
2005-10-30 13:16:22 -08:00
|
|
|
fi
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
# Check for Python include path
|
|
|
|
# if PYTHON_CFLAGS is set, do not do anything
|
|
|
|
if test $python_found = yes; then
|
|
|
|
AC_MSG_CHECKING([for Python include path])
|
|
|
|
|
|
|
|
if test -z "$PYTHON_CFLAGS"; 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"
|
2005-10-30 13:16:22 -08:00
|
|
|
fi
|
2006-08-04 02:17:32 -07:00
|
|
|
PYTHON_CFLAGS=$python_path
|
|
|
|
fi
|
2006-02-06 20:25:14 -08:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
AC_MSG_RESULT([$PYTHON_CFLAGS])
|
|
|
|
AC_SUBST([PYTHON_CFLAGS])
|
|
|
|
fi
|
2006-02-06 20:25:14 -08:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
# Check for Python linker flags
|
|
|
|
# if PYTHON_LIBS is set, do not do anything
|
|
|
|
if test $python_found = yes; then
|
|
|
|
AC_MSG_CHECKING([Python linker flags])
|
|
|
|
|
|
|
|
if test -z "$PYTHON_LIBS"; 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
|
2006-02-06 20:25:14 -08:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
PYTHON_LIBS=`$PYTHON -c "from distutils.sysconfig import *; \
|
|
|
|
from string import join; \
|
|
|
|
print '-L' + get_python_lib(0,1), \
|
|
|
|
'-lpython';"`$py_version
|
2005-10-30 13:16:22 -08:00
|
|
|
fi
|
2006-08-04 02:17:32 -07:00
|
|
|
|
|
|
|
AC_MSG_RESULT([$PYTHON_LIBS])
|
|
|
|
AC_SUBST([PYTHON_LIBS])
|
2005-10-30 13:16:22 -08:00
|
|
|
fi
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
# Check for Python extra linker flags
|
|
|
|
# if PYTHON_EXTRA_LIBS is set, do not do anything
|
|
|
|
if test $python_found = yes; then
|
|
|
|
AC_MSG_CHECKING([Python extra linker flags])
|
|
|
|
|
|
|
|
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')"`
|
|
|
|
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
|
|
|
|
conf = distutils.sysconfig.get_config_var; \
|
|
|
|
print conf('LINKFORSHARED')"`
|
|
|
|
PYTHON_EXTRA_LIBS="$PYTHON_EXTRA_LIBS $PYTHON_EXTRA_LDFLAGS"
|
|
|
|
fi
|
2005-10-30 13:16:22 -08:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
|
|
|
|
AC_SUBST([PYTHON_EXTRA_LIBS])
|
2005-10-30 13:16:22 -08:00
|
|
|
fi
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
if test $python_found = yes; then
|
2005-10-30 13:16:22 -08:00
|
|
|
$1
|
|
|
|
else
|
|
|
|
$2
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# _MOO_AC_CHECK_PYTHON_UNIX(min-version,action-if-found,action-if-not-found)
|
|
|
|
# checks python stuff when building for unix
|
|
|
|
#
|
|
|
|
AC_DEFUN([_MOO_AC_CHECK_PYTHON_UNIX],[
|
|
|
|
AM_PATH_PYTHON([$1],[
|
|
|
|
_MOO_AC_PYTHON_DEVEL([
|
|
|
|
python_found=yes
|
|
|
|
],[
|
|
|
|
AC_MSG_WARN([Found python interpreter but no development headers or libraries])
|
|
|
|
python_found=no
|
|
|
|
])
|
|
|
|
],[
|
|
|
|
python_found=no
|
|
|
|
])
|
|
|
|
|
|
|
|
if test x$python_found = xyes; then
|
|
|
|
$2
|
|
|
|
else
|
2006-08-04 02:17:32 -07:00
|
|
|
PYTHON_CFLAGS=""
|
|
|
|
PYTHON_LIBS=""
|
2005-10-30 13:16:22 -08:00
|
|
|
PYTHON_EXTRA_LIBS=""
|
|
|
|
$3
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# MOO_AC_CHECK_PYTHON(min-version,action-if-found,action-if-not-found)
|
|
|
|
# checks for python, python includes and libs
|
|
|
|
#
|
|
|
|
AC_DEFUN([MOO_AC_CHECK_PYTHON],[
|
|
|
|
AC_MSG_NOTICE([checking for headers and libs required to compile python extensions])
|
|
|
|
AC_REQUIRE([MOO_AC_CHECK_OS])
|
|
|
|
if test x$MOO_OS_CYGWIN != xyes; then
|
|
|
|
if test x$MOO_OS_MINGW = xyes; then
|
|
|
|
_MOO_AC_CHECK_PYTHON_MINGW([$1],[$2],[$3])
|
|
|
|
else
|
|
|
|
_MOO_AC_CHECK_PYTHON_UNIX([$1],[$2],[$3])
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
])
|