1
#----------------------------------------------------------------
3
#----------------------------------------------------------------
5
AC_DEFUN(SW_FIND_PYTHON,
13
# I don't think any of this commented stuff works anymore
15
#PYLINK="-lModules -lPython -lObjects -lParser"
17
#AC_ARG_WITH(py,[ --with-py=path Set location of Python],[
18
# PYPACKAGE="$withval"], [PYPACKAGE=])
19
#AC_ARG_WITH(pyincl,[ --with-pyincl=path Set location of Python include directory],[
20
# PYINCLUDE="$withval"], [PYINCLUDE=])
21
#AC_ARG_WITH(pylib,[ --with-pylib=path Set location of Python library directory],[
22
# PYLIB="$withval"], [PYLIB=])
24
#if test -z "$PYINCLUDE"; then
25
# if test -n "$PYPACKAGE"; then
26
# PYINCLUDE="$PYPACKAGE/include"
30
#if test -z "$PYLIB"; then
31
# if test -n "$PYPACKAGE"; then
32
# PYLIB="$PYPACKAGE/lib"
36
AC_ARG_WITH(python,[ --with-python=path Set location of Python executable],[ PYBIN="$withval"], [PYBIN=])
38
# First figure out the name of the Python executable
40
if test -z "$PYBIN"; then
41
AC_PATH_PROGS(PYTHON, $prefix/bin/python python python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python)
46
if test -n "$PYTHON"; then
47
AC_MSG_CHECKING(for Python prefix)
48
PYPREFIX=`($PYTHON -c "import sys; print sys.prefix") 2>/dev/null`
49
AC_MSG_RESULT($PYPREFIX)
50
AC_MSG_CHECKING(for Python exec-prefix)
51
PYEPREFIX=`($PYTHON -c "import sys; print sys.exec_prefix") 2>/dev/null`
52
AC_MSG_RESULT($PYEPREFIX)
55
# Note: I could not think of a standard way to get the version string from different versions.
56
# This trick pulls it out of the file location for a standard library file.
58
AC_MSG_CHECKING(for Python version)
60
# Need to do this hack since autoconf replaces __file__ with the name of the configure file
62
PYVERSION=`($PYTHON -c "import string,operator; print operator.getitem(string.split(string.__$filehack,'/'),-2)")`
63
AC_MSG_RESULT($PYVERSION)
65
# Set the include directory
67
AC_MSG_CHECKING(for Python header files)
68
if test -r $PYPREFIX/include/$PYVERSION/Python.h; then
69
PYINCLUDE="-I$PYPREFIX/include/$PYVERSION -I$PYEPREFIX/lib/$PYVERSION/config"
71
if test -z "$PYINCLUDE"; then
72
if test -r $PYPREFIX/include/Py/Python.h; then
73
PYINCLUDE="-I$PYPREFIX/include/Py -I$PYEPREFIX/lib/python/lib"
76
AC_MSG_RESULT($PYINCLUDE)
78
# Set the library directory blindly. This probably won't work with older versions
79
AC_MSG_CHECKING(for Python library)
80
dirs="$PYVERSION/config $PYVERSION/lib python/lib"
82
if test -d $PYEPREFIX/lib/$i; then
83
PYLIB="$PYEPREFIX/lib/$i"
84
PYTHONBUILD=python_make
88
if test -z "$PYLIB"; then
89
AC_MSG_RESULT(Not found)
94
# Check for really old versions
95
if test -r $PYLIB/libPython.a; then
96
PYLINK="-lModules -lPython -lObjects -lParser"
102
# Only cygwin (Windows) needs the library for dynamic linking
103
case $ac_sys_system/$ac_sys_release in
104
CYGWIN*) PYTHONDYNAMICLINKING="-L$PYLIB $PYLINK"
105
PYINCLUDE="-DUSE_DL_IMPORT $PYINCLUDE"
107
*)PYTHONDYNAMICLINKING="";;
114
AC_SUBST(PYTHONBUILD)
115
AC_SUBST(PYTHONDYNAMICLINKING)