the following proposed patch for stable 3.1, refactors the logic used to
detect the python interpreter so that it works in platforms that don't have it
installed with a /usr prefix.

it defines a --with-python configure flag to help configure locate the python
binary and implicitly enable python support (overrides --disable-python) by
indicating the location of the python interpreter or the prefix where it is
installed.

this proposal contains changes from r1300 and r1303 and has been tested in
DragonFlyBSD, FreeBSD, NetBSD, OpenBSD, Solaris, Cygwin and Gentoo Linux

Carlo

---
Index: configure.in
===================================================================
--- configure.in        (revision 1317)
+++ configure.in        (working copy)
@@ -152,8 +152,12 @@
 
 AM_CONDITIONAL(BUILD_GMETAD, test x$gmetad = xyes)
 
+AC_ARG_WITH( python,
+[  --with-python=PATH      Specify prefix for python or full path to 
interpreter],
+[if test x"$withval" != xno; then enable_python="yes"; PYTHON_BIN=$withval; 
fi])
+
 AC_ARG_WITH( librrd,
-[  --with-librrd=PATH      Specify location for librrd],
+[  --with-librrd=DIR       Specify location for librrd],
 [if test x"$withval" != xno; then librrd=yes; librrdpath=$withval; fi])
 
 AC_ARG_WITH( libapr,
@@ -193,7 +197,7 @@
 
 AC_ARG_ENABLE( python,
 [  --disable-python        exclude mod_python and support for metric modules 
written in python],
-[ enable_python="no" ], [ enable_python="yes" ] )
+[ if test x"$enableval" != xyes; then enable_python="no"; fi ], [ 
enable_python="yes" ] )
 
 
 AC_ARG_ENABLE( status,
@@ -246,32 +250,41 @@
   # check for Python executable
   if test -z "$PYTHON_BIN"; then
     AC_PATH_PROG(PYTHON_BIN, python)
-    if test -z "$PYTHON_BIN"; then
-      AC_MSG_ERROR(python binary not found in path)
+  else
+    if test -d $PYTHON_BIN; then
+      PYTHON_BIN="$PYTHON_BIN/bin/python"
     fi
   fi
 
-  # find out python version
-  AC_MSG_CHECKING(Python version)
-  PyVERSION=`$PYTHON_BIN -c ['import sys; print sys.version[:3]'`]
-  PyMAJVERSION=`$PYTHON_BIN -c ['import sys; print sys.version[:1]'`]
-  AC_MSG_RESULT($PyVERSION)
-  PYTHON_VERSION=$PyVERSION
-  AC_SUBST(PYTHON_VERSION)
+  if test -n "$PYTHON_BIN"; then
+    # find out python version
+    AC_MSG_CHECKING(Python version)
+    PyVERSION=`$PYTHON_BIN -c ['import sys; print sys.version[:3]'`]
+    PyMAJVERSION=`$PYTHON_BIN -c ['import sys; print sys.version[:1]'`]
+    AC_MSG_RESULT($PyVERSION)
+    PYTHON_VERSION=$PyVERSION
+    AC_SUBST(PYTHON_VERSION)
 
-dnl   AC_CHECK_LIB(python{PyVERSION}, set_python_path, [echo "The ganglia 
python support module requires Python to compile"], [echo "Python library not 
found"], [-lm])
-   AC_CHECK_HEADERS(python$PyVERSION/Python.h python/Python.h, [ 
found_python_header=yes ])
-   if test "$found_python_header" = yes; then
-      if test -d "/usr/include/python"; then
-         PYTHON_INCLUDES="-I/usr/include/python"
+    PyEXEC_INSTALLDIR=`$PYTHON_BIN -c "import sys; print sys.exec_prefix"`
+    if test -d "$PyEXEC_INSTALLDIR/include/python"; then
+      PYTHON_INCLUDES="-I$PyEXEC_INSTALLDIR/include/python"
+    else 
+      if test -d "$PyEXEC_INSTALLDIR/include/python$PyVERSION"; then
+        PYTHON_INCLUDES="-I$PyEXEC_INSTALLDIR/include/python$PyVERSION"
       else
-         PYTHON_INCLUDES="-I/usr/include/python$PyVERSION"
+        PYTHON_INCLUDES=""
+        enable_python="no"
       fi
-      AC_SUBST(PYTHON_INCLUDES)
-   fi
+    fi
+    AC_SUBST(PYTHON_INCLUDES)
+  else
+    enable_python="no"
+  fi
 fi
 
-AM_CONDITIONAL(BUILD_PYTHON, test "$enable_python" = yes -a 
"$found_python_header" = yes)
+AC_MSG_CHECKING(Python support)
+AC_MSG_RESULT($enable_python)
+AM_CONDITIONAL(BUILD_PYTHON, test "$enable_python" = "yes")
 
 echo
 echo Checking for apr
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to