configure: Support pkg-config for zlib

Message ID 20180712192603.11599-1-sw@weilnetz.de
State New
Headers show
Series
  • configure: Support pkg-config for zlib
Related show

Commit Message

Stefan Weil July 12, 2018, 7:26 p.m.
This is needed for builds with the mingw64-* packages from Cygwin,
but also works for Linux.

Move the zlib test also more to the end because users should
get information on the really important missing packages
(which also require zlib) first.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 configure | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

Comments

Stefan Hajnoczi July 18, 2018, 4:04 p.m. | #1
On Thu, Jul 12, 2018 at 09:26:03PM +0200, Stefan Weil wrote:
> This is needed for builds with the mingw64-* packages from Cygwin,
> but also works for Linux.
> 
> Move the zlib test also more to the end because users should
> get information on the really important missing packages
> (which also require zlib) first.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  configure | 40 +++++++++++++++++++++++-----------------
>  1 file changed, 23 insertions(+), 17 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Daniel P. Berrangé July 18, 2018, 4:21 p.m. | #2
On Thu, Jul 12, 2018 at 09:26:03PM +0200, Stefan Weil wrote:
> This is needed for builds with the mingw64-* packages from Cygwin,
> but also works for Linux.
> 
> Move the zlib test also more to the end because users should
> get information on the really important missing packages
> (which also require zlib) first.

According to the zlib Changelog file pkgconfig support was added
in 2006 !

[quote]
Changes in 1.2.3.1 (16 August 2006)

  - Add pkgconfig support [Weigelt]
[/quote]

Given our target build platforms support guidelines

  https://qemu.weilnetz.de/doc/qemu-doc.html#Supported-build-platforms

we can safely say that all supported platforms will have a zlib
that contains pkgconfig support, so......

> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  configure | 40 +++++++++++++++++++++++-----------------
>  1 file changed, 23 insertions(+), 17 deletions(-)
> 
> diff --git a/configure b/configure
> index 2a7796ea80..dcaab01729 100755
> --- a/configure
> +++ b/configure
> @@ -2140,23 +2140,6 @@ EOF
>    fi
>  fi
>  
> -#########################################
> -# zlib check
> -
> -if test "$zlib" != "no" ; then
> -    cat > $TMPC << EOF
> -#include <zlib.h>
> -int main(void) { zlibVersion(); return 0; }
> -EOF
> -    if compile_prog "" "-lz" ; then
> -        :
> -    else
> -        error_exit "zlib check failed" \
> -            "Make sure to have the zlib libs and headers installed."
> -    fi
> -fi
> -LIBS="$LIBS -lz"
> -
>  ##########################################
>  # lzo check
>  
> @@ -3525,6 +3508,29 @@ if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
>      fi
>  fi
>  
> +#########################################
> +# zlib check
> +
> +if test "$zlib" != "no" ; then
> +    if $pkg_config --exists zlib; then
> +        zlib_cflags=$($pkg_config --cflags zlib)
> +        zlib_libs=$($pkg_config --libs zlib)
> +        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
> +        LIBS="$zlib_libs $LIBS"
> +    else
> +        cat > $TMPC << EOF
> +#include <zlib.h>
> +int main(void) { zlibVersion(); return 0; }
> +EOF
> +        if compile_prog "" "-lz" ; then
> +            LIBS="$LIBS -lz"
> +        else
> +            error_exit "zlib check failed" \
> +                "Make sure to have the zlib libs and headers installed."
> +        fi
> +    fi

.... this fallback support for non-pkgconfig scenarios can be entirely
deleted, just leaving the error_exit message. 


