DAQ++ git-vmedaq
Brought to you by:
lacasta
dnl a macro to check for ability to create python extensions
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_REQUIRE([AM_CONDITIONAL])
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}"
fi
AC_SUBST(PYTHON_INCLUDES)
dnl Function to check if the python-config binary is available
dnl "python${PYTHON_VERSION}-config python-config"
#AC_DEFUN([AX_PROG_PYTHON_CONFIG],
AS_IF(
[test "x${PYTHON}" != x],
[AC_CHECK_PROGS(
[PYTHON_CONFIG],
[python${PYTHON_VERSION}-config python-config])
])
AS_IF(
[test "x${PYTHON_CONFIG}" = x],
[AC_MSG_ERROR(
[Unable to find python-config])
])
AC_SUBST(
[PYTHON_CONFIG],
[$PYTHON_CONFIG])
dnl Find the python library
py_lflags=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('LINKFORSHARED')"`
py_lib="python${PYTHON_VERSION}"
PYTHON_LIBS="${py_lflags} -L${py_prefix}/lib -l${py_lib}"
AC_SUBST(PYTHON_LIBS)
has_python="false"
AC_MSG_RESULT(Python: lflags-> $py_lflags lib->$py_lib LFLAGS->$PYTHON_LIBS)
if test -e ${py_prefix}/lib/lib${py_lib}.so; then
has_python="true"
AC_DEFINE([HAS_PYTHON],1,'we have python')
fi
AS_IF(
[test "x${PYTHON_CONFIG}" != x],
[
dnl Check for Python libraries
PYTHON_LDFLAGS=`${PYTHON_CONFIG} --ldflags 2>/dev/null`;
AC_MSG_CHECKING(
[for Python libraries])
AC_MSG_RESULT(
[$PYTHON_LDFLAGS])
AC_SUBST(
[PYTHON_LIBS],
[$PYTHON_LDFLAGS])
])
dnl check if the headers exist:
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
AC_TRY_CPP([#include <Python.h>],dnl
[AC_MSG_RESULT(found)
$1],dnl
[AC_MSG_RESULT(not found)
$2])
CPPFLAGS="$save_CPPFLAGS"
])