diff mbox

ui/gtk: require at least GTK 2.18 and VTE 0.26

Message ID 1361544102-9359-1-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori Feb. 22, 2013, 2:41 p.m. UTC
This gives us the bare amount of features we need.  We can add work arounds
for older versions and lower the requirement but this should be a good
starting point.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 configure | 45 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)

Comments

Daniel P. Berrangé Feb. 22, 2013, 2:48 p.m. UTC | #1
On Fri, Feb 22, 2013 at 08:41:42AM -0600, Anthony Liguori wrote:
> This gives us the bare amount of features we need.  We can add work arounds
> for older versions and lower the requirement but this should be a good
> starting point.
> 
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  configure | 45 +++++++++++++++++++++++++++++++++++++++------
>  1 file changed, 39 insertions(+), 6 deletions(-)
> 
> diff --git a/configure b/configure
> index 0dadd31..259fa7d 100755
> --- a/configure
> +++ b/configure
> @@ -1640,18 +1640,51 @@ if test "$sparse" != "no" ; then
>    fi
>  fi
>  
> +gtk_check_version()
> +{
> +    version="$1"
> +    major="$2"
> +    minor="$3"
> +    release="$4"
> +
> +    a=`echo $version | cut -f1 -d.`
> +    b=`echo $version | cut -f2 -d.`
> +    c=`echo $version | cut -f3 -d.`
> +
> +    if test $a != $major; then
> +	return 1
> +    elif test $b -lt $minor; then
> +	return 1
> +    elif test $b = $minor -a $c -lt $release; then
> +	return 1
> +    fi
> +
> +    return 0
> +}
> +
>  ##########################################
>  # GTK probe
>  
>  if test "$gtk" != "no"; then
>      if $pkg_config gtk+-2.0 --modversion >/dev/null 2>/dev/null && \
>         $pkg_config vte --modversion >/dev/null 2>/dev/null; then
> -	gtk_cflags=`$pkg_config --cflags gtk+-2.0 2>/dev/null`
> -	gtk_libs=`$pkg_config --libs gtk+-2.0 2>/dev/null`
> -	vte_cflags=`$pkg_config --cflags vte 2>/dev/null`
> -	vte_libs=`$pkg_config --libs vte 2>/dev/null`
> -	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
> -	gtk="yes"
> +	gtk_version=`$pkg_config --modversion gtk+-2.0`
> +	vte_version=`$pkg_config --modversion vte`
> +
> +	if gtk_check_version $gtk_version 2 18 0 &&
> +	    gtk_check_version $vte_version 0 26 0; then


Isn't most of this version checking code just re-inventing what
pkg-config can do for you already

  # pkg-config --exists 'gtk+-2.0 > 2.20.0'
  # echo $?
  0
  # pkg-config --exists 'gtk+-2.0 > 2.50.0'
  # echo $?
  1

Regards,
Daniel
Anthony Liguori Feb. 22, 2013, 3:49 p.m. UTC | #2
"Daniel P. Berrange" <berrange@redhat.com> writes:

> On Fri, Feb 22, 2013 at 08:41:42AM -0600, Anthony Liguori wrote:
>> This gives us the bare amount of features we need.  We can add work arounds
>> for older versions and lower the requirement but this should be a good
>> starting point.
>> 
>> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>> ---
>>  configure | 45 +++++++++++++++++++++++++++++++++++++++------
>>  1 file changed, 39 insertions(+), 6 deletions(-)
>> 
>> diff --git a/configure b/configure
>> index 0dadd31..259fa7d 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1640,18 +1640,51 @@ if test "$sparse" != "no" ; then
>>    fi
>>  fi
>>  
>> +gtk_check_version()
>> +{
>> +    version="$1"
>> +    major="$2"
>> +    minor="$3"
>> +    release="$4"
>> +
>> +    a=`echo $version | cut -f1 -d.`
>> +    b=`echo $version | cut -f2 -d.`
>> +    c=`echo $version | cut -f3 -d.`
>> +
>> +    if test $a != $major; then
>> +	return 1
>> +    elif test $b -lt $minor; then
>> +	return 1
>> +    elif test $b = $minor -a $c -lt $release; then
>> +	return 1
>> +    fi
>> +
>> +    return 0
>> +}
>> +
>>  ##########################################
>>  # GTK probe
>>  
>>  if test "$gtk" != "no"; then
>>      if $pkg_config gtk+-2.0 --modversion >/dev/null 2>/dev/null && \
>>         $pkg_config vte --modversion >/dev/null 2>/dev/null; then
>> -	gtk_cflags=`$pkg_config --cflags gtk+-2.0 2>/dev/null`
>> -	gtk_libs=`$pkg_config --libs gtk+-2.0 2>/dev/null`
>> -	vte_cflags=`$pkg_config --cflags vte 2>/dev/null`
>> -	vte_libs=`$pkg_config --libs vte 2>/dev/null`
>> -	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
>> -	gtk="yes"
>> +	gtk_version=`$pkg_config --modversion gtk+-2.0`
>> +	vte_version=`$pkg_config --modversion vte`
>> +
>> +	if gtk_check_version $gtk_version 2 18 0 &&
>> +	    gtk_check_version $vte_version 0 26 0; then
>
>
> Isn't most of this version checking code just re-inventing what
> pkg-config can do for you already
>
>   # pkg-config --exists 'gtk+-2.0 > 2.20.0'
>   # echo $?
>   0
>   # pkg-config --exists 'gtk+-2.0 > 2.50.0'
>   # echo $?
>   1

