# byte-order mark (BOM) when writing UTF-16 or UTF-32 and always writes in
# big-endian format.
#
-# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound.
+# Define NO_DEFLATE_BOUND if your zlib does not have deflateBound. Define
+# ZLIB_NG if you want to use zlib-ng instead of zlib.
#
# Define NO_NORETURN if using buggy versions of gcc 4.6+ and profile feedback,
# as the compiler can crash (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49299)
endif
IMAP_SEND_LDFLAGS += $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
-ifdef ZLIB_PATH
- BASIC_CFLAGS += -I$(ZLIB_PATH)/include
- EXTLIBS += $(call libpath_template,$(ZLIB_PATH)/$(lib))
+ifdef ZLIB_NG
+ BASIC_CFLAGS += -DHAVE_ZLIB_NG
+ ifdef ZLIB_NG_PATH
+ BASIC_CFLAGS += -I$(ZLIB_NG_PATH)/include
+ EXTLIBS += $(call libpath_template,$(ZLIB_NG_PATH)/$(lib))
+ endif
+ EXTLIBS += -lz-ng
+else
+ ifdef ZLIB_PATH
+ BASIC_CFLAGS += -I$(ZLIB_PATH)/include
+ EXTLIBS += $(call libpath_template,$(ZLIB_PATH)/$(lib))
+ endif
+ EXTLIBS += -lz
endif
-EXTLIBS += -lz
ifndef NO_OPENSSL
OPENSSL_LIBSSL = -lssl
#ifndef COMPAT_ZLIB_H
#define COMPAT_ZLIB_H
-#include <zlib.h>
+#ifdef HAVE_ZLIB_NG
+# include <zlib-ng.h>
-#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
-# define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
-#endif
+# define z_stream zng_stream
+#define gz_header_s zng_gz_header_s
+
+# define crc32(crc, buf, len) zng_crc32(crc, buf, len)
+
+# define inflate(strm, bits) zng_inflate(strm, bits)
+# define inflateEnd(strm) zng_inflateEnd(strm)
+# define inflateInit(strm) zng_inflateInit(strm)
+# define inflateInit2(strm, bits) zng_inflateInit2(strm, bits)
+# define inflateReset(strm) zng_inflateReset(strm)
+
+# define deflate(strm, flush) zng_deflate(strm, flush)
+# define deflateBound(strm, source_len) zng_deflateBound(strm, source_len)
+# define deflateEnd(strm) zng_deflateEnd(strm)
+# define deflateInit(strm, level) zng_deflateInit(strm, level)
+# define deflateInit2(stream, level, method, window_bits, mem_level, strategy) zng_deflateInit2(stream, level, method, window_bits, mem_level, strategy)
+# define deflateReset(strm) zng_deflateReset(strm)
+# define deflateSetHeader(strm, head) zng_deflateSetHeader(strm, head)
+
+#else
+# include <zlib.h>
+
+# if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
+# define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
+# endif
/*
* zlib only gained support for setting up the gzip header in v1.2.2.1. In
* operating systems, so it's fine to simply make this a no-op when using a
* zlib version that doesn't support this yet.
*/
-#if ZLIB_VERNUM < 0x1221
+# if ZLIB_VERNUM < 0x1221
struct gz_header_s {
int os;
};
(void)(head);
return Z_OK;
}
-#endif
+# endif
+#endif /* HAVE_ZLIB_NG */
#endif /* COMPAT_ZLIB_H */
build_options_config.set('NO_PERL_CPAN_FALLBACKS', '')
endif
-zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])
-if zlib.version().version_compare('<1.2.0')
- libgit_c_args += '-DNO_DEFLATE_BOUND'
+zlib_backend = get_option('zlib_backend')
+if zlib_backend in ['auto', 'zlib-ng']
+ zlib_ng = dependency('zlib-ng', required: zlib_backend == 'zlib-ng')
+ if zlib_ng.found()
+ zlib_backend = 'zlib-ng'
+ libgit_c_args += '-DHAVE_ZLIB_NG'
+ libgit_dependencies += zlib_ng
+ endif
+endif
+if zlib_backend in ['auto', 'zlib']
+ zlib = dependency('zlib', default_options: ['default_library=static', 'tests=disabled'])
+ if zlib.version().version_compare('<1.2.0')
+ libgit_c_args += '-DNO_DEFLATE_BOUND'
+ endif
+ zlib_backend = 'zlib'
+ libgit_dependencies += zlib
endif
-libgit_dependencies += zlib
threads = dependency('threads', required: false)
if threads.found()
'sha1': sha1_backend,
'sha1_unsafe': sha1_unsafe_backend,
'sha256': sha256_backend,
+ 'zlib': zlib_backend,
}, section: 'Backends')
description: 'The backend used for hashing data with the SHA1 object format in case no cryptographic security is needed.')
option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt', 'block'], value: 'block',
description: 'The backend used for hashing objects with the SHA256 object format.')
+option('zlib_backend', type: 'combo', choices: ['auto', 'zlib', 'zlib-ng'], value: 'auto',
+ description: 'The backend used for compressing objects and other data.')
# Build tweaks.
option('macos_use_homebrew_gettext', type: 'boolean', value: true,