source: git/m4/ax_python_with_version.m4 @ 7b9d49

fieker-DuValspielwiese
Last change on this file since 7b9d49 was 7b9d49, checked in by Alexander Dreyer <adreyer@…>, 11 years ago
Fix nonexisting or old python won't break build
  • Property mode set to 100644
File size: 2.5 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@<:@=PYTHON@:>@],
31                [absolute path name of Python executable]
32            ),
33            [],[withval="yes"]
34        )
35        AC_MSG_RESULT($withval)
36        if test "$withval" = "no"
37        then
38            ax_python_use=false
39        else       
40            if test "$withval" = "yes"
41            then
42                # "yes" was specified, but we don't have a path
43                # for the executable.
44                # So, let's search the PATH Environment Variable.
45                AC_PATH_PROG(
46                    [PYTHON],
47                    python,
48                    [],
49                    $2
50                )
51            else
52                # $withval must be the executable path then.
53                AC_SUBST([PYTHON], ["${withval}"])
54            fi
55            if test -z "$PYTHON"
56            then
57                AC_MSG_RESULT([no path to python found, skipping python interface!])
58            else
59                AX_PYTHON_VERSION_CHECK([$1],
60                                        [ ax_python_use=true
61                                          AC_MSG_RESULT(yes)
62                                          AX_PYTHON_PREFIX( )
63                                          AX_PYTHON_LSPEC( )
64                                          AX_PYTHON_CSPEC( )
65                                        ],
66                                        [ax_python_use=false; AC_MSG_RESULT([too old, skipping python interface!])]
67                )
68            fi
69        fi   
70        AM_CONDITIONAL(PYTHON_USE, test x"$ax_python_use" = x"true")
71    fi
72
73])
74
Note: See TracBrowser for help on using the repository browser.