erofs-utils: support zlib auto-detection
PATCH 1/2 erofs-utils: support zlib auto-detection
Fix explicit --with-zlib so that it errors out when zlib is unavailable.
Signed-off-by Gao Xiang <[email protected]>
--- configure.ac | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-)
configure.ac +23 -12
@@ -124,7 +124,7 @@ AC_ARG_ENABLE(lzma, AC_ARG_WITH(zlib, [AS_HELP_STRING([--without-zlib], - [Ignore presence of zlib inflate support @<:@default=enabled@:>@])]) + [Ignore presence of zlib inflate support @<:@default=auto@:>@])]) AC_ARG_WITH(libdeflate, [AS_HELP_STRING([--with-libdeflate],
@@ -426,18 +426,29 @@ if test "x$enable_lzma" = "xyes"; then fi # Configure zlib +have_zlib="no" AS_IF([test "x$with_zlib" != "xno"], [ - PKG_CHECK_MODULES([zlib], [zlib]) - # Paranoia: don't trust the result reported by pkgconfig before trying out - saved_LIBS="$LIBS" - saved_CPPFLAGS=${CPPFLAGS} - CPPFLAGS="${zlib_CFLAGS} ${CPPFLAGS}" - LIBS="${zlib_LIBS} $LIBS" - AC_CHECK_LIB(z, inflate, [ - have_zlib="yes" ], [ - AC_MSG_ERROR([zlib doesn't work properly])]) - LIBS="${saved_LIBS}" - CPPFLAGS="${saved_CPPFLAGS}"], [have_zlib="no"]) + PKG_CHECK_MODULES([zlib], [zlib], [ + # Paranoia: don't trust the result reported by pkgconfig before trying out + saved_LIBS="$LIBS" + saved_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${zlib_CFLAGS} ${CPPFLAGS}" + LIBS="${zlib_LIBS} $LIBS" + AC_CHECK_HEADERS([zlib.h],[ + AC_CHECK_LIB(z, inflate, [], [ + AC_MSG_ERROR([zlib doesn't work properly])]) + AC_CHECK_DECL(inflate, [have_zlib="yes"], + [AC_MSG_ERROR([zlib doesn't work properly])], [[ +#include <zlib.h> + ]]) + ]) + LIBS="${saved_LIBS}" + CPPFLAGS="${saved_CPPFLAGS}"], [ + AS_IF([test "x$with_zlib" = "xyes"], [ + AC_MSG_ERROR([Cannot find proper zlib]) + ]) + ]) +]) # Configure libdeflate AS_IF([test "x$with_libdeflate" != "xno"], [
Signature · 1 line
2.39.3
PATCH 2/2 erofs-utils: support liblzma auto-detection
The new XZ Utils 5.4 is now available in most Linux distributions.
Let's enable liblzma auto-detection as well as get rid of MicroLZMA EXPERIMENTAL warning.
Signed-off-by Gao Xiang <[email protected]>
--- configure.ac | 54 ++++++++++++++++++---------------------- lib/compressor_liblzma.c | 3 +-- 2 files changed, 25 insertions(+), 32 deletions(-)
configure.ac +24 -30
@@ -119,8 +119,8 @@ AC_ARG_ENABLE(lz4, [enable_lz4="$enableval"], [enable_lz4="yes"]) AC_ARG_ENABLE(lzma, - [AS_HELP_STRING([--enable-lzma], [enable LZMA compression support @<:@default=no@:>@])], - [enable_lzma="$enableval"], [enable_lzma="no"]) + [AS_HELP_STRING([--disable-lzma], [disable LZMA compression support @<:@default=auto@:>@])], + [enable_lzma="$enableval"]) AC_ARG_WITH(zlib, [AS_HELP_STRING([--without-zlib],
@@ -161,14 +161,6 @@ AC_ARG_WITH(lz4-libdir, AC_ARG_VAR([LZ4_CFLAGS], [C compiler flags for lz4]) AC_ARG_VAR([LZ4_LIBS], [linker flags for lz4]) -AC_ARG_WITH(liblzma-incdir, - [AS_HELP_STRING([--with-liblzma-incdir=DIR], [liblzma include directory])], [ - EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])]) - -AC_ARG_WITH(liblzma-libdir, - [AS_HELP_STRING([--with-liblzma-libdir=DIR], [liblzma lib directory])], [ - EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])]) - # Checks for header files. AC_CHECK_HEADERS(m4_flatten([ dirent.h
@@ -400,30 +392,32 @@ if test "x$enable_lz4" = "xyes"; then CPPFLAGS=${saved_CPPFLAGS} fi -if test "x$enable_lzma" = "xyes"; then +# Configure liblzma +have_liblzma="no" +AS_IF([test "x$enable_lzma" != "xno"], [ saved_CPPFLAGS=${CPPFLAGS} - test -z "${with_liblzma_incdir}" || - CPPFLAGS="-I$with_liblzma_incdir $CPPFLAGS" - AC_CHECK_HEADERS([lzma.h],[have_lzmah="yes"], []) - - if test "x${have_lzmah}" = "xyes" ; then + PKG_CHECK_MODULES([liblzma], [liblzma], [ + # Paranoia: don't trust the result reported by pkgconfig before trying out saved_LIBS="$LIBS" - saved_LDFLAGS="$LDFLAGS" - - test -z "${with_liblzma_libdir}" || - LDFLAGS="-L$with_liblzma_libdir ${LDFLAGS}" - AC_CHECK_LIB(lzma, lzma_microlzma_encoder, [], - [AC_MSG_ERROR([Cannot find proper liblzma])]) - - AC_CHECK_DECL(lzma_microlzma_encoder, [have_liblzma="yes"], - [AC_MSG_ERROR([Cannot find proper liblzma])], [[ + saved_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${liblzma_CFLAGS} ${CPPFLAGS}" + LIBS="${liblzma_LIBS} $LIBS" + AC_CHECK_HEADERS([lzma.h],[ + AC_CHECK_LIB(lzma, lzma_microlzma_encoder, [], + [AC_MSG_ERROR([Cannot find proper liblzma])]) + + AC_CHECK_DECL(lzma_microlzma_encoder, [have_liblzma="yes"], + [AC_MSG_ERROR([Cannot find proper liblzma])], [[ #include <lzma.h> - ]]) - LDFLAGS="${saved_LDFLAGS}" + ]]) + ]) LIBS="${saved_LIBS}" - fi - CPPFLAGS="${saved_CPPFLAGS}" -fi + CPPFLAGS="${saved_CPPFLAGS}" ], [ + AS_IF([test "x$enable_lzma" = "xyes"], [ + AC_MSG_ERROR([Cannot find proper liblzma]) + ]) + ]) +]) # Configure zlib have_zlib="no"
lib/compressor_liblzma.c +1 -2
@@ -103,8 +103,7 @@ static int erofs_compressor_liblzma_init(struct erofs_compress *c) ctx->opt.dict_size = c->dict_size; c->private_data = ctx; -erofs_warn ("EXPERIMENTAL MicroLZMA feature in use. Use at your own risk!" ); -erofs_warn ("Note that it may take more time since the compressor is still single-threaded for now." ); +erofs_warn ("It may take a longer time since MicroLZMA is still single-threaded for now." );return 0 ; }
Signature · 1 line
2.39.3
PATCH v2 2/2 erofs-utils: support liblzma auto-detection
The new XZ Utils 5.4 is now available in most Linux distributions.
Let's enable liblzma auto-detection as well as get rid of MicroLZMA EXPERIMENTAL warning.
Signed-off-by Gao Xiang <[email protected]>
---
v2:
- fix build errors:
https://github.com/erofs/erofsnightly/actions/runs/7982759356
https://github.com/erofs/erofsnightly/actions/runs/7982793191
configure.ac | 53 +++++++++++++++++----------------------- lib/compressor_liblzma.c | 3 +-- 2 files changed, 24 insertions(+), 32 deletions(-)
configure.ac +23 -30
@@ -119,8 +119,8 @@ AC_ARG_ENABLE(lz4, [enable_lz4="$enableval"], [enable_lz4="yes"]) AC_ARG_ENABLE(lzma, - [AS_HELP_STRING([--enable-lzma], [enable LZMA compression support @<:@default=no@:>@])], - [enable_lzma="$enableval"], [enable_lzma="no"]) + [AS_HELP_STRING([--disable-lzma], [disable LZMA compression support @<:@default=auto@:>@])], + [enable_lzma="$enableval"]) AC_ARG_WITH(zlib, [AS_HELP_STRING([--without-zlib],
@@ -161,14 +161,6 @@ AC_ARG_WITH(lz4-libdir, AC_ARG_VAR([LZ4_CFLAGS], [C compiler flags for lz4]) AC_ARG_VAR([LZ4_LIBS], [linker flags for lz4]) -AC_ARG_WITH(liblzma-incdir, - [AS_HELP_STRING([--with-liblzma-incdir=DIR], [liblzma include directory])], [ - EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])]) - -AC_ARG_WITH(liblzma-libdir, - [AS_HELP_STRING([--with-liblzma-libdir=DIR], [liblzma lib directory])], [ - EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])]) - # Checks for header files. AC_CHECK_HEADERS(m4_flatten([ dirent.h
@@ -400,30 +392,31 @@ if test "x$enable_lz4" = "xyes"; then CPPFLAGS=${saved_CPPFLAGS} fi -if test "x$enable_lzma" = "xyes"; then +# Configure liblzma +have_liblzma="no" +AS_IF([test "x$enable_lzma" != "xno"], [ saved_CPPFLAGS=${CPPFLAGS} - test -z "${with_liblzma_incdir}" || - CPPFLAGS="-I$with_liblzma_incdir $CPPFLAGS" - AC_CHECK_HEADERS([lzma.h],[have_lzmah="yes"], []) - - if test "x${have_lzmah}" = "xyes" ; then + PKG_CHECK_MODULES([liblzma], [liblzma], [ + # Paranoia: don't trust the result reported by pkgconfig before trying out saved_LIBS="$LIBS" - saved_LDFLAGS="$LDFLAGS" - - test -z "${with_liblzma_libdir}" || - LDFLAGS="-L$with_liblzma_libdir ${LDFLAGS}" - AC_CHECK_LIB(lzma, lzma_microlzma_encoder, [], - [AC_MSG_ERROR([Cannot find proper liblzma])]) - - AC_CHECK_DECL(lzma_microlzma_encoder, [have_liblzma="yes"], - [AC_MSG_ERROR([Cannot find proper liblzma])], [[ + saved_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${liblzma_CFLAGS} ${CPPFLAGS}" + LIBS="${liblzma_LIBS} $LIBS" + AC_CHECK_HEADERS([lzma.h],[ + AC_CHECK_LIB(lzma, lzma_microlzma_encoder, [ + AC_CHECK_DECL(lzma_microlzma_encoder, [have_liblzma="yes"], + [], [[ #include <lzma.h> - ]]) - LDFLAGS="${saved_LDFLAGS}" + ]]) + ]) + ]) LIBS="${saved_LIBS}" - fi - CPPFLAGS="${saved_CPPFLAGS}" -fi + CPPFLAGS="${saved_CPPFLAGS}" + ]) + AS_IF([test "x$enable_lzma" = "xyes" -a "x$have_liblzma" != "xyes"], [ + AC_MSG_ERROR([Cannot find proper liblzma]) + ]) +]) # Configure zlib have_zlib="no"
lib/compressor_liblzma.c +1 -2
@@ -103,8 +103,7 @@ static int erofs_compressor_liblzma_init(struct erofs_compress *c) ctx->opt.dict_size = c->dict_size; c->private_data = ctx; -erofs_warn ("EXPERIMENTAL MicroLZMA feature in use. Use at your own risk!" ); -erofs_warn ("Note that it may take more time since the compressor is still single-threaded for now." ); +erofs_warn ("It may take a longer time since MicroLZMA is still single-threaded for now." );return 0 ; }
Signature · 1 line
2.39.3