Don't try to distribute COPYING.AFL-2.1 and COPYING.GPL-2, which we no longer have...
[dbus-python-phuang.git] / m4 / am-check-python-headers.m4
blob92ea204be78ddd37a8d365ebfefa8f4cb719140c
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`
10 if test $? = 0; then
11   AC_MSG_RESULT($PYTHON_INCLUDES)
12 else
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}"
20   fi
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
30 [AC_MSG_RESULT(yes)
31 $1],dnl
32 [AC_MSG_RESULT(no)
33 $2])
34 CPPFLAGS="$save_CPPFLAGS"