Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 236 lines (208 sloc) 9.558 kB
1b5a049 @gholms Use AM_PATH_PYTHON to locate python
gholms authored
1 # generated automatically by aclocal 1.11.1 -*- Autoconf -*-
2
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 # 2005, 2006, 2007, 2008, 2009 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.
8
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
12 # PARTICULAR PURPOSE.
13
14 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
15 # Free Software Foundation, Inc.
16 #
17 # This file is free software; the Free Software Foundation
18 # gives unlimited permission to copy and/or distribute it,
19 # with or without modifications, as long as this notice is preserved.
20
21 # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
22 # ---------------------------------------------------------------------------
23 # Adds support for distributing Python modules and packages. To
24 # install modules, copy them to $(pythondir), using the python_PYTHON
25 # automake variable. To install a package with the same name as the
26 # automake package, install to $(pkgpythondir), or use the
27 # pkgpython_PYTHON automake variable.
28 #
29 # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
30 # locations to install python extension modules (shared libraries).
31 # Another macro is required to find the appropriate flags to compile
32 # extension modules.
33 #
34 # If your package is configured with a different prefix to python,
35 # users will have to add the install directory to the PYTHONPATH
36 # environment variable, or create a .pth file (see the python
37 # documentation for details).
38 #
39 # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
40 # cause an error if the version of python installed on the system
41 # doesn't meet the requirement. MINIMUM-VERSION should consist of
42 # numbers and dots only.
43 AC_DEFUN([AM_PATH_PYTHON],
44 [
45 dnl Find a Python interpreter. Python versions prior to 2.0 are not
46 dnl supported. (2.0 was released on October 16, 2000).
47 m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
48 [python python2 python3 python3.0 python2.5 python2.4 python2.3 python2.2 dnl
49 python2.1 python2.0])
50
51 m4_if([$1],[],[
52 dnl No version check is needed.
53 # Find any Python interpreter.
54 if test -z "$PYTHON"; then
55 AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
56 fi
57 am_display_PYTHON=python
58 ], [
59 dnl A version check is needed.
60 if test -n "$PYTHON"; then
61 # If the user set $PYTHON, use it and don't search something else.
62 AC_MSG_CHECKING([whether $PYTHON version >= $1])
63 AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
64 [AC_MSG_RESULT(yes)],
65 [AC_MSG_ERROR(too old)])
66 am_display_PYTHON=$PYTHON
67 else
68 # Otherwise, try each interpreter until we find one that satisfies
69 # VERSION.
70 AC_CACHE_CHECK([for a Python interpreter with version >= $1],
71 [am_cv_pathless_PYTHON],[
72 for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
73 test "$am_cv_pathless_PYTHON" = none && break
74 AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
75 done])
76 # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
77 if test "$am_cv_pathless_PYTHON" = none; then
78 PYTHON=:
79 else
80 AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
81 fi
82 am_display_PYTHON=$am_cv_pathless_PYTHON
83 fi
84 ])
85
86 if test "$PYTHON" = :; then
87 dnl Run any user-specified action, or abort.
88 m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
89 else
90
91 dnl Query Python for its version number. Getting [:3] seems to be
92 dnl the best way to do this; it's what "site.py" does in the standard
93 dnl library.
94
95 AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
96 [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
97 AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
98
99 dnl Use the values of $prefix and $exec_prefix for the corresponding
100 dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
101 dnl distinct variables so they can be overridden if need be. However,
102 dnl general consensus is that you shouldn't need this ability.
103
104 AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
105 AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
106
107 dnl At times (like when building shared libraries) you may want
108 dnl to know which OS platform Python thinks this is.
109
110 AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
111 [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
112 AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
113
114
115 dnl Set up 4 directories:
116
117 dnl pythondir -- where to install python scripts. This is the
118 dnl site-packages directory, not the python standard library
119 dnl directory like in previous automake betas. This behavior
120 dnl is more consistent with lispdir.m4 for example.
121 dnl Query distutils for this directory. distutils does not exist in
122 dnl Python 1.5, so we fall back to the hardcoded directory if it
123 dnl doesn't work.
124 AC_CACHE_CHECK([for $am_display_PYTHON script directory],
125 [am_cv_python_pythondir],
126 [if test "x$prefix" = xNONE
127 then
128 am_py_prefix=$ac_default_prefix
129 else
130 am_py_prefix=$prefix
131 fi
132 am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null ||
133 echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
134 case $am_cv_python_pythondir in
135 $am_py_prefix*)
136 am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
137 am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
138 ;;
139 *)
140 case $am_py_prefix in
141 /usr|/System*) ;;
142 *)
143 am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
144 ;;
145 esac
146 ;;
147 esac
148 ])
149 AC_SUBST([pythondir], [$am_cv_python_pythondir])
150
151 dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
152 dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
153 dnl more consistent with the rest of automake.
154
155 AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
156
157 dnl pyexecdir -- directory for installing python extension modules
158 dnl (shared libraries)
159 dnl Query distutils for this directory. distutils does not exist in
160 dnl Python 1.5, so we fall back to the hardcoded directory if it
161 dnl doesn't work.
162 AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
163 [am_cv_python_pyexecdir],
164 [if test "x$exec_prefix" = xNONE
165 then
166 am_py_exec_prefix=$am_py_prefix
167 else
168 am_py_exec_prefix=$exec_prefix
169 fi
170 am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null ||
171 echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
172 case $am_cv_python_pyexecdir in
173 $am_py_exec_prefix*)
174 am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
175 am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
176 ;;
177 *)
178 case $am_py_exec_prefix in
179 /usr|/System*) ;;
180 *)
181 am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
182 ;;
183 esac
184 ;;
185 esac
186 ])
187 AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
188
189 dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
190
191 AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
192
193 dnl Run any user-specified action.
194 $2
195 fi
196
197 ])
198
199
200 # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
201 # ---------------------------------------------------------------------------
202 # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
203 # Run ACTION-IF-FALSE otherwise.
204 # This test uses sys.hexversion instead of the string equivalent (first
205 # word of sys.version), in order to cope with versions such as 2.2c1.
206 # This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
207 AC_DEFUN([AM_PYTHON_CHECK_VERSION],
208 [prog="import sys
209 # split strings by '.' and convert to numeric. Append some zeros
210 # because we need at least 4 digits for the hex conversion.
211 # map returns an iterator in Python 3.0 and a list in 2.x
212 minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
213 minverhex = 0
214 # xrange is not present in Python 3.0 and range returns an iterator
215 for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
216 sys.exit(sys.hexversion < minverhex)"
217 AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
218
219 # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
220 #
221 # This file is free software; the Free Software Foundation
222 # gives unlimited permission to copy and/or distribute it,
223 # with or without modifications, as long as this notice is preserved.
224
225 # AM_RUN_LOG(COMMAND)
226 # -------------------
227 # Run COMMAND, save the exit status in ac_status, and log it.
228 # (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
229 AC_DEFUN([AM_RUN_LOG],
230 [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
231 ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
232 ac_status=$?
233 echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
234 (exit $ac_status); }])
235
Something went wrong with that request. Please try again.