[gnome-dvb-daemon] m4/python.m4: Add python3 support



commit 957f753191d1ba9ceb4bbb900be91461557675d5
Author: Sebastian Pölsterl <sebp k-d-w org>
Date:   Fri Aug 8 09:06:06 2014 -0400

    m4/python.m4: Add python3 support

 m4/python.m4 |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)
---
diff --git a/m4/python.m4 b/m4/python.m4
index a820c98..1067384 100755
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -33,9 +33,6 @@ else
   AC_MSG_RESULT(no)
   ifelse([$4], [],, [$4
 ])dnl
-  AC_MSG_ERROR([
-  Cannot find Python module [$1]
-  ])
 fi
 ])
 
@@ -46,11 +43,14 @@ 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}"
+if test "x$PYTHON_INCLUDES" = x; then
+  PYTHON_CONFIG=`which $PYTHON`-config
+  if test -x "$PYTHON_CONFIG"; then
+    PYTHON_INCLUDES=`$PYTHON_CONFIG --includes 2>/dev/null`
+  else
+    PYTHON_INCLUDES=`$PYTHON -c "import distutils.sysconfig, sys; 
sys.stdout.write(distutils.sysconfig.get_python_inc(True))"`
+    PYTHON_INCLUDES="-I$PYTHON_INCLUDES"
+  fi
 fi
 AC_SUBST(PYTHON_INCLUDES)
 dnl check if the headers exist:
@@ -63,3 +63,33 @@ $1],dnl
 $2])
 CPPFLAGS="$save_CPPFLAGS"
 ])
+
+dnl a macro to check for ability to embed python
+dnl  AM_CHECK_PYTHON_LIBS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
+dnl function also defines PYTHON_LIBS
+AC_DEFUN([AM_CHECK_PYTHON_LIBS],
+[AC_REQUIRE([AM_PATH_PYTHON])
+AC_MSG_CHECKING(for libraries required to embed python)
+dnl deduce PYTHON_LIBS
+py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`
+if test "x$PYTHON_LIBS" = x; then
+  PYTHON_CONFIG=`which $PYTHON`-config
+  if test -x "$PYTHON_CONFIG"; then
+    PYTHON_LIBS=`$PYTHON_CONFIG --ldflags 2>/dev/null`
+  else
+    PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}"
+  fi
+fi
+if test "x$PYTHON_LIB_LOC" = x; then
+       PYTHON_LIB_LOC="${py_prefix}/lib"
+fi
+AC_SUBST(PYTHON_LIBS)
+AC_SUBST(PYTHON_LIB_LOC)
+dnl check if the headers exist:
+save_LIBS="$LIBS"
+LIBS="$LIBS $PYTHON_LIBS"
+AC_TRY_LINK_FUNC(Py_Initialize, dnl
+         [LIBS="$save_LIBS"; AC_MSG_RESULT(yes); $1], dnl
+         [LIBS="$save_LIBS"; AC_MSG_RESULT(no); $2])
+
+])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]