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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
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`"
# With python3.8 it is expected that C extension do not link against
# libpythonX.Y anymore but only the application loading the extension links
# the library. pyhton3.8-config adds a new option --embed for this use
# case. See
# https://docs.python.org/dev/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build
# for details. Since the dlopen-test checks the python modules as well we
# have to make sure that it links libpythonX.Y.
#
# To build the Python modules PYTHON_LIBS must be used, python-config will
# take care that this does not include libpythonX.Y for Python3.8.
#
# For our dlopen-test PYTHON_DLOPEN_LIB must be used. It is either empty or
# contains libpythonX.Y if needed.
$PYTHON_CONFIG --libs --embed 1> /dev/null 2> /dev/null
if test $? -eq 0; then
PYTHON_DLOPEN_LIB="` $PYTHON_CONFIG --libs --embed | grep -o -- '-lpython@<:@^ @:>@*' |sed -e 's/^-l/lib/'`"
if test x"$PYTHON_DLOPEN_LIB" != x; then
python_lib_paths="` $PYTHON_CONFIG --ldflags | grep -o -- '-L/@<:@^ @:>@*' | sed -e 's/^-L//'`"
for p in $python_lib_paths; do
if test -e $p"/"$PYTHON_DLOPEN_LIB; then
PYTHON_DLOPEN_LIB=$p"/"$PYTHON_DLOPEN_LIB
break
fi
done
PYTHON_DLOPEN_LIB=$PYTHON_DLOPEN_LIB".so"
AC_DEFINE_UNQUOTED([PYTHON_DLOPEN_LIB], ["$PYTHON_DLOPEN_LIB"], [The path of libpython for dlopen-tests])
fi
fi
])
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 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_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
])
dnl ===========================================================================
dnl http://www.gnu.org/software/autoconf-archive/ax_python_module.html
dnl ===========================================================================
dnl
dnl SYNOPSIS
dnl
dnl AM_PYTHON2_MODULE(modname[, fatal])
dnl
dnl DESCRIPTION
dnl
dnl Checks for Python 2 module.
dnl
dnl If fatal is non-empty then absence of a module will trigger an error.
dnl
dnl LICENSE
dnl
dnl Copyright (c) 2008 Andrew Collier
dnl
dnl Copying and distribution of this file, with or without modification, are
dnl permitted in any medium without royalty provided the copyright notice
dnl and this notice are preserved. This file is offered as-is, without any
dnl warranty.
AC_DEFUN([AM_PYTHON2_MODULE],[
if test x"$PYTHON2" = x; then
if test -n "$2"; then
AC_MSG_ERROR([cannot look for $1 module: Python 2 not found])
else
AC_MSG_NOTICE([cannot look for $1 module: Python 2 not found])
eval AS_TR_CPP(HAVE_PY2MOD_$1)=no
fi
else
AC_MSG_CHECKING($(basename $PYTHON2) module: $1)
$PYTHON2 -c "import $1" 2>/dev/null
if test $? -eq 0; then
AC_MSG_RESULT(yes)
eval AS_TR_CPP(HAVE_PY2MOD_$1)=yes
else
AC_MSG_RESULT(no)
eval AS_TR_CPP(HAVE_PY2MOD_$1)=no
#
if test -n "$2"
then
AC_MSG_ERROR(failed to find required module $1)
exit 1
fi
fi
fi
])
AC_DEFUN([AM_PYTHON3_MODULE],[
if test x"$PYTHON3" = x; then
if test -n "$2"; then
AC_MSG_ERROR([cannot look for $1 module: Python 3 not found])
else
AC_MSG_NOTICE([cannot look for $1 module: Python 3 not found])
eval AS_TR_CPP(HAVE_PY3MOD_$1)=no
fi
else
AC_MSG_CHECKING($(basename $PYTHON3) module: $1)
$PYTHON3 -c "import $1" 2>/dev/null
if test $? -eq 0; then
AC_MSG_RESULT(yes)
eval AS_TR_CPP(HAVE_PY3MOD_$1)=yes
else
AC_MSG_RESULT(no)
eval AS_TR_CPP(HAVE_PY3MOD_$1)=no
#
if test -n "$2"
then
AC_MSG_ERROR(failed to find required module $1)
exit 1
fi
fi
fi
])
dnl SYNOPSIS
dnl
dnl SSS_CHECK_PYTEST(python_interpreter, have_suffix)
dnl
dnl DESCRIPTION
dnl
dnl Checks for pytest
AC_DEFUN([SSS_CHECK_PYTEST],[
if test x"$1" = x; then
if test -n "$2"; then
AC_MSG_ERROR([cannot look for pytest: $(basename $1) not found])
else
AC_MSG_NOTICE([cannot look for pytest module: $(basename $1) not found])
eval AS_TR_CPP(HAVE_$2)=no
fi
else
AC_MSG_CHECKING($(basename $1) pytest)
$1 -m pytest --version 2>/dev/null
if test $? -eq 0; then
AC_MSG_RESULT(yes)
eval AS_TR_CPP(HAVE_$2)=yes
else
AC_MSG_RESULT(no)
eval AS_TR_CPP(HAVE_$2)=no
fi
fi
])
|