summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac41
-rw-r--r--libmount/python/Makemodule.am3
2 files changed, 26 insertions, 18 deletions
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:
diff --git a/libmount/python/Makemodule.am b/libmount/python/Makemodule.am
index 550ea774b..657cdcb2c 100644
--- a/libmount/python/Makemodule.am
+++ b/libmount/python/Makemodule.am
@@ -12,11 +12,10 @@ pylibmount_la_SOURCES = \
libmount/python/tab.c \
libmount/python/context.c
-pylibmount_la_LIBADD = libmount.la -lpython$(PYTHON_VERSION)
+pylibmount_la_LIBADD = libmount.la $(PYTHON_LIBS)
pylibmount_la_CFLAGS = \
$(AM_CFLAGS) \
- $(PYTHON_INCLUDES) \
$(PYTHON_CFLAGS) \
-I$(ul_libmount_incdir) \
-fno-strict-aliasing #-ggdb3 -O0