m4/am-check-python-headers.m4: Try python-config --includes
Some systems (e.g. Arch Linux) put the Python C headers in a strange place, so try and run `$PYTHON-config --includes` first to find the -I options to pass to the C compiler. Fall back to the old method if it fails. Thanks to Darrell Enns for reporting the problem and suggesting a solution. I changed it a bit.
This commit is contained in:
parent
155529234a
commit
5f3b60573e
1 changed files with 17 additions and 9 deletions
|
@ -3,22 +3,30 @@ dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
|
|||
dnl function also defines PYTHON_INCLUDES
|
||||
AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
|
||||
[AC_REQUIRE([AM_PATH_PYTHON])
|
||||
AC_MSG_CHECKING(for headers required to compile python extensions)
|
||||
dnl deduce PYTHON_INCLUDES
|
||||
py_prefix=`$PYTHON -c "import sys; print(sys.prefix)"`
|
||||
py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
|
||||
PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
|
||||
if test "$py_prefix" != "$py_exec_prefix"; then
|
||||
PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
|
||||
AC_MSG_CHECKING([for python headers using $PYTHON-config --includes])
|
||||
PYTHON_INCLUDES=`$PYTHON-config --includes`
|
||||
if test $? = 0; then
|
||||
AC_MSG_RESULT([$PYTHON_INCLUDES])
|
||||
else
|
||||
AC_MSG_RESULT([failed, will try another way])
|
||||
py_prefix=`$PYTHON -c "import sys; print(sys.prefix)"`
|
||||
py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
|
||||
PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
|
||||
if test "$py_prefix" != "$py_exec_prefix"; then
|
||||
PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
|
||||
fi
|
||||
AC_MSG_NOTICE([setting python headers to $PYTHON_INCLUDES])
|
||||
fi
|
||||
AC_SUBST(PYTHON_INCLUDES)
|
||||
dnl check if the headers exist:
|
||||
AC_MSG_CHECKING([whether python headers are sufficient])
|
||||
AC_SUBST(PYTHON_INCLUDES)
|
||||
save_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
|
||||
AC_TRY_CPP([#include <Python.h>],dnl
|
||||
[AC_MSG_RESULT(found)
|
||||
[AC_MSG_RESULT(yes)
|
||||
$1],dnl
|
||||
[AC_MSG_RESULT(not found)
|
||||
[AC_MSG_RESULT(no)
|
||||
$2])
|
||||
CPPFLAGS="$save_CPPFLAGS"
|
||||
])
|
||||
|
|
Loading…
Add table
Reference in a new issue