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

[Xen-changelog] [xen-unstable] autoconf: fix python-dev detection on old python versions



# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
# Date 1333459725 -3600
# Node ID 0879faaf4c09596d06aad313b20e1bc952f4efde
# Parent  8aa1697d57e480e00b5aaef587c940b52055c064
autoconf: fix python-dev detection on old python versions

Replaced the use of python-config (that is only present in Python >= 2.5.x)
with the distutils python module.

Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
Cc: Zhang, Yang Z <yang.z.zhang@xxxxxxxxx>
Tested-by: KUWAMURA Shin'ya <kuwa@xxxxxxxxxxxxxx>
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r 8aa1697d57e4 -r 0879faaf4c09 tools/configure
--- a/tools/configure   Tue Apr 03 12:35:35 2012 +0200
+++ b/tools/configure   Tue Apr 03 14:28:45 2012 +0100
@@ -6143,27 +6143,26 @@ else
 $as_echo "yes" >&6; }
 fi
 
+ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("VERSION")'`
 ac_previous_cppflags=$CPPFLAGS
-CPPFLAGS="$CFLAGS `$PYTHON-config --includes`"
+CPPFLAGS="$CFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print "-I" + distutils.sysconfig.get_config_var("INCLUDEPY")'`"
+CPPFLAGS="$CPPFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("CFLAGS")'`"
 ac_previous_ldflags=$LDFLAGS
-for flag in `$PYTHON-config --ldflags`
-do
-    case $flag in
-    -L*)
-        LDFLAGS="$LDLFAGS $flag"
-        ;;
-    -lpython*)
-        python_lib=`echo $flag | sed 's/^-l//'`
-        ;;
-    -l*)
-        # Ignore other libraries, we are only interested in testing python-dev
-        ;;
-    *)
-        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Strange ldflag found 
in $PYTHON-config output: $flag" >&5
-$as_echo "$as_me: WARNING: Strange ldflag found in $PYTHON-config output: 
$flag" >&2;}
-        ;;
-    esac
-done
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("LIBS")'`"
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("SYSLIBS")'`"
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print "-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\
+    standard_lib=1) + "/config"'`"
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("LINKFORSHARED")'`"
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("LDFLAGS")'`"
+
 ac_fn_c_check_header_mongrel "$LINENO" "Python.h" "ac_cv_header_Python_h" 
"$ac_includes_default"
 if test "x$ac_cv_header_Python_h" = x""yes; then :
 
@@ -6172,14 +6171,14 @@ else
 fi
 
 
-as_ac_Lib=`$as_echo "ac_cv_lib_$python_lib''_PyArg_ParseTuple" | $as_tr_sh`
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PyArg_ParseTuple in 
-l$python_lib" >&5
-$as_echo_n "checking for PyArg_ParseTuple in -l$python_lib... " >&6; }
+as_ac_Lib=`$as_echo "ac_cv_lib_python$ac_python_version''_PyArg_ParseTuple" | 
$as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PyArg_ParseTuple in 
-lpython$ac_python_version" >&5
+$as_echo_n "checking for PyArg_ParseTuple in -lpython$ac_python_version... " 
>&6; }
 if eval "test \"\${$as_ac_Lib+set}\"" = set; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
-LIBS="-l$python_lib  $LIBS"
+LIBS="-lpython$ac_python_version  $LIBS"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -6212,10 +6211,10 @@ eval ac_res=\$$as_ac_Lib
 $as_echo "$ac_res" >&6; }
 if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_LIB$python_lib" | $as_tr_cpp` 1
-_ACEOF
-
-  LIBS="-l$python_lib $LIBS"
+#define `$as_echo "HAVE_LIBpython$ac_python_version" | $as_tr_cpp` 1
+_ACEOF
+
+  LIBS="-lpython$ac_python_version $LIBS"
 
 else
   as_fn_error $? "Unable to find a suitable python development library" 
"$LINENO" 5
diff -r 8aa1697d57e4 -r 0879faaf4c09 tools/m4/python_devel.m4
--- a/tools/m4/python_devel.m4  Tue Apr 03 12:35:35 2012 +0200
+++ b/tools/m4/python_devel.m4  Tue Apr 03 14:28:45 2012 +0100
@@ -1,27 +1,27 @@
 AC_DEFUN([AX_CHECK_PYTHON_DEVEL], [
+ac_python_version=`$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("VERSION")'`
 ac_previous_cppflags=$CPPFLAGS
-CPPFLAGS="$CFLAGS `$PYTHON-config --includes`"
+CPPFLAGS="$CFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print "-I" + distutils.sysconfig.get_config_var("INCLUDEPY")'`"
+CPPFLAGS="$CPPFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("CFLAGS")'`"
 ac_previous_ldflags=$LDFLAGS
-for flag in `$PYTHON-config --ldflags`
-do
-    case $flag in
-    -L*)
-        LDFLAGS="$LDLFAGS $flag"
-        ;;
-    -lpython*)
-        python_lib=`echo $flag | sed 's/^-l//'`
-        ;;
-    -l*)
-        # Ignore other libraries, we are only interested in testing python-dev
-        ;;
-    *)
-        AC_MSG_WARN([Strange ldflag found in $PYTHON-config output: $flag])
-        ;;
-    esac
-done
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("LIBS")'`"
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("SYSLIBS")'`"
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print "-L" + distutils.sysconfig.get_python_lib(plat_specific=1,\
+    standard_lib=1) + "/config"'`"
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("LINKFORSHARED")'`"
+LDFLAGS="$LDFLAGS `$PYTHON -c 'import distutils.sysconfig; \
+    print distutils.sysconfig.get_config_var("LDFLAGS")'`"
+
 AC_CHECK_HEADER([Python.h], [],
     [AC_MSG_ERROR([Unable to find Python development headers])],)
-AC_CHECK_LIB($python_lib, PyArg_ParseTuple, [],
+AC_CHECK_LIB(python$ac_python_version, PyArg_ParseTuple, [],
     [AC_MSG_ERROR([Unable to find a suitable python development library])])
 CPPFLAGS=$ac_previous_cppflags
 LDLFAGS=$ac_previous_ldflags

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.