This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=ccf91bef46858f62be45e3417785e047e7ce85b1

commit ccf91bef46858f62be45e3417785e047e7ce85b1
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Thu Jan 20 04:31:01 2022 +0100

    build: Fix zlib implementation selection
    
    We need to select only one of the possibly available zlib
    implementations. Turn the code to use a pre-processor "enum", by
    defining the various values as different macros, that we will select
    from a variable macro.
    
    Changelog: silent
    Fixes: commit 863af2464d7bf20ad458ee51e2d187a9845214ca
---
 lib/compat/compat-zlib.h |  8 +++-----
 lib/dpkg/compress.c      |  6 +++---
 m4/dpkg-libs.m4          | 12 ++++++++++++
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/lib/compat/compat-zlib.h b/lib/compat/compat-zlib.h
index 654b36692..aa15e4af8 100644
--- a/lib/compat/compat-zlib.h
+++ b/lib/compat/compat-zlib.h
@@ -21,15 +21,13 @@
 #ifndef COMPAT_ZLIB_H
 #define COMPAT_ZLIB_H
 
-#ifdef WITH_LIBZ_NG
+#if USE_LIBZ_IMPL == USE_LIBZ_IMPL_ZLIB_NG
 #include <zlib-ng.h>
-#else
-#ifdef WITH_LIBZ
+#elif USE_LIBZ_IMPL == USE_LIBZ_IMPL_ZLIB
 #include <zlib.h>
 #endif
-#endif
 
-#ifdef WITH_LIBZ_NG
+#if USE_LIBZ_IMPL == USE_LIBZ_IMPL_ZLIB_NG
 /* Compatibility symbols for zlib-ng. */
 #define gzdopen                zng_gzdopen
 #define gzopen         zng_gzopen
diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c
index 325593041..93e8e012b 100644
--- a/lib/dpkg/compress.c
+++ b/lib/dpkg/compress.c
@@ -33,7 +33,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
-#if defined(WITH_LIBZ) || defined(WITH_LIBZ_NG)
+#if USE_LIBZ_IMPL != USE_LIBZ_IMPL_NONE
 #include <compat-zlib.h>
 #endif
 #ifdef WITH_LIBLZMA
@@ -51,7 +51,7 @@
 #include <dpkg/buffer.h>
 #include <dpkg/command.h>
 #include <dpkg/compress.h>
-#if !(defined(WITH_LIBZ_NG) || defined(WITH_LIBZ)) || \
+#if USE_LIBZ_IMPL == USE_LIBZ_IMPL_NONE || \
     !defined(WITH_LIBLZMA) || \
     !defined(WITH_LIBBZ2)
 #include <dpkg/subproc.h>
@@ -154,7 +154,7 @@ fixup_gzip_params(struct compress_params *params)
                params->type = COMPRESSOR_TYPE_NONE;
 }
 
-#if defined(WITH_LIBZ_NG) || defined(WITH_LIBZ)
+#if USE_LIBZ_IMPL != USE_LIBZ_IMPL_NONE
 static void
 decompress_gzip(struct compress_params *params, int fd_in, int fd_out,
                 const char *desc)
diff --git a/m4/dpkg-libs.m4 b/m4/dpkg-libs.m4
index 08abb0f3a..7f227c381 100644
--- a/m4/dpkg-libs.m4
+++ b/m4/dpkg-libs.m4
@@ -75,17 +75,29 @@ AC_DEFUN([DPKG_LIB_Z], [
   DPKG_WITH_COMPRESS_LIB([z], [zlib.h], [gzdopen])
   DPKG_WITH_COMPRESS_LIB([z-ng], [zlib-ng.h], [zng_gzdopen])
 
+  AC_DEFINE([USE_LIBZ_IMPL_NONE], [0],
+            [Define none as 0 for the zlib implementation enum])
+  AC_DEFINE([USE_LIBZ_IMPL_ZLIB], [1],
+            [Define zlib as 1 for the zlib implementation enum])
+  AC_DEFINE([USE_LIBZ_IMPL_ZLIB_NG], [2],
+            [Define zlib-ng as 2 for the zlib implementation enum])
+
   # If we have been requested the stock zlib, override the auto-detection.
   AS_IF([test "x$with_libz" != "xyes" && test "x$have_libz_ng" = "xyes"], [
     AC_DEFINE([WITH_GZFILEOP], [yes],
       [Define to yes to use zlib-ng gzFile IO support])
     Z_LIBS=$Z_NG_LIBS
+    use_libz_impl="USE_LIBZ_IMPL_ZLIB_NG"
     have_libz_impl="yes (zlib-ng)"
   ], [test "x$have_libz" = "xyes"], [
+    use_libz_impl="USE_LIBZ_IMPL_ZLIB"
     have_libz_impl="yes (zlib)"
   ], [
+    use_libz_impl="USE_LIBZ_IMPL_NONE"
     have_libz_impl="no"
   ])
+  AC_DEFINE_UNQUOTED([USE_LIBZ_IMPL], [$use_libz_impl],
+                     [Define to the zlib implementation to use])
 ])# DPKG_LIB_Z
 
 # DPKG_LIB_LZMA

-- 
Dpkg.Org's dpkg

Reply via email to