jamie@126: # =========================================================================== jamie@126: # http://www.gnu.org/software/autoconf-archive/ax_python_devel.html jamie@126: # =========================================================================== jamie@126: # jamie@126: # SYNOPSIS jamie@126: # jamie@126: # AX_PYTHON_DEVEL([version]) jamie@126: # jamie@126: # DESCRIPTION jamie@126: # jamie@126: # Note: Defines as a precious variable "PYTHON_VERSION". Don't override it jamie@126: # in your configure.ac. jamie@126: # jamie@126: # This macro checks for Python and tries to get the include path to jamie@126: # 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) jamie@126: # output variables. It also exports $(PYTHON_EXTRA_LIBS) and jamie@126: # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. jamie@126: # jamie@126: # You can search for some particular version of Python by passing a jamie@126: # parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please jamie@126: # note that you *have* to pass also an operator along with the version to jamie@126: # match, and pay special attention to the single quotes surrounding the jamie@126: # version number. Don't use "PYTHON_VERSION" for this: that environment jamie@126: # variable is declared as precious and thus reserved for the end-user. jamie@126: # jamie@126: # This macro should work for all versions of Python >= 2.1.0. As an end jamie@126: # user, you can disable the check for the python version by setting the jamie@126: # PYTHON_NOVERSIONCHECK environment variable to something else than the jamie@126: # empty string. jamie@126: # jamie@126: # If you need to use this macro for an older Python version, please jamie@126: # contact the authors. We're always open for feedback. jamie@126: # jamie@126: # LICENSE jamie@126: # jamie@126: # Copyright (c) 2009 Sebastian Huber jamie@126: # Copyright (c) 2009 Alan W. Irwin jamie@126: # Copyright (c) 2009 Rafael Laboissiere jamie@126: # Copyright (c) 2009 Andrew Collier jamie@126: # Copyright (c) 2009 Matteo Settenvini jamie@126: # Copyright (c) 2009 Horst Knorr jamie@126: # jamie@126: # This program is free software: you can redistribute it and/or modify it jamie@126: # under the terms of the GNU General Public License as published by the jamie@126: # Free Software Foundation, either version 3 of the License, or (at your jamie@126: # option) any later version. jamie@126: # jamie@126: # This program is distributed in the hope that it will be useful, but jamie@126: # WITHOUT ANY WARRANTY; without even the implied warranty of jamie@126: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General jamie@126: # Public License for more details. jamie@126: # jamie@126: # You should have received a copy of the GNU General Public License along jamie@126: # with this program. If not, see . jamie@126: # jamie@126: # As a special exception, the respective Autoconf Macro's copyright owner jamie@126: # gives unlimited permission to copy, distribute and modify the configure jamie@126: # scripts that are the output of Autoconf when processing the Macro. You jamie@126: # need not follow the terms of the GNU General Public License when using jamie@126: # or distributing such scripts, even though portions of the text of the jamie@126: # Macro appear in them. The GNU General Public License (GPL) does govern jamie@126: # all other use of the material that constitutes the Autoconf Macro. jamie@126: # jamie@126: # This special exception to the GPL applies to versions of the Autoconf jamie@126: # Macro released by the Autoconf Archive. When you make and distribute a jamie@126: # modified version of the Autoconf Macro, you may extend this special jamie@126: # exception to the GPL to apply to your modified version as well. jamie@126: jamie@126: #serial 8 jamie@126: jamie@126: AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) jamie@126: AC_DEFUN([AX_PYTHON_DEVEL],[ jamie@126: # jamie@126: # Allow the use of a (user set) custom python version jamie@126: # jamie@126: AC_ARG_VAR([PYTHON_VERSION],[The installed Python jamie@126: version to use, for example '2.3'. This string jamie@126: will be appended to the Python interpreter jamie@126: canonical name.]) jamie@126: jamie@126: AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) jamie@126: if test -z "$PYTHON"; then jamie@126: AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path]) jamie@126: PYTHON_VERSION="" jamie@126: fi jamie@126: jamie@126: # jamie@126: # Check for a version of Python >= 2.1.0 jamie@126: # jamie@126: AC_MSG_CHECKING([for a version of Python >= '2.1.0']) jamie@126: ac_supports_python_ver=`$PYTHON -c "import sys; \ jamie@126: ver = sys.version.split ()[[0]]; \ jamie@126: print (ver >= '2.1.0')"` jamie@126: if test "$ac_supports_python_ver" != "True"; then jamie@126: if test -z "$PYTHON_NOVERSIONCHECK"; then jamie@126: AC_MSG_RESULT([no]) jamie@126: AC_MSG_FAILURE([ jamie@126: This version of the AC@&t@_PYTHON_DEVEL macro jamie@126: doesn't work properly with versions of Python before jamie@126: 2.1.0. You may need to re-run configure, setting the jamie@126: variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, jamie@126: PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. jamie@126: Moreover, to disable this check, set PYTHON_NOVERSIONCHECK jamie@126: to something else than an empty string. jamie@126: ]) jamie@126: else jamie@126: AC_MSG_RESULT([skip at user request]) jamie@126: fi jamie@126: else jamie@126: AC_MSG_RESULT([yes]) jamie@126: fi jamie@126: jamie@126: # jamie@126: # if the macro parameter ``version'' is set, honour it jamie@126: # jamie@126: if test -n "$1"; then jamie@126: AC_MSG_CHECKING([for a version of Python $1]) jamie@126: ac_supports_python_ver=`$PYTHON -c "import sys; \ jamie@126: ver = sys.version.split ()[[0]]; \ jamie@126: print (ver $1)"` jamie@126: if test "$ac_supports_python_ver" = "True"; then jamie@126: AC_MSG_RESULT([yes]) jamie@126: else jamie@126: AC_MSG_RESULT([no]) jamie@126: AC_MSG_ERROR([this package requires Python $1. jamie@126: If you have it installed, but it isn't the default Python jamie@126: interpreter in your system path, please pass the PYTHON_VERSION jamie@126: variable to configure. See ``configure --help'' for reference. jamie@126: ]) jamie@126: PYTHON_VERSION="" jamie@126: fi jamie@126: fi jamie@126: jamie@126: # jamie@126: # Check if you have distutils, else fail jamie@126: # jamie@126: AC_MSG_CHECKING([for the distutils Python package]) jamie@126: ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` jamie@126: if test -z "$ac_distutils_result"; then jamie@126: AC_MSG_RESULT([yes]) jamie@126: else jamie@126: AC_MSG_RESULT([no]) jamie@126: AC_MSG_ERROR([cannot import Python module "distutils". jamie@126: Please check your Python installation. The error was: jamie@126: $ac_distutils_result]) jamie@126: PYTHON_VERSION="" jamie@126: fi jamie@126: jamie@126: # jamie@126: # Check for Python include path jamie@126: # jamie@126: AC_MSG_CHECKING([for Python include path]) jamie@126: if test -z "$PYTHON_CPPFLAGS"; then jamie@126: python_path=`$PYTHON -c "import distutils.sysconfig; \ jamie@126: print (distutils.sysconfig.get_python_inc ());"` jamie@126: if test -n "${python_path}"; then jamie@126: python_path="-I$python_path" jamie@126: fi jamie@126: PYTHON_CPPFLAGS=$python_path jamie@126: fi jamie@126: AC_MSG_RESULT([$PYTHON_CPPFLAGS]) jamie@126: AC_SUBST([PYTHON_CPPFLAGS]) jamie@126: jamie@126: # jamie@126: # Check for Python library path jamie@126: # jamie@126: AC_MSG_CHECKING([for Python library path]) jamie@126: if test -z "$PYTHON_LDFLAGS"; then jamie@126: # (makes two attempts to ensure we've got a version number jamie@126: # from the interpreter) jamie@126: ac_python_version=`cat<]], jamie@126: [[Py_Initialize();]]) jamie@126: ],[pythonexists=yes],[pythonexists=no]) jamie@126: AC_LANG_POP([C]) jamie@126: # turn back to default flags jamie@126: CPPFLAGS="$ac_save_CPPFLAGS" jamie@126: LIBS="$ac_save_LIBS" jamie@126: jamie@126: AC_MSG_RESULT([$pythonexists]) jamie@126: jamie@126: if test ! "x$pythonexists" = "xyes"; then jamie@126: AC_MSG_FAILURE([ jamie@126: Could not link test program to Python. Maybe the main Python library has been jamie@126: installed in some non-standard library path. If so, pass it to configure, jamie@126: via the LDFLAGS environment variable. jamie@126: Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" jamie@126: ============================================================================ jamie@126: ERROR! jamie@126: You probably have to install the development version of the Python package jamie@126: for your distribution. The exact name of this package varies among them. jamie@126: ============================================================================ jamie@126: ]) jamie@126: PYTHON_VERSION="" jamie@126: fi jamie@126: jamie@126: # jamie@126: # all done! jamie@126: # jamie@126: ])