1 # generated automatically by aclocal 1.8.3 -*- Autoconf -*-
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
16 # Free Software Foundation, Inc.
18 # This program is free software; you can redistribute it and/or modify
19 # it under the terms of the GNU General Public License as published by
20 # the Free Software Foundation; either version 2, or (at your option)
23 # This program is distributed in the hope that it will be useful,
24 # but WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 # GNU General Public License for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with this program; if not, write to the Free Software
30 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
35 # Adds support for distributing Python modules and packages. To
36 # install modules, copy them to $(pythondir), using the python_PYTHON
37 # automake variable. To install a package with the same name as the
38 # automake package, install to $(pkgpythondir), or use the
39 # pkgpython_PYTHON automake variable.
41 # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
42 # locations to install python extension modules (shared libraries).
43 # Another macro is required to find the appropriate flags to compile
46 # If your package is configured with a different prefix to python,
47 # users will have to add the install directory to the PYTHONPATH
48 # environment variable, or create a .pth file (see the python
49 # documentation for details).
51 # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
52 # cause an error if the version of python installed on the system
53 # doesn't meet the requirement. MINIMUM-VERSION should consist of
54 # numbers and dots only.
56 AC_DEFUN([AM_PATH_PYTHON],
58 dnl Find a Python interpreter. Python versions prior to 1.5 are not
59 dnl supported because the default installation locations changed from
60 dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
62 m4_define([_AM_PYTHON_INTERPRETER_LIST],
63 [python python2 python2.4 python2.3 python2.2 dnl
64 python2.1 python2.0 python1.6 python1.5])
67 dnl No version check is needed.
68 # Find any Python interpreter.
69 if test -z "$PYTHON"; then
71 AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST)
73 am_display_PYTHON=python
75 dnl A version check is needed.
76 if test -n "$PYTHON"; then
77 # If the user set $PYTHON, use it and don't search something else.
78 AC_MSG_CHECKING([whether $PYTHON version >= $1])
79 AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
81 [AC_MSG_ERROR(too old)])
83 # Otherwise, try each interpreter until we find one that satisfies
85 AC_CACHE_CHECK([for a Python interpreter with version >= $1],
86 [am_cv_pathless_PYTHON],[
87 for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
88 test "$am_cv_pathless_PYTHON" = none && break
89 AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
91 # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
92 if test "$am_cv_pathless_PYTHON" = none; then
95 AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
97 am_display_PYTHON=$am_cv_pathless_PYTHON
101 if test "$PYTHON" = :; then
102 dnl Run any user-specified action, or abort.
103 m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
106 dnl Query Python for its version number. Getting [:3] seems to be
107 dnl the best way to do this; it's what "site.py" does in the standard
110 AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
111 [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
112 AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
114 dnl Use the values of $prefix and $exec_prefix for the corresponding
115 dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
116 dnl distinct variables so they can be overridden if need be. However,
117 dnl general consensus is that you shouldn't need this ability.
119 AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
120 AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
122 dnl At times (like when building shared libraries) you may want
123 dnl to know which OS platform Python thinks this is.
125 AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
126 [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
127 AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
130 dnl Set up 4 directories:
132 dnl pythondir -- where to install python scripts. This is the
133 dnl site-packages directory, not the python standard library
134 dnl directory like in previous automake betas. This behavior
135 dnl is more consistent with lispdir.m4 for example.
136 dnl Query distutils for this directory. distutils does not exist in
137 dnl Python 1.5, so we fall back to the hardcoded directory if it
139 AC_CACHE_CHECK([for $am_display_PYTHON script directory],
140 [am_cv_python_pythondir],
141 [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
142 echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`])
143 AC_SUBST([pythondir], [$am_cv_python_pythondir])
145 dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
146 dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
147 dnl more consistent with the rest of automake.
149 AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
151 dnl pyexecdir -- directory for installing python extension modules
152 dnl (shared libraries)
153 dnl Query distutils for this directory. distutils does not exist in
154 dnl Python 1.5, so we fall back to the hardcoded directory if it
156 AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
157 [am_cv_python_pyexecdir],
158 [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
159 echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`])
160 AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
162 dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
164 AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
166 dnl Run any user-specified action.
173 # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
174 # ---------------------------------------------------------------------------
175 # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
176 # Run ACTION-IF-FALSE otherwise.
177 # This test uses sys.hexversion instead of the string equivalent (first
178 # word of sys.version), in order to cope with versions such as 2.2c1.
179 # hexversion has been introduced in Python 1.5.2; it's probably not
180 # worth to support older versions (1.5.1 was released on October 31, 1998).
181 AC_DEFUN([AM_PYTHON_CHECK_VERSION],
182 [prog="import sys, string
183 # split strings by '.' and convert to numeric. Append some zeros
184 # because we need at least 4 digits for the hex conversion.
185 minver = map(int, string.split('$2', '.')) + [[0, 0, 0]]
187 for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]]
188 sys.exit(sys.hexversion < minverhex)"
189 AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
191 # Copyright (C) 2001, 2003 Free Software Foundation, Inc. -*- Autoconf -*-
193 # This program is free software; you can redistribute it and/or modify
194 # it under the terms of the GNU General Public License as published by
195 # the Free Software Foundation; either version 2, or (at your option)
198 # This program is distributed in the hope that it will be useful,
199 # but WITHOUT ANY WARRANTY; without even the implied warranty of
200 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
201 # GNU General Public License for more details.
203 # You should have received a copy of the GNU General Public License
204 # along with this program; if not, write to the Free Software
205 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
208 # AM_RUN_LOG(COMMAND)
209 # -------------------
210 # Run COMMAND, save the exit status in ac_status, and log it.
211 # (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
212 AC_DEFUN([AM_RUN_LOG],
213 [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
214 ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
216 echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
217 (exit $ac_status); }])
219 m4_include([acinclude.m4])