erofs-utils: build: support building static library liberofsfuse
authorComixHe <heyuming@deepin.org>
Thu, 6 Jun 2024 07:39:48 +0000 (15:39 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 11 Jun 2024 09:26:31 +0000 (17:26 +0800)
Add new option '--enable-static-fuse' so that we
could import erofsfuse as a static library directly
into other projects

Signed-off-by: ComixHe <heyuming@deepin.org>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/3399126AB01D5AB6+2bad5767fc035a7a2234408b0fffa53b3a07aa51.1717659178.git.heyuming@deepin.org
[ Gao Xiang: the target static library shouldn't have dependencies. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
configure.ac
fuse/Makefile.am

index cfbde433fcdff6eab01f7e18a4cc97ae70cf64ba..dc5f7871cc25f6dbec7655004f70d49fd7231334 100644 (file)
@@ -152,6 +152,12 @@ AC_ARG_ENABLE(fuse,
    [AS_HELP_STRING([--enable-fuse], [enable erofsfuse @<:@default=no@:>@])],
    [enable_fuse="$enableval"], [enable_fuse="no"])
 
+AC_ARG_ENABLE([static-fuse],
+    [AS_HELP_STRING([--enable-static-fuse],
+                    [build erofsfuse as a static library @<:@default=no@:>@])],
+    [enable_static_fuse="$enableval"],
+    [enable_static_fuse="no"])
+
 AC_ARG_WITH(uuid,
    [AS_HELP_STRING([--without-uuid],
       [Ignore presence of libuuid and disable uuid support @<:@default=enabled@:>@])])
@@ -556,6 +562,7 @@ AM_CONDITIONAL([ENABLE_LIBLZMA], [test "x${have_liblzma}" = "xyes"])
 AM_CONDITIONAL([ENABLE_LIBDEFLATE], [test "x${have_libdeflate}" = "xyes"])
 AM_CONDITIONAL([ENABLE_LIBZSTD], [test "x${have_libzstd}" = "xyes"])
 AM_CONDITIONAL([ENABLE_QPL], [test "x${have_qpl}" = "xyes"])
+AM_CONDITIONAL([ENABLE_STATIC_FUSE], [test "x${enable_static_fuse}" = "xyes"])
 
 if test "x$have_uuid" = "xyes"; then
   AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found])
index 2fd9b6d92101987bf77246c92eb3edf9c29b06d6..1062b73d03b38e25738d140b6e3c7f754c436b98 100644 (file)
@@ -9,3 +9,11 @@ erofsfuse_CFLAGS += ${libfuse2_CFLAGS} ${libfuse3_CFLAGS} ${libselinux_CFLAGS}
 erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse2_LIBS} ${libfuse3_LIBS} ${liblz4_LIBS} \
        ${libselinux_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} ${libzstd_LIBS} \
        ${libqpl_LIBS}
+
+if ENABLE_STATIC_FUSE
+lib_LIBRARIES = liberofsfuse.a
+liberofsfuse_a_SOURCES = main.c
+liberofsfuse_a_CFLAGS  = -Wall -I$(top_srcdir)/include
+liberofsfuse_a_CFLAGS += -Dmain=erofsfuse_main ${libfuse2_CFLAGS} ${libfuse3_CFLAGS} ${libselinux_CFLAGS}
+liberofsfuse_a_LIBADD  = $(top_builddir)/lib/liberofs.la
+endif