1 # Copyright 2012, 2013, 2014 Brandon Invergo <brandon@invergo.net>
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.
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.
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.
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/>.
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:
28 # Copyright (C) 1999-2012 Free Software Foundation, Inc.
30 # This file is free software; the Free Software Foundation
31 # gives unlimited permission to copy and/or distribute it,
32 # with or without modifications, as long as this notice is preserved.
36 # 1. Language selection
37 # and routines to produce programs in a given language.
39 # 2. Producing programs in a given language.
41 # 3. Looking for a compiler
42 # And possibly the associated preprocessor.
44 # 4. Looking for specific libs & functionality
47 ## ----------------------- ##
48 ## 1. Language selection. ##
49 ## ----------------------- ##
54 AC_LANG_DEFINE([Python], [py], [PY], [PYTHON], [],
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'
63 AU_DEFUN([AC_LANG_PYTHON], [AC_LANG(Python)])
66 ## ----------------------- ##
67 ## 2. Producing programs. ##
68 ## ----------------------- ##
71 # AC_LANG_PROGRAM(Python)([PROLOGUE], [BODY])
72 # -------------------------------------------
73 m4_define([AC_LANG_PROGRAM(Python)], [dnl
76 m4_if([$2], [], [], [dnl
77 if __name__ == '__main__':
81 # _AC_LANG_IO_PROGRAM(Python)
82 # ---------------------------
83 # Produce source that performs I/O.
84 m4_define([_AC_LANG_IO_PROGRAM(Python)],
88 h = open('conftest.out')
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])])
104 ## -------------------------------------------- ##
105 ## 3. Looking for Compilers and Interpreters. ##
106 ## -------------------------------------------- ##
109 AC_DEFUN([AC_LANG_COMPILER(Python)],
110 [AC_REQUIRE([PC_PROG_PYTHON])])
113 # PC_INIT([MIN-VERSION], [MAX-VERSION])
114 # -----------------------------
115 # Initialize pyconfigure, finding a Python interpreter with a given
116 # minimum and/or maximum version.
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.
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.])])])
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.])])])
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],
142 dnl If we want some Python 3 versions (max version >= 3.0),
143 dnl also search for "python3"
144 m4_if(m4_version_compare(pc_max_ver, [2.9]), [1], [python3], []) \
145 dnl If we want some Python 2 versions (min version <= 2.7),
146 dnl also search for "python2".
147 m4_if(m4_version_compare(pc_min_ver, [2.8]), [-1], [python2], []) \
148 dnl Construct a comma-separated list of interpreter names (python2.6,
149 dnl python2.7, etc). We only care about the first 3 characters of the
150 dnl version strings (major-dot-minor; not
151 dnl major-dot-minor-dot-bugfix[-dot-whatever])
153 m4_esyscmd_s(seq -s[[", "]] -f["[[%.1f]]"] m4_substr(pc_max_ver, [0], [3]) -0.1 m4_substr(pc_min_ver, [0], [3])),
154 dnl Remove python2.8 and python2.9 since they will never exist
155 [m4_bmatch(pc_ver, [2.[89]], [], [python]pc_ver)])])
156 dnl Do the actual search at last.
158 [AC_PATH_PROGS(PYTHON, [$1 _PC_PYTHON_INTERPRETER_LIST])],
159 [AC_PATH_PROGS(PYTHON, [_PC_PYTHON_INTERPRETER_LIST])])
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`])
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
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
193 [AC_LANG_PROGRAM([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]]
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.
208 if sys.hexversion $1 reqverhex:
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
217 AS_IF([test "$[pc_cv_python_req_version_]pc_python_safe_ver" = "no"], [$4], [$3])
218 ])# PC_PYTHON_VERIFY_VERSION
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
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
234 sys.stdout.write(sys.version[[:3]])
236 [pc_cv_python_version=`./conftest`],
237 [AC_MSG_FAILURE([failed to run Python program])])
238 AC_LANG_POP(Python)[]dnl
240 AC_SUBST([PYTHON_VERSION], [$pc_cv_python_version])
241 ])# PC_PYTHON_CHECK_VERSION
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`
257 AC_LANG_PUSH(Python)[]dnl
258 AC_LINK_IFELSE([AC_LANG_PROGRAM([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])
266 [AC_MSG_FAILURE([failed to run Python program])])
267 AC_LANG_POP(Python)[]dnl
269 AC_SUBST([PYTHON_PREFIX], [$pc_cv_python_prefix])])
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`
282 AC_LANG_PUSH(Python)[]dnl
283 AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
286 sys.stdout.write(sys.exec_prefix)
288 [pc_cv_python_exec_prefix=`./conftest`;
289 if test $? != 0; then
290 AC_MSG_FAILURE([could not determine Python exec_prefix])
292 [AC_MSG_FAILURE([failed to run Python program])])
293 AC_LANG_POP(Python)[]dnl
296 AC_SUBST([PYTHON_EXEC_PREFIX], [$pc_cv_python_exec_prefix])])
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`
310 pc_cv_python_includes="[-I$includedir/$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS,
314 AC_SUBST([PYTHON_INCLUDES], [$pc_cv_python_includes])])
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
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`
339 pc_cv_python_libs="[-l$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS, PYTHON_ABI_FLAGS,)"
342 AC_SUBST([PYTHON_LIBS], [$pc_cv_python_libs])])
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
355 pc_libpython=`echo $lflag | sed -e 's/^-l//'`
360 AC_CHECK_LIB([$pc_libpython], [$1], [$2], [$3])])
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`
376 AC_SUBST([PYTHON_CFLAGS], [$pc_cv_python_cflags])])
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`
389 pc_cv_python_ldflags=
392 AC_SUBST([PYTHON_LDFLAGS], [$pc_cv_python_ldflags])])
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`
405 pc_cv_python_extension_suffix=
408 AC_SUBST([PYTHON_EXTENSION_SUFFIX], [$pc_cv_python_extension_suffix])])
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`
421 pc_cv_python_abi_flags=
424 AC_SUBST([PYTHON_ABI_FLAGS], [$pc_cv_python_abi_flags])])
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
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])
444 [AC_MSG_FAILURE([failed to run Python program])])
445 AC_LANG_POP(Python)[]dnl
447 AC_SUBST([PYTHON_PLATFORM], [$pc_cv_python_platform])
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
462 pc_py_prefix=$ac_default_prefix
466 AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
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>
474 can_use_sysconfig = False
476 can_use_sysconfig = True
477 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')
484 sitedir = sysconfig.get_path('purelib', vars={'base':'$pc_py_prefix'})
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
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/,,"`
496 case $pc_py_prefix in
499 pc_cv_python_site_dir=lib/python$PYTHON_VERSION/site-packages
505 AC_SUBST([pythondir], [\${prefix}/$pc_cv_python_site_dir])])# PC_PYTHON_CHECK_SITE_DIR
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])])
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
525 pc_py_exec_prefix=$pc_cv_python_prefix
527 pc_py_exec_prefix=$pc_cv_python_exec_prefix
529 AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
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>
537 can_use_sysconfig = False
539 can_use_sysconfig = True
540 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')
547 sitedir = sysconfig.get_path('purelib', vars={'platbase':'$pc_py_exec_prefix'})
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
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/,,"`
559 case $pc_py_exec_prefix in
562 pc_cv_python_exec_dir=lib/python$PYTHON_VERSION/site-packages
568 AC_SUBST([pyexecdir], [\${exec_prefix}/$pc_cv_python_pyexecdir])]) #PY_PYTHON_CHECK_EXEC_LIB_DIR
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])])
579 ## -------------------------------------------- ##
580 ## 4. Looking for specific libs & functionality ##
581 ## -------------------------------------------- ##
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
594 [AC_LANG_PROGRAM([dnl
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
607 AS_IF([test "$[pc_cv_python_module_]pc_python_safe_mod" = "no"], [$3], [$2])
608 ])# PC_PYTHON_CHECK_MODULE
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
622 [AC_LANG_PROGRAM([dnl
624 m4_ifnblank([$1], [dnl
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
645 AS_IF([test "$[pc_cv_python_func_]pc_python_safe_mod[_$2]" = "no"], [$5], [$4])
646 ])# PC_PYTHON_CHECK_FUNC