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
7 AC_DEFUN([PYTHON_DEVEL],
9 AC_REQUIRE([AM_PATH_PYTHON])
11 python_prefix=${PYTHON%/bin*}
13 # Check for Python include path
14 AC_MSG_CHECKING([for python include path])
15 for i in "$python_prefix/include/python$PYTHON_VERSION/" \
16 "$python_prefix/include/python/" "$python_prefix/"
18 python_path=`find $i -type f -name Python.h -print 2> /dev/null`
19 test "$python_path" && break
23 python_path=${python_path%/Python.h}
26 if test "$python_path"
28 AC_MSG_RESULT([$python_path])
30 AC_MSG_ERROR([cannot find python include path])
32 AC_SUBST([PYTHON_CFLAGS], [-I$python_path])
34 # Check for a Python library
35 AC_MSG_CHECKING([for python library])
37 for i in "$python_prefix/lib" \
38 "$python_prefix/lib/python$PYTHON_VERSION/config" \
39 "$python_prefix/lib/python$PYTHON_VERSION/lib" \
40 "$python_prefix/lib/python/lib"
42 if test -r "$i/libpython$PYTHON_VERSION.so"; then
43 PYLIB="$i/libpython$PYTHON_VERSION.so"
44 PYTHON_LIBS="-L$i -lpython$PYTHON_VERSION"
47 if test -r "$i/libpython$PYTHON_VERSION.a"; then
48 PYLIB="$i/libpython$PYTHON_VERSION.a"
49 PYTHON_LIBS="-L$i -lpython$PYTHON_VERSION -lpthread -ldl -lutil -lm"
52 # look for really old versions
53 if test -r "$i/libPython.a"; then
54 PYLIB="$i/libPython.a"
55 PYTHON_LIBS="-L$i -lModules -lPython -lObjects -lParser"
63 AC_MSG_RESULT([$PYLIB])
65 AC_MSG_ERROR([cannot find python library])
67 AC_SUBST([PYTHON_LIBS])