From 79e1d351cf71cc15a13223b093174377b83ae6a8 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Tue, 10 Feb 2015 16:14:59 +0100 Subject: [PATCH 93/99] BUILD: Use python-config for detection *FLAGS The script python-config was not available in older versions of python. This patch simplify detection of python CFLAGS and LDFLAGS and increase minimal required version of python to 2.6 Reviewed-by: Stephen Gallagher --- configure.ac | 6 +++-- src/external/python.m4 | 63 +++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/configure.ac b/configure.ac index cdbe6f9bff3822bb80d8d43b593e02c39d729f64..f72e448528edcffb855504a38a179c400f98ac42 100644 --- a/configure.ac +++ b/configure.ac @@ -248,11 +248,13 @@ AM_CONDITIONAL([HAVE_MANPAGES], [test "x$HAVE_MANPAGES" != "x"]) AM_CONDITIONAL([HAVE_PO4A], [test "x$PO4A" != "xno"]) if test x$HAVE_PYTHON_BINDINGS != x; then - AM_PATH_PYTHON([2.4]) + AM_PATH_PYTHON([2.6]) + AM_PYTHON_CONFIG([python]) AM_CHECK_PYTHON_HEADERS([], AC_MSG_ERROR([Could not find python headers])) - AM_PYTHON_CONFIG AM_CHECK_PYTHON_COMPAT + AC_SUBST([PYTHON_CFLAGS]) + AC_SUBST([PYTHON_LIBS]) fi if test x$HAVE_SELINUX != x; then diff --git a/src/external/python.m4 b/src/external/python.m4 index d59233aa01ac591cfc86be974d8ae26ebbe4635d..c91e8df17b0371538f02bfeb9cade1ce639074bd 100644 --- a/src/external/python.m4 +++ b/src/external/python.m4 @@ -1,46 +1,33 @@ dnl Check for python-config and substitute needed CFLAGS and LDFLAGS dnl Usage: -dnl AM_PYTHON_CONFIG +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_SUBST(PYTHON_CFLAGS) - AC_SUBST(PYTHON_LIBS) +[ + 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.])) -dnl We need to check for python build flags using distutils.sysconfig -dnl We cannot use python-config, as it was not available on older -dnl versions of python - AC_PATH_PROG(PYTHON, python) - AC_MSG_CHECKING([for working python]) - if test -x "$PYTHON"; then - PYTHON_CFLAGS="`$PYTHON -c \"from distutils import sysconfig; \ - print('-I' + sysconfig.get_python_inc() + \ - ' -I' + sysconfig.get_python_inc(plat_specific=True) + ' ' + \ - sysconfig.get_config_var('BASECFLAGS'))\"`" - PYTHON_LIBS="`$PYTHON -c \"from distutils import sysconfig; \ - print(' '.join(sysconfig.get_config_var('LIBS').split() + \ - sysconfig.get_config_var('SYSLIBS').split()) + \ - ' ' + sysconfig.get_config_var('BLDLIBRARY') + ' ' + \ - ' -L' + sysconfig.get_config_var('LIBDIR'))\"`" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - AC_MSG_ERROR([Please install python devel package]) - fi + 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]) -dnl function also defines PYTHON_INCLUDES AC_DEFUN([AM_CHECK_PYTHON_HEADERS], -[AC_REQUIRE([AM_PATH_PYTHON]) +[ + AC_REQUIRE([AM_PATH_PYTHON]) AC_MSG_CHECKING(for headers required to compile python extensions) - dnl deduce PYTHON_INCLUDES - PYTHON_INCLUDES=-I`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_config_var('INCLUDEPY'))"` - - AC_SUBST(PYTHON_INCLUDES) - dnl check if the headers exist: save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" @@ -56,7 +43,8 @@ AC_DEFUN([AM_CHECK_PYTHON_HEADERS], 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]) +[ + AC_REQUIRE([AM_CHECK_PYTHON_HEADERS]) save_CPPFLAGS="$CPPFLAGS" save_LIBS="$LIBS" CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" @@ -67,3 +55,16 @@ AC_DEFUN([AM_CHECK_PYTHON_COMPAT], 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 +]) -- 2.4.0