|
@@ -1,646 +1,243 @@
|
1
|
|
-# Copyright 2012, 2013, 2014 Brandon Invergo <brandon@invergo.net>
|
2
|
|
-#
|
3
|
|
-# This file is part of pyconfigure. This program is free
|
4
|
|
-# software; you can redistribute it and/or modify it under the
|
5
|
|
-# terms of the GNU General Public License as published by the
|
6
|
|
-# Free Software Foundation, either version 3 of the License, or
|
7
|
|
-# (at your option) any later version.
|
8
|
|
-#
|
9
|
|
-# This program is distributed in the hope that it will be useful,
|
10
|
|
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
|
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
|
-# GNU General Public License for more details.
|
13
|
|
-#
|
14
|
|
-# Under Section 7 of GPL version 3, you are granted additional
|
15
|
|
-# permissions described in the Autoconf Configure Script Exception,
|
16
|
|
-# version 3.0, as published by the Free Software Foundation.
|
17
|
|
-#
|
18
|
|
-# You should have received a copy of the GNU General Public License
|
19
|
|
-# and a copy of the Autoconf Configure Script Exception along with
|
20
|
|
-# this program; see the files COPYINGv3 and COPYING.EXCEPTION
|
21
|
|
-# respectively. If not, see <http://www.gnu.org/licenses/>.
|
22
|
|
-
|
23
|
|
-
|
24
|
|
-# Many of these macros were adapted from ones written by Andrew Dalke
|
25
|
|
-# and James Henstridge and are included with the Automake utility
|
26
|
|
-# under the following copyright terms:
|
27
|
|
-#
|
28
|
|
-# Copyright (C) 1999-2012 Free Software Foundation, Inc.
|
|
1
|
+## ------------------------ -*- Autoconf -*-
|
|
2
|
+## Python file handling
|
|
3
|
+## From Andrew Dalke
|
|
4
|
+## Updated by James Henstridge
|
|
5
|
+## ------------------------
|
|
6
|
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
|
29
|
7
|
#
|
30
|
8
|
# This file is free software; the Free Software Foundation
|
31
|
9
|
# gives unlimited permission to copy and/or distribute it,
|
32
|
10
|
# with or without modifications, as long as this notice is preserved.
|
33
|
11
|
|
34
|
|
-# Table of Contents:
|
35
|
|
-#
|
36
|
|
-# 1. Language selection
|
37
|
|
-# and routines to produce programs in a given language.
|
|
12
|
+
|
|
13
|
+# AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
|
14
|
+# ---------------------------------------------------------------------------
|
|
15
|
+# Adds support for distributing Python modules and packages. To
|
|
16
|
+# install modules, copy them to $(pythondir), using the python_PYTHON
|
|
17
|
+# automake variable. To install a package with the same name as the
|
|
18
|
+# automake package, install to $(pkgpythondir), or use the
|
|
19
|
+# pkgpython_PYTHON automake variable.
|
38
|
20
|
#
|
39
|
|
-# 2. Producing programs in a given language.
|
|
21
|
+# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
|
|
22
|
+# locations to install python extension modules (shared libraries).
|
|
23
|
+# Another macro is required to find the appropriate flags to compile
|
|
24
|
+# extension modules.
|
40
|
25
|
#
|
41
|
|
-# 3. Looking for a compiler
|
42
|
|
-# And possibly the associated preprocessor.
|
|
26
|
+# If your package is configured with a different prefix to python,
|
|
27
|
+# users will have to add the install directory to the PYTHONPATH
|
|
28
|
+# environment variable, or create a .pth file (see the python
|
|
29
|
+# documentation for details).
|
43
|
30
|
#
|
44
|
|
-# 4. Looking for specific libs & functionality
|
45
|
|
-
|
46
|
|
-
|
47
|
|
-## ----------------------- ##
|
48
|
|
-## 1. Language selection. ##
|
49
|
|
-## ----------------------- ##
|
50
|
|
-
|
51
|
|
-
|
52
|
|
-# AC_LANG(Python)
|
53
|
|
-# ---------------
|
54
|
|
-AC_LANG_DEFINE([Python], [py], [PY], [PYTHON], [],
|
55
|
|
-[ac_ext=py
|
56
|
|
-ac_compile='chmod +x conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
|
57
|
|
-ac_link='chmod +x conftest.$ac_ext && cp conftest.$ac_ext conftest >&AS_MESSAGE_LOG_FD'
|
58
|
|
-])
|
59
|
|
-
|
60
|
|
-
|
61
|
|
-# AC_LANG_PYTHON
|
62
|
|
-# --------------
|
63
|
|
-AU_DEFUN([AC_LANG_PYTHON], [AC_LANG(Python)])
|
64
|
|
-
|
65
|
|
-
|
66
|
|
-## ----------------------- ##
|
67
|
|
-## 2. Producing programs. ##
|
68
|
|
-## ----------------------- ##
|
69
|
|
-
|
70
|
|
-
|
71
|
|
-# AC_LANG_PROGRAM(Python)([PROLOGUE], [BODY])
|
72
|
|
-# -------------------------------------------
|
73
|
|
-m4_define([AC_LANG_PROGRAM(Python)], [dnl
|
74
|
|
-@%:@!$PYTHON
|
75
|
|
-$1
|
76
|
|
-m4_if([$2], [], [], [dnl
|
77
|
|
-if __name__ == '__main__':
|
78
|
|
-$2])])
|
79
|
|
-
|
80
|
|
-
|
81
|
|
-# _AC_LANG_IO_PROGRAM(Python)
|
82
|
|
-# ---------------------------
|
83
|
|
-# Produce source that performs I/O.
|
84
|
|
-m4_define([_AC_LANG_IO_PROGRAM(Python)],
|
85
|
|
-[AC_LANG_PROGRAM([dnl
|
|
31
|
+# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
|
|
32
|
+# cause an error if the version of python installed on the system
|
|
33
|
+# doesn't meet the requirement. MINIMUM-VERSION should consist of
|
|
34
|
+# numbers and dots only.
|
|
35
|
+AC_DEFUN([AM_PATH_PYTHON],
|
|
36
|
+ [
|
|
37
|
+ dnl Find a Python interpreter. Python versions prior to 2.0 are not
|
|
38
|
+ dnl supported. (2.0 was released on October 16, 2000).
|
|
39
|
+ m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
|
|
40
|
+[python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 dnl
|
|
41
|
+ python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0])
|
|
42
|
+
|
|
43
|
+ AC_ARG_VAR([PYTHON], [the Python interpreter])
|
|
44
|
+
|
|
45
|
+ m4_if([$1],[],[
|
|
46
|
+ dnl No version check is needed.
|
|
47
|
+ # Find any Python interpreter.
|
|
48
|
+ if test -z "$PYTHON"; then
|
|
49
|
+ AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
|
|
50
|
+ fi
|
|
51
|
+ am_display_PYTHON=python
|
|
52
|
+ ], [
|
|
53
|
+ dnl A version check is needed.
|
|
54
|
+ if test -n "$PYTHON"; then
|
|
55
|
+ # If the user set $PYTHON, use it and don't search something else.
|
|
56
|
+ AC_MSG_CHECKING([whether $PYTHON version is >= $1])
|
|
57
|
+ AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
|
|
58
|
+ [AC_MSG_RESULT([yes])],
|
|
59
|
+ [AC_MSG_RESULT([no])
|
|
60
|
+ AC_MSG_ERROR([Python interpreter is too old])])
|
|
61
|
+ am_display_PYTHON=$PYTHON
|
|
62
|
+ else
|
|
63
|
+ # Otherwise, try each interpreter until we find one that satisfies
|
|
64
|
+ # VERSION.
|
|
65
|
+ AC_CACHE_CHECK([for a Python interpreter with version >= $1],
|
|
66
|
+ [am_cv_pathless_PYTHON],[
|
|
67
|
+ for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
|
|
68
|
+ test "$am_cv_pathless_PYTHON" = none && break
|
|
69
|
+ AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
|
|
70
|
+ done])
|
|
71
|
+ # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
|
|
72
|
+ if test "$am_cv_pathless_PYTHON" = none; then
|
|
73
|
+ PYTHON=:
|
|
74
|
+ else
|
|
75
|
+ AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
|
|
76
|
+ fi
|
|
77
|
+ am_display_PYTHON=$am_cv_pathless_PYTHON
|
|
78
|
+ fi
|
|
79
|
+ ])
|
|
80
|
+
|
|
81
|
+ if test "$PYTHON" = :; then
|
|
82
|
+ dnl Run any user-specified action, or abort.
|
|
83
|
+ m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
|
|
84
|
+ else
|
|
85
|
+
|
|
86
|
+ dnl Query Python for its version number. Getting [:3] seems to be
|
|
87
|
+ dnl the best way to do this; it's what "site.py" does in the standard
|
|
88
|
+ dnl library.
|
|
89
|
+
|
|
90
|
+ AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
|
|
91
|
+ [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
|
|
92
|
+ AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
|
|
93
|
+
|
|
94
|
+ dnl Use the values of $prefix and $exec_prefix for the corresponding
|
|
95
|
+ dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
|
|
96
|
+ dnl distinct variables so they can be overridden if need be. However,
|
|
97
|
+ dnl general consensus is that you shouldn't need this ability.
|
|
98
|
+
|
|
99
|
+ AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
|
|
100
|
+ AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
|
|
101
|
+
|
|
102
|
+ dnl At times (like when building shared libraries) you may want
|
|
103
|
+ dnl to know which OS platform Python thinks this is.
|
|
104
|
+
|
|
105
|
+ AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
|
|
106
|
+ [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
|
|
107
|
+ AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
|
|
108
|
+
|
|
109
|
+ # Just factor out some code duplication.
|
|
110
|
+ am_python_setup_sysconfig="\
|
86
|
111
|
import sys
|
|
112
|
+# Prefer sysconfig over distutils.sysconfig, for better compatibility
|
|
113
|
+# with python 3.x. See automake bug#10227.
|
|
114
|
+# But not see <https://bugs.launchpad.net/ubuntu/+source/python3-defaults/+bug/1408092>
|
87
|
115
|
try:
|
88
|
|
- h = open('conftest.out')
|
89
|
|
-except:
|
90
|
|
- sys.exit(1)
|
|
116
|
+ import sysconfig
|
|
117
|
+except ImportError:
|
|
118
|
+ can_use_sysconfig = 0
|
91
|
119
|
else:
|
92
|
|
- close(h)
|
93
|
|
- sys.exit(0)
|
94
|
|
-], [])])
|
95
|
|
-
|
96
|
|
-
|
97
|
|
-# _AC_LANG_CALL(Python)([PROLOGUE], [FUNCTION])
|
98
|
|
-# ---------------------
|
99
|
|
-# Produce source that calls FUNCTION
|
100
|
|
-m4_define([_AC_LANG_CALL(Python)],
|
101
|
|
-[AC_LANG_PROGRAM([$1], [$2])])
|
102
|
|
-
|
103
|
|
-
|
104
|
|
-## -------------------------------------------- ##
|
105
|
|
-## 3. Looking for Compilers and Interpreters. ##
|
106
|
|
-## -------------------------------------------- ##
|
107
|
|
-
|
108
|
|
-
|
109
|
|
-AC_DEFUN([AC_LANG_COMPILER(Python)],
|
110
|
|
-[AC_REQUIRE([PC_PROG_PYTHON])])
|
111
|
|
-
|
112
|
|
-
|
113
|
|
-# PC_INIT([MIN-VERSION], [MAX-VERSION])
|
114
|
|
-# -----------------------------
|
115
|
|
-# Initialize pyconfigure, finding a Python interpreter with a given
|
116
|
|
-# minimum and/or maximum version.
|
117
|
|
-AC_DEFUN([PC_INIT],
|
118
|
|
-[PC_PROG_PYTHON([], [$1], [$2])
|
119
|
|
-dnl If we found something, do a sanity check that the interpreter really
|
120
|
|
-dnl has the version its name would suggest.
|
121
|
|
-m4_ifval([PYTHON],
|
122
|
|
- [PC_PYTHON_VERIFY_VERSION([>=], [pc_min_ver], [],
|
123
|
|
- [AC_MSG_FAILURE([No compatible Python interpreter found. If you're sure that you have one, try setting the PYTHON environment variable to the location of the interpreter.])])])
|
124
|
|
-m4_ifval([PYTHON],
|
125
|
|
- [PC_PYTHON_VERIFY_VERSION([<=], [pc_max_ver], [],
|
126
|
|
- [AC_MSG_FAILURE([No compatible Python interpreter found. If you're sure that you have one, try setting the PYTHON environment variable to the location of the interpreter.])])])
|
127
|
|
-])# PC_INIT
|
128
|
|
-
|
129
|
|
-# PC_PROG_PYTHON([PROG-TO-CHECK-FOR], [MIN-VERSION], [MAX-VERSION])
|
130
|
|
-# ---------------------------------
|
131
|
|
-# Find a Python interpreter. Python versions prior to 2.0 are not
|
132
|
|
-# supported. (2.0 was released on October 16, 2000).
|
133
|
|
-AC_DEFUN_ONCE([PC_PROG_PYTHON],
|
134
|
|
-[AC_ARG_VAR([PYTHON], [the Python interpreter])
|
135
|
|
-dnl The default minimum version is 2.0
|
136
|
|
-m4_define_default([pc_min_ver], m4_ifval([$2], [$2], [2.0]))
|
137
|
|
-dnl The default maximum version is 3.3
|
138
|
|
-m4_define_default([pc_max_ver], m4_ifval([$3], [$3], [4.0]))
|
139
|
|
-dnl Build up a list of possible interpreter names.
|
140
|
|
-m4_define_default([_PC_PYTHON_INTERPRETER_LIST],
|
141
|
|
- [dnl If we want some Python 3 versions (max version >= 3.0),
|
142
|
|
-dnl also search for "python3"
|
143
|
|
- m4_if(m4_version_compare(pc_max_ver, [2.9]), [1], [python3], []) \
|
144
|
|
-dnl If we want some Python 2 versions (min version <= 2.7),
|
145
|
|
-dnl also search for "python2".
|
146
|
|
- m4_if(m4_version_compare(pc_min_ver, [2.8]), [-1], [python2], []) \
|
147
|
|
-dnl Construct a comma-separated list of interpreter names (python2.6,
|
148
|
|
-dnl python2.7, etc). We only care about the first 3 characters of the
|
149
|
|
-dnl version strings (major-dot-minor; not
|
150
|
|
-dnl major-dot-minor-dot-bugfix[-dot-whatever])
|
151
|
|
- m4_foreach([pc_ver],
|
152
|
|
- m4_esyscmd_s(seq -s[[", "]] -f["[[%.1f]]"] m4_substr(pc_max_ver, [0], [3]) -0.1 m4_substr(pc_min_ver, [0], [3])),
|
153
|
|
-dnl Remove python2.8 and python2.9 since they will never exist
|
154
|
|
- [m4_bmatch(pc_ver, [2.[89]], [], [python]pc_ver)]) \
|
155
|
|
- [python]])
|
156
|
|
-dnl Do the actual search at last.
|
157
|
|
-m4_ifval([$1],
|
158
|
|
- [AC_PATH_PROGS(PYTHON, [$1 _PC_PYTHON_INTERPRETER_LIST])],
|
159
|
|
- [AC_PATH_PROGS(PYTHON, [_PC_PYTHON_INTERPRETER_LIST])])
|
160
|
|
-])# PC_PROG_PYTHON
|
161
|
|
-
|
162
|
|
-
|
163
|
|
-# PC_PYTHON_PROG_PYTHON_CONFIG(PROG-TO-CHECK-FOR)
|
164
|
|
-# ----------------------------------------------
|
165
|
|
-# Find the python-config program
|
166
|
|
-AC_DEFUN([PC_PYTHON_PROG_PYTHON_CONFIG],
|
167
|
|
-[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
|
168
|
|
-AC_ARG_VAR([PYTHON_CONFIG], [the Python-config program])
|
169
|
|
-dnl python-config's binary name is normally based on the Python interpreter's
|
170
|
|
-dnl binary name (i.e. python2.7 -> python2.7-config)
|
171
|
|
-m4_define([_PYTHON_BASENAME], [`basename $PYTHON`])
|
172
|
|
-m4_ifval([$1],
|
173
|
|
- [AC_PATH_PROGS(PYTHON_CONFIG, [$1 _PYTHON_BASENAME-config])],
|
174
|
|
- [AC_PATH_PROG(PYTHON_CONFIG, _PYTHON_BASENAME-config)])
|
175
|
|
-]) # PC_PYTHON_PROG_PYTHON_CONFIG
|
176
|
|
-
|
177
|
|
-
|
178
|
|
-# PC_PYTHON_VERIFY_VERSION([RELATION], [VERSION], [ACTION-IF-TRUE], [ACTION-IF-FALSE])
|
179
|
|
-# ---------------------------------------------------------------------------
|
180
|
|
-# Run ACTION-IF-TRUE if the Python interpreter PROG has version [RELATION] VERSION.
|
181
|
|
-# i.e if RELATION is "<", check if PROG has a version number less than VERSION.
|
182
|
|
-# Run ACTION-IF-FALSE otherwise.
|
183
|
|
-# Specify RELATION as any mathematical comparison "<", ">", "<=", ">=", "==" or "!="
|
184
|
|
-# This test uses sys.hexversion instead of the string equivalent (first
|
185
|
|
-# word of sys.version), in order to cope with versions such as 2.2c1.
|
186
|
|
-# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
|
187
|
|
-AC_DEFUN([PC_PYTHON_VERIFY_VERSION],
|
188
|
|
-[m4_define([pc_python_safe_ver], m4_bpatsubsts($2, [\.], [_]))
|
189
|
|
-AC_CACHE_CHECK([if Python $1 '$2'],
|
190
|
|
- [[pc_cv_python_req_version_]pc_python_safe_ver],
|
191
|
|
- [AC_LANG_PUSH(Python)[]dnl
|
192
|
|
- AC_RUN_IFELSE(
|
193
|
|
- [AC_LANG_PROGRAM([dnl
|
194
|
|
-import sys
|
195
|
|
-], [dnl
|
196
|
|
- # split strings by '.' and convert to numeric. Append some zeros
|
197
|
|
- # because we need at least 4 digits for the hex conversion.
|
198
|
|
- # map returns an iterator in Python 3.0 and a list in 2.x
|
199
|
|
- reqver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
|
200
|
|
- reqverhex = 0
|
201
|
|
- # xrange is not present in Python 3.0 and range returns an iterator
|
202
|
|
- for i in list(range(4)):
|
203
|
|
- reqverhex = (reqverhex << 8) + reqver[[i]]
|
204
|
|
- # the final 8 bits are "0xf0" for final versions, which are all
|
205
|
|
- # we'll test against, since it's doubtful that a released software
|
206
|
|
- # will depend on an alpha- or beta-state Python.
|
207
|
|
- reqverhex += 0xf0
|
208
|
|
- if sys.hexversion $1 reqverhex:
|
209
|
|
- sys.exit()
|
210
|
|
- else:
|
211
|
|
- sys.exit(1)
|
212
|
|
-])],
|
213
|
|
- [[pc_cv_python_req_version_]pc_python_safe_ver=yes],
|
214
|
|
- [[pc_cv_python_req_version_]pc_python_safe_ver=no])
|
215
|
|
- AC_LANG_POP(Python)[]dnl
|
216
|
|
- ])
|
217
|
|
-AS_IF([test "$[pc_cv_python_req_version_]pc_python_safe_ver" = "no"], [$4], [$3])
|
218
|
|
-])# PC_PYTHON_VERIFY_VERSION
|
219
|
|
-
|
220
|
|
-
|
221
|
|
-# PC_PYTHON_CHECK_VERSION
|
222
|
|
-# -----------------------
|
223
|
|
-# Query Python for its version number. Getting [:3] seems to be
|
224
|
|
-# the best way to do this; it's what "site.py" does in the standard
|
225
|
|
-# library.
|
226
|
|
-AC_DEFUN([PC_PYTHON_CHECK_VERSION],
|
227
|
|
-[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
|
228
|
|
-AC_CACHE_CHECK([for $1 version],
|
229
|
|
- [pc_cv_python_version],
|
230
|
|
- [AC_LANG_PUSH(Python)[]dnl
|
231
|
|
- AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
|
232
|
|
-import sys
|
233
|
|
-], [dnl
|
234
|
|
- sys.stdout.write(sys.version[[:3]])
|
235
|
|
-])],
|
236
|
|
- [pc_cv_python_version=`./conftest`],
|
237
|
|
- [AC_MSG_FAILURE([failed to run Python program])])
|
238
|
|
- AC_LANG_POP(Python)[]dnl
|
239
|
|
- ])
|
240
|
|
-AC_SUBST([PYTHON_VERSION], [$pc_cv_python_version])
|
241
|
|
-])# PC_PYTHON_CHECK_VERSION
|
242
|
|
-
|
243
|
|
-
|
244
|
|
-# PC_PYTHON_CHECK_PREFIX
|
245
|
|
-# ----------------------
|
246
|
|
-# Use the value of $prefix for the corresponding value of
|
247
|
|
-# PYTHON_PREFIX. This is made a distinct variable so it can be
|
248
|
|
-# overridden if need be. However, general consensus is that you
|
249
|
|
-# shouldn't need this ability.
|
250
|
|
-AC_DEFUN([PC_PYTHON_CHECK_PREFIX],
|
251
|
|
-[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
|
252
|
|
-dnl Try to get it with python-config otherwise do it from within Python
|
253
|
|
-AC_CACHE_CHECK([for Python prefix], [pc_cv_python_prefix],
|
254
|
|
-[if test -x "$PYTHON_CONFIG"; then
|
255
|
|
- pc_cv_python_prefix=`$PYTHON_CONFIG --prefix 2>&AS_MESSAGE_LOG_FD`
|
256
|
|
-else
|
257
|
|
- AC_LANG_PUSH(Python)[]dnl
|
258
|
|
- AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
|
259
|
|
-import sys
|
260
|
|
-], [dnl
|
261
|
|
- sys.stdout.write(sys.prefix)
|
262
|
|
-])], [pc_cv_python_prefix=`./conftest`;
|
263
|
|
- if test $? != 0; then
|
264
|
|
- AC_MSG_FAILURE([could not determine Python prefix])
|
265
|
|
- fi],
|
266
|
|
- [AC_MSG_FAILURE([failed to run Python program])])
|
267
|
|
- AC_LANG_POP(Python)[]dnl
|
268
|
|
-fi])
|
269
|
|
-AC_SUBST([PYTHON_PREFIX], [$pc_cv_python_prefix])])
|
270
|
|
-
|
271
|
|
-
|
272
|
|
-# PC_PYTHON_CHECK_EXEC_PREFIX
|
273
|
|
-# --------------------------
|
274
|
|
-# Like above, but for $exec_prefix
|
275
|
|
-AC_DEFUN([PC_PYTHON_CHECK_EXEC_PREFIX],
|
276
|
|
-[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
|
277
|
|
-dnl Try to get it with python-config otherwise do it from within Python
|
278
|
|
-AC_CACHE_CHECK([for Python exec-prefix], [pc_cv_python_exec_prefix],
|
279
|
|
-[if test -x "$PYTHON_CONFIG"; then
|
280
|
|
- pc_cv_python_exec_prefix=`$PYTHON_CONFIG --exec-prefix 2>&AS_MESSAGE_LOG_FD`
|
281
|
|
-else
|
282
|
|
- AC_LANG_PUSH(Python)[]dnl
|
283
|
|
- AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
|
284
|
|
-import sys
|
285
|
|
-], [dnl
|
286
|
|
- sys.stdout.write(sys.exec_prefix)
|
287
|
|
-])],
|
288
|
|
- [pc_cv_python_exec_prefix=`./conftest`;
|
289
|
|
- if test $? != 0; then
|
290
|
|
- AC_MSG_FAILURE([could not determine Python exec_prefix])
|
291
|
|
- fi],
|
292
|
|
- [AC_MSG_FAILURE([failed to run Python program])])
|
293
|
|
- AC_LANG_POP(Python)[]dnl
|
294
|
|
-fi
|
295
|
|
-])
|
296
|
|
-AC_SUBST([PYTHON_EXEC_PREFIX], [$pc_cv_python_exec_prefix])])
|
297
|
|
-
|
298
|
|
-
|
299
|
|
-# PC_PYTHON_CHECK_INCLUDES
|
300
|
|
-# ------------------------
|
301
|
|
-# Find the Python header file include flags (ie
|
302
|
|
-# '-I/usr/include/python')
|
303
|
|
-AC_DEFUN([PC_PYTHON_CHECK_INCLUDES],
|
304
|
|
-[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
|
305
|
|
-dnl Try to find the headers location with python-config otherwise guess
|
306
|
|
-AC_CACHE_CHECK([for Python includes], [pc_cv_python_includes],
|
307
|
|
-[if test -x "$PYTHON_CONFIG"; then
|
308
|
|
- pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>&AS_MESSAGE_LOG_FD`
|
309
|
|
-else
|
310
|
|
- pc_cv_python_includes="[-I$includedir/$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS,
|
311
|
|
- PYTHON_ABI_FLAGS,)"
|
312
|
|
-fi
|
313
|
|
-])
|
314
|
|
-AC_SUBST([PYTHON_INCLUDES], [$pc_cv_python_includes])])
|
315
|
|
-
|
316
|
|
-
|
317
|
|
-# PC_PYTHON_CHECK_HEADERS([ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
|
318
|
|
-# -----------------------
|
319
|
|
-# Check for the presence and usability of Python.h
|
320
|
|
-AC_DEFUN([PC_PYTHON_CHECK_HEADERS],
|
321
|
|
-[AC_REQUIRE([PC_PYTHON_CHECK_INCLUDES])[]dnl
|
322
|
|
-pc_cflags_store=$CPPFLAGS
|
323
|
|
-CPPFLAGS="$CFLAGS $PYTHON_INCLUDES"
|
324
|
|
-AC_CHECK_HEADER([Python.h], [$1], [$2])
|
325
|
|
-CPPFLAGS=$pc_cflags_store
|
326
|
|
-])
|
327
|
|
-
|
328
|
|
-
|
329
|
|
-# PC_PYTHON_CHECK_LIBS
|
330
|
|
-# --------------------
|
331
|
|
-# Find the Python lib flags (ie '-lpython')
|
332
|
|
-AC_DEFUN([PC_PYTHON_CHECK_LIBS],
|
333
|
|
-[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
|
334
|
|
-dnl Try to find the lib flags with python-config otherwise guess
|
335
|
|
-AC_CACHE_CHECK([for Python libs], [pc_cv_python_libs],
|
336
|
|
-[if test -x "$PYTHON_CONFIG"; then
|
337
|
|
- pc_cv_python_libs=`$PYTHON_CONFIG --libs 2>&AS_MESSAGE_LOG_FD`
|
338
|
|
-else
|
339
|
|
- pc_cv_python_libs="[-l$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS, PYTHON_ABI_FLAGS,)"
|
340
|
|
-fi
|
341
|
|
-])
|
342
|
|
-AC_SUBST([PYTHON_LIBS], [$pc_cv_python_libs])])
|
343
|
|
-
|
344
|
|
-
|
345
|
|
-# PC_PYTHON_TEST_LIBS(LIBRARY-FUNCTION, [ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
|
346
|
|
-# -------------------
|
347
|
|
-# Verify that the Python libs can be loaded
|
348
|
|
-AC_DEFUN([PC_PYTHON_TEST_LIBS],
|
349
|
|
-[AC_REQUIRE([PC_PYTHON_CHECK_LIBS])[]dnl
|
350
|
|
-pc_libflags_store=$LIBS
|
351
|
|
-for lflag in $PYTHON_LIBS; do
|
352
|
|
- case $lflag in
|
353
|
|
- -lpython*@:}@
|
354
|
|
- LIBS="$LIBS $lflag"
|
355
|
|
- pc_libpython=`echo $lflag | sed -e 's/^-l//'`
|
356
|
|
- ;;
|
357
|
|
- *@:}@;;
|
358
|
|
- esac
|
359
|
|
-done
|
360
|
|
-AC_CHECK_LIB([$pc_libpython], [$1], [$2], [$3])])
|
361
|
|
-
|
362
|
|
-
|
363
|
|
-# PC_PYTHON_CHECK_CFLAGS
|
364
|
|
-# ----------------------
|
365
|
|
-# Find the Python CFLAGS
|
366
|
|
-AC_DEFUN([PC_PYTHON_CHECK_CFLAGS],
|
367
|
|
-[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
|
368
|
|
-dnl Try to find the CFLAGS with python-config otherwise give up
|
369
|
|
-AC_CACHE_CHECK([for Python CFLAGS], [pc_cv_python_cflags],
|
370
|
|
-[if test -x "$PYTHON_CONFIG"; then
|
371
|
|
- pc_cv_python_cflags=`$PYTHON_CONFIG --cflags 2>&AS_MESSAGE_LOG_FD`
|
372
|
|
-else
|
373
|
|
- pc_cv_python_cflags=
|
374
|
|
-fi
|
375
|
|
-])
|
376
|
|
-AC_SUBST([PYTHON_CFLAGS], [$pc_cv_python_cflags])])
|
377
|
|
-
|
378
|
|
-
|
379
|
|
-# PC_PYTHON_CHECK_LDFLAGS
|
380
|
|
-# -----------------------
|
381
|
|
-# Find the Python LDFLAGS
|
382
|
|
-AC_DEFUN([PC_PYTHON_CHECK_LDFLAGS],
|
383
|
|
-[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
|
384
|
|
-dnl Try to find the LDFLAGS with python-config otherwise give up
|
385
|
|
-AC_CACHE_CHECK([for Python LDFLAGS], [pc_cv_python_ldflags],
|
386
|
|
-[if test -x "$PYTHON_CONFIG"; then
|
387
|
|
- pc_cv_python_ldflags=`$PYTHON_CONFIG --ldflags 2>&AS_MESSAGE_LOG_FD`
|
388
|
|
-else
|
389
|
|
- pc_cv_python_ldflags=
|
390
|
|
-fi
|
391
|
|
-])
|
392
|
|
-AC_SUBST([PYTHON_LDFLAGS], [$pc_cv_python_ldflags])])
|
393
|
|
-
|
394
|
|
-
|
395
|
|
-# PC_PYTHON_CHECK_EXTENSION_SUFFIX
|
396
|
|
-# --------------------------------
|
397
|
|
-# Find the Python extension suffix (i.e. '.cpython-32.so')
|
398
|
|
-AC_DEFUN([PC_PYTHON_CHECK_EXTENSION_SUFFIX],
|
399
|
|
-[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
|
400
|
|
-dnl Try to find the suffix with python-config otherwise give up
|
401
|
|
-AC_CACHE_CHECK([for Python extension suffix], [pc_cv_python_extension_suffix],
|
402
|
|
-[if test -x "$PYTHON_CONFIG"; then
|
403
|
|
- pc_cv_python_extension_suffix=`$PYTHON_CONFIG --extension-suffix 2>&AS_MESSAGE_LOG_FD`
|
404
|
|
-else
|
405
|
|
- pc_cv_python_extension_suffix=
|
406
|
|
-fi
|
407
|
|
-])
|
408
|
|
-AC_SUBST([PYTHON_EXTENSION_SUFFIX], [$pc_cv_python_extension_suffix])])
|
409
|
|
-
|
410
|
|
-
|
411
|
|
-# PC_PYTHON_CHECK_ABI_FLAGS
|
412
|
|
-# -------------------------
|
413
|
|
-# Find the Python ABI flags
|
414
|
|
-AC_DEFUN([PC_PYTHON_CHECK_ABI_FLAGS],
|
415
|
|
-[AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
|
416
|
|
-dnl Try to find the ABI flags with python-config otherwise give up
|
417
|
|
-AC_CACHE_CHECK([for Python ABI flags], [pc_cv_python_abi_flags],
|
418
|
|
-[if test -x "$PYTHON_CONFIG"; then
|
419
|
|
- pc_cv_python_abi_flags=`$PYTHON_CONFIG --abiflags 2>&AS_MESSAGE_LOG_FD`
|
420
|
|
-else
|
421
|
|
- pc_cv_python_abi_flags=
|
422
|
|
-fi
|
423
|
|
-])
|
424
|
|
-AC_SUBST([PYTHON_ABI_FLAGS], [$pc_cv_python_abi_flags])])
|
425
|
|
-
|
426
|
|
-
|
427
|
|
-# PC_PYTHON_CHECK_PLATFORM
|
428
|
|
-# ------------------------
|
429
|
|
-# At times (like when building shared libraries) you may want
|
430
|
|
-# to know which OS platform Python thinks this is.
|
431
|
|
-AC_DEFUN([PC_PYTHON_CHECK_PLATFORM],
|
432
|
|
-[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
|
433
|
|
-dnl Get the platform from within Python (sys.platform)
|
434
|
|
-AC_CACHE_CHECK([for Python platform], [pc_cv_python_platform],
|
435
|
|
- [AC_LANG_PUSH(Python)[]dnl
|
436
|
|
- AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
|
437
|
|
-import sys
|
438
|
|
-], [dnl
|
439
|
|
- sys.stdout.write(sys.platform)
|
440
|
|
-])], [pc_cv_python_platform=`./conftest`;
|
441
|
|
- if test $? != 0; then
|
442
|
|
- AC_MSG_FAILURE([could not determine Python platform])
|
443
|
|
- fi],
|
444
|
|
- [AC_MSG_FAILURE([failed to run Python program])])
|
445
|
|
- AC_LANG_POP(Python)[]dnl
|
446
|
|
- ])
|
447
|
|
-AC_SUBST([PYTHON_PLATFORM], [$pc_cv_python_platform])
|
448
|
|
-])
|
449
|
|
-
|
450
|
|
-
|
451
|
|
-# PC_PYTHON_CHECK_SITE_DIR
|
452
|
|
-# ---------------------
|
453
|
|
-# The directory to which new libraries are installed (i.e. the
|
454
|
|
-# "site-packages" directory.
|
455
|
|
-AC_DEFUN([PC_PYTHON_CHECK_SITE_DIR],
|
456
|
|
-[AC_REQUIRE([PC_PROG_PYTHON])AC_REQUIRE([PC_PYTHON_CHECK_PREFIX])[]dnl
|
457
|
|
-AC_CACHE_CHECK([for Python site-packages directory],
|
458
|
|
- [pc_cv_python_site_dir],
|
459
|
|
- [AC_LANG_PUSH(Python)[]dnl
|
460
|
|
- if test "x$prefix" = xNONE
|
|
120
|
+ can_use_sysconfig = 1
|
|
121
|
+# Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs:
|
|
122
|
+# <https://github.com/pypa/virtualenv/issues/118>
|
|
123
|
+# Can't use sysconfig in CPython > 3.0 in debian since it's broken :
|
|
124
|
+# <https://bugs.launchpad.net/ubuntu/+source/python3-defaults/+bug/1408092>
|
|
125
|
+try:
|
|
126
|
+ from platform import python_implementation
|
|
127
|
+ if python_implementation() == 'CPython' and ( \
|
|
128
|
+ float(sys.version[[:3]]) > 3.0 or sys.version[[:3]] == '2.7'):
|
|
129
|
+ can_use_sysconfig = 0
|
|
130
|
+except ImportError:
|
|
131
|
+ pass"
|
|
132
|
+
|
|
133
|
+ dnl Set up 4 directories:
|
|
134
|
+
|
|
135
|
+ dnl pythondir -- where to install python scripts. This is the
|
|
136
|
+ dnl site-packages directory, not the python standard library
|
|
137
|
+ dnl directory like in previous automake betas. This behavior
|
|
138
|
+ dnl is more consistent with lispdir.m4 for example.
|
|
139
|
+ dnl Query distutils for this directory.
|
|
140
|
+ AC_CACHE_CHECK([for $am_display_PYTHON script directory],
|
|
141
|
+ [am_cv_python_pythondir],
|
|
142
|
+ [if test "x$prefix" = xNONE
|
461
|
143
|
then
|
462
|
|
- pc_py_prefix=$ac_default_prefix
|
|
144
|
+ am_py_prefix=$ac_default_prefix
|
463
|
145
|
else
|
464
|
|
- pc_py_prefix=$prefix
|
|
146
|
+ am_py_prefix=$prefix
|
465
|
147
|
fi
|
466
|
|
- AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
|
467
|
|
-import sys
|
468
|
|
-from platform import python_implementation
|
469
|
|
-# sysconfig in CPython 2.7 doesn't work in virtualenv
|
470
|
|
-# <https://github.com/pypa/virtualenv/issues/118>
|
471
|
|
-try:
|
472
|
|
- import sysconfig
|
473
|
|
-except:
|
474
|
|
- can_use_sysconfig = False
|
475
|
|
-else:
|
476
|
|
- can_use_sysconfig = True
|
|
148
|
+ am_cv_python_pythondir=`$PYTHON -c "
|
|
149
|
+$am_python_setup_sysconfig
|
477
|
150
|
if can_use_sysconfig:
|
478
|
|
- if python_implementation() == "CPython" and sys.version[[:3]] == '2.7':
|
479
|
|
- can_use_sysconfig = False
|
480
|
|
-if not can_use_sysconfig:
|
481
|
|
- from distutils import sysconfig
|
482
|
|
- sitedir = sysconfig.get_python_lib(False, False, prefix='$pc_py_prefix')
|
|
151
|
+ sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
|
483
|
152
|
else:
|
484
|
|
- sitedir = sysconfig.get_path('purelib', vars={'base':'$pc_py_prefix'})
|
485
|
|
-], [dnl
|
486
|
|
- sys.stdout.write(sitedir)
|
487
|
|
-])], [pc_cv_python_site_dir=`./conftest`],
|
488
|
|
- [AC_MSG_FAILURE([failed to run Python program])])
|
489
|
|
- AC_LANG_POP(Python)[]dnl
|
490
|
|
- case $pc_cv_python_site_dir in
|
491
|
|
- $pc_py_prefix*)
|
492
|
|
- pc__strip_prefix=`echo "$pc_py_prefix" | sed 's|.|.|g'`
|
493
|
|
- pc_cv_python_site_dir=`echo "$pc_cv_python_site_dir" | sed "s,^$pc__strip_prefix/,,"`
|
|
153
|
+ from distutils import sysconfig
|
|
154
|
+ sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
|
|
155
|
+sys.stdout.write(sitedir)"`
|
|
156
|
+ case $am_cv_python_pythondir in
|
|
157
|
+ $am_py_prefix*)
|
|
158
|
+ am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
|
|
159
|
+ am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"`
|
494
|
160
|
;;
|
495
|
161
|
*)
|
496
|
|
- case $pc_py_prefix in
|
|
162
|
+ case $am_py_prefix in
|
497
|
163
|
/usr|/System*) ;;
|
498
|
164
|
*)
|
499
|
|
- pc_cv_python_site_dir=lib/python$PYTHON_VERSION/site-packages
|
|
165
|
+ am_cv_python_pythondir=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages
|
500
|
166
|
;;
|
501
|
167
|
esac
|
502
|
168
|
;;
|
503
|
169
|
esac
|
504
|
|
- ])
|
505
|
|
-AC_SUBST([pythondir], [\${prefix}/$pc_cv_python_site_dir])])# PC_PYTHON_CHECK_SITE_DIR
|
|
170
|
+ ])
|
|
171
|
+ AC_SUBST([pythondir], [$am_cv_python_pythondir])
|
506
|
172
|
|
507
|
|
-# PC_PYTHON_SITE_PACKAGE_DIR
|
508
|
|
-# --------------------------
|
509
|
|
-# $PACKAGE directory under PYTHON_SITE_DIR
|
510
|
|
-AC_DEFUN([PC_PYTHON_SITE_PACKAGE_DIR],
|
511
|
|
-[AC_REQUIRE([PC_PYTHON_CHECK_SITE_DIR])[]dnl
|
512
|
|
-AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE_NAME])])
|
|
173
|
+ dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
|
|
174
|
+ dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
|
|
175
|
+ dnl more consistent with the rest of automake.
|
513
|
176
|
|
|
177
|
+ AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
|
514
|
178
|
|
515
|
|
-# PC_PYTHON_CHECK_EXEC_DIR
|
516
|
|
-# ------------------------
|
517
|
|
-# directory for installing python extension modules (shared libraries)
|
518
|
|
-AC_DEFUN([PC_PYTHON_CHECK_EXEC_DIR],
|
519
|
|
-[AC_REQUIRE([PC_PROG_PYTHON])AC_REQUIRE([PC_PYTHON_CHECK_EXEC_PREFIX])[]dnl
|
520
|
|
- AC_CACHE_CHECK([for Python extension module directory],
|
521
|
|
- [pc_cv_python_exec_dir],
|
522
|
|
- [AC_LANG_PUSH(Python)[]dnl
|
523
|
|
- if test "x$pc_cv_python_exec_prefix" = xNONE
|
|
179
|
+ dnl pyexecdir -- directory for installing python extension modules
|
|
180
|
+ dnl (shared libraries)
|
|
181
|
+ dnl Query distutils for this directory.
|
|
182
|
+ AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
|
|
183
|
+ [am_cv_python_pyexecdir],
|
|
184
|
+ [if test "x$exec_prefix" = xNONE
|
524
|
185
|
then
|
525
|
|
- pc_py_exec_prefix=$pc_cv_python_prefix
|
|
186
|
+ am_py_exec_prefix=$am_py_prefix
|
526
|
187
|
else
|
527
|
|
- pc_py_exec_prefix=$pc_cv_python_exec_prefix
|
|
188
|
+ am_py_exec_prefix=$exec_prefix
|
528
|
189
|
fi
|
529
|
|
- AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
|
530
|
|
-import sys
|
531
|
|
-from platform import python_implementation
|
532
|
|
-# sysconfig in CPython 2.7 doesn't work in virtualenv
|
533
|
|
-# <https://github.com/pypa/virtualenv/issues/118>
|
534
|
|
-try:
|
535
|
|
- import sysconfig
|
536
|
|
-except:
|
537
|
|
- can_use_sysconfig = False
|
538
|
|
-else:
|
539
|
|
- can_use_sysconfig = True
|
|
190
|
+ am_cv_python_pyexecdir=`$PYTHON -c "
|
|
191
|
+$am_python_setup_sysconfig
|
540
|
192
|
if can_use_sysconfig:
|
541
|
|
- if python_implementation() == "CPython" and sys.version[[:3]] == '2.7':
|
542
|
|
- can_use_sysconfig = False
|
543
|
|
-if not can_use_sysconfig:
|
544
|
|
- from distutils import sysconfig
|
545
|
|
- sitedir = sysconfig.get_python_lib(False, False, prefix='$pc_py__exec_prefix')
|
|
193
|
+ sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'})
|
546
|
194
|
else:
|
547
|
|
- sitedir = sysconfig.get_path('purelib', vars={'platbase':'$pc_py_exec_prefix'})
|
548
|
|
-], [dnl
|
549
|
|
- sys.stdout.write(sitedir)
|
550
|
|
-])], [pc_cv_python_exec_dir=`./conftest`],
|
551
|
|
- [AC_MSG_FAILURE([failed to run Python program])])
|
552
|
|
- AC_LANG_POP(Python)[]dnl
|
553
|
|
- case $pc_cv_python_exec_dir in
|
554
|
|
- $pc_py_exec_prefix*)
|
555
|
|
- pc__strip_prefix=`echo "$pc_py_exec_prefix" | sed 's|.|.|g'`
|
556
|
|
- pc_cv_python_exec_dir=`echo "$pc_cv_python_exec_dir" | sed "s,^$pc__strip_prefix/,,"`
|
|
195
|
+ from distutils import sysconfig
|
|
196
|
+ sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix')
|
|
197
|
+sys.stdout.write(sitedir)"`
|
|
198
|
+ case $am_cv_python_pyexecdir in
|
|
199
|
+ $am_py_exec_prefix*)
|
|
200
|
+ am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
|
|
201
|
+ am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"`
|
557
|
202
|
;;
|
558
|
203
|
*)
|
559
|
|
- case $pc_py_exec_prefix in
|
|
204
|
+ case $am_py_exec_prefix in
|
560
|
205
|
/usr|/System*) ;;
|
561
|
206
|
*)
|
562
|
|
- pc_cv_python_exec_dir=lib/python$PYTHON_VERSION/site-packages
|
|
207
|
+ am_cv_python_pyexecdir=$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages
|
563
|
208
|
;;
|
564
|
209
|
esac
|
565
|
210
|
;;
|
566
|
211
|
esac
|
567
|
212
|
])
|
568
|
|
-AC_SUBST([pyexecdir], [\${exec_prefix}/$pc_cv_python_pyexecdir])]) #PY_PYTHON_CHECK_EXEC_LIB_DIR
|
569
|
|
-
|
|
213
|
+ AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
|
570
|
214
|
|
571
|
|
-# PC_PYTHON_EXEC_PACKAGE_DIR
|
572
|
|
-# --------------------------
|
573
|
|
-# $PACKAGE directory under PYTHON_SITE_DIR
|
574
|
|
-AC_DEFUN([PC_PYTHON_EXEC_PACKAGE_DIR],
|
575
|
|
-[AC_REQUIRE([PC_PYTHON_CHECK_EXEC_DIR])[]dnl
|
576
|
|
-AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE_NAME])])
|
|
215
|
+ dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
|
577
|
216
|
|
|
217
|
+ AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
|
578
|
218
|
|
579
|
|
-## -------------------------------------------- ##
|
580
|
|
-## 4. Looking for specific libs & functionality ##
|
581
|
|
-## -------------------------------------------- ##
|
|
219
|
+ dnl Run any user-specified action.
|
|
220
|
+ $2
|
|
221
|
+ fi
|
582
|
222
|
|
583
|
|
-
|
584
|
|
-# PC_PYTHON_CHECK_MODULE(LIBRARY, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
585
|
|
-# ----------------------------------------------------------------------
|
586
|
|
-# Macro for checking if a Python library is installed
|
587
|
|
-AC_DEFUN([PC_PYTHON_CHECK_MODULE],
|
588
|
|
-[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
|
589
|
|
-m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
|
590
|
|
-AC_CACHE_CHECK([for Python '$1' library],
|
591
|
|
- [[pc_cv_python_module_]pc_python_safe_mod],
|
592
|
|
- [AC_LANG_PUSH(Python)[]dnl
|
593
|
|
- AC_RUN_IFELSE(
|
594
|
|
- [AC_LANG_PROGRAM([dnl
|
595
|
|
-import sys
|
596
|
|
-try:
|
597
|
|
- import $1
|
598
|
|
-except:
|
599
|
|
- sys.exit(1)
|
600
|
|
-else:
|
601
|
|
- sys.exit(0)
|
602
|
|
-], [])],
|
603
|
|
- [[pc_cv_python_module_]pc_python_safe_mod="yes"],
|
604
|
|
- [[pc_cv_python_module_]pc_python_safe_mod="no"])
|
605
|
|
- AC_LANG_POP(Python)[]dnl
|
606
|
|
- ])
|
607
|
|
-AS_IF([test "$[pc_cv_python_module_]pc_python_safe_mod" = "no"], [$3], [$2])
|
608
|
|
-])# PC_PYTHON_CHECK_MODULE
|
|
223
|
+])
|
609
|
224
|
|
610
|
225
|
|
611
|
|
-# PC_PYTHON_CHECK_FUNC([LIBRARY], FUNCTION, ARGS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
612
|
|
-# ---------------------------------------------------------------------------------------
|
613
|
|
-# Check to see if a given function call, optionally from a module, can
|
614
|
|
-# be successfully called
|
615
|
|
-AC_DEFUN([PC_PYTHON_CHECK_FUNC],
|
616
|
|
-[AC_REQUIRE([PC_PROG_PYTHON])[]dnl
|
617
|
|
-m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
|
618
|
|
-AC_CACHE_CHECK([for Python m4_ifnblank($1, '$1.$2()', '$2()') function],
|
619
|
|
- [[pc_cv_python_func_]pc_python_safe_mod[_$2]],
|
620
|
|
- [AC_LANG_PUSH(Python)[]dnl
|
621
|
|
- AC_RUN_IFELSE(
|
622
|
|
- [AC_LANG_PROGRAM([dnl
|
623
|
|
-import sys
|
624
|
|
-m4_ifnblank([$1], [dnl
|
625
|
|
-try:
|
626
|
|
- import $1
|
627
|
|
-except:
|
628
|
|
- sys.exit(1)
|
629
|
|
-], [])],
|
630
|
|
-[
|
631
|
|
-m4_ifnblank([$1], [
|
632
|
|
- try:
|
633
|
|
- $1.$2($3)], [
|
634
|
|
- try:
|
635
|
|
- $2($3)])
|
636
|
|
- except:
|
637
|
|
- sys.exit(1)
|
638
|
|
- else:
|
639
|
|
- sys.exit(0)
|
640
|
|
-])],
|
641
|
|
- [[pc_cv_python_func_]pc_python_safe_mod[_$2]="yes"],
|
642
|
|
- [[pc_cv_python_func_]pc_python_safe_mod[_$2]="no"])
|
643
|
|
- AC_LANG_POP(Python)[]dnl
|
644
|
|
- ])
|
645
|
|
-AS_IF([test "$[pc_cv_python_func_]pc_python_safe_mod[_$2]" = "no"], [$5], [$4])
|
646
|
|
-])# PC_PYTHON_CHECK_FUNC
|
|
226
|
+# AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
|
|
227
|
+# ---------------------------------------------------------------------------
|
|
228
|
+# Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
|
|
229
|
+# Run ACTION-IF-FALSE otherwise.
|
|
230
|
+# This test uses sys.hexversion instead of the string equivalent (first
|
|
231
|
+# word of sys.version), in order to cope with versions such as 2.2c1.
|
|
232
|
+# This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
|
|
233
|
+AC_DEFUN([AM_PYTHON_CHECK_VERSION],
|
|
234
|
+ [prog="import sys
|
|
235
|
+# split strings by '.' and convert to numeric. Append some zeros
|
|
236
|
+# because we need at least 4 digits for the hex conversion.
|
|
237
|
+# map returns an iterator in Python 3.0 and a list in 2.x
|
|
238
|
+minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
|
|
239
|
+minverhex = 0
|
|
240
|
+# xrange is not present in Python 3.0 and range returns an iterator
|
|
241
|
+for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
|
|
242
|
+sys.exit(sys.hexversion < minverhex)"
|
|
243
|
+ AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
|