I didn't know that existed.  Thanks!

Regards,

Anthony Liguori

>
> Regards,
> Daniel
> -- 
> |: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org              -o-             http://virt-manager.org :|
> |: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
> |: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
Stefan Weil Feb. 22, 2013, 3:58 p.m. UTC | #3
Am 22.02.2013 15:48, schrieb Daniel P. Berrange:
> On Fri, Feb 22, 2013 at 08:41:42AM -0600, Anthony Liguori wrote:
>> This gives us the bare amount of features we need.  We can add work arounds
>> for older versions and lower the requirement but this should be a good
>> starting point.
>>
>> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>> ---
>>  configure | 45 +++++++++++++++++++++++++++++++++++++++------
>>  1 file changed, 39 insertions(+), 6 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 0dadd31..259fa7d 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1640,18 +1640,51 @@ if test "$sparse" != "no" ; then
>>    fi
>>  fi
>>  
>> +gtk_check_version()
>> +{
>> +    version="$1"
>> +    major="$2"
>> +    minor="$3"
>> +    release="$4"
>> +
>> +    a=`echo $version | cut -f1 -d.`
>> +    b=`echo $version | cut -f2 -d.`
>> +    c=`echo $version | cut -f3 -d.`
>> +
>> +    if test $a != $major; then
>> +	return 1
>> +    elif test $b -lt $minor; then
>> +	return 1
>> +    elif test $b = $minor -a $c -lt $release; then
>> +	return 1
>> +    fi
>> +
>> +    return 0
>> +}
>> +
>>  ##########################################
>>  # GTK probe
>>  
>>  if test "$gtk" != "no"; then
>>      if $pkg_config gtk+-2.0 --modversion >/dev/null 2>/dev/null && \
>>         $pkg_config vte --modversion >/dev/null 2>/dev/null; then
>> -	gtk_cflags=`$pkg_config --cflags gtk+-2.0 2>/dev/null`
>> -	gtk_libs=`$pkg_config --libs gtk+-2.0 2>/dev/null`
>> -	vte_cflags=`$pkg_config --cflags vte 2>/dev/null`
>> -	vte_libs=`$pkg_config --libs vte 2>/dev/null`
>> -	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
>> -	gtk="yes"
>> +	gtk_version=`$pkg_config --modversion gtk+-2.0`
>> +	vte_version=`$pkg_config --modversion vte`
>> +
>> +	if gtk_check_version $gtk_version 2 18 0 &&
>> +	    gtk_check_version $vte_version 0 26 0; then
>
> Isn't most of this version checking code just re-inventing what
> pkg-config can do for you already
>
>   # pkg-config --exists 'gtk+-2.0 > 2.20.0'
>   # echo $?
>   0
>   # pkg-config --exists 'gtk+-2.0 > 2.50.0'
>   # echo $?
>   1
>
> Regards,
> Daniel

Daniel is right, --exists greatly simplifies the code here
(and in most existing checks in configure).

Instead of using --exists, you can also use --atleast-version to
test for existence and for the moduleversion in a single statement:

if $pkg_config --atleast-version=2.18.0gtk+-2.0; then ...

There is also no need to redirect stdout or stderr if pkg-config
is used like that.

Regards,
StefanWeil
diff mbox

Patch

diff --git a/configure b/configure
index 0dadd31..259fa7d 100755
--- a/configure
+++ b/configure
@@ -1640,18 +1640,51 @@  if test "$sparse" != "no" ; then
   fi
 fi
 
+gtk_check_version()
+{
+    version="$1"
+    major="$2"
+    minor="$3"
+    release="$4"
+
+    a=`echo $version | cut -f1 -d.`
+    b=`echo $version | cut -f2 -d.`
+    c=`echo $version | cut -f3 -d.`
+
+    if test $a != $major; then
+	return 1
+    elif test $b -lt $minor; then
+	return 1
+    elif test $b = $minor -a $c -lt $release; then
+	return 1
+    fi
+
+    return 0
+}
+
 ##########################################
 # GTK probe
 
 if test "$gtk" != "no"; then
     if $pkg_config gtk+-2.0 --modversion >/dev/null 2>/dev/null && \
        $pkg_config vte --modversion >/dev/null 2>/dev/null; then
-	gtk_cflags=`$pkg_config --cflags gtk+-2.0 2>/dev/null`
-	gtk_libs=`$pkg_config --libs gtk+-2.0 2>/dev/null`
-	vte_cflags=`$pkg_config --cflags vte 2>/dev/null`
-	vte_libs=`$pkg_config --libs vte 2>/dev/null`
-	libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
-	gtk="yes"
+	gtk_version=`$pkg_config --modversion gtk+-2.0`
+	vte_version=`$pkg_config --modversion vte`
+
+	if gtk_check_version $gtk_version 2 18 0 &&
+	    gtk_check_version $vte_version 0 26 0; then
+	    gtk_cflags=`$pkg_config --cflags gtk+-2.0 2>/dev/null`
+	    gtk_libs=`$pkg_config --libs gtk+-2.0 2>/dev/null`
+	    vte_cflags=`$pkg_config --cflags vte 2>/dev/null`
+	    vte_libs=`$pkg_config --libs vte 2>/dev/null`
+	    libs_softmmu="$gtk_libs $vte_libs $libs_softmmu"
+	    gtk="yes"
+	else
+	    if test "$gtk" = "yes" ; then
+		feature_not_found "gtk"
+	    fi
+	    gtk="no"
+	fi
     else
 	if test "$gtk" = "yes" ; then
 	    feature_not_found "gtk"