source: git/m4/ax_python_with_version.m4 @ c2ff413

spielwiese
Last change on this file since c2ff413 was c2ff413, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Fix building without Python
  • Property mode set to 100644
File size: 3.7 KB
Line 
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
18AC_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)
28        AC_ARG_WITH(
29            python,
30            AS_HELP_STRING([--with-python@<:@=@<:@embed,@:>@PYTHON@:>@],
31                [absolute path name of Python executable]
32            ),
33            [],[withval="yes"]
34        )
35        py_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
36        for elt in $withval; do
37          IFS="$py_save_ifs"
38          case $elt in
39            embed|embedding)
40              si_try_embed=true
41            ;;
42            static|dynamic|shared|module)
43            ;;
44            *)
45            si_withval=$elt
46          esac
47        done
48        IFS="$py_save_ifs"
49        if test x"$si_withval" = x""
50        then
51           withval="yes"
52        else
53           withval="$si_withval"
54        fi
55
56        AC_MSG_RESULT($withval)
57        if test "$withval" = "no"
58        then
59            ax_python_use=false
60        else       
61            if test "$withval" = "yes"
62            then
63                # "yes" was specified, but we don't have a path
64                # for the executable.
65                # So, let's search the PATH Environment Variable.
66                AC_PATH_PROG(
67                    [PYTHON],
68                    python,
69                    [],
70                    $2
71                )
72            else
73                # $withval must be the executable path then.
74                AC_SUBST([PYTHON], ["${withval}"])
75            fi
76            if test -z "$PYTHON"
77            then
78                AC_MSG_RESULT([no path to python found, skipping python interface!])
79            else
80                AX_PYTHON_VERSION_CHECK([$1],
81                                        [ ax_python_use=true
82                                          si_embed_python=$si_try_embed
83                                          AC_MSG_RESULT(yes)
84                                          AX_PYTHON_PREFIX( )
85                                          AX_PYTHON_LSPEC( )
86                                          AX_PYTHON_CSPEC( )
87                                        ],
88                                        [ax_python_use=false
89                                         AC_MSG_RESULT([too old, skipping python interface!])]
90                )
91            fi
92        fi   
93
94        if  test x"$si_embed_python" = x"true"
95        then
96          AC_DEFINE(EMBED_PYTHON,1,integrate python)
97          AC_SUBST(EMBED_PYOBJECT_CFLAGS,"\${PYTHON_CSPEC}")
98          AC_SUBST(EMBED_PYOBJECT_LDFLAGS,"\${PYTHON_LSPEC}")
99        fi
100        if test x"$ax_python_use" = x"true"
101        then
102          AC_DEFINE(HAVE_PYTHON,1,[compile python-related stuff])
103        fi
104    fi
105   
106    AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true")
107    AM_CONDITIONAL(SI_EMBED_PYTHON, test x"$si_embed_python" = x"true")
108    AM_CONDITIONAL(PYTHON_MODULE, test x"$si_embed_python" != x"true")
109
110])
111
Note: See TracBrowser for help on using the repository browser.