summaryrefslogtreecommitdiffstats
path: root/src/external/python.m4
blob: c91e8df17b0371538f02bfeb9cade1ce639074bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
dnl Check for python-config and substitute needed CFLAGS and LDFLAGS
dnl Usage:
dnl     AM_PYTHON_CONFIG(python_with_major_version)
dnl     argument python_with_major_version should be either python2 or python3
dnl This function sets the PYTHON_CFLAGS, PYTHON_LIBS and PYTHON_INCLUDES
dnl variables

AC_DEFUN([AM_PYTHON_CONFIG],
[
    AC_PATH_PROG([PYTHON_CONFIG], [python$PYTHON_VERSION-config])
    AS_IF([test x"$PYTHON_CONFIG" = x],
          AC_MSG_ERROR([
The program python$PYTHON_VERSION-config was not found in search path.
Please ensure that it is installed and its directory is included in the search
path. If you want to build sssd without $1 bindings then specify
--without-$1-bindings when running configure.]))

    PYTHON_CFLAGS="` $PYTHON_CONFIG --cflags`"
    PYTHON_LIBS="` $PYTHON_CONFIG --libs`"
    PYTHON_INCLUDES="` $PYTHON_CONFIG --includes`"
])

dnl Taken from GNOME sources
dnl a macro to check for ability to create python extensions
dnl  AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
[
    AC_REQUIRE([AM_PATH_PYTHON])
    AC_MSG_CHECKING(for headers required to compile python extensions)

    dnl check if the headers exist:
    save_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
    AC_TRY_CPP([#include <Python.h>],dnl
               [AC_MSG_RESULT([found])
                $1],dnl
               [AC_MSG_RESULT([not found])
               $2])
    CPPFLAGS="$save_CPPFLAGS"
])


dnl Checks for a couple of functions we use that may not be defined
dnl in some older python (< 2.6) versions used e.g. on RHEL6
AC_DEFUN([AM_CHECK_PYTHON_COMPAT],
[
    AC_REQUIRE([AM_CHECK_PYTHON_HEADERS])
    save_CPPFLAGS="$CPPFLAGS"
    save_LIBS="$LIBS"
    CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
    LIBS="$LIBS $PYTHON_LIBS"

    AC_CHECK_FUNCS([PyErr_NewExceptionWithDoc])

    CPPFLAGS="$save_CPPFLAGS"
    LIBS="$save_LIBS"
])

dnl Clean variables after detection of python
AC_DEFUN([SSS_CLEAN_PYTHON_VARIABLES],
[
    unset pyexecdir pkgpyexecdir pythondir pgkpythondir
    unset PYTHON PYTHON_CFLAGS PYTHON_LIBS PYTHON_INCLUDES
    unset PYTHON_PREFIX PYTHON_EXEC_PREFIX PYTHON_VERSION PYTHON_CONFIG

    dnl removed cached variables, required for reusing of AM_PATH_PYTHON
    unset am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_version
    unset am_cv_python_platform am_cv_python_pythondir am_cv_python_pyexecdir
    unset ac_cv_path_PYTHON_CONFIG
])