]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: support --with-python[={2,3}]
authorKarel Zak <kzak@redhat.com>
Fri, 20 Sep 2013 10:42:45 +0000 (12:42 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 20 Sep 2013 10:42:45 +0000 (12:42 +0200)
 * 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 <kzak@redhat.com>
configure.ac
libmount/python/Makemodule.am

index d24ed8f7f80dbd2210c29979ac24b9cc9b3c5fb2..85faa2e0730558b64dee28bd49e32483c4b0e94d 100644 (file)
@@ -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:
 
index 550ea774bb2765fab188be60068bf77d4dc50cd7..657cdcb2cb72b2ad110bf8913f9af49b8b28dc0d 100644 (file)
@@ -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