From 8e5c46750073137ff35154242437e56c3b41ec1b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 20 Sep 2013 12:42:45 +0200 Subject: build-sys: support --with-python[={2,3}] * we use pkg-config to get CGLAGS and LIBS, use package specific config (e.g. python-config) is non-sense. * default is to follow distribution and use pkg-config module name "python". This is probably symlink to python2.pc or python3.pc. * --with-python=2 forces to pkg-module "python2 >= 2" * --with-python=3 forces to pkg-module "python3 >= 3" Signed-off-by: Karel Zak --- configure.ac | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index d24ed8f7f..85faa2e07 100644 --- a/configure.ac +++ b/configure.ac @@ -1374,26 +1374,33 @@ AM_CONDITIONAL([BUILD_BASH_COMPLETION], [test "x$enable_bash_completion" = xyes] AC_ARG_WITH([python], - AS_HELP_STRING([--without-python], [do not generate python bindings]), - [], [with_python=yes] + AS_HELP_STRING([--without-python], [do not generate python bindings, use --with-python={2,3} to force version]), + [], [with_python=check] ) + have_python=no -AS_IF([test "x$with_python" = xyes], [ - AM_PATH_PYTHON([2.4]) - AS_IF([test -x "$PYTHON-config"], [ - have_python=yes - PYTHON_INCLUDES=$($PYTHON-config --includes) - AC_SUBST(PYTHON_INCLUDES) +AS_IF([test "x$with_python" != xno], [ + # We follow distributions default and look for PKG module name "python" + # (minimal version is 2) but if major version is explicitly specified by + # --with-python=2 or --with-python=3 then we look for PKG module "python2" or + # "python3". + pymajor="2" + modname="python" + AS_IF([test "x$withval" != xno -a "x$withval" != xyes], [ + pymajor="$withval" + modname="python${pymajor}" ]) + PKG_CHECK_MODULES(PYTHON,[${modname} >= $pymajor], + [have_python=yes + PYTHON_VERSION=`$PKG_CONFIG --modversion $modname` + AC_SUBST([PYTHON_VERSION])], + [have_python=no]) + AS_CASE([$with_python:$have_python], + [yes:no], + [AC_MSG_ERROR([python selected but libpython not found])], + ) ]) -dnl FIXME: the python3 should be fixed in future. -AS_CASE([$PYTHON_VERSION], - [2.*], [], - [3.*], [AC_MSG_ERROR([pylibmount will not work with python3])], - [AC_MSG_ERROR([unanticipated python version])] -) - UL_BUILD_INIT([pylibmount], [check]) UL_REQUIRES_HAVE([pylibmount], [python]) UL_REQUIRES_BUILD([pylibmount], [libmount]) @@ -1531,7 +1538,9 @@ AC_MSG_RESULT([ suid cflags: ${SUID_CFLAGS} ldflags: ${LDFLAGS} suid ldflags: ${SUID_LDFLAGS} - Bash completions dir: ${with_bashcompletiondir} + + Python: ${PYTHON_VERSION} + Bash completions: ${with_bashcompletiondir} warnings: -- cgit v1.2.3-55-g7522