Regards,
Daniel
Stefan Weil July 18, 2018, 4:59 p.m. | #3
Am 18.07.2018 um 18:21 schrieb Daniel P. Berrangé:
> On Thu, Jul 12, 2018 at 09:26:03PM +0200, Stefan Weil wrote:
>> This is needed for builds with the mingw64-* packages from Cygwin,
>> but also works for Linux.
>>
>> Move the zlib test also more to the end because users should
>> get information on the really important missing packages
>> (which also require zlib) first.
> 
> According to the zlib Changelog file pkgconfig support was added
> in 2006 !
> 
> [quote]
> Changes in 1.2.3.1 (16 August 2006)
> 
>   - Add pkgconfig support [Weigelt]
> [/quote]
> 
> Given our target build platforms support guidelines
> 
>   https://qemu.weilnetz.de/doc/qemu-doc.html#Supported-build-platforms
> 
> we can safely say that all supported platforms will have a zlib
> that contains pkgconfig support, so......
> 
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>  configure | 40 +++++++++++++++++++++++-----------------
>>  1 file changed, 23 insertions(+), 17 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 2a7796ea80..dcaab01729 100755
>> --- a/configure
>> +++ b/configure
>> @@ -2140,23 +2140,6 @@ EOF
>>    fi
>>  fi
>>  
>> -#########################################
>> -# zlib check
>> -
>> -if test "$zlib" != "no" ; then
>> -    cat > $TMPC << EOF
>> -#include <zlib.h>
>> -int main(void) { zlibVersion(); return 0; }
>> -EOF
>> -    if compile_prog "" "-lz" ; then
>> -        :
>> -    else
>> -        error_exit "zlib check failed" \
>> -            "Make sure to have the zlib libs and headers installed."
>> -    fi
>> -fi
>> -LIBS="$LIBS -lz"
>> -
>>  ##########################################
>>  # lzo check
>>  
>> @@ -3525,6 +3508,29 @@ if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
>>      fi
>>  fi
>>  
>> +#########################################
>> +# zlib check
>> +
>> +if test "$zlib" != "no" ; then
>> +    if $pkg_config --exists zlib; then
>> +        zlib_cflags=$($pkg_config --cflags zlib)
>> +        zlib_libs=$($pkg_config --libs zlib)
>> +        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
>> +        LIBS="$zlib_libs $LIBS"
>> +    else
>> +        cat > $TMPC << EOF
>> +#include <zlib.h>
>> +int main(void) { zlibVersion(); return 0; }
>> +EOF
>> +        if compile_prog "" "-lz" ; then
>> +            LIBS="$LIBS -lz"
>> +        else
>> +            error_exit "zlib check failed" \
>> +                "Make sure to have the zlib libs and headers installed."
>> +        fi
>> +    fi
> 
> .... this fallback support for non-pkgconfig scenarios can be entirely
> deleted, just leaving the error_exit message. 
> 
> 
> Regards,
> Daniel

I have no objection. Thank you for the investigation of the zlib
history. Removing old unneeded code is always good, but maybe that's
something which could be done after release 3.0.

Or would you suggest to do it now? Then I can either send an updated
patch (v2), or whoever pulls that patch can make that trivial modification.

Cheers
Stefan
Daniel P. Berrangé July 18, 2018, 5:04 p.m. | #4
On Wed, Jul 18, 2018 at 06:59:25PM +0200, Stefan Weil wrote:
> Am 18.07.2018 um 18:21 schrieb Daniel P. Berrangé:
> > On Thu, Jul 12, 2018 at 09:26:03PM +0200, Stefan Weil wrote:
> >> This is needed for builds with the mingw64-* packages from Cygwin,
> >> but also works for Linux.
> >>
> >> Move the zlib test also more to the end because users should
> >> get information on the really important missing packages
> >> (which also require zlib) first.
> > 
> > According to the zlib Changelog file pkgconfig support was added
> > in 2006 !
> > 
> > [quote]
> > Changes in 1.2.3.1 (16 August 2006)
> > 
> >   - Add pkgconfig support [Weigelt]
> > [/quote]
> > 
> > Given our target build platforms support guidelines
> > 
> >   https://qemu.weilnetz.de/doc/qemu-doc.html#Supported-build-platforms
> > 
> > we can safely say that all supported platforms will have a zlib
> > that contains pkgconfig support, so......
> > 
> >>
> >> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> >> ---
> >>  configure | 40 +++++++++++++++++++++++-----------------
> >>  1 file changed, 23 insertions(+), 17 deletions(-)
> >>
> >> diff --git a/configure b/configure
> >> index 2a7796ea80..dcaab01729 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -2140,23 +2140,6 @@ EOF
> >>    fi
> >>  fi
> >>  
> >> -#########################################
> >> -# zlib check
> >> -
> >> -if test "$zlib" != "no" ; then
> >> -    cat > $TMPC << EOF
> >> -#include <zlib.h>
> >> -int main(void) { zlibVersion(); return 0; }
> >> -EOF
> >> -    if compile_prog "" "-lz" ; then
> >> -        :
> >> -    else
> >> -        error_exit "zlib check failed" \
> >> -            "Make sure to have the zlib libs and headers installed."
> >> -    fi
> >> -fi
> >> -LIBS="$LIBS -lz"
> >> -
> >>  ##########################################
> >>  # lzo check
> >>  
> >> @@ -3525,6 +3508,29 @@ if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
> >>      fi
> >>  fi
> >>  
> >> +#########################################
> >> +# zlib check
> >> +
> >> +if test "$zlib" != "no" ; then
> >> +    if $pkg_config --exists zlib; then
> >> +        zlib_cflags=$($pkg_config --cflags zlib)
> >> +        zlib_libs=$($pkg_config --libs zlib)
> >> +        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
> >> +        LIBS="$zlib_libs $LIBS"
> >> +    else
> >> +        cat > $TMPC << EOF
> >> +#include <zlib.h>
> >> +int main(void) { zlibVersion(); return 0; }
> >> +EOF
> >> +        if compile_prog "" "-lz" ; then
> >> +            LIBS="$LIBS -lz"
> >> +        else
> >> +            error_exit "zlib check failed" \
> >> +                "Make sure to have the zlib libs and headers installed."
> >> +        fi
> >> +    fi
> > 
> > .... this fallback support for non-pkgconfig scenarios can be entirely
> > deleted, just leaving the error_exit message. 
> 
> I have no objection. Thank you for the investigation of the zlib
> history. Removing old unneeded code is always good, but maybe that's
> something which could be done after release 3.0.
> 
> Or would you suggest to do it now? Then I can either send an updated
> patch (v2), or whoever pulls that patch can make that trivial modification.

