retitle 756476 AM_PATH_GTK_3_0 fails if gthread is in 4th argument
forwarded 756476 https://bugzilla.gnome.org/show_bug.cgi?id=641638
tags 756476 + patch upstream
thanks

On Wed, 06 Aug 2014 at 01:49:05 +0300, Yavor Doganov wrote:
> The problem is due to changed behavior of pkg-config, most probably
> occurred in version 0.28.  "pkg-config --atleast-version N libA libB"
> now checks if both libraries are >= N (which will always return false
> for gtk+-3.0 if the last macro argument is used because the
> gthread-2.0 version is 2.40.x).

Retitling bug, thanks for this analysis.

I don't think this should be considered RC: AM_PATH_GTK_3_0 is rarely-used
and there are much better ways to achieve the same thing (pkg-config).
Gtk maintainers' opinions?

gtk-3.0.m4 should be considered deprecated: it's far too complicated
for the value it provides. All packages that use AM_PATH_GTK_3_0 should simply
replace it with an equivalent PKG_CHECK_MODULES call, something like:

    AM_PATH_GTK_3_0([3.4]) -> PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.4])

    AM_PATH_GTK_3_0([3.4], [], [], [gthread]) ->
        PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.4, gthread-2.0])

(PKG_CHECK_MODULES can also take ACTION-IF-FOUND and ACTION-IF-NOT-FOUND
arguments if you really need them.)

> Trivial patch attached.  I can't reproduce this with pkg-config/0.26-1
> on wheezy which makes me think that this is new behavior as of 0.28.
> I am not sure it was intended though, seems unnatural/incorrect to me.

"pkg-config --atleast-version V pkg1 pkg2" is documented to be equivalent
to pkg1 >= V, pkg2 >= V. It looks as though the documented behaviour was
not actually implemented until recently.

I think all uses of pkg-config --atleast-version should be replaced by
explicit ">=" version specifiers. I attach a patch which does that;
I think that's better than deleting the gthread check entirely, but
not as good as adapting packages that use AM_PATH_GTK_3_0 to stop
doing so.

For packages that do not already use autoreconf at build time, a sourceful
upload will be needed to pick up the new gtk-3.0.m4, and if you're
doing a sourceful upload anyway, please just fix your configure.ac to not
do this. It'll make your build quicker, too.

Regards,
    S
>From d2fb42cbaec9328f65d0413d13bde9f6cb065df2 Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvit...@collabora.co.uk>
Date: Wed, 6 Aug 2014 11:02:38 +0100
Subject: [PATCH 1/3] Avoid "pkg-config --atleast-version"

AM_PATH_GTK_3_0([3.4], [], [], [gthread]) results in calling
"pkg-config --atleast-version 3.4 gtk+-3.0 gthread-2.0".

With pkg-config 0.28, that test fails, because the version of
gthread-2.0 is smaller than 3.4. This appears to be a behaviour
change since 0.26, but matches what the documentation said in 0.26.
---
 m4macros/gtk-3.0.m4 | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/m4macros/gtk-3.0.m4 b/m4macros/gtk-3.0.m4
index 5238b43..0d605fb 100644
--- a/m4macros/gtk-3.0.m4
+++ b/m4macros/gtk-3.0.m4
@@ -11,8 +11,9 @@ dnl Get the cflags and libraries from pkg-config
 dnl
 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run a test GTK+ program],
 		    , enable_gtktest=yes)
+  min_gtk_version=ifelse([$1], [], [3.0.0], [$1])
 
-  pkg_config_args=gtk+-3.0
+  pkg_config_args="gtk+-3.0 >= $min_gtk_version"
   for module in . $4
   do
       case "$module" in
@@ -38,7 +39,6 @@ AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run
     no_gtk=yes
   fi
 
-  min_gtk_version=ifelse([$1], ,3.0.0,$1)
   AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
 
   if test x$PKG_CONFIG != xno ; then
@@ -48,7 +48,7 @@ AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run
 	  enable_gtktest=no
     fi
 
-    if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
+    if $PKG_CONFIG $pkg_config_args; then
 	  :
     else
 	  no_gtk=yes
@@ -202,10 +202,11 @@ AC_DEFUN([GTK_CHECK_BACKEND],
 [
   pkg_config_args=ifelse([$1],,gtk+-3.0, gtk+-$1-3.0)
   min_gtk_version=ifelse([$2],,3.0.0,$2)
+  pkg_config_args="$pkg_config_args >= $min_gtk_version"
 
   AC_PATH_PROG(PKG_CONFIG, [pkg-config], [AC_MSG_ERROR([No pkg-config found])])
 
-  if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args ; then
+  if $PKG_CONFIG $pkg_config_args ; then
     target_found=yes
   else
     target_found=no
-- 
2.1.0.rc1

>From b3f49ec9fa9ec67142d614e9b4a7959d80eba07f Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvit...@collabora.co.uk>
Date: Wed, 6 Aug 2014 11:23:23 +0100
Subject: [PATCH 2/3] Deprecate AM_PATH_GTK_3_0 in favour of PKG_CHECK_MODULES

That's what GNOME applications use.
---
 m4macros/gtk-3.0.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/m4macros/gtk-3.0.m4 b/m4macros/gtk-3.0.m4
index 0d605fb..274cd32 100644
--- a/m4macros/gtk-3.0.m4
+++ b/m4macros/gtk-3.0.m4
@@ -6,7 +6,7 @@ dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified i
 dnl pass to pkg-config
 dnl
 AC_DEFUN([AM_PATH_GTK_3_0],
-[dnl 
+[m4_warn([obsolete], [AM_PATH_GTK_3_0 is deprecated, use PKG_CHECK_MODULES([GTK], [gtk+-3.0]) instead])
 dnl Get the cflags and libraries from pkg-config
 dnl
 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run a test GTK+ program],
-- 
2.1.0.rc1

Reply via email to