3 # Checks for Python and tries to get the include path to 'Python.h', and
4 # the libpython library.
5 # It provides the $(PYTHON_CFLAGS) $(PYTHON_LIBS) output variables.
6 AC_DEFUN([PYTHON_DEVEL],
8 AC_REQUIRE([AM_PATH_PYTHON])
10 python_prefix=${PYTHON%/bin*}
12 # Check for Python include path
13 AC_MSG_CHECKING([for python include path])
14 for i in "$python_prefix/include/python$PYTHON_VERSION/" \
15 "$python_prefix/include/python/" "$python_prefix/"
17 python_path=`find $i -type f -name Python.h -print`
18 test "$python_path" && break
22 python_path=${python_path%/Python.h}
25 if test "$python_path"
27 AC_MSG_RESULT([$python_path])
29 AC_MSG_ERROR([cannot find python include path])
31 AC_SUBST([PYTHON_CFLAGS], [-I$python_path])
33 # Check for a Python library
34 AC_MSG_CHECKING([for python library])
36 for i in "$python_prefix/lib" \
37 "$python_prefix/lib/python$PYTHON_VERSION/config" \
38 "$python_prefix/lib/python$PYTHON_VERSION/lib" \
39 "$python_prefix/lib/python/lib"
41 if test -r "$i/libpython$PYTHON_VERSION.so"; then
42 PYLIB="$i/libpython$PYTHON_VERSION.so"
43 PYTHON_LIBS="-L$i -l$PYVERSION"
46 if test -r "$i/lib$PYVERSION.a"; then
47 PYLIB="$i/lib$PYVERSION.a"
48 PYTHON_LIBS="-L$i -l$PYVERSION -lpthread -ldl -lutil -lm"
51 # look for really old versions
52 if test -r "$i/libPython.a"; then
53 PYLIB="$i/libPython.a"
54 PYTHON_LIBS="-L$i -lModules -lPython -lObjects -lParser"
60 if test "$python_path"
62 AC_MSG_RESULT([$PYLIB])
64 AC_MSG_ERROR([cannot find python library])
66 AC_SUBST([PYTHON_LIBS])