[libpeas/proxys: 20/25] Update configure.ac code for Python detection.



commit 0a353881f15b95178d311f25bb1b1e922015745f
Author: Steve Frécinaux <code istique net>
Date:   Thu May 20 18:19:03 2010 +0200

    Update configure.ac code for Python detection.

 configure.ac |  104 ++++++++++++++++++++++++++-------------------------------
 1 files changed, 47 insertions(+), 57 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 33f0af1..b357353 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,73 +152,63 @@ dnl ================================================================
 dnl Python
 dnl ================================================================
 
-AC_MSG_CHECKING([for Python support.])
+PYTHON_REQUIRED=2.5.2
+PYGOBJECT_REQUIRED=2.20
+
 AC_ARG_ENABLE(python,
-	      AS_HELP_STRING([--enable-python], [Enable python support]),
-	      [enable_python=$enableval have_python=$enableval],
-	      [enable_python=autodetect have_python=yes])
-AC_MSG_RESULT([$enable_python])
-
-if test "x$have_python" != "xno"; then
-	AM_PATH_PYTHON([2.3],[],[no])
-	if test "x$PYTHON" = "x:"; then
-		have_python=no
+	      AS_HELP_STRING([--enable-python],[Enable Python support]),
+	      [enable_python=$enableval],
+	      [enable_python=auto])
+
+if test "$enable_python" = "no"; then
+	found_python="no (disabled, use --enable-python to enable)"
+else
+	AM_PATH_PYTHON($PYTHON_REQUIRED,
+		       [found_python=yes],
+		       [found_python="no (python interpretor >= ${PYTHON_REQUIRED} not found"])
+
+	if test "$found_python" = "yes"; then
+		AC_PATH_TOOL(PYTHON_CONFIG, "python${PYTHON_VERSION}-config")
+		if test -z "$PYTHON_CONFIG"; then
+			AC_PATH_TOOL(PYTHON_CONFIG, "python-config-${PYTHON_VERSION}")
+			if test -z "$PYTHON_CONFIG"; then
+				found_python="no (python${PYTHON_VERSION}-config not found)"
+			fi
+		fi
 	fi
-fi
 
-#if test "x$have_python" != "xno"; then
-#	AM_CHECK_PYTHON_HEADERS([],[have_python=no])
-#fi
-
-if test "x$have_python" != "xno"; then
-	PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'`
-	PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'`
-	PYTHON_LIBS="-lpython$PYTHON_VERSION"
-	PYTHON_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config"
-	PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION"
-	PYTHON_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config/Makefile"
-	PYTHON_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
-	PYTHON_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
-	PYTHON_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
-	PYTHON_EXTRA_LIBS="$PYTHON_LOCALMODLIBS $PYTHON_BASEMODLIBS $PYTHON_OTHER_LIBS"
-	AC_SUBST([PYTHON_LIBS])
-	AC_SUBST([PYTHON_LIB_LOC])
-	AC_SUBST([PYTHON_CFLAGS])
-	AC_SUBST([PYTHON_EXTRA_LIBS])
-fi
+	if test "$found_python" = "yes"; then
+		save_CPPFLAGS="${CPPFLAGS}"
+		CPPFLAGS="$CPPFLAGS `$PYTHON_CONFIG --includes`"
+		AC_CHECK_HEADER(Python.h,,[found_python="no (Python headers not found)"])
+		CPPFLAGS="${save_CPPFLAGS}"
+	fi
 
-if test "x$have_python" != "xyes"; then
-	if test "x$enable_python" = "xyes"; then
-		AC_MSG_ERROR([Python not found])
-	elif test "x$enable_python" = "xautodetect"; then
-		enable_python=no
-		AC_MSG_WARN([Python not found, disabling python support])
+	AC_MSG_CHECKING([for PyGObject availability.])
+	if test "$found_python" = "yes"; then
+		PKG_CHECK_EXISTS([pygobject-2.0 >= $PYGOBJECT_REQUIRED],,
+				 [found_python="no (pygobject >= $PYGOBJECT_REQURED) not found)"])
 	fi
+	AC_MSG_RESULT([$found_python])
+
+	dnl FIXME: shall we check explicitely for PyGI here? Strictly speaking,
+	dnl it's not required for building libpeas, merely to use it properly.
 fi
 
-if test "x$have_python" != "xno"; then
-	PKG_CHECK_MODULES([PYGTK], [
-		pygobject-2.0 >= 2.16
-		pygtk-2.0 >= 2.14],
-		[],
-		[
-		have_python=no
-		if test "x$enable_python" = "xyes"; then
-			AC_MSG_ERROR([$PYGTK_PKG_ERRORS])
-		elif test "x$enable_python" = "xautodetect"; then
-			enable_python=no
-			AC_MSG_WARN([$PYGTK_PKG_ERRORS])
-			AC_MSG_WARN([Disabling python support])
-		fi
-		])
+if test "$enable_python" = "yes" -a "$found_python" = "no"; then
+	AC_MSG_ERROR([$found_python])
 fi
 
-if test "x$have_python" != "xno" -a "x$enable_python" != "xno"; then
-	enable_python=yes
-	AC_DEFINE([ENABLE_PYTHON],[1],[Define to compile with python support])
+if test "$found_python" = "yes"; then
+	PYTHON_CFLAGS="`$PKG_CONFIG --cflags pygobject-2.0` `$PYTHON_CONFIG --includes`"
+	PYTHON_LIBS="`$PKG_CONFIG --libs pygobject-2.0` `$PYTHON_CONFIG --libs`"
+	AC_SUBST(PYTHON_CFLAGS)
+	AC_SUBST(PYTHON_LIBS)
+
+	AC_DEFINE(ENABLE_PYTHON,1,[Define to compile with Python support])
 fi
 
-AM_CONDITIONAL([ENABLE_PYTHON],[test "x$enable_python" = "xyes"])
+AM_CONDITIONAL([ENABLE_PYTHON],[test "$found_python" = "yes"])
 
 dnl ================================================================
 dnl Documentation
@@ -286,5 +276,5 @@ Configuration:
         Compiler                      : ${CC}
         Installation prefix           : ${prefix}
         Seed JS support               : ${found_seed}
-        Python support                : ${enable_python}
+        Python support                : ${found_python}
 "



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