[7b9d49] | 1 | # AX_PYTHON_WITH_VERSION( [version], [path] ) |
---|
| 2 | # ----------------------------------------------------------------- |
---|
| 3 | # Handles the various --with-python commands. |
---|
| 4 | # Input: |
---|
| 5 | # $1 is the minimun required python version |
---|
| 6 | # $2 is the optional search path for the python executable if needed |
---|
| 7 | # Ouput: |
---|
| 8 | # PYTHON_USE (AM_CONDITIONAL) is true if python executable found |
---|
| 9 | # and --with-python was requested; otherwise false. |
---|
| 10 | # $PYTHON contains the full executable path to python if PYTHON_USE |
---|
| 11 | # is true. |
---|
| 12 | # |
---|
| 13 | # Example: |
---|
| 14 | # AX_PYTHON_WITH_VERSION([2.4]) |
---|
| 15 | # or |
---|
| 16 | # AX_PYTHON_WITH_VERSION([2.4], "/usr/bin") |
---|
| 17 | |
---|
| 18 | AC_DEFUN([AX_PYTHON_WITH_VERSION], |
---|
| 19 | [ |
---|
| 20 | AC_ARG_VAR([PYTHON],[Python Executable Path]) |
---|
| 21 | |
---|
| 22 | # unless PYTHON was supplied to us (as a precious variable), |
---|
| 23 | # see if --with-python[=PythonExecutablePath], --with-python, |
---|
| 24 | # --without-python or --with-python=no was given. |
---|
| 25 | if test -z "$PYTHON" |
---|
| 26 | then |
---|
| 27 | AC_MSG_CHECKING(for --with-python) |
---|
[46dd2e] | 28 | # @<:@=@<:@embed,@:>@PYTHON@:>@ |
---|
| 29 | AC_ARG_WITH( |
---|
[7b9d49] | 30 | python, |
---|
[46dd2e] | 31 | AS_HELP_STRING([--with-python], |
---|
[7b9d49] | 32 | [absolute path name of Python executable] |
---|
| 33 | ), |
---|
| 34 | [],[withval="yes"] |
---|
[75f460] | 35 | ) |
---|
[ebdbfd] | 36 | si_try_embed="no" |
---|
[c1e7a6] | 37 | py_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," |
---|
| 38 | for elt in $withval; do |
---|
| 39 | IFS="$py_save_ifs" |
---|
| 40 | case $elt in |
---|
| 41 | embed|embedding) |
---|
[ebdbfd] | 42 | si_try_embed="yes" |
---|
[c1e7a6] | 43 | ;; |
---|
| 44 | static|dynamic|shared|module) |
---|
| 45 | ;; |
---|
| 46 | *) |
---|
| 47 | si_withval=$elt |
---|
[75f460] | 48 | esac |
---|
[c1e7a6] | 49 | done |
---|
| 50 | IFS="$py_save_ifs" |
---|
| 51 | if test x"$si_withval" = x"" |
---|
| 52 | then |
---|
| 53 | withval="yes" |
---|
| 54 | else |
---|
| 55 | withval="$si_withval" |
---|
| 56 | fi |
---|
| 57 | |
---|
[7b9d49] | 58 | AC_MSG_RESULT($withval) |
---|
| 59 | if test "$withval" = "no" |
---|
| 60 | then |
---|
| 61 | ax_python_use=false |
---|
[75f460] | 62 | else |
---|
[7b9d49] | 63 | if test "$withval" = "yes" |
---|
| 64 | then |
---|
| 65 | # "yes" was specified, but we don't have a path |
---|
| 66 | # for the executable. |
---|
| 67 | # So, let's search the PATH Environment Variable. |
---|
[ebdbfd] | 68 | AC_PATH_PROGS( |
---|
[7b9d49] | 69 | [PYTHON], |
---|
[1684c3] | 70 | [python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2 python], |
---|
[7b9d49] | 71 | [], |
---|
| 72 | $2 |
---|
| 73 | ) |
---|
| 74 | else |
---|
| 75 | # $withval must be the executable path then. |
---|
| 76 | AC_SUBST([PYTHON], ["${withval}"]) |
---|
| 77 | fi |
---|
| 78 | if test -z "$PYTHON" |
---|
| 79 | then |
---|
| 80 | AC_MSG_RESULT([no path to python found, skipping python interface!]) |
---|
[75f460] | 81 | else |
---|
[7b9d49] | 82 | AX_PYTHON_VERSION_CHECK([$1], |
---|
[ebdbfd] | 83 | [ AC_MSG_RESULT(yes) |
---|
| 84 | AX_PYTHON_VERSION_CHECK([3], |
---|
| 85 | [ ax_python_use=false |
---|
| 86 | AC_MSG_RESULT([too recent, skipping python interface!]) |
---|
| 87 | ], |
---|
[69e438] | 88 | [ AC_MSG_RESULT([no (ok)]) |
---|
| 89 | ax_python_version=`$PYTHON -c "import sys; print '.'.join(sys.version.split('.')[[:2]])"` |
---|
| 90 | AC_CHECK_LIB([python${ax_python_version}],[main], [ |
---|
| 91 | ax_python_use=true |
---|
| 92 | si_embed_python=$si_try_embed |
---|
| 93 | AC_MSG_CHECKING(embedding python interface module) |
---|
| 94 | AC_MSG_RESULT($si_try_embed) |
---|
| 95 | AX_PYTHON_PREFIX( ) |
---|
| 96 | AX_PYTHON_LSPEC( ) |
---|
| 97 | AX_PYTHON_CSPEC( ) |
---|
| 98 | ], |
---|
| 99 | [ ax_python_use=false |
---|
| 100 | AC_MSG_RESULT([Cannot link to python, skipping python interface!]) |
---|
| 101 | ] |
---|
| 102 | ) |
---|
[ebdbfd] | 103 | ]) |
---|
| 104 | ], |
---|
| 105 | [ ax_python_use=false |
---|
| 106 | AC_MSG_RESULT([too old, skipping python interface!])] |
---|
[7b9d49] | 107 | ) |
---|
| 108 | fi |
---|
[75f460] | 109 | fi |
---|
[c1e7a6] | 110 | |
---|
[ebdbfd] | 111 | if test x"$si_embed_python" = x"yes" |
---|
[75f460] | 112 | then |
---|
[c1e7a6] | 113 | AC_DEFINE(EMBED_PYTHON,1,integrate python) |
---|
[99b54a] | 114 | # AC_SUBST(EMBED_PYOBJECT_CFLAGS,"\${PYTHON_CSPEC}") |
---|
| 115 | # AC_SUBST(EMBED_PYOBJECT_LDFLAGS,"\${PYTHON_LSPEC}") |
---|
[c1e7a6] | 116 | fi |
---|
[75f460] | 117 | if test x"$ax_python_use" = x"true" |
---|
| 118 | then |
---|
[c2ff413] | 119 | AC_DEFINE(HAVE_PYTHON,1,[compile python-related stuff]) |
---|
| 120 | fi |
---|
[7b9d49] | 121 | fi |
---|
[75f460] | 122 | |
---|
[c2ff413] | 123 | AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true") |
---|
[ebdbfd] | 124 | AM_CONDITIONAL(SI_EMBED_PYTHON, test x"$ax_python_use$si_embed_python" = x"trueyes") |
---|
| 125 | AM_CONDITIONAL(PYTHON_MODULE, test x"$ax_python_use" = x"true" -a x"$si_embed_python" != x"yes" ) |
---|
[7b9d49] | 126 | |
---|
| 127 | ]) |
---|
| 128 | |
---|