If we're ok with adding support for pkg-config in 3.0, I think it is
reasonable to drop the fallback check at the same time.  I think it
this stills qualify as a bug fix patch in terms of our freeze rules,
since we're specificially aiming to fix build problems on one of our
supported platforms.

So personally I'd suggest sending a v2 with the fallback dropped.
for 3.0

Regards,
Daniel
Peter Maydell July 18, 2018, 7:07 p.m. | #5
On 18 July 2018 at 18:04, Daniel P. Berrangé <berrange@redhat.com> wrote:
> On Wed, Jul 18, 2018 at 06:59:25PM +0200, Stefan Weil wrote:
>> Am 18.07.2018 um 18:21 schrieb Daniel P. Berrangé:
>> > .... this fallback support for non-pkgconfig scenarios can be entirely
>> > deleted, just leaving the error_exit message.
>>
>> I have no objection. Thank you for the investigation of the zlib
>> history. Removing old unneeded code is always good, but maybe that's
>> something which could be done after release 3.0.
>>
>> Or would you suggest to do it now? Then I can either send an updated
>> patch (v2), or whoever pulls that patch can make that trivial modification.
>
> If we're ok with adding support for pkg-config in 3.0, I think it is
> reasonable to drop the fallback check at the same time.  I think it
> this stills qualify as a bug fix patch in terms of our freeze rules,
> since we're specificially aiming to fix build problems on one of our
> supported platforms.
>
> So personally I'd suggest sending a v2 with the fallback dropped.
> for 3.0

I would favour doing that part in 3.1. This feels like the
kind of change that we're all pretty certain is safe that
then turns out not to be for some case or other, and it's
easier not to have to fix it up later.

thanks
-- PMM

Patch

diff --git a/configure b/configure
index 2a7796ea80..dcaab01729 100755
--- a/configure
+++ b/configure
@@ -2140,23 +2140,6 @@  EOF
   fi
 fi
 
-#########################################
-# zlib check
-
-if test "$zlib" != "no" ; then
-    cat > $TMPC << EOF
-#include <zlib.h>
-int main(void) { zlibVersion(); return 0; }
-EOF
-    if compile_prog "" "-lz" ; then
-        :
-    else
-        error_exit "zlib check failed" \
-            "Make sure to have the zlib libs and headers installed."
-    fi
-fi
-LIBS="$LIBS -lz"
-
 ##########################################
 # lzo check
 
@@ -3525,6 +3508,29 @@  if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
     fi
 fi
 
+#########################################
+# zlib check
+
+if test "$zlib" != "no" ; then
+    if $pkg_config --exists zlib; then
+        zlib_cflags=$($pkg_config --cflags zlib)
+        zlib_libs=$($pkg_config --libs zlib)
+        QEMU_CFLAGS="$zlib_cflags $QEMU_CFLAGS"
+        LIBS="$zlib_libs $LIBS"
+    else
+        cat > $TMPC << EOF
+#include <zlib.h>
+int main(void) { zlibVersion(); return 0; }
+EOF
+        if compile_prog "" "-lz" ; then
+            LIBS="$LIBS -lz"
+        else
+            error_exit "zlib check failed" \
+                "Make sure to have the zlib libs and headers installed."
+        fi
+    fi
+fi
+
 ##########################################
 # SHA command probe for modules
 if test "$modules" = yes; then