summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2019-04-04 01:54:18 +0300
committerGravatar Nikias Bassen2019-04-04 01:54:18 +0300
commiteea4f1be9107c8ab621fd71460e47d0d38e55d71 (patch)
treed050e7a4966c16e4b7067f2cf071e601423355ae
parent0584aa90c93ff6ce46927b8d67887cb987ab9545 (diff)
downloadlibimobiledevice-eea4f1be9107c8ab621fd71460e47d0d38e55d71.tar.gz
libimobiledevice-eea4f1be9107c8ab621fd71460e47d0d38e55d71.tar.bz2
Updated ac_python_devel.m4 to newer ax_python_devel.m4
-rw-r--r--m4/ax_python_devel.m4 (renamed from m4/ac_python_devel.m4)188
1 files changed, 123 insertions, 65 deletions
diff --git a/m4/ac_python_devel.m4 b/m4/ax_python_devel.m4
index 545c607..44dbd83 100644
--- a/m4/ac_python_devel.m4
+++ b/m4/ax_python_devel.m4
@@ -1,10 +1,10 @@
1# =========================================================================== 1# ===========================================================================
2# http://autoconf-archive.cryp.to/ac_python_devel.html 2# https://www.gnu.org/software/autoconf-archive/ax_python_devel.html
3# =========================================================================== 3# ===========================================================================
4# 4#
5# SYNOPSIS 5# SYNOPSIS
6# 6#
7# AC_PYTHON_DEVEL([version]) 7# AX_PYTHON_DEVEL([version])
8# 8#
9# DESCRIPTION 9# DESCRIPTION
10# 10#
@@ -12,8 +12,8 @@
12# in your configure.ac. 12# in your configure.ac.
13# 13#
14# This macro checks for Python and tries to get the include path to 14# This macro checks for Python and tries to get the include path to
15# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) 15# 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output
16# output variables. It also exports $(PYTHON_EXTRA_LIBS) and 16# variables. It also exports $(PYTHON_EXTRA_LIBS) and
17# $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. 17# $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
18# 18#
19# You can search for some particular version of Python by passing a 19# You can search for some particular version of Python by passing a
@@ -31,18 +31,15 @@
31# If you need to use this macro for an older Python version, please 31# If you need to use this macro for an older Python version, please
32# contact the authors. We're always open for feedback. 32# contact the authors. We're always open for feedback.
33# 33#
34# LAST MODIFICATION 34# LICENSE
35# 35#
36# 2008-04-12 36# Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de>
37# 37# Copyright (c) 2009 Alan W. Irwin
38# COPYLEFT 38# Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net>
39# 39# Copyright (c) 2009 Andrew Collier
40# Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de> 40# Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org>
41# Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca> 41# Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org>
42# Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net> 42# Copyright (c) 2013 Daniel Mullner <muellner@math.stanford.edu>
43# Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
44# Copyright (c) 2008 Matteo Settenvini <matteo@member.fsf.org>
45# Copyright (c) 2008 Horst Knorr <hk_classes@knoda.org>
46# 43#
47# This program is free software: you can redistribute it and/or modify it 44# This program is free software: you can redistribute it and/or modify it
48# under the terms of the GNU General Public License as published by the 45# under the terms of the GNU General Public License as published by the
@@ -55,7 +52,7 @@
55# Public License for more details. 52# Public License for more details.
56# 53#
57# You should have received a copy of the GNU General Public License along 54# You should have received a copy of the GNU General Public License along
58# with this program. If not, see <http://www.gnu.org/licenses/>. 55# with this program. If not, see <https://www.gnu.org/licenses/>.
59# 56#
60# As a special exception, the respective Autoconf Macro's copyright owner 57# As a special exception, the respective Autoconf Macro's copyright owner
61# gives unlimited permission to copy, distribute and modify the configure 58# gives unlimited permission to copy, distribute and modify the configure
@@ -66,11 +63,14 @@
66# all other use of the material that constitutes the Autoconf Macro. 63# all other use of the material that constitutes the Autoconf Macro.
67# 64#
68# This special exception to the GPL applies to versions of the Autoconf 65# This special exception to the GPL applies to versions of the Autoconf
69# Macro released by the Autoconf Macro Archive. When you make and 66# Macro released by the Autoconf Archive. When you make and distribute a
70# distribute a modified version of the Autoconf Macro, you may extend this 67# modified version of the Autoconf Macro, you may extend this special
71# special exception to the GPL to apply to your modified version as well. 68# exception to the GPL to apply to your modified version as well.
72 69
73AC_DEFUN([AC_PYTHON_DEVEL],[ 70#serial 21
71
72AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
73AC_DEFUN([AX_PYTHON_DEVEL],[
74 # 74 #
75 # Allow the use of a (user set) custom python version 75 # Allow the use of a (user set) custom python version
76 # 76 #
@@ -90,8 +90,8 @@ AC_DEFUN([AC_PYTHON_DEVEL],[
90 # 90 #
91 AC_MSG_CHECKING([for a version of Python >= '2.1.0']) 91 AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
92 ac_supports_python_ver=`$PYTHON -c "import sys; \ 92 ac_supports_python_ver=`$PYTHON -c "import sys; \
93 ver = sys.version.split()[[0]]; \ 93 ver = sys.version.split ()[[0]]; \
94 print(ver >= '2.1.0')"` 94 print (ver >= '2.1.0')"`
95 if test "$ac_supports_python_ver" != "True"; then 95 if test "$ac_supports_python_ver" != "True"; then
96 if test -z "$PYTHON_NOVERSIONCHECK"; then 96 if test -z "$PYTHON_NOVERSIONCHECK"; then
97 AC_MSG_RESULT([no]) 97 AC_MSG_RESULT([no])
@@ -99,7 +99,7 @@ AC_DEFUN([AC_PYTHON_DEVEL],[
99This version of the AC@&t@_PYTHON_DEVEL macro 99This version of the AC@&t@_PYTHON_DEVEL macro
100doesn't work properly with versions of Python before 100doesn't work properly with versions of Python before
1012.1.0. You may need to re-run configure, setting the 1012.1.0. You may need to re-run configure, setting the
102variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, 102variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG,
103PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. 103PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
104Moreover, to disable this check, set PYTHON_NOVERSIONCHECK 104Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
105to something else than an empty string. 105to something else than an empty string.
@@ -117,10 +117,10 @@ to something else than an empty string.
117 if test -n "$1"; then 117 if test -n "$1"; then
118 AC_MSG_CHECKING([for a version of Python $1]) 118 AC_MSG_CHECKING([for a version of Python $1])
119 ac_supports_python_ver=`$PYTHON -c "import sys; \ 119 ac_supports_python_ver=`$PYTHON -c "import sys; \
120 ver = sys.version.split()[[0]]; \ 120 ver = sys.version.split ()[[0]]; \
121 print(ver >= '2.1.0')"` 121 print (ver $1)"`
122 if test "$ac_supports_python_ver" = "True"; then 122 if test "$ac_supports_python_ver" = "True"; then
123 AC_MSG_RESULT([yes]) 123 AC_MSG_RESULT([yes])
124 else 124 else
125 AC_MSG_RESULT([no]) 125 AC_MSG_RESULT([no])
126 AC_MSG_ERROR([this package requires Python $1. 126 AC_MSG_ERROR([this package requires Python $1.
@@ -137,7 +137,7 @@ variable to configure. See ``configure --help'' for reference.
137 # 137 #
138 AC_MSG_CHECKING([for the distutils Python package]) 138 AC_MSG_CHECKING([for the distutils Python package])
139 ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` 139 ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
140 if test -z "$ac_distutils_result"; then 140 if test $? -eq 0; then
141 AC_MSG_RESULT([yes]) 141 AC_MSG_RESULT([yes])
142 else 142 else
143 AC_MSG_RESULT([no]) 143 AC_MSG_RESULT([no])
@@ -151,14 +151,17 @@ $ac_distutils_result])
151 # Check for Python include path 151 # Check for Python include path
152 # 152 #
153 AC_MSG_CHECKING([for Python include path]) 153 AC_MSG_CHECKING([for Python include path])
154 if type $PYTHON-config; then
155 PYTHON_CPPFLAGS=`$PYTHON-config --includes`
156 fi
157 if test -z "$PYTHON_CPPFLAGS"; then 154 if test -z "$PYTHON_CPPFLAGS"; then
158 python_path=`$PYTHON -c "import distutils.sysconfig; \ 155 python_path=`$PYTHON -c "import distutils.sysconfig; \
159 print(distutils.sysconfig.get_python_inc());"` 156 print (distutils.sysconfig.get_python_inc ());"`
157 plat_python_path=`$PYTHON -c "import distutils.sysconfig; \
158 print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
160 if test -n "${python_path}"; then 159 if test -n "${python_path}"; then
161 python_path="-I$python_path" 160 if test "${plat_python_path}" != "${python_path}"; then
161 python_path="-I$python_path -I$plat_python_path"
162 else
163 python_path="-I$python_path"
164 fi
162 fi 165 fi
163 PYTHON_CPPFLAGS=$python_path 166 PYTHON_CPPFLAGS=$python_path
164 fi 167 fi
@@ -169,29 +172,80 @@ $ac_distutils_result])
169 # Check for Python library path 172 # Check for Python library path
170 # 173 #
171 AC_MSG_CHECKING([for Python library path]) 174 AC_MSG_CHECKING([for Python library path])
172 if type $PYTHON-config; then 175 if test -z "$PYTHON_LIBS"; then
173 PYTHON_LDFLAGS=`$PYTHON-config --ldflags`
174 fi
175 if test -z "$PYTHON_LDFLAGS"; then
176 # (makes two attempts to ensure we've got a version number 176 # (makes two attempts to ensure we've got a version number
177 # from the interpreter) 177 # from the interpreter)
178 py_version=`$PYTHON -c "from distutils.sysconfig import *; \ 178 ac_python_version=`cat<<EOD | $PYTHON -
179 print(' '.join(get_config_vars('VERSION')))"` 179
180 if test "$py_version" = "[None]"; then 180# join all versioning strings, on some systems
181# major/minor numbers could be in different list elements
182from distutils.sysconfig import *
183e = get_config_var('VERSION')
184if e is not None:
185 print(e)
186EOD`
187
188 if test -z "$ac_python_version"; then
181 if test -n "$PYTHON_VERSION"; then 189 if test -n "$PYTHON_VERSION"; then
182 py_version=$PYTHON_VERSION 190 ac_python_version=$PYTHON_VERSION
183 else 191 else
184 py_version=`$PYTHON -c "import sys; \ 192 ac_python_version=`$PYTHON -c "import sys; \
185 print(sys.version[[:3]]")` 193 print (sys.version[[:3]])"`
186 fi 194 fi
187 fi 195 fi
188 196
189 PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \ 197 # Make the versioning information available to the compiler
190 print('-L' + get_python_lib(0,1) + \ 198 AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
191 ' -lpython');"`$py_version 199 [If available, contains the Python version number currently in use.])
200
201 # First, the library directory:
202 ac_python_libdir=`cat<<EOD | $PYTHON -
203
204# There should be only one
205import distutils.sysconfig
206e = distutils.sysconfig.get_config_var('LIBDIR')
207if e is not None:
208 print (e)
209EOD`
210
211 # Now, for the library:
212 ac_python_library=`cat<<EOD | $PYTHON -
213
214import distutils.sysconfig
215c = distutils.sysconfig.get_config_vars()
216if 'LDVERSION' in c:
217 print ('python'+c[['LDVERSION']])
218else:
219 print ('python'+c[['VERSION']])
220EOD`
221
222 # This small piece shamelessly adapted from PostgreSQL python macro;
223 # credits goes to momjian, I think. I'd like to put the right name
224 # in the credits, if someone can point me in the right direction... ?
225 #
226 if test -n "$ac_python_libdir" -a -n "$ac_python_library"
227 then
228 # use the official shared library
229 ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
230 PYTHON_LIBS="-L$ac_python_libdir -l$ac_python_library"
231 else
232 # old way: use libpython from python_configdir
233 ac_python_libdir=`$PYTHON -c \
234 "from distutils.sysconfig import get_python_lib as f; \
235 import os; \
236 print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
237 PYTHON_LIBS="-L$ac_python_libdir -lpython$ac_python_version"
238 fi
239
240 if test -z "PYTHON_LIBS"; then
241 AC_MSG_ERROR([
242 Cannot determine location of your Python DSO. Please check it was installed with
243 dynamic libraries enabled, or try setting PYTHON_LIBS by hand.
244 ])
245 fi
192 fi 246 fi
193 AC_MSG_RESULT([$PYTHON_LDFLAGS]) 247 AC_MSG_RESULT([$PYTHON_LIBS])
194 AC_SUBST([PYTHON_LDFLAGS]) 248 AC_SUBST([PYTHON_LIBS])
195 249
196 # 250 #
197 # Check for site packages 251 # Check for site packages
@@ -199,7 +253,7 @@ $ac_distutils_result])
199 AC_MSG_CHECKING([for Python site-packages path]) 253 AC_MSG_CHECKING([for Python site-packages path])
200 if test -z "$PYTHON_SITE_PKG"; then 254 if test -z "$PYTHON_SITE_PKG"; then
201 PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ 255 PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
202 print(distutils.sysconfig.get_python_lib(0,0))"` 256 print (distutils.sysconfig.get_python_lib(0,0));"`
203 fi 257 fi
204 AC_MSG_RESULT([$PYTHON_SITE_PKG]) 258 AC_MSG_RESULT([$PYTHON_SITE_PKG])
205 AC_SUBST([PYTHON_SITE_PKG]) 259 AC_SUBST([PYTHON_SITE_PKG])
@@ -211,7 +265,7 @@ $ac_distutils_result])
211 if test -z "$PYTHON_EXTRA_LIBS"; then 265 if test -z "$PYTHON_EXTRA_LIBS"; then
212 PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ 266 PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
213 conf = distutils.sysconfig.get_config_var; \ 267 conf = distutils.sysconfig.get_config_var; \
214 print(conf('LOCALMODLIBS'), conf('LIBS'))"` 268 print (conf('LIBS') + ' ' + conf('SYSLIBS'))"`
215 fi 269 fi
216 AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) 270 AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
217 AC_SUBST(PYTHON_EXTRA_LIBS) 271 AC_SUBST(PYTHON_EXTRA_LIBS)
@@ -223,7 +277,7 @@ $ac_distutils_result])
223 if test -z "$PYTHON_EXTRA_LDFLAGS"; then 277 if test -z "$PYTHON_EXTRA_LDFLAGS"; then
224 PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \ 278 PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
225 conf = distutils.sysconfig.get_config_var; \ 279 conf = distutils.sysconfig.get_config_var; \
226 print(conf('LINKFORSHARED'))"` 280 print (conf('LINKFORSHARED'))"`
227 fi 281 fi
228 AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS]) 282 AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
229 AC_SUBST(PYTHON_EXTRA_LDFLAGS) 283 AC_SUBST(PYTHON_EXTRA_LDFLAGS)
@@ -232,24 +286,32 @@ $ac_distutils_result])
232 # final check to see if everything compiles alright 286 # final check to see if everything compiles alright
233 # 287 #
234 AC_MSG_CHECKING([consistency of all components of python development environment]) 288 AC_MSG_CHECKING([consistency of all components of python development environment])
235 AC_LANG_PUSH([C])
236 # save current global flags 289 # save current global flags
237 LIBS="$ac_save_LIBS $PYTHON_LDFLAGS" 290 ac_save_LIBS="$LIBS"
291 ac_save_LDFLAGS="$LDFLAGS"
292 ac_save_CPPFLAGS="$CPPFLAGS"
293 LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_EXTRA_LIBS"
294 LDFLAGS="$ac_save_LDFLAGS $PYTHON_EXTRA_LDFLAGS"
238 CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" 295 CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
239 AC_TRY_LINK([ 296 AC_LANG_PUSH([C])
240 #include <Python.h> 297 AC_LINK_IFELSE([
241 ],[ 298 AC_LANG_PROGRAM([[#include <Python.h>]],
242 Py_Initialize(); 299 [[Py_Initialize();]])
243 ],[pythonexists=yes],[pythonexists=no]) 300 ],[pythonexists=yes],[pythonexists=no])
301 AC_LANG_POP([C])
302 # turn back to default flags
303 CPPFLAGS="$ac_save_CPPFLAGS"
304 LIBS="$ac_save_LIBS"
305 LDFLAGS="$ac_save_LDFLAGS"
244 306
245 AC_MSG_RESULT([$pythonexists]) 307 AC_MSG_RESULT([$pythonexists])
246 308
247 if test ! "$pythonexists" = "yes"; then 309 if test ! "x$pythonexists" = "xyes"; then
248 AC_MSG_ERROR([ 310 AC_MSG_FAILURE([
249 Could not link test program to Python. Maybe the main Python library has been 311 Could not link test program to Python. Maybe the main Python library has been
250 installed in some non-standard library path. If so, pass it to configure, 312 installed in some non-standard library path. If so, pass it to configure,
251 via the LDFLAGS environment variable. 313 via the LIBS environment variable.
252 Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" 314 Example: ./configure LIBS="-L/usr/non-standard-path/python/lib"
253 ============================================================================ 315 ============================================================================
254 ERROR! 316 ERROR!
255 You probably have to install the development version of the Python package 317 You probably have to install the development version of the Python package
@@ -258,10 +320,6 @@ $ac_distutils_result])
258 ]) 320 ])
259 PYTHON_VERSION="" 321 PYTHON_VERSION=""
260 fi 322 fi
261 AC_LANG_POP
262 # turn back to default flags
263 CPPFLAGS="$ac_save_CPPFLAGS"
264 LIBS="$ac_save_LIBS"
265 323
266 # 324 #
267 # all done! 325 # all done!