[PATCH 1/3] erofs-utils: add liblzma dependency
Gao Xiang
xiang at kernel.org
Sat Oct 30 13:01:16 AEDT 2021
liblzma [1] has a fixed-sized output LZMA compression implementation
now since v5.3.2alpha. Let's add such dependency in the build system.
[1] https://git.tukaani.org/?p=xz.git
Cc: Lasse Collin <lasse.collin at tukaani.org>
Signed-off-by: Gao Xiang <xiang at kernel.org>
---
README | 3 +++
configure.ac | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
fuse/Makefile.am | 3 ++-
lib/Makefile.am | 1 +
mkfs/Makefile.am | 3 ++-
5 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/README b/README
index 3f8301006ccc..333dcb49cc42 100644
--- a/README
+++ b/README
@@ -8,6 +8,7 @@ Dependencies & build
--------------------
lz4 1.8.0+ for lz4 enabled [2], lz4 1.9.3+ highly recommended [4][5].
+ XZ Utils 5.3.2alpha [6] or later versions for MicroLZMA enabled.
libfuse 2.6+ for erofsfuse enabled as a plus.
@@ -221,3 +222,5 @@ Comments
https://github.com/lz4/lz4/issues/783
which is also resolved in lz4-1.9.3.
+
+[6] https://tukaani.org/xz/xz-5.3.2alpha.tar.xz
diff --git a/configure.ac b/configure.ac
index b2c32259c5bd..b50c00c5d6c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,10 @@ AC_ARG_ENABLE(lz4,
[AS_HELP_STRING([--disable-lz4], [disable LZ4 compression support @<:@default=enabled@:>@])],
[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"])
+
AC_ARG_ENABLE(fuse,
[AS_HELP_STRING([--enable-fuse], [enable erofsfuse @<:@default=no@:>@])],
[enable_fuse="$enableval"], [enable_fuse="no"])
@@ -99,6 +103,14 @@ 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
@@ -263,10 +275,36 @@ if test "x$enable_lz4" = "xyes"; then
CPPFLAGS=${saved_CPPFLAGS}
fi
+if test "x$enable_lzma" = "xyes"; then
+ 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
+ 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])], [[
+#include <lzma.h>
+ ]])
+ LDFLAGS="${saved_LDFLAGS}"
+ LIBS="${saved_LIBS}"
+ fi
+ CPPFLAGS="${saved_CPPFLAGS}"
+fi
+
# Set up needed symbols, conditionals and compiler/linker flags
AM_CONDITIONAL([ENABLE_LZ4], [test "x${have_lz4}" = "xyes"])
AM_CONDITIONAL([ENABLE_LZ4HC], [test "x${have_lz4hc}" = "xyes"])
AM_CONDITIONAL([ENABLE_FUSE], [test "x${have_fuse}" = "xyes"])
+AM_CONDITIONAL([ENABLE_LIBLZMA], [test "x${have_liblzma}" = "xyes"])
if test "x$have_uuid" = "xyes"; then
AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found])
@@ -293,6 +331,17 @@ if test "x${have_lz4}" = "xyes"; then
fi
AC_SUBST([liblz4_LIBS])
+if test "x${have_liblzma}" = "xyes"; then
+ AC_DEFINE([HAVE_LIBLZMA], [1], [Define to 1 if liblzma is enabled.])
+ liblzma_LIBS="-llzma"
+ test -z "${with_liblzma_libdir}" ||
+ liblzma_LIBS="-L${with_liblzma_libdir} $liblzma_LIBS"
+ test -z "${with_liblzma_incdir}" ||
+ liblzma_CFLAGS="-I${with_liblzma_incdir}"
+ AC_SUBST([liblzma_LIBS])
+ AC_SUBST([liblzma_CFLAGS])
+fi
+
AC_CONFIG_FILES([Makefile
man/Makefile
lib/Makefile
diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index 6893a97ccaf1..7b007f3fec11 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -5,4 +5,5 @@ bin_PROGRAMS = erofsfuse
erofsfuse_SOURCES = dir.c main.c
erofsfuse_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
erofsfuse_CFLAGS += -DFUSE_USE_VERSION=26 ${libfuse_CFLAGS} ${libselinux_CFLAGS}
-erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse_LIBS} ${liblz4_LIBS} ${libselinux_LIBS}
+erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse_LIBS} ${liblz4_LIBS} \
+ ${libselinux_LIBS} ${liblzma_LIBS}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b64d90b3e144..370de844146f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -31,3 +31,4 @@ if ENABLE_LZ4HC
liberofs_la_SOURCES += compressor_lz4hc.c
endif
endif
+liberofs_la_CFLAGS += ${liblzma_CFLAGS}
diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am
index e488f86cff90..2a4bc1d58769 100644
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -5,4 +5,5 @@ bin_PROGRAMS = mkfs.erofs
AM_CPPFLAGS = ${libuuid_CFLAGS} ${libselinux_CFLAGS}
mkfs_erofs_SOURCES = main.c
mkfs_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include
-mkfs_erofs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} ${liblz4_LIBS}
+mkfs_erofs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
+ ${liblz4_LIBS} ${liblzma_LIBS}
--
2.20.1
More information about the Linux-erofs
mailing list