1 | # generated automatically by aclocal 1.9.5 -*- Autoconf -*- |
---|
2 | |
---|
3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
---|
4 | # 2005 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 |
---|
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 1.5 are not |
---|
46 | dnl supported because the default installation locations changed from |
---|
47 | dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages |
---|
48 | dnl in 1.5. |
---|
49 | m4_define_default([_AM_PYTHON_INTERPRETER_LIST], |
---|
50 | [python python2 python2.4 python2.3 python2.2 dnl |
---|
51 | python2.1 python2.0 python1.6 python1.5]) |
---|
52 | |
---|
53 | m4_if([$1],[],[ |
---|
54 | dnl No version check is needed. |
---|
55 | # Find any Python interpreter. |
---|
56 | if test -z "$PYTHON"; then |
---|
57 | AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :) |
---|
58 | fi |
---|
59 | am_display_PYTHON=python |
---|
60 | ], [ |
---|
61 | dnl A version check is needed. |
---|
62 | if test -n "$PYTHON"; then |
---|
63 | # If the user set $PYTHON, use it and don't search something else. |
---|
64 | AC_MSG_CHECKING([whether $PYTHON version >= $1]) |
---|
65 | AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], |
---|
66 | [AC_MSG_RESULT(yes)], |
---|
67 | [AC_MSG_ERROR(too old)]) |
---|
68 | am_display_PYTHON=$PYTHON |
---|
69 | else |
---|
70 | # Otherwise, try each interpreter until we find one that satisfies |
---|
71 | # VERSION. |
---|
72 | AC_CACHE_CHECK([for a Python interpreter with version >= $1], |
---|
73 | [am_cv_pathless_PYTHON],[ |
---|
74 | for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do |
---|
75 | test "$am_cv_pathless_PYTHON" = none && break |
---|
76 | AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) |
---|
77 | done]) |
---|
78 | # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. |
---|
79 | if test "$am_cv_pathless_PYTHON" = none; then |
---|
80 | PYTHON=: |
---|
81 | else |
---|
82 | AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) |
---|
83 | fi |
---|
84 | am_display_PYTHON=$am_cv_pathless_PYTHON |
---|
85 | fi |
---|
86 | ]) |
---|
87 | |
---|
88 | if test "$PYTHON" = :; then |
---|
89 | dnl Run any user-specified action, or abort. |
---|
90 | m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) |
---|
91 | else |
---|
92 | |
---|
93 | dnl Query Python for its version number. Getting [:3] seems to be |
---|
94 | dnl the best way to do this; it's what "site.py" does in the standard |
---|
95 | dnl library. |
---|
96 | |
---|
97 | AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], |
---|
98 | [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`]) |
---|
99 | AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) |
---|
100 | |
---|
101 | dnl Use the values of $prefix and $exec_prefix for the corresponding |
---|
102 | dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made |
---|
103 | dnl distinct variables so they can be overridden if need be. However, |
---|
104 | dnl general consensus is that you shouldn't need this ability. |
---|
105 | |
---|
106 | AC_SUBST([PYTHON_PREFIX], ['${prefix}']) |
---|
107 | AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) |
---|
108 | |
---|
109 | dnl At times (like when building shared libraries) you may want |
---|
110 | dnl to know which OS platform Python thinks this is. |
---|
111 | |
---|
112 | AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], |
---|
113 | [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`]) |
---|
114 | AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) |
---|
115 | |
---|
116 | |
---|
117 | dnl Set up 4 directories: |
---|
118 | |
---|
119 | dnl pythondir -- where to install python scripts. This is the |
---|
120 | dnl site-packages directory, not the python standard library |
---|
121 | dnl directory like in previous automake betas. This behavior |
---|
122 | dnl is more consistent with lispdir.m4 for example. |
---|
123 | dnl Query distutils for this directory. distutils does not exist in |
---|
124 | dnl Python 1.5, so we fall back to the hardcoded directory if it |
---|
125 | dnl doesn't work. |
---|
126 | AC_CACHE_CHECK([for $am_display_PYTHON script directory], |
---|
127 | [am_cv_python_pythondir], |
---|
128 | [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null || |
---|
129 | echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`]) |
---|
130 | AC_SUBST([pythondir], [$am_cv_python_pythondir]) |
---|
131 | |
---|
132 | dnl pkgpythondir -- $PACKAGE directory under pythondir. Was |
---|
133 | dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is |
---|
134 | dnl more consistent with the rest of automake. |
---|
135 | |
---|
136 | AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) |
---|
137 | |
---|
138 | dnl pyexecdir -- directory for installing python extension modules |
---|
139 | dnl (shared libraries) |
---|
140 | dnl Query distutils for this directory. distutils does not exist in |
---|
141 | dnl Python 1.5, so we fall back to the hardcoded directory if it |
---|
142 | dnl doesn't work. |
---|
143 | AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], |
---|
144 | [am_cv_python_pyexecdir], |
---|
145 | [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null || |
---|
146 | echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`]) |
---|
147 | AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) |
---|
148 | |
---|
149 | dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) |
---|
150 | |
---|
151 | AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) |
---|
152 | |
---|
153 | dnl Run any user-specified action. |
---|
154 | $2 |
---|
155 | fi |
---|
156 | |
---|
157 | ]) |
---|
158 | |
---|
159 | |
---|
160 | # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) |
---|
161 | # --------------------------------------------------------------------------- |
---|
162 | # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. |
---|
163 | # Run ACTION-IF-FALSE otherwise. |
---|
164 | # This test uses sys.hexversion instead of the string equivalent (first |
---|
165 | # word of sys.version), in order to cope with versions such as 2.2c1. |
---|
166 | # hexversion has been introduced in Python 1.5.2; it's probably not |
---|
167 | # worth to support older versions (1.5.1 was released on October 31, 1998). |
---|
168 | AC_DEFUN([AM_PYTHON_CHECK_VERSION], |
---|
169 | [prog="import sys, string |
---|
170 | # split strings by '.' and convert to numeric. Append some zeros |
---|
171 | # because we need at least 4 digits for the hex conversion. |
---|
172 | minver = map(int, string.split('$2', '.')) + [[0, 0, 0]] |
---|
173 | minverhex = 0 |
---|
174 | for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]] |
---|
175 | sys.exit(sys.hexversion < minverhex)" |
---|
176 | AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) |
---|
177 | |
---|