1 dnl a macro to check for ability to create python extensions
2 dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
3 dnl function also defines PYTHON_INCLUDES
4 AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
5 [AC_REQUIRE([AM_PATH_PYTHON])
6 dnl deduce PYTHON_INCLUDES
8 AC_MSG_CHECKING(for Python headers using $PYTHON-config --includes)
9 PYTHON_INCLUDES=`$PYTHON-config --includes`
11 AC_MSG_RESULT($PYTHON_INCLUDES)
13 AC_MSG_RESULT([failed, will try another way])
14 py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
15 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
16 AC_MSG_CHECKING(for Python headers in $py_prefix and $py_exec_prefix)
17 PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
18 if test "$py_prefix" != "$py_exec_prefix"; then
19 PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
21 AC_MSG_RESULT($PYTHON_INCLUDES)
24 AC_MSG_CHECKING(whether those headers are sufficient)
25 AC_SUBST(PYTHON_INCLUDES)
26 dnl check if the headers exist:
27 save_CPPFLAGS="$CPPFLAGS"
28 CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
29 AC_TRY_CPP([#include <Python.h>],dnl
34 CPPFLAGS="$save_CPPFLAGS"