add pyconfigure stuff
[mediagoblin.git] / m4 / python.m4
1 # Copyright 2012 Brandon Invergo <brandon@invergo.net>
2 #
3 # Copying and distribution of this file, with or without modification,
4 # are permitted in any medium without royalty provided the copyright
5 # notice and this notice are preserved. This file is offered as-is,
6 # without any warranty.
7
8 # Many of these macros were adapted from ones written by Andrew Dalke
9 # and James Henstridge and are included with the Automake utility
10 # under the following copyright terms:
11 #
12 # Copyright (C) 1999-2012 Free Software Foundation, Inc.
13 #
14 # This file is free software; the Free Software Foundation
15 # gives unlimited permission to copy and/or distribute it,
16 # with or without modifications, as long as this notice is preserved.
17
18 # Table of Contents:
19 #
20 # 1. Language selection
21 # and routines to produce programs in a given language.
22 #
23 # 2. Producing programs in a given language.
24 #
25 # 3. Looking for a compiler
26 # And possibly the associated preprocessor.
27 #
28 # 4. Looking for specific libs & functionality
29
30
31 ## ----------------------- ##
32 ## 1. Language selection. ##
33 ## ----------------------- ##
34
35
36 # AC_LANG(Python)
37 # ---------------
38 AC_LANG_DEFINE([Python], [py], [PY], [PYTHON], [],
39 [ac_ext=py
40 ac_compile='chmod +x conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
41 ac_link='chmod +x conftest.$ac_ext && cp conftest.$ac_ext conftest >&AS_MESSAGE_LOG_FD'
42 ])
43
44
45 # AC_LANG_PYTHON
46 # --------------
47 AU_DEFUN([AC_LANG_PYTHON], [AC_LANG(Python)])
48
49
50 ## ----------------------- ##
51 ## 2. Producing programs. ##
52 ## ----------------------- ##
53
54
55 # AC_LANG_PROGRAM(Python)([PROLOGUE], [BODY])
56 # -------------------------------------------
57 m4_define([AC_LANG_PROGRAM(Python)], [dnl
58 @%:@!$PYTHON
59 $1
60 m4_if([$2], [], [], [dnl
61 if __name__ == '__main__':
62 $2])])
63
64
65 # _AC_LANG_IO_PROGRAM(Python)
66 # ---------------------------
67 # Produce source that performs I/O.
68 m4_define([_AC_LANG_IO_PROGRAM(Python)],
69 [AC_LANG_PROGRAM([dnl
70 import sys
71 try:
72 h = open('conftest.out')
73 except:
74 sys.exit(1)
75 else:
76 close(h)
77 sys.exit(0)
78 ], [])])
79
80
81 # _AC_LANG_CALL(Python)([PROLOGUE], [FUNCTION])
82 # ---------------------
83 # Produce source that calls FUNCTION
84 m4_define([_AC_LANG_CALL(Python)],
85 [AC_LANG_PROGRAM([$1], [$2])])
86
87
88
89 ## -------------------------------------------- ##
90 ## 3. Looking for Compilers and Interpreters. ##
91 ## -------------------------------------------- ##
92
93
94 AC_DEFUN([AC_LANG_COMPILER(Python)],
95 [AC_REQUIRE([AC_PROG_PYTHON])])
96
97
98 # AC_PROG_PYTHON(PROG-TO-CHECK-FOR)
99 # ---------------------------------
100 # Find a Python interpreter. Python versions prior to 2.0 are not
101 # supported. (2.0 was released on October 16, 2000).
102 AC_DEFUN([AC_PROG_PYTHON],
103 [AC_ARG_VAR([PYTHON], [the Python interpreter])
104 m4_define_default([_PC_PYTHON_INTERPRETER_LIST],
105 [python python3 python3.2 python3.1 python3.0 python2 python2.7 dnl
106 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0])
107 m4_ifval([$1],
108 [AC_PATH_PROGS(PYTHON, [$1 _PC_PYTHON_INTERPRETER_LIST])],
109 [AC_PATH_PROGS(PYTHON, [_PC_PYTHON_INTERPRETER_LIST])])
110 ])
111
112
113 # PC_PYTHON_PROG_PYTHON_CONFIG(PROG-TO-CHECK-FOR)
114 # ----------------------------------------------
115 # Find the python-config program
116 AC_DEFUN([PC_PYTHON_PROG_PYTHON_CONFIG],
117 [AC_REQUIRE([AC_PROG_PYTHON])[]dnl
118 AC_ARG_VAR([PYTHON_CONFIG], [the Python-config program])
119 m4_define([_PYTHON_BASENAME], [`basename $PYTHON`])
120 m4_ifval([$1],
121 [AC_PATH_PROGS(PYTHON_CONFIG, [$1 _PYTHON_BASENAME-config])],
122 [AC_PATH_PROG(PYTHON_CONFIG, _PYTHON_BASENAME-config)])
123 ]) # PC_PYTHON_PROG_PYTHON_CONFIG
124
125
126 # PC_PYTHON_VERIFY_VERSION(PYTHON-PROGRAM, VERSION, [ACTION-IF-TRUE], [ACTION-IF-NOT-FOUND])
127 # ---------------------------------------------------------------------------
128 # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
129 # Run ACTION-IF-FALSE otherwise.
130 # This test uses sys.hexversion instead of the string equivalent (first
131 # word of sys.version), in order to cope with versions such as 2.2c1.
132 # This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
133 AC_DEFUN([PC_PYTHON_VERIFY_VERSION],
134 [AC_REQUIRE([AC_PROG_PYTHON])[]dnl
135 m4_define([pc_python_safe_ver], m4_bpatsubsts($2, [\.], [_]))
136 AC_CACHE_CHECK([if Python >= '$2'],
137 [[pc_cv_python_min_version_]pc_python_safe_ver],
138 [AC_LANG_PUSH(Python)[]dnl
139 AC_RUN_IFELSE(
140 [AC_LANG_PROGRAM([dnl
141 import sys
142 ], [dnl
143 # split strings by '.' and convert to numeric. Append some zeros
144 # because we need at least 4 digits for the hex conversion.
145 # map returns an iterator in Python 3.0 and a list in 2.x
146 minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
147 minverhex = 0
148 # xrange is not present in Python 3.0 and range returns an iterator
149 for i in list(range(4)):
150 minverhex = (minverhex << 8) + minver[[i]]
151 sys.exit(sys.hexversion < minverhex)
152 ])],
153 [[pc_cv_python_min_version_]pc_python_safe_ver="yes"],
154 [[pc_cv_python_min_version_]pc_python_safe_ver="no"])
155 AC_LANG_POP(Python)[]dnl
156 ])
157 AS_IF([test "$[pc_cv_python_min_version_]pc_python_safe_ver" = "no"], [$4], [$3])
158 ])# PC_PYTHON_VERIFY_VERSION
159
160
161 # PC_PYTHON_CHECK_VERSION
162 # -----------------------
163 # Query Python for its version number. Getting [:3] seems to be
164 # the best way to do this; it's what "site.py" does in the standard
165 # library.
166 AC_DEFUN([PC_PYTHON_CHECK_VERSION],
167 [AC_REQUIRE([AC_PROG_PYTHON])[]dnl
168 AC_CACHE_CHECK([for $1 version],
169 [pc_cv_python_version],
170 [AC_LANG_PUSH(Python)[]dnl
171 AC_LANG_CONFTEST([
172 AC_LANG_PROGRAM([dnl
173 import sys
174 ], [dnl
175 sys.stdout.write(sys.version[[:3]])
176 ])])
177 pc_cv_python_version=`$PYTHON conftest.py`
178 AC_LANG_POP(Python)[]dnl
179 ])
180 AC_SUBST([PYTHON_VERSION], [$pc_cv_python_version])
181 ])# PC_PYTHON_CHECK_VERSION
182
183
184 # PC_PYTHON_CHECK_PREFIX
185 # ----------------------
186 # Use the value of $prefix for the corresponding value of
187 # PYTHON_PREFIX. This is made a distinct variable so it can be
188 # overridden if need be. However, general consensus is that you
189 # shouldn't need this ability.
190 AC_DEFUN([PC_PYTHON_CHECK_PREFIX],
191 [AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
192 AC_CACHE_CHECK([for Python prefix], [pc_cv_python_prefix],
193 [if test -x "$PYTHON_CONFIG"; then
194 pc_cv_python_prefix=`$PYTHON_CONFIG --prefix 2>> AS_MESSAGE_LOG_FD`
195 else
196 AC_LANG_PUSH(Python)[]dnl
197 pc_cv_python_prefix=AC_LANG_CONFTEST([AC_LANG_PROGRAM([dnl
198 import sys
199 ], [dnl
200 sys.exit(sys.prefix)
201 ])])
202 AC_LANG_POP(Python)[]dnl
203 fi])
204 AC_SUBST([PYTHON_PREFIX], [$pc_cv_python_prefix])])
205
206
207 # PC_PYTHON_CHECK_EXEC_PREFIX
208 # --------------------------
209 # Like above, but for $exec_prefix
210 AC_DEFUN([PC_PYTHON_CHECK_EXEC_PREFIX],
211 [AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
212 AC_CACHE_CHECK([for Python exec-prefix], [pc_cv_python_exec_prefix],
213 [if test -x "$PYTHON_CONFIG"; then
214 pc_cv_python_exec_prefix=`$PYTHON_CONFIG --exec-prefix 2>> AS_MESSAGE_LOG_FD`
215 else
216 AC_LANG_PUSH(Python)[]dnl
217 pc_cv_python_exec_prefix=AC_LANG_CONFTEST([AC_LANG_PROGRAM([dnl
218 import sys
219 ], [dnl
220 sys.exit(sys.exec_prefix)
221 ])])
222 AC_LANG_POP(Python)[]dnl
223 fi
224 ])
225 AC_SUBST([PYTHON_EXEC_PREFIX], [$pc_cv_python_exec_prefix])])
226
227
228 # PC_PYTHON_CHECK_INCLUDES
229 # ------------------------
230 # Find the Python header file include flags (ie
231 # '-I/usr/include/python')
232 AC_DEFUN([PC_PYTHON_CHECK_INCLUDES],
233 [AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
234 AC_CACHE_CHECK([for Python includes], [pc_cv_python_includes],
235 [if test -x "$PYTHON_CONFIG"; then
236 pc_cv_python_includes=`$PYTHON_CONFIG --includes 2>> AS_MESSAGE_LOG_FD`
237 else
238 pc_cv_python_includes="[-I$includedir/$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS,
239 PYTHON_ABI_FLAGS,)"
240 fi
241 ])
242 AC_SUBST([PYTHON_INCLUDES], [$pc_cv_python_includes])])
243
244
245 # PC_PYTHON_CHECK_HEADERS([ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
246 # -----------------------
247 # Check for the presence and usability of Python.h
248 AC_DEFUN([PC_PYTHON_CHECK_HEADERS],
249 [AC_REQUIRE([PC_PYTHON_CHECK_INCLUDES])[]dnl
250 pc_cflags_store=$CPPFLAGS
251 CPPFLAGS="$CFLAGS $PYTHON_INCLUDES"
252 AC_CHECK_HEADER([Python.h], [$1], [$2])
253 CPPFLAGS=$pc_cflags_store
254 ])
255
256
257 # PC_PYTHON_CHECK_LIBS
258 # --------------------
259 # Find the Python lib flags (ie '-lpython')
260 AC_DEFUN([PC_PYTHON_CHECK_LIBS],
261 [AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
262 AC_CACHE_CHECK([for Python libs], [pc_cv_python_libs],
263 [if test -x "$PYTHON_CONFIG"; then
264 pc_cv_python_libs=`$PYTHON_CONFIG --libs 2>> AS_MESSAGE_LOG_FD`
265 else
266 pc_cv_python_libs="[-l$_PYTHON_BASENAME]m4_ifdef(PYTHON_ABI_FLAGS, PYTHON_ABI_FLAGS,)"
267 fi
268 ])
269 AC_SUBST([PYTHON_LIBS], [$pc_cv_python_libs])])
270
271
272 # PC_PYTHON_TEST_LIBS(LIBRARY-FUNCTION, [ACTION-IF-PRESENT], [ACTION-IF-ABSENT])
273 # -------------------
274 # Verify that the Python libs can be loaded
275 AC_DEFUN([PC_PYTHON_TEST_LIBS],
276 [AC_REQUIRE([PC_PYTHON_CHECK_LIBS])[]dnl
277 pc_libflags_store=$LIBS
278 for lflag in $PYTHON_LIBS; do
279 case $lflag in
280 -lpython*@:}@
281 LIBS="$LIBS $lflag"
282 pc_libpython=`echo $lflag | sed -e 's/^-l//'`
283 ;;
284 *@:}@;;
285 esac
286 done
287 AC_CHECK_LIB([$pc_libpython], [$1], [$2], [$3])])
288
289
290 # PC_PYTHON_CHECK_CFLAGS
291 # ----------------------
292 # Find the Python CFLAGS
293 AC_DEFUN([PC_PYTHON_CHECK_CFLAGS],
294 [AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
295 AC_CACHE_CHECK([for Python CFLAGS], [pc_cv_python_cflags],
296 [if test -x "$PYTHON_CONFIG"; then
297 pc_cv_python_cflags=`$PYTHON_CONFIG --cflags 2>> AS_MESSAGE_LOG_FD`
298 else
299 pc_cv_python_cflags=
300 fi
301 ])
302 AC_SUBST([PYTHON_CFLAGS], [$pc_cv_python_cflags])])
303
304
305 # PC_PYTHON_CHECK_LDFLAGS
306 # -----------------------
307 # Find the Python LDFLAGS
308 AC_DEFUN([PC_PYTHON_CHECK_LDFLAGS],
309 [AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
310 AC_CACHE_CHECK([for Python LDFLAGS], [pc_cv_python_ldflags],
311 [if test -x "$PYTHON_CONFIG"; then
312 pc_cv_python_ldflags=`$PYTHON_CONFIG --ldflags 2>> AS_MESSAGE_LOG_FD`
313 else
314 pc_cv_python_ldflags=
315 fi
316 ])
317 AC_SUBST([PYTHON_LDFLAGS], [$pc_cv_python_ldflags])])
318
319
320 # PC_PYTHON_CHECK_EXTENSION_SUFFIX
321 # --------------------------------
322 # Find the Python extension suffix (i.e. '.cpython-32.so')
323 AC_DEFUN([PC_PYTHON_CHECK_EXTENSION_SUFFIX],
324 [AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
325 AC_CACHE_CHECK([for Python extension suffix], [pc_cv_python_extension_suffix],
326 [if test -x "$PYTHON_CONFIG"; then
327 pc_cv_python_extension_suffix=`$PYTHON_CONFIG --extension-suffix 2>> AS_MESSAGE_LOG_FD`
328 else
329 pc_cv_python_extension_suffix=
330 fi
331 ])
332 AC_SUBST([PYTHON_EXTENSION_SUFFIX], [$pc_cv_python_extension_suffix])])
333
334
335 # PC_PYTHON_CHECK_ABI_FLAGS
336 # -------------------------
337 # Find the Python ABI flags
338 AC_DEFUN([PC_PYTHON_CHECK_ABI_FLAGS],
339 [AC_REQUIRE([PC_PYTHON_PROG_PYTHON_CONFIG])[]dnl
340 AC_CACHE_CHECK([for Python ABI flags], [pc_cv_python_abi_flags],
341 [if test -x "$PYTHON_CONFIG"; then
342 pc_cv_python_abi_flags=`$PYTHON_CONFIG --abiflags 2>> AS_MESSAGE_LOG_FD`
343 else
344 pc_cv_python_abi_flags=
345 fi
346 ])
347 AC_SUBST([PYTHON_ABI_FLAGS], [$pc_cv_python_abi_flags])])
348
349
350 # PC_PYTHON_CHECK_PLATFORM
351 # ------------------------
352 # At times (like when building shared libraries) you may want
353 # to know which OS platform Python thinks this is.
354 AC_DEFUN([PC_PYTHON_CHECK_PLATFORM],
355 [AC_REQUIRE([AC_PROG_PYTHON])[]dnl
356 AC_CACHE_CHECK([for Python platform],
357 [pc_cv_python_platform],
358 [AC_LANG_PUSH(Python)[]dnl
359 AC_LANG_CONFTEST([
360 AC_LANG_PROGRAM([dnl
361 import sys
362 ], [dnl
363 sys.stdout.write(sys.platform)
364 ])])
365 pc_cv_python_platform=`$PYTHON conftest.py`
366 AC_LANG_POP(Python)[]dnl
367 ])
368 AC_SUBST([PYTHON_PLATFORM], [$pc_cv_python_platform])
369 ])
370
371
372 # PC_PYTHON_CHECK_SITE_DIR
373 # ---------------------
374 # The directory to which new libraries are installed (i.e. the
375 # "site-packages" directory.
376 AC_DEFUN([PC_PYTHON_CHECK_SITE_DIR],
377 [AC_REQUIRE([AC_PROG_PYTHON])AC_REQUIRE([PC_PYTHON_CHECK_PREFIX])[]dnl
378 AC_CACHE_CHECK([for Python site-packages directory],
379 [pc_cv_python_site_dir],
380 [AC_LANG_PUSH(Python)[]dnl
381 if test "x$prefix" = xNONE
382 then
383 pc_py_prefix=$ac_default_prefix
384 else
385 pc_py_prefix=$prefix
386 fi
387 AC_LANG_CONFTEST([
388 AC_LANG_PROGRAM([dnl
389 import sys
390 try:
391 import sysconfig
392 except:
393 from distutils import sysconfig
394 sitedir = sysconfig.get_python_lib(False, False, prefix='$pc_py_prefix')
395 else:
396 sitedir = sysconfig.get_path('purelib', vars={'base':'$pc_py_prefix'})
397 ], [dnl
398 sys.stdout.write(sitedir)
399 ])])
400 pc_cv_python_site_dir=`$PYTHON conftest.py`
401 AC_LANG_POP(Python)[]dnl
402 case $pc_cv_python_site_dir in
403 $pc_py_prefix*)
404 pc__strip_prefix=`echo "$pc_py_prefix" | sed 's|.|.|g'`
405 pc_cv_python_site_dir=`echo "$pc_cv_python_site_dir" | sed "s,^$pc__strip_prefix/,,"`
406 ;;
407 *)
408 case $pc_py_prefix in
409 /usr|/System*) ;;
410 *)
411 pc_cv_python_site_dir=lib/python$PYTHON_VERSION/site-packages
412 ;;
413 esac
414 ;;
415 esac
416 ])
417 AC_SUBST([pythondir], [\${prefix}/$pc_cv_python_site_dir])])# PC_PYTHON_CHECK_SITE_DIR
418 ])
419
420 # PC_PYTHON_SITE_PACKAGE_DIR
421 # --------------------------
422 # $PACKAGE directory under PYTHON_SITE_DIR
423 AC_DEFUN([PC_PYTHON_SITE_PACKAGE_DIR],
424 [AC_REQUIRE([PC_PYTHON_CHECK_SITE_DIR])[]dnl
425 AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])])
426
427
428 # PC_PYTHON_CHECK_EXEC_DIR
429 # ------------------------
430 # directory for installing python extension modules (shared libraries)
431 AC_DEFUN([PC_PYTHON_CHECK_EXEC_DIR],
432 [AC_REQUIRE([AC_PROG_PYTHON])AC_REQUIRE([PC_PYTHON_CHECK_EXEC_PREFIX])[]dnl
433 AC_CACHE_CHECK([for Python extension module directory],
434 [pc_cv_python_exec_dir],
435 [AC_LANG_PUSH(Python)[]dnl
436 if test "x$pc_cv_python_exec_prefix" = xNONE
437 then
438 pc_py_exec_prefix=$pc_cv_python_prefix
439 else
440 pc_py_exec_prefix=$pc_cv_python_exec_prefix
441 fi
442 AC_LANG_CONFTEST([
443 AC_LANG_PROGRAM([dnl
444 import sys
445 try:
446 import sysconfig
447 except:
448 from distutils import sysconfig
449 sitedir = sysconfig.get_python_lib(True, False, prefix='$pc_py_exec_prefix')
450 else:
451 sitedir = sysconfig.get_path('platlib', vars={'platbase':'$pc_py_exec_prefix'})
452 ], [dnl
453 sys.stdout.write(sitedir)
454 ])])
455 pc_cv_python_exec_dir=`$PYTHON conftest.py`
456 AC_LANG_POP(Python)[]dnl
457 case $pc_cv_python_exec_dir in
458 $pc_py_exec_prefix*)
459 pc__strip_prefix=`echo "$pc_py_exec_prefix" | sed 's|.|.|g'`
460 pc_cv_python_exec_dir=`echo "$pc_cv_python_exec_dir" | sed "s,^$pc__strip_prefix/,,"`
461 ;;
462 *)
463 case $pc_py_exec_prefix in
464 /usr|/System*) ;;
465 *)
466 pc_cv_python_exec_dir=lib/python$PYTHON_VERSION/site-packages
467 ;;
468 esac
469 ;;
470 esac
471 ])
472 AC_SUBST([pyexecdir], [\${exec_prefix}/$pc_cv_python_pyexecdir])]) #PY_PYTHON_CHECK_EXEC_LIB_DIR
473 ])
474
475 # PC_PYTHON_EXEC_PACKAGE_DIR
476 # --------------------------
477 # $PACKAGE directory under PYTHON_SITE_DIR
478 AC_DEFUN([PC_PYTHON_EXEC_PACKAGE_DIR],
479 [AC_REQUIRE([PC_PYTHON_CHECK_EXEC_DIR])[]dnl
480 AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])])
481
482
483 ## -------------------------------------------- ##
484 ## 4. Looking for specific libs & functionality ##
485 ## -------------------------------------------- ##
486
487
488 # PC_PYTHON_CHECK_MODULE(LIBRARY, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
489 # ----------------------------------------------------------------------
490 # Macro for checking if a Python library is installed
491 AC_DEFUN([PC_PYTHON_CHECK_MODULE],
492 [AC_REQUIRE([AC_PROG_PYTHON])[]dnl
493 m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
494 AC_CACHE_CHECK([for Python '$1' library],
495 [[pc_cv_python_module_]pc_python_safe_mod],
496 [AC_LANG_PUSH(Python)[]dnl
497 AC_RUN_IFELSE(
498 [AC_LANG_PROGRAM([dnl
499 import sys
500 try:
501 import $1
502 except:
503 sys.exit(1)
504 else:
505 sys.exit(0)
506 ], [])],
507 [[pc_cv_python_module_]pc_python_safe_mod="yes"],
508 [[pc_cv_python_module_]pc_python_safe_mod="no"])
509 AC_LANG_POP(Python)[]dnl
510 ])
511 AS_IF([test "$[pc_cv_python_module_]pc_python_safe_mod" = "no"], [$3], [$2])
512 ])# PC_PYTHON_CHECK_MODULE
513
514
515 # PC_PYTHON_CHECK_FUNC([LIBRARY], FUNCTION, ARGS, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
516 # ---------------------------------------------------------------------------------------
517 # Check to see if a given function call, optionally from a module, can
518 # be successfully called
519 AC_DEFUN([PC_PYTHON_CHECK_FUNC],
520 [AC_REQUIRE([AC_PROG_PYTHON])[]dnl
521 m4_define([pc_python_safe_mod], m4_bpatsubsts($1, [\.], [_]))
522 AC_CACHE_CHECK([for Python m4_ifnblank($1, '$1.$2()', '$2()') function],
523 [[pc_cv_python_func_]pc_python_safe_mod[_$2]],
524 [AC_LANG_PUSH(Python)[]dnl
525 AC_RUN_IFELSE(
526 [AC_LANG_PROGRAM([dnl
527 import sys
528 m4_ifnblank([$1], [dnl
529 try:
530 import $1
531 except:
532 sys.exit(1)
533 ], [])],
534 [
535 m4_ifnblank([$1], [
536 try:
537 $1.$2($3)], [
538 try:
539 $2($3)])
540 except:
541 sys.exit(1)
542 else:
543 sys.exit(0)
544 ])],
545 [[pc_cv_python_func_]pc_python_safe_mod[_$2]="yes"],
546 [[pc_cv_python_func_]pc_python_safe_mod[_$2]="no"])
547 AC_LANG_POP(Python)[]dnl
548 ])
549 AS_IF([test "$[pc_cv_python_func_]pc_python_safe_mod[_$2]" = "no"], [$5], [$4])
550 ])# PC_PYTHON_CHECK_FUNC