[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] autoconf: change python configure testing
On Thu, 2012-02-23 at 12:13 +0000, Roger Pau Monne wrote: > # HG changeset patch > # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> > # Date 1329999113 -3600 > # Node ID 6688425179fdf1fb39f3093362ba8053d1ae4f21 > # Parent 1b68427875f7ffe3025ea13c7f6e8cf71ce54769 > autoconf: change python configure testing > > Switch from our custom m4 macro to ax_python_devel.m4 found in: > > http://www.gnu.org/software/autoconf-archive/ax_python_devel.html > > This provides the same set of test but uses python distutils instead > of python-config. > > This change will also force users to switch from setting PYTHON env > variable to using PYTHON_VERSION, which has to contain the python > version to use (e.g.: '2.6'), if the user has several python versions > installed and would like to use one different than the default. Are these env vars documented anywhere? Perhaps we could set PYTHON_VERSION based on PYTHON if the former is not set and the later is? > Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> > > diff -r 1b68427875f7 -r 6688425179fd config/Tools.mk.in > --- a/config/Tools.mk.in Thu Mar 15 15:20:37 2012 +0000 > +++ b/config/Tools.mk.in Thu Feb 23 13:11:53 2012 +0100 > @@ -8,8 +8,8 @@ debug := @debug@ > # Tools path > BISON := @BISON@ > FLEX := @FLEX@ > -PYTHON := @PYTHON@ > -PYTHON_PATH := @PYTHONPATH@ > +PYTHON := python@PYTHON_VERSION@ > +PYTHON_PATH := @PYTHON@ > PERL := @PERL@ > IP := @IP@ > CURL_CONFIG := @CURL@ > diff -r 1b68427875f7 -r 6688425179fd tools/configure > --- a/tools/configure Thu Mar 15 15:20:37 2012 +0000 > +++ b/tools/configure Thu Feb 23 13:11:53 2012 +0100 > @@ -613,7 +613,13 @@ PKG_CONFIG_LIBDIR > PKG_CONFIG_PATH > PKG_CONFIG > CURSES_LIBS > -PYTHONPATH > +PYTHON_EXTRA_LDFLAGS > +PYTHON_EXTRA_LIBS > +PYTHON_SITE_PKG > +PYTHON_LDFLAGS > +PYTHON_CPPFLAGS > +PYTHON > +PYTHON_VERSION > OCAMLBUILD > OCAMLDOC > OCAMLMKLIB > @@ -640,7 +646,6 @@ CURL > FLEX > BISON > PERL > -PYTHON > APPEND_LIB > APPEND_INCLUDES > PREPEND_LIB > @@ -736,7 +741,6 @@ PREPEND_INCLUDES > PREPEND_LIB > APPEND_INCLUDES > APPEND_LIB > -PYTHON > PERL > BISON > FLEX > @@ -744,6 +748,7 @@ CURL > XML > BASH > XGETTEXT > +PYTHON_VERSION > PKG_CONFIG > PKG_CONFIG_PATH > PKG_CONFIG_LIBDIR > @@ -1389,7 +1394,6 @@ Some influential environment variables: > APPEND_INCLUDES > List of include folders to append to CFLAGS (without -I) > APPEND_LIB List of library folders to append to LDFLAGS (without -L) > - PYTHON Path to the Python parser > PERL Path to Perl parser > BISON Path to Bison parser generator > FLEX Path to Flex lexical analyser generator > @@ -1397,6 +1401,10 @@ Some influential environment variables: > XML Path to xml2-config tool > BASH Path to bash shell > XGETTEXT Path to xgetttext tool > + PYTHON_VERSION > + The installed Python version to use, for example '2.3'. This > + string will be appended to the Python interpreter canonical > + name. > PKG_CONFIG path to pkg-config utility > PKG_CONFIG_PATH > directories to add to pkg-config's search path > @@ -3808,7 +3816,94 @@ case $host_os in *\ *) host_os=`echo "$h > > > > - > +# =========================================================================== > +# http://www.gnu.org/software/autoconf-archive/ax_python_devel.html > +# =========================================================================== > +# > +# SYNOPSIS > +# > +# AX_PYTHON_DEVEL([version]) > +# > +# DESCRIPTION > +# > +# Note: Defines as a precious variable "PYTHON_VERSION". Don't override it > +# in your configure.ac. > +# > +# This macro checks for Python and tries to get the include path to > +# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) > +# output variables. It also exports $(PYTHON_EXTRA_LIBS) and > +# $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. > +# > +# You can search for some particular version of Python by passing a > +# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please > +# note that you *have* to pass also an operator along with the version to > +# match, and pay special attention to the single quotes surrounding the > +# version number. Don't use "PYTHON_VERSION" for this: that environment > +# variable is declared as precious and thus reserved for the end-user. > +# > +# This macro should work for all versions of Python >= 2.1.0. As an end > +# user, you can disable the check for the python version by setting the > +# PYTHON_NOVERSIONCHECK environment variable to something else than the > +# empty string. > +# > +# If you need to use this macro for an older Python version, please > +# contact the authors. We're always open for feedback. > +# > +# LICENSE > +# > +# Copyright (c) 2009 Sebastian Huber <sebastian-huber@xxxxxx> > +# Copyright (c) 2009 Alan W. Irwin <irwin@xxxxxxxxxxxxxxxxxxx> > +# Copyright (c) 2009 Rafael Laboissiere <rafael@xxxxxxxxxxxxxxx> > +# Copyright (c) 2009 Andrew Collier <colliera@xxxxxxxxxx> > +# Copyright (c) 2009 Matteo Settenvini <matteo@xxxxxxxxxxxxxx> > +# Copyright (c) 2009 Horst Knorr <hk_classes@xxxxxxxxx> > +# > +# This program is free software: you can redistribute it and/or modify it > +# under the terms of the GNU General Public License as published by the > +# Free Software Foundation, either version 3 of the License, or (at your > +# option) any later version. > +# > +# This program is distributed in the hope that it will be useful, but > +# WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General > +# Public License for more details. > +# > +# You should have received a copy of the GNU General Public License along > +# with this program. If not, see <http://www.gnu.org/licenses/>. > +# > +# As a special exception, the respective Autoconf Macro's copyright owner > +# gives unlimited permission to copy, distribute and modify the configure > +# scripts that are the output of Autoconf when processing the Macro. You > +# need not follow the terms of the GNU General Public License when using > +# or distributing such scripts, even though portions of the text of the > +# Macro appear in them. The GNU General Public License (GPL) does govern > +# all other use of the material that constitutes the Autoconf Macro. > +# > +# This special exception to the GPL applies to versions of the Autoconf > +# Macro released by the Autoconf Archive. When you make and distribute a > +# modified version of the Autoconf Macro, you may extend this special > +# exception to the GPL to apply to your modified version as well. > + > +#serial 8 > + > +# This is what autoupdate's m4 run will expand. It fires > +# the warning (with _au_warn_XXX), outputs it into the > +# updated configure.ac (with AC_DIAGNOSE), and then outputs > +# the replacement expansion. > + > + > +# This is an auxiliary macro that is also run when > +# autoupdate runs m4. It simply calls m4_warning, but > +# we need a wrapper so that each warning is emitted only > +# once. We break the quoting in m4_warning's argument in > +# order to expand this macro's arguments, not AU_DEFUN's. > + > + > +# Finally, this is the expansion that is picked up by > +# autoconf. It tells the user to run autoupdate, and > +# then outputs the replacement expansion. We do not care > +# about autoupdate's warning because that contains > +# information on what to do *after* running autoupdate. > > > > @@ -4131,7 +4226,6 @@ LDFLAGS="$PREPEND_LDFLAGS $LDFLAGS $APPE > > > > - > # Checks for programs. > { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not > truncate output" >&5 > $as_echo_n "checking for a sed that does not truncate output... " >&6; } > @@ -6074,26 +6168,22 @@ then > fi > if test "x$pythontools" = "xy"; then : > > - if echo "$PYTHON" | grep -q "^/"; then : > - > - PYTHONPATH=$PYTHON > - PYTHON=`basename $PYTHONPATH` > - > -elif test -z "$PYTHON"; then : > - PYTHON="python" > -else > - as_fn_error $? "PYTHON specified, but is not an absolute path" "$LINENO" 5 > -fi > - # Extract the first word of "$PYTHON", so it can be a program name with > args. > -set dummy $PYTHON; ac_word=$2 > + > + # > + # Allow the use of a (user set) custom python version > + # > + > + > + # Extract the first word of "python[$PYTHON_VERSION]", so it can be a > program name with args. > +set dummy python$PYTHON_VERSION; ac_word=$2 > { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 > $as_echo_n "checking for $ac_word... " >&6; } > -if test "${ac_cv_path_PYTHONPATH+set}" = set; then : > - $as_echo_n "(cached) " >&6 > -else > - case $PYTHONPATH in > +if test "${ac_cv_path_PYTHON+set}" = set; then : > + $as_echo_n "(cached) " >&6 > +else > + case $PYTHON in > [\\/]* | ?:[\\/]*) > - ac_cv_path_PYTHONPATH="$PYTHONPATH" # Let the user override the test with > a path. > + ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path. > ;; > *) > as_save_IFS=$IFS; IFS=$PATH_SEPARATOR > @@ -6103,7 +6193,7 @@ do > test -z "$as_dir" && as_dir=. > for ac_exec_ext in '' $ac_executable_extensions; do > if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x > "$as_dir/$ac_word$ac_exec_ext"; }; then > - ac_cv_path_PYTHONPATH="$as_dir/$ac_word$ac_exec_ext" > + ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext" > $as_echo "$as_me:${as_lineno-$LINENO}: found > $as_dir/$ac_word$ac_exec_ext" >&5 > break 2 > fi > @@ -6111,118 +6201,319 @@ done > done > IFS=$as_save_IFS > > - test -z "$ac_cv_path_PYTHONPATH" && ac_cv_path_PYTHONPATH="no" > ;; > esac > fi > -PYTHONPATH=$ac_cv_path_PYTHONPATH > -if test -n "$PYTHONPATH"; then > - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHONPATH" >&5 > -$as_echo "$PYTHONPATH" >&6; } > +PYTHON=$ac_cv_path_PYTHON > +if test -n "$PYTHON"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 > +$as_echo "$PYTHON" >&6; } > else > { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 > $as_echo "no" >&6; } > fi > > > -if test x"${PYTHONPATH}" == x"no" > -then > - as_fn_error $? "Unable to find $PYTHON, please install $PYTHON" > "$LINENO" 5 > -fi > - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python version >= > 2.3 " >&5 > -$as_echo_n "checking for python version >= 2.3 ... " >&6; } > -`$PYTHON -c 'import sys; sys.exit(eval("sys.version_info < (2, 3)"))'` > -if test "$?" != "0" > -then > - python_version=`$PYTHON -V 2>&1` > - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 > + if test -z "$PYTHON"; then > + as_fn_error $? "Cannot find python$PYTHON_VERSION in your system > path" "$LINENO" 5 > + PYTHON_VERSION="" > + fi > + > + # > + # Check for a version of Python >= 2.1.0 > + # > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a version of > Python >= '2.1.0'" >&5 > +$as_echo_n "checking for a version of Python >= '2.1.0'... " >&6; } > + ac_supports_python_ver=`$PYTHON -c "import sys; \ > + ver = sys.version.split ()[0]; \ > + print (ver >= '2.1.0')"` > + if test "$ac_supports_python_ver" != "True"; then > + if test -z "$PYTHON_NOVERSIONCHECK"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" > >&5 > $as_echo "no" >&6; } > - as_fn_error $? "$python_version is too old, minimum required version is > 2.3" "$LINENO" 5 > -else > - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 > + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in > \`$ac_pwd':" >&5 > +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} > +as_fn_error $? " > +This version of the AC_PYTHON_DEVEL macro > +doesn't work properly with versions of Python before > +2.1.0. You may need to re-run configure, setting the > +variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, > +PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. > +Moreover, to disable this check, set PYTHON_NOVERSIONCHECK > +to something else than an empty string. > + > +See \`config.log' for more details" "$LINENO" 5 ; } > + else > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: skip > at user request" >&5 > +$as_echo "skip at user request" >&6; } > + fi > + else > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 > $as_echo "yes" >&6; } > -fi > - > -ac_previous_cppflags=$CPPFLAGS > -CPPFLAGS="$CFLAGS `$PYTHON-config --includes`" > -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 > -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 : > - > -else > - as_fn_error $? "Unable to find Python development headers" "$LINENO" 5 > -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; } > -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" > -cat confdefs.h - <<_ACEOF >conftest.$ac_ext > + fi > + > + # > + # if the macro parameter ``version'' is set, honour it > + # > + if test -n ">= '2.3'"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a > version of Python >= '2.3'" >&5 > +$as_echo_n "checking for a version of Python >= '2.3'... " >&6; } > + ac_supports_python_ver=`$PYTHON -c "import sys; \ > + ver = sys.version.split ()[0]; \ > + print (ver >= '2.3')"` > + if test "$ac_supports_python_ver" = "True"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 > +$as_echo "yes" >&6; } > + else > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" > >&5 > +$as_echo "no" >&6; } > + as_fn_error $? "this package requires Python >= '2.3'. > +If you have it installed, but it isn't the default Python > +interpreter in your system path, please pass the PYTHON_VERSION > +variable to configure. See \`\`configure --help'' for reference. > +" "$LINENO" 5 > + PYTHON_VERSION="" > + fi > + fi > + > + # > + # Check if you have distutils, else fail > + # > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the distutils > Python package" >&5 > +$as_echo_n "checking for the distutils Python package... " >&6; } > + ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` > + if test -z "$ac_distutils_result"; then > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 > +$as_echo "yes" >&6; } > + else > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 > +$as_echo "no" >&6; } > + as_fn_error $? "cannot import Python module \"distutils\". > +Please check your Python installation. The error was: > +$ac_distutils_result" "$LINENO" 5 > + PYTHON_VERSION="" > + fi > + > + # > + # Check for Python include path > + # > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python include > path" >&5 > +$as_echo_n "checking for Python include path... " >&6; } > + if test -z "$PYTHON_CPPFLAGS"; then > + python_path=`$PYTHON -c "import distutils.sysconfig; \ > + print (distutils.sysconfig.get_python_inc ());"` > + if test -n "${python_path}"; then > + python_path="-I$python_path" > + fi > + PYTHON_CPPFLAGS=$python_path > + fi > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_CPPFLAGS" >&5 > +$as_echo "$PYTHON_CPPFLAGS" >&6; } > + > + > + # > + # Check for Python library path > + # > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python library > path" >&5 > +$as_echo_n "checking for Python library path... " >&6; } > + if test -z "$PYTHON_LDFLAGS"; then > + # (makes two attempts to ensure we've got a version number > + # from the interpreter) > + ac_python_version=`cat<<EOD | $PYTHON - > + > +# join all versioning strings, on some systems > +# major/minor numbers could be in different list elements > +from distutils.sysconfig import * > +ret = '' > +for e in get_config_vars ('VERSION'): > + if (e != None): > + ret += e > +print (ret) > +EOD` > + > + if test -z "$ac_python_version"; then > + if test -n "$PYTHON_VERSION"; then > + ac_python_version=$PYTHON_VERSION > + else > + ac_python_version=`$PYTHON -c "import sys; \ > + print (sys.version[:3])"` > + fi > + fi > + > + # Make the versioning information available to the compiler > + > +cat >>confdefs.h <<_ACEOF > +#define HAVE_PYTHON "$ac_python_version" > +_ACEOF > + > + > + # First, the library directory: > + ac_python_libdir=`cat<<EOD | $PYTHON - > + > +# There should be only one > +import distutils.sysconfig > +for e in distutils.sysconfig.get_config_vars ('LIBDIR'): > + if e != None: > + print (e) > + break > +EOD` > + > + # Before checking for libpythonX.Y, we need to know > + # the extension the OS we're on uses for libraries > + # (we take the first one, if there's more than one fix me!): > + ac_python_soext=`$PYTHON -c \ > + "import distutils.sysconfig; \ > + print (distutils.sysconfig.get_config_vars('SO')[0])"` > + > + # Now, for the library: > + ac_python_soname=`$PYTHON -c \ > + "import distutils.sysconfig; \ > + print > (distutils.sysconfig.get_config_vars('LDLIBRARY')[0])"` > + > + # Strip away extension from the end to canonicalize its name: > + ac_python_library=`echo "$ac_python_soname" | sed > "s/${ac_python_soext}$//"` > + > + # This small piece shamelessly adapted from PostgreSQL python > macro; > + # credits goes to momjian, I think. I'd like to put the right > name > + # in the credits, if someone can point me in the right > direction... ? > + # > + if test -n "$ac_python_libdir" -a -n "$ac_python_library" \ > + -a x"$ac_python_library" != x"$ac_python_soname" > + then > + # use the official shared library > + ac_python_library=`echo "$ac_python_library" | sed > "s/^lib//"` > + PYTHON_LDFLAGS="-L$ac_python_libdir > -l$ac_python_library" > + else > + # old way: use libpython from python_configdir > + ac_python_libdir=`$PYTHON -c \ > + "from distutils.sysconfig import get_python_lib as > f; \ > + import os; \ > + print (os.path.join(f(plat_specific=1, > standard_lib=1), 'config'));"` > + PYTHON_LDFLAGS="-L$ac_python_libdir > -lpython$ac_python_version" > + fi > + > + if test -z "PYTHON_LDFLAGS"; then > + as_fn_error $? " > + Cannot determine location of your Python DSO. Please check it was > installed with > + dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand. > + " "$LINENO" 5 > + fi > + fi > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_LDFLAGS" >&5 > +$as_echo "$PYTHON_LDFLAGS" >&6; } > + > + > + # > + # Check for site packages > + # > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Python > site-packages path" >&5 > +$as_echo_n "checking for Python site-packages path... " >&6; } > + if test -z "$PYTHON_SITE_PKG"; then > + PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ > + print (distutils.sysconfig.get_python_lib(0,0));"` > + fi > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_SITE_PKG" >&5 > +$as_echo "$PYTHON_SITE_PKG" >&6; } > + > + > + # > + # libraries which must be linked in when embedding > + # > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking python extra > libraries" >&5 > +$as_echo_n "checking python extra libraries... " >&6; } > + if test -z "$PYTHON_EXTRA_LIBS"; then > + PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ > + conf = distutils.sysconfig.get_config_var; \ > + print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"` > + fi > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_EXTRA_LIBS" > >&5 > +$as_echo "$PYTHON_EXTRA_LIBS" >&6; } > + > + > + # > + # linking flags needed when embedding > + # > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking python extra > linking flags" >&5 > +$as_echo_n "checking python extra linking flags... " >&6; } > + if test -z "$PYTHON_EXTRA_LDFLAGS"; then > + PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; > \ > + conf = distutils.sysconfig.get_config_var; \ > + print (conf('LINKFORSHARED'))"` > + fi > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: > $PYTHON_EXTRA_LDFLAGS" >&5 > +$as_echo "$PYTHON_EXTRA_LDFLAGS" >&6; } > + > + > + # > + # final check to see if everything compiles alright > + # > + { $as_echo "$as_me:${as_lineno-$LINENO}: checking consistency of all > components of python development environment" >&5 > +$as_echo_n "checking consistency of all components of python development > environment... " >&6; } > + # save current global flags > + ac_save_LIBS="$LIBS" > + ac_save_CPPFLAGS="$CPPFLAGS" > + LIBS="$ac_save_LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS > $PYTHON_EXTRA_LIBS" > + CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" > + ac_ext=c > +ac_cpp='$CPP $CPPFLAGS' > +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' > +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS > conftest.$ac_ext $LIBS >&5' > +ac_compiler_gnu=$ac_cv_c_compiler_gnu > + > + cat confdefs.h - <<_ACEOF >conftest.$ac_ext > /* end confdefs.h. */ > > -/* Override any GCC internal prototype to avoid an error. > - Use char because int might match the return type of a GCC > - builtin and then its argument prototype would still apply. */ > -#ifdef __cplusplus > -extern "C" > -#endif > -char PyArg_ParseTuple (); > + #include <Python.h> > int > main () > { > -return PyArg_ParseTuple (); > +Py_Initialize(); > ; > return 0; > } > + > _ACEOF > if ac_fn_c_try_link "$LINENO"; then : > - eval "$as_ac_Lib=yes" > -else > - eval "$as_ac_Lib=no" > + pythonexists=yes > +else > + pythonexists=no > fi > rm -f core conftest.err conftest.$ac_objext \ > conftest$ac_exeext conftest.$ac_ext > -LIBS=$ac_check_lib_save_LIBS > -fi > -eval ac_res=\$$as_ac_Lib > - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 > -$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" > - > -else > - as_fn_error $? "Unable to find a suitable python development library" > "$LINENO" 5 > -fi > - > -CPPFLAGS=$ac_previous_cppflags > -LDLFAGS=$ac_previous_ldflags > + ac_ext=c > +ac_cpp='$CPP $CPPFLAGS' > +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' > +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS > conftest.$ac_ext $LIBS >&5' > +ac_compiler_gnu=$ac_cv_c_compiler_gnu > + > + # turn back to default flags > + CPPFLAGS="$ac_save_CPPFLAGS" > + LIBS="$ac_save_LIBS" > + > + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pythonexists" >&5 > +$as_echo "$pythonexists" >&6; } > + > + if test ! "x$pythonexists" = "xyes"; then > + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" > >&5 > +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} > +as_fn_error $? " > + Could not link test program to Python. Maybe the main Python library has > been > + installed in some non-standard library path. If so, pass it to configure, > + via the LDFLAGS environment variable. > + Example: ./configure LDFLAGS=\"-L/usr/non-standard-path/python/lib\" > + > ============================================================================ > + ERROR! > + You probably have to install the development version of the Python package > + for your distribution. The exact name of this package varies among them. > + > ============================================================================ > + > +See \`config.log' for more details" "$LINENO" 5 ; } > + PYTHON_VERSION="" > + fi > + > + # > + # all done! > + # > > > fi > diff -r 1b68427875f7 -r 6688425179fd tools/configure.ac > --- a/tools/configure.ac Thu Mar 15 15:20:37 2012 +0000 > +++ b/tools/configure.ac Thu Feb 23 13:11:53 2012 +0100 > @@ -26,8 +26,7 @@ AC_CANONICAL_HOST > m4_include([m4/enable_feature.m4]) > m4_include([m4/disable_feature.m4]) > m4_include([m4/path_or_fail.m4]) > -m4_include([m4/python_version.m4]) > -m4_include([m4/python_devel.m4]) > +m4_include([m4/ax_python_devel.m4]) > m4_include([m4/ocaml.m4]) > m4_include([m4/default_lib.m4]) > m4_include([m4/set_cflags_ldflags.m4]) > @@ -58,7 +57,6 @@ AC_ARG_VAR([APPEND_LIB], > > AX_SET_FLAGS > > -AC_ARG_VAR([PYTHON], [Path to the Python parser]) > AC_ARG_VAR([PERL], [Path to Perl parser]) > AC_ARG_VAR([BISON], [Path to Bison parser generator]) > AC_ARG_VAR([FLEX], [Path to Flex lexical analyser generator]) > @@ -88,14 +86,7 @@ AS_IF([test "x$ocamltools" = "xy"], [ > ]) > AX_PATH_PROG_OR_FAIL([BASH], [bash]) > AS_IF([test "x$pythontools" = "xy"], [ > - AS_IF([echo "$PYTHON" | grep -q "^/"], [ > - PYTHONPATH=$PYTHON > - PYTHON=`basename $PYTHONPATH` > - ],[test -z "$PYTHON"], [PYTHON="python"], > - [AC_MSG_ERROR([PYTHON specified, but is not an absolute path])]) > - AX_PATH_PROG_OR_FAIL([PYTHONPATH], [$PYTHON]) > - AX_CHECK_PYTHON_VERSION([2], [3]) > - AX_CHECK_PYTHON_DEVEL() > + AX_PYTHON_DEVEL([>= '2.3']) > ]) > AX_PATH_PROG_OR_FAIL([XGETTEXT], [xgettext]) > AX_CHECK_UUID > diff -r 1b68427875f7 -r 6688425179fd tools/m4/ax_python_devel.m4 > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/tools/m4/ax_python_devel.m4 Thu Feb 23 13:11:53 2012 +0100 > @@ -0,0 +1,325 @@ > +# =========================================================================== > +# http://www.gnu.org/software/autoconf-archive/ax_python_devel.html > +# =========================================================================== > +# > +# SYNOPSIS > +# > +# AX_PYTHON_DEVEL([version]) > +# > +# DESCRIPTION > +# > +# Note: Defines as a precious variable "PYTHON_VERSION". Don't override it > +# in your configure.ac. > +# > +# This macro checks for Python and tries to get the include path to > +# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) > +# output variables. It also exports $(PYTHON_EXTRA_LIBS) and > +# $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. > +# > +# You can search for some particular version of Python by passing a > +# parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please > +# note that you *have* to pass also an operator along with the version to > +# match, and pay special attention to the single quotes surrounding the > +# version number. Don't use "PYTHON_VERSION" for this: that environment > +# variable is declared as precious and thus reserved for the end-user. > +# > +# This macro should work for all versions of Python >= 2.1.0. As an end > +# user, you can disable the check for the python version by setting the > +# PYTHON_NOVERSIONCHECK environment variable to something else than the > +# empty string. > +# > +# If you need to use this macro for an older Python version, please > +# contact the authors. We're always open for feedback. > +# > +# LICENSE > +# > +# Copyright (c) 2009 Sebastian Huber <sebastian-huber@xxxxxx> > +# Copyright (c) 2009 Alan W. Irwin <irwin@xxxxxxxxxxxxxxxxxxx> > +# Copyright (c) 2009 Rafael Laboissiere <rafael@xxxxxxxxxxxxxxx> > +# Copyright (c) 2009 Andrew Collier <colliera@xxxxxxxxxx> > +# Copyright (c) 2009 Matteo Settenvini <matteo@xxxxxxxxxxxxxx> > +# Copyright (c) 2009 Horst Knorr <hk_classes@xxxxxxxxx> > +# > +# This program is free software: you can redistribute it and/or modify it > +# under the terms of the GNU General Public License as published by the > +# Free Software Foundation, either version 3 of the License, or (at your > +# option) any later version. > +# > +# This program is distributed in the hope that it will be useful, but > +# WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General > +# Public License for more details. > +# > +# You should have received a copy of the GNU General Public License along > +# with this program. If not, see <http://www.gnu.org/licenses/>. > +# > +# As a special exception, the respective Autoconf Macro's copyright owner > +# gives unlimited permission to copy, distribute and modify the configure > +# scripts that are the output of Autoconf when processing the Macro. You > +# need not follow the terms of the GNU General Public License when using > +# or distributing such scripts, even though portions of the text of the > +# Macro appear in them. The GNU General Public License (GPL) does govern > +# all other use of the material that constitutes the Autoconf Macro. > +# > +# This special exception to the GPL applies to versions of the Autoconf > +# Macro released by the Autoconf Archive. When you make and distribute a > +# modified version of the Autoconf Macro, you may extend this special > +# exception to the GPL to apply to your modified version as well. > + > +#serial 8 > + > +AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) > +AC_DEFUN([AX_PYTHON_DEVEL],[ > + # > + # Allow the use of a (user set) custom python version > + # > + AC_ARG_VAR([PYTHON_VERSION],[The installed Python > + version to use, for example '2.3'. This string > + will be appended to the Python interpreter > + canonical name.]) > + > + AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) > + if test -z "$PYTHON"; then > + AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system > path]) > + PYTHON_VERSION="" > + fi > + > + # > + # Check for a version of Python >= 2.1.0 > + # > + AC_MSG_CHECKING([for a version of Python >= '2.1.0']) > + ac_supports_python_ver=`$PYTHON -c "import sys; \ > + ver = sys.version.split ()[[0]]; \ > + print (ver >= '2.1.0')"` > + if test "$ac_supports_python_ver" != "True"; then > + if test -z "$PYTHON_NOVERSIONCHECK"; then > + AC_MSG_RESULT([no]) > + AC_MSG_FAILURE([ > +This version of the AC@&t@_PYTHON_DEVEL macro > +doesn't work properly with versions of Python before > +2.1.0. You may need to re-run configure, setting the > +variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, > +PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. > +Moreover, to disable this check, set PYTHON_NOVERSIONCHECK > +to something else than an empty string. > +]) > + else > + AC_MSG_RESULT([skip at user request]) > + fi > + else > + AC_MSG_RESULT([yes]) > + fi > + > + # > + # if the macro parameter ``version'' is set, honour it > + # > + if test -n "$1"; then > + AC_MSG_CHECKING([for a version of Python $1]) > + ac_supports_python_ver=`$PYTHON -c "import sys; \ > + ver = sys.version.split ()[[0]]; \ > + print (ver $1)"` > + if test "$ac_supports_python_ver" = "True"; then > + AC_MSG_RESULT([yes]) > + else > + AC_MSG_RESULT([no]) > + AC_MSG_ERROR([this package requires Python $1. > +If you have it installed, but it isn't the default Python > +interpreter in your system path, please pass the PYTHON_VERSION > +variable to configure. See ``configure --help'' for reference. > +]) > + PYTHON_VERSION="" > + fi > + fi > + > + # > + # Check if you have distutils, else fail > + # > + AC_MSG_CHECKING([for the distutils Python package]) > + ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` > + if test -z "$ac_distutils_result"; then > + AC_MSG_RESULT([yes]) > + else > + AC_MSG_RESULT([no]) > + AC_MSG_ERROR([cannot import Python module "distutils". > +Please check your Python installation. The error was: > +$ac_distutils_result]) > + PYTHON_VERSION="" > + fi > + > + # > + # Check for Python include path > + # > + AC_MSG_CHECKING([for Python include path]) > + if test -z "$PYTHON_CPPFLAGS"; then > + python_path=`$PYTHON -c "import distutils.sysconfig; \ > + print (distutils.sysconfig.get_python_inc ());"` > + if test -n "${python_path}"; then > + python_path="-I$python_path" > + fi > + PYTHON_CPPFLAGS=$python_path > + fi > + AC_MSG_RESULT([$PYTHON_CPPFLAGS]) > + AC_SUBST([PYTHON_CPPFLAGS]) > + > + # > + # Check for Python library path > + # > + AC_MSG_CHECKING([for Python library path]) > + if test -z "$PYTHON_LDFLAGS"; then > + # (makes two attempts to ensure we've got a version number > + # from the interpreter) > + ac_python_version=`cat<<EOD | $PYTHON - > + > +# join all versioning strings, on some systems > +# major/minor numbers could be in different list elements > +from distutils.sysconfig import * > +ret = '' > +for e in get_config_vars ('VERSION'): > + if (e != None): > + ret += e > +print (ret) > +EOD` > + > + if test -z "$ac_python_version"; then > + if test -n "$PYTHON_VERSION"; then > + ac_python_version=$PYTHON_VERSION > + else > + ac_python_version=`$PYTHON -c "import sys; \ > + print (sys.version[[:3]])"` > + fi > + fi > + > + # Make the versioning information available to the compiler > + AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"], > + [If available, contains the Python > version number currently in use.]) > + > + # First, the library directory: > + ac_python_libdir=`cat<<EOD | $PYTHON - > + > +# There should be only one > +import distutils.sysconfig > +for e in distutils.sysconfig.get_config_vars ('LIBDIR'): > + if e != None: > + print (e) > + break > +EOD` > + > + # Before checking for libpythonX.Y, we need to know > + # the extension the OS we're on uses for libraries > + # (we take the first one, if there's more than one fix me!): > + ac_python_soext=`$PYTHON -c \ > + "import distutils.sysconfig; \ > + print (distutils.sysconfig.get_config_vars('SO')[[0]])"` > + > + # Now, for the library: > + ac_python_soname=`$PYTHON -c \ > + "import distutils.sysconfig; \ > + print > (distutils.sysconfig.get_config_vars('LDLIBRARY')[[0]])"` > + > + # Strip away extension from the end to canonicalize its name: > + ac_python_library=`echo "$ac_python_soname" | sed > "s/${ac_python_soext}$//"` > + > + # This small piece shamelessly adapted from PostgreSQL python > macro; > + # credits goes to momjian, I think. I'd like to put the right > name > + # in the credits, if someone can point me in the right > direction... ? > + # > + if test -n "$ac_python_libdir" -a -n "$ac_python_library" \ > + -a x"$ac_python_library" != x"$ac_python_soname" > + then > + # use the official shared library > + ac_python_library=`echo "$ac_python_library" | sed > "s/^lib//"` > + PYTHON_LDFLAGS="-L$ac_python_libdir > -l$ac_python_library" > + else > + # old way: use libpython from python_configdir > + ac_python_libdir=`$PYTHON -c \ > + "from distutils.sysconfig import get_python_lib as > f; \ > + import os; \ > + print (os.path.join(f(plat_specific=1, > standard_lib=1), 'config'));"` > + PYTHON_LDFLAGS="-L$ac_python_libdir > -lpython$ac_python_version" > + fi > + > + if test -z "PYTHON_LDFLAGS"; then > + AC_MSG_ERROR([ > + Cannot determine location of your Python DSO. Please check it was > installed with > + dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand. > + ]) > + fi > + fi > + AC_MSG_RESULT([$PYTHON_LDFLAGS]) > + AC_SUBST([PYTHON_LDFLAGS]) > + > + # > + # Check for site packages > + # > + AC_MSG_CHECKING([for Python site-packages path]) > + if test -z "$PYTHON_SITE_PKG"; then > + PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ > + print (distutils.sysconfig.get_python_lib(0,0));"` > + fi > + AC_MSG_RESULT([$PYTHON_SITE_PKG]) > + AC_SUBST([PYTHON_SITE_PKG]) > + > + # > + # libraries which must be linked in when embedding > + # > + AC_MSG_CHECKING(python extra libraries) > + if test -z "$PYTHON_EXTRA_LIBS"; then > + PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ > + conf = distutils.sysconfig.get_config_var; \ > + print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"` > + fi > + AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) > + AC_SUBST(PYTHON_EXTRA_LIBS) > + > + # > + # linking flags needed when embedding > + # > + AC_MSG_CHECKING(python extra linking flags) > + if test -z "$PYTHON_EXTRA_LDFLAGS"; then > + PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; > \ > + conf = distutils.sysconfig.get_config_var; \ > + print (conf('LINKFORSHARED'))"` > + fi > + AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS]) > + AC_SUBST(PYTHON_EXTRA_LDFLAGS) > + > + # > + # final check to see if everything compiles alright > + # > + AC_MSG_CHECKING([consistency of all components of python development > environment]) > + # save current global flags > + ac_save_LIBS="$LIBS" > + ac_save_CPPFLAGS="$CPPFLAGS" > + LIBS="$ac_save_LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS > $PYTHON_EXTRA_LIBS" > + CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" > + AC_LANG_PUSH([C]) > + AC_LINK_IFELSE([ > + AC_LANG_PROGRAM([[#include <Python.h>]], > + [[Py_Initialize();]]) > + ],[pythonexists=yes],[pythonexists=no]) > + AC_LANG_POP([C]) > + # turn back to default flags > + CPPFLAGS="$ac_save_CPPFLAGS" > + LIBS="$ac_save_LIBS" > + > + AC_MSG_RESULT([$pythonexists]) > + > + if test ! "x$pythonexists" = "xyes"; then > + AC_MSG_FAILURE([ > + Could not link test program to Python. Maybe the main Python library has > been > + installed in some non-standard library path. If so, pass it to configure, > + via the LDFLAGS environment variable. > + Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" > + > ============================================================================ > + ERROR! > + You probably have to install the development version of the Python package > + for your distribution. The exact name of this package varies among them. > + > ============================================================================ > + ]) > + PYTHON_VERSION="" > + fi > + > + # > + # all done! > + # > +]) > diff -r 1b68427875f7 -r 6688425179fd tools/m4/python_devel.m4 > --- a/tools/m4/python_devel.m4 Thu Mar 15 15:20:37 2012 +0000 > +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 > @@ -1,28 +0,0 @@ > -AC_DEFUN([AX_CHECK_PYTHON_DEVEL], [ > -ac_previous_cppflags=$CPPFLAGS > -CPPFLAGS="$CFLAGS `$PYTHON-config --includes`" > -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 > -AC_CHECK_HEADER([Python.h], [], > - [AC_MSG_ERROR([Unable to find Python development headers])],) > -AC_CHECK_LIB($python_lib, PyArg_ParseTuple, [], > - [AC_MSG_ERROR([Unable to find a suitable python development library])]) > -CPPFLAGS=$ac_previous_cppflags > -LDLFAGS=$ac_previous_ldflags > -]) > diff -r 1b68427875f7 -r 6688425179fd tools/m4/python_version.m4 > --- a/tools/m4/python_version.m4 Thu Mar 15 15:20:37 2012 +0000 > +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 > @@ -1,12 +0,0 @@ > -AC_DEFUN([AX_CHECK_PYTHON_VERSION], > -[AC_MSG_CHECKING([for python version >= $1.$2 ]) > -`$PYTHON -c 'import sys; sys.exit(eval("sys.version_info < ($1, $2)"))'` > -if test "$?" != "0" > -then > - python_version=`$PYTHON -V 2>&1` > - AC_MSG_RESULT([no]) > - AC_MSG_ERROR( > - [$python_version is too old, minimum required version is $1.$2]) > -else > - AC_MSG_RESULT([yes]) > -fi]) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |