1 | # =========================================================================== |
---|
2 | # https://www.gnu.org/software/autoconf-archive/ax_python_embed.html |
---|
3 | # =========================================================================== |
---|
4 | # |
---|
5 | # SYNOPSIS |
---|
6 | # |
---|
7 | # AX_PYTHON_DEFAULT |
---|
8 | # AX_PYTHON_ENABLE |
---|
9 | # AX_PYTHON_WITH |
---|
10 | # AX_PYTHON_PATH |
---|
11 | # AX_PYTHON_VERSION_ENSURE( [2.2] ) |
---|
12 | # AX_PYTHON_CSPEC |
---|
13 | # AX_PYTHON_LSPEC |
---|
14 | # |
---|
15 | # DESCRIPTION |
---|
16 | # |
---|
17 | # This file provides autoconf support for those applications that want to |
---|
18 | # embed python. It supports all pythons >= 2.2 which is the first official |
---|
19 | # release containing distutils. Version 2.2 of python was released |
---|
20 | # December 21, 2001. Since it actually executes the python, cross platform |
---|
21 | # configuration will probably not work. Also, most of the platforms |
---|
22 | # supported are consistent until you look into Mac OS X. The python |
---|
23 | # included with it is installed as a framework which is a very different |
---|
24 | # environment to set up the normal tools such as gcc and libtool to deal |
---|
25 | # with. Therefore, once we establish which python that we are going to |
---|
26 | # use, we use its distutils to actually compile and link our modules or |
---|
27 | # applications. |
---|
28 | # |
---|
29 | # At this time, it does NOT support linking with Python statically. It |
---|
30 | # does support dynamic linking. |
---|
31 | # |
---|
32 | # This set of macros help define $PYTHON, $PYTHON_USE, $PYTHON_CSPEC and |
---|
33 | # $PYTHON_LSPEC. $PYTHON defines the full executable path for the Python |
---|
34 | # being linked to and is used within these macros to determine if that has |
---|
35 | # been specified or found. These macros do execute this python version so |
---|
36 | # it must be present on the system at configure time. |
---|
37 | # |
---|
38 | # $PYTHON_USE is an automake variable that defines whether Python support |
---|
39 | # should be included or not in your application. $PYTHON_CSPEC is a |
---|
40 | # variable that supplies additional CFLAGS for the compilation of the |
---|
41 | # application/shared library. $PYTHON_LSPEC is a variable that supplies |
---|
42 | # additional LDFLAGS for linking the application/shared library. |
---|
43 | # |
---|
44 | # The following is an example of how to set up for python usage within |
---|
45 | # your application in your configure.in: |
---|
46 | # |
---|
47 | # AX_PYTHON_DEFAULT( ) |
---|
48 | # AX_PYTHON_ENABLE( ) # Optional |
---|
49 | # AX_PYTHON_WITH( ) # Optional |
---|
50 | # AX_PYTHON_PATH( ) # or AX_PYTHON_INSIST( ) |
---|
51 | # # if $PYTHON is not defined, then the following do nothing. |
---|
52 | # AX_PYTHON_VERSION_ENSURE( [2.2] ) |
---|
53 | # AX_PYTHON_CSPEC |
---|
54 | # AX_PYTHON_LSPEC |
---|
55 | # |
---|
56 | # The AX_PYTHON_DEFAULT sets the $PYTHON_USE to false. Thereby, excluding |
---|
57 | # it if it was optional. |
---|
58 | # |
---|
59 | # The AX_PYTHON_ENABLE looks for the optional configure parameters of |
---|
60 | # --enable-python/--disable-python and establishes the $PYTHON and |
---|
61 | # $PYTHON_USE variables accordingly. |
---|
62 | # |
---|
63 | # The AX_PYTHON_WITH looks for the optional configure parameters of |
---|
64 | # --with-python/--without-python and establishes the $PYTHON and |
---|
65 | # $PYTHON_USE variables accordingly. |
---|
66 | # |
---|
67 | # The AX_PYTHON_PATH looks for python assuming that none has been |
---|
68 | # previously found or defined and issues an error if it does not find it. |
---|
69 | # If it does find it, it establishes the $PYTHON and $PYTHON_USE variables |
---|
70 | # accordingly. AX_PYTHON_INSIST could be used here instead if you want to |
---|
71 | # insist that Python support be included using the --enable-python or |
---|
72 | # --with-python checks previously done. |
---|
73 | # |
---|
74 | # The AX_PYTHON_VERSION_ENSURE issues an error if the Python previously |
---|
75 | # found is not of version 2.2 or greater. |
---|
76 | # |
---|
77 | # Once that these macros have be run, we can use PYTHON_USE within the |
---|
78 | # makefile.am file to conditionally add the Python support such as: |
---|
79 | # |
---|
80 | # Makefile.am example showing optional inclusion of directories: |
---|
81 | # |
---|
82 | # if PYTHON_USE |
---|
83 | # plugins = plugins |
---|
84 | # src = src |
---|
85 | # else |
---|
86 | # plugins = |
---|
87 | # src = |
---|
88 | # endif |
---|
89 | # |
---|
90 | # SUBDIRS = . $(plugins) $(src) |
---|
91 | # |
---|
92 | # Makefile.am example showing optional shared library build: |
---|
93 | # |
---|
94 | # if PYTHON_USE |
---|
95 | # lib_LTLIBRARIES = libElemList.la |
---|
96 | # libElemList_la_SOURCES = libElemList.c |
---|
97 | # libElemList_la_CFLAGS = @PYTHON_CSPEC@ |
---|
98 | # libElemList_la_LDFLAGS = @PYTHON_LSPEC@ |
---|
99 | # endif |
---|
100 | # |
---|
101 | # Makefile.am example showing optional program build: |
---|
102 | # |
---|
103 | # if PYTHON_USE |
---|
104 | # bin_PROGRAMS = runFunc |
---|
105 | # runFunc_SOURCES = runFunc.c |
---|
106 | # runFunc_CFLAGS = @PYTHON_CSPEC@ |
---|
107 | # runFunc_LDFLAGS = @PYTHON_LSPEC@ |
---|
108 | # endif |
---|
109 | # |
---|
110 | # The above compiles the modules only if PYTHON_USE was specified as true. |
---|
111 | # Also, the else portion of the if was optional. |
---|
112 | # |
---|
113 | # LICENSE |
---|
114 | # |
---|
115 | # Copyright (c) 2008 Robert White <kranki@mac.com> |
---|
116 | # Copyright (c) 2008 Dustin J. Mitchell <dustin@cs.uchicago.edu> |
---|
117 | # |
---|
118 | # Copying and distribution of this file, with or without modification, are |
---|
119 | # permitted in any medium without royalty provided the copyright notice |
---|
120 | # and this notice are preserved. This file is offered as-is, without any |
---|
121 | # warranty. |
---|
122 | |
---|
123 | #serial 15 |
---|
124 | |
---|
125 | # AX_PYTHON_DEFAULT( ) |
---|
126 | # ----------------- |
---|
127 | # Sets the default to not include Python support. |
---|
128 | |
---|
129 | AC_DEFUN([AX_PYTHON_DEFAULT], |
---|
130 | [ |
---|
131 | ax_python_use=false |
---|
132 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
133 | ]) |
---|
134 | |
---|
135 | |
---|
136 | |
---|
137 | # AX_PYTHON_ENABLE( [path] ) |
---|
138 | # ----------------------------------------------------------------- |
---|
139 | # Handles the various --enable-python commands. |
---|
140 | # Input: |
---|
141 | # $1 is the optional search path for the python executable if needed |
---|
142 | # Output: |
---|
143 | # PYTHON_USE (AM_CONDITIONAL) is true if python executable found |
---|
144 | # and --enable-python was requested; otherwise false. |
---|
145 | # $PYTHON contains the full executable path to python if PYTHON_ENABLE_USE |
---|
146 | # is true. |
---|
147 | # |
---|
148 | # Example: |
---|
149 | # AX_PYTHON_ENABLE( ) |
---|
150 | # or |
---|
151 | # AX_PYTHON_ENABLE( "/usr/bin" ) |
---|
152 | |
---|
153 | AC_DEFUN([AX_PYTHON_ENABLE], |
---|
154 | [ |
---|
155 | AC_ARG_VAR([PYTHON],[Python Executable Path]) |
---|
156 | |
---|
157 | # unless PYTHON was supplied to us (as a precious variable), |
---|
158 | # see if --enable-python[=PythonExecutablePath], --enable-python, |
---|
159 | # --disable-python or --enable-python=no was given. |
---|
160 | if test -z "$PYTHON" |
---|
161 | then |
---|
162 | AC_MSG_CHECKING(for --enable-python) |
---|
163 | AC_ARG_ENABLE( |
---|
164 | python, |
---|
165 | AS_HELP_STRING([--enable-python@<:@=PYTHON@:>@], |
---|
166 | [absolute path name of Python executable] |
---|
167 | ), |
---|
168 | [ |
---|
169 | if test "$enableval" = "yes" |
---|
170 | then |
---|
171 | # "yes" was specified, but we don't have a path |
---|
172 | # for the executable. |
---|
173 | # So, let's search the PATH Environment Variable. |
---|
174 | AC_MSG_RESULT(yes) |
---|
175 | AC_PATH_PROG( |
---|
176 | [PYTHON], |
---|
177 | python, |
---|
178 | [], |
---|
179 | $1 |
---|
180 | ) |
---|
181 | if test -z "$PYTHON" |
---|
182 | then |
---|
183 | AC_MSG_ERROR(no path to python found) |
---|
184 | fi |
---|
185 | ax_python_use=true |
---|
186 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
187 | AX_PYTHON_PREFIX( ) |
---|
188 | elif test "$enableval" = "no" |
---|
189 | then |
---|
190 | AC_MSG_RESULT(no) |
---|
191 | ax_python_use=false |
---|
192 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
193 | else |
---|
194 | # $enableval must be the executable path then. |
---|
195 | AC_SUBST([PYTHON], ["${enableval}"]) |
---|
196 | AC_MSG_RESULT($withval) |
---|
197 | ax_python_use=true |
---|
198 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
199 | AX_PYTHON_PREFIX( ) |
---|
200 | fi |
---|
201 | ], |
---|
202 | [ |
---|
203 | # --with-python was not specified. |
---|
204 | AC_MSG_RESULT(no) |
---|
205 | ax_python_use=false |
---|
206 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
207 | ] |
---|
208 | ) |
---|
209 | fi |
---|
210 | |
---|
211 | ]) |
---|
212 | |
---|
213 | |
---|
214 | |
---|
215 | # AX_PYTHON_CSPEC( ) |
---|
216 | # ----------------- |
---|
217 | # Set up the c compiler options to compile Python |
---|
218 | # embedded programs/libraries in $PYTHON_CSPEC if |
---|
219 | # $PYTHON has been defined. |
---|
220 | |
---|
221 | AC_DEFUN([AX_PYTHON_CSPEC], |
---|
222 | [ |
---|
223 | AC_ARG_VAR( [PYTHON], [Python Executable Path] ) |
---|
224 | if test -n "$PYTHON" |
---|
225 | then |
---|
226 | ax_python_prefix=`${PYTHON} -c "import sys; print(sys.prefix)"` |
---|
227 | if test -z "$ax_python_prefix" |
---|
228 | then |
---|
229 | AC_MSG_ERROR([Python Prefix is not known]) |
---|
230 | fi |
---|
231 | ax_python_execprefix=`${PYTHON} -c "import sys; print(sys.exec_prefix)"` |
---|
232 | ax_python_version=`$PYTHON -c "import sys; print(sys.version[[:3]])"` |
---|
233 | ax_python_includespec="-I${ax_python_prefix}/include/python${ax_python_version}" |
---|
234 | if test x"$python_prefix" != x"$python_execprefix"; then |
---|
235 | ax_python_execspec="-I${ax_python_execprefix}/include/python${ax_python_version}" |
---|
236 | ax_python_includespec="${ax_python_includespec} $ax_python_execspec" |
---|
237 | fi |
---|
238 | ax_python_ccshared=`${PYTHON} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('CFLAGSFORSHARED'))"` |
---|
239 | ax_python_cspec="${ax_python_ccshared} ${ax_python_includespec}" |
---|
240 | AC_SUBST([PYTHON_CSPEC], [${ax_python_cspec}]) |
---|
241 | AC_MSG_NOTICE([PYTHON_CSPEC=${ax_python_cspec}]) |
---|
242 | fi |
---|
243 | ]) |
---|
244 | |
---|
245 | |
---|
246 | |
---|
247 | # AX_PYTHON_INSIST( ) |
---|
248 | # ----------------- |
---|
249 | # Look for Python and set the output variable 'PYTHON' |
---|
250 | # to 'python' if found, empty otherwise. |
---|
251 | |
---|
252 | AC_DEFUN([AX_PYTHON_INSIST], |
---|
253 | [ |
---|
254 | AC_ARG_VAR( [PYTHON], [Python Executable Path] ) |
---|
255 | if test -z "$PYTHON" |
---|
256 | then |
---|
257 | AC_MSG_ERROR([Python Executable not found]) |
---|
258 | fi |
---|
259 | ]) |
---|
260 | |
---|
261 | |
---|
262 | |
---|
263 | # AX_PYTHON_LSPEC( ) |
---|
264 | # ----------------- |
---|
265 | # Set up the linker options to link Python embedded |
---|
266 | # programs/libraries in $PYTHON_LSPEC if $PYTHON |
---|
267 | # has been defined. |
---|
268 | |
---|
269 | AC_DEFUN([AX_PYTHON_LSPEC], |
---|
270 | [ |
---|
271 | AC_ARG_VAR( [PYTHON], [Python Executable Path] ) |
---|
272 | if test -n "$PYTHON" |
---|
273 | then |
---|
274 | AX_PYTHON_RUN([ |
---|
275 | import sys |
---|
276 | import distutils.sysconfig |
---|
277 | strUseFrameWork = "--enable-framework" |
---|
278 | dictConfig = distutils.sysconfig.get_config_vars( ) |
---|
279 | strConfigArgs = dictConfig.get("CONFIG_ARGS") |
---|
280 | strLinkSpec = dictConfig.get('LDFLAGS') |
---|
281 | if -1 == strConfigArgs.find(strUseFrameWork): |
---|
282 | strLibPL = dictConfig.get("LIBPL") |
---|
283 | if strLibPL and (strLibPL != ""): |
---|
284 | strLinkSpec += " -L%s" % (strLibPL) |
---|
285 | strSys = dictConfig.get("SYSLIBS") |
---|
286 | if strSys and (strSys != ""): |
---|
287 | strLinkSpec += " %s" % (strSys) |
---|
288 | strSHL = dictConfig.get("SHLIBS") |
---|
289 | if strSHL and (strSHL != ""): |
---|
290 | strLinkSpec += " %s" % (strSHL) |
---|
291 | # Construct the Python Library Name. |
---|
292 | strTmplte = " -lpython%d.%d" |
---|
293 | if (sys.platform == "win32") or (sys.platform == "os2emx"): |
---|
294 | strTmplte = " -lpython%d%d" |
---|
295 | strWrk = strTmplte % ( (sys.hexversion >> 24), |
---|
296 | ((sys.hexversion >> 16) & 0xff)) |
---|
297 | strLinkSpec += strWrk |
---|
298 | else: |
---|
299 | # This is not ideal since it changes the search path |
---|
300 | # for Frameworks which could have side-effects on |
---|
301 | # other included Frameworks. However, it is necessary |
---|
302 | # where someone has installed more than one frameworked |
---|
303 | # Python. Frameworks are really only used in MacOSX. |
---|
304 | strLibFW = dictConfig.get("PYTHONFRAMEWORKPREFIX") |
---|
305 | if strLibFW and (strLibFW != ""): |
---|
306 | strLinkSpec += " -F%s" % (strLibFW) |
---|
307 | strLinkSpec += " %s" % (dictConfig.get('LINKFORSHARED')) |
---|
308 | print(strLinkSpec) |
---|
309 | ]) |
---|
310 | AC_SUBST([PYTHON_LSPEC], [${ax_python_output}]) |
---|
311 | AC_DEFINE(HAVE_PYTHON,1,[can embed python]) |
---|
312 | AC_MSG_NOTICE([PYTHON_LSPEC=${ax_python_output}]) |
---|
313 | fi |
---|
314 | ]) |
---|
315 | |
---|
316 | |
---|
317 | |
---|
318 | # AX_PYTHON_PATH( ) |
---|
319 | # ----------------- |
---|
320 | # Look for Python and set the output variable 'PYTHON' |
---|
321 | # to 'python' if found, empty otherwise. |
---|
322 | |
---|
323 | AC_DEFUN([AX_PYTHON_PATH], |
---|
324 | [ |
---|
325 | AC_ARG_VAR( [PYTHON], [Python Executable Path] ) |
---|
326 | #AC_PATH_PROG( PYTHON, python, [], $1 ) |
---|
327 | if test -z "$PYTHON" |
---|
328 | then |
---|
329 | AC_MSG_RESULT([Python Executable not found]) |
---|
330 | else |
---|
331 | ax_python_use=true |
---|
332 | fi |
---|
333 | AM_CONDITIONAL(PYTHON_USE, test "$ax_python_use" = "true") |
---|
334 | ]) |
---|
335 | |
---|
336 | |
---|
337 | |
---|
338 | # AX_PYTHON_PREFIX( ) |
---|
339 | # ------------------- |
---|
340 | # Use the values of $prefix and $exec_prefix for the corresponding |
---|
341 | # values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. |
---|
342 | |
---|
343 | AC_DEFUN([AX_PYTHON_PREFIX], |
---|
344 | [ |
---|
345 | if test -z "$PYTHON" |
---|
346 | then |
---|
347 | AC_MSG_ERROR([Python Executable Path is not known]) |
---|
348 | fi |
---|
349 | ax_python_prefix=`${PYTHON} -c "import sys; print(sys.prefix)"` |
---|
350 | ax_python_execprefix=`${PYTHON} -c "import sys; print(sys.exec_prefix)"` |
---|
351 | AC_SUBST([PYTHON_PREFIX], ["${ax_python_prefix}"]) |
---|
352 | AC_SUBST([PYTHON_EXECPREFIX], ["${ax_python_execprefix}"]) |
---|
353 | ]) |
---|
354 | |
---|
355 | |
---|
356 | |
---|
357 | # AX_PYTHON_RUN( PYTHON_PROGRAM ) |
---|
358 | # ----------------- |
---|
359 | # Run a Python Test Program saving its output |
---|
360 | # in ax_python_output and its condition code |
---|
361 | # in ax_python_cc. |
---|
362 | |
---|
363 | AC_DEFUN([AX_PYTHON_RUN], |
---|
364 | [ |
---|
365 | AC_ARG_VAR( [PYTHON], [Python Executable Path] ) |
---|
366 | if test -z "$PYTHON" |
---|
367 | then |
---|
368 | AC_MSG_ERROR([Python Executable not found]) |
---|
369 | else |
---|
370 | cat >conftest.py <<_ACEOF |
---|
371 | $1 |
---|
372 | _ACEOF |
---|
373 | ax_python_output=`$PYTHON conftest.py` |
---|
374 | ax_python_cc=$? |
---|
375 | rm conftest.py |
---|
376 | if test -f "conftest.pyc" |
---|
377 | then |
---|
378 | rm conftest.pyc |
---|
379 | fi |
---|
380 | fi |
---|
381 | ]) |
---|
382 | |
---|
383 | |
---|
384 | |
---|
385 | # AX_PYTHON_VERSION_CHECK( VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE] ) |
---|
386 | # ----------------------------------------------------------------------------- |
---|
387 | # Run ACTION-IF-TRUE if the Python interpreter has version == VERSION. |
---|
388 | # Run ACTION-IF-FALSE otherwise. |
---|
389 | # This test uses sys.hexversion instead of the string equivalent (first |
---|
390 | # word of sys.version), in order to cope with versions such as 2.2c1. |
---|
391 | # hexversion has been introduced in Python 1.5.2; it's probably not |
---|
392 | # worth to support older versions (1.5.1 was released on October 31, 1998). |
---|
393 | |
---|
394 | AC_DEFUN([AX_PYTHON_VERSION_CHECK], |
---|
395 | [ |
---|
396 | AC_ARG_VAR( [PYTHON], [Python Executable Path] ) |
---|
397 | if test -n "$PYTHON" |
---|
398 | then |
---|
399 | AC_MSG_CHECKING([whether $PYTHON version == $1]) |
---|
400 | AX_PYTHON_RUN([ |
---|
401 | import sys |
---|
402 | # split strings by '.' and convert to numeric. Append some zeros |
---|
403 | # because we need at least 4 digits for the hex conversion. |
---|
404 | # It accepts a string like "X[.Y[.Z]]" with X,Y,Z=digits |
---|
405 | # and [] means optional. |
---|
406 | minver = list(map(int, '$1'.split('.'))) + [[0, 0, 0]] |
---|
407 | minver[3] = 255 |
---|
408 | minverhex = 0 |
---|
409 | for i in range(0, 4): minverhex = (minverhex << 8) + minver[[i]] |
---|
410 | if sys.hexversion >= minverhex: |
---|
411 | if sys.hexversion <=0x03000000: |
---|
412 | sys.exit( 0 ) |
---|
413 | else: |
---|
414 | sys.exit( 1 ) |
---|
415 | fi |
---|
416 | else: |
---|
417 | sys.exit( 1 ) |
---|
418 | ]) |
---|
419 | if test $ax_python_cc -eq 0 |
---|
420 | then |
---|
421 | $2 |
---|
422 | m4_ifvaln( |
---|
423 | [$3], |
---|
424 | [else $3] |
---|
425 | ) |
---|
426 | fi |
---|
427 | fi |
---|
428 | ]) |
---|
429 | |
---|
430 | |
---|
431 | |
---|
432 | # AX_PYTHON_VERSION_ENSURE( VERSION ) |
---|
433 | # ----------------- |
---|
434 | # Insure that the Python Interpreter Version |
---|
435 | # is greater than or equal to the VERSION |
---|
436 | # parameter. |
---|
437 | |
---|
438 | AC_DEFUN([AX_PYTHON_VERSION_ENSURE], |
---|
439 | [ |
---|
440 | AX_PYTHON_VERSION_CHECK( |
---|
441 | [$1], |
---|
442 | [AC_MSG_RESULT(yes)], |
---|
443 | [AC_MSG_RESULT(no) |
---|
444 | PYTHON="" |
---|
445 | ax_ython_use=false] |
---|
446 | ) |
---|
447 | ]) |
---|
448 | |
---|
449 | |
---|
450 | |
---|
451 | # AX_PYTHON_WITH( [path] ) |
---|
452 | # ----------------------------------------------------------------- |
---|
453 | # Handles the various --with-python commands. |
---|
454 | # Input: |
---|
455 | # $1 is the optional search path for the python executable if needed |
---|
456 | # Output: |
---|
457 | # PYTHON_USE (AM_CONDITIONAL) is true if python executable found |
---|
458 | # and --with-python was requested; otherwise false. |
---|
459 | # $PYTHON contains the full executable path to python if PYTHON_USE |
---|
460 | # is true. |
---|
461 | # |
---|
462 | # Example: |
---|
463 | # AX_PYTHON_WITH( ) |
---|
464 | # or |
---|
465 | # AX_PYTHON_WITH("/usr/bin") |
---|
466 | |
---|
467 | AC_DEFUN([AX_PYTHON_WITH], |
---|
468 | [ |
---|
469 | AC_ARG_VAR([PYTHON],[Python Executable Path]) |
---|
470 | |
---|
471 | # unless PYTHON was supplied to us (as a precious variable), |
---|
472 | # see if --with-python[=PythonExecutablePath], --with-python, |
---|
473 | # --without-python or --with-python=no was given. |
---|
474 | if test -z "$PYTHON" |
---|
475 | then |
---|
476 | AC_MSG_CHECKING(for --with-python) |
---|
477 | AC_ARG_WITH( |
---|
478 | python, |
---|
479 | AS_HELP_STRING([--with-python@<:@=PYTHON@:>@], |
---|
480 | [absolute path name of Python executable] |
---|
481 | ), |
---|
482 | [ |
---|
483 | if test "$withval" = "yes" |
---|
484 | then |
---|
485 | # "yes" was specified, but we don't have a path |
---|
486 | # for the executable. |
---|
487 | # So, let's search the PATH Environment Variable. |
---|
488 | AC_MSG_RESULT(yes) |
---|
489 | AC_PATH_PROG( |
---|
490 | [PYTHON], |
---|
491 | python, |
---|
492 | [], |
---|
493 | $1 |
---|
494 | ) |
---|
495 | if test -z "$PYTHON" |
---|
496 | then |
---|
497 | AC_MSG_ERROR(no path to python found) |
---|
498 | fi |
---|
499 | ax_python_use=true |
---|
500 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
501 | AX_PYTHON_PREFIX( ) |
---|
502 | elif test "$withval" = "no" |
---|
503 | then |
---|
504 | AC_MSG_RESULT(no) |
---|
505 | ax_python_use=false |
---|
506 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
507 | else |
---|
508 | # $withval must be the executable path then. |
---|
509 | AC_SUBST([PYTHON], ["${withval}"]) |
---|
510 | AC_MSG_RESULT($withval) |
---|
511 | ax_python_use=true |
---|
512 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
513 | AX_PYTHON_PREFIX( ) |
---|
514 | fi |
---|
515 | ], |
---|
516 | [ |
---|
517 | # --with-python was not specified. |
---|
518 | AC_MSG_RESULT(no) |
---|
519 | ax_python_use=false |
---|
520 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
521 | ] |
---|
522 | ) |
---|
523 | fi |
---|
524 | |
---|
525 | ]) |
---|