All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] build: support building static library
@ 2024-05-23  7:31 ComixHe
  2024-05-23  8:05 ` Gao Xiang
  2024-06-06  4:18 ` [PATCH] build: support building static library liberofsfuse ComixHe
  0 siblings, 2 replies; 16+ messages in thread
From: ComixHe @ 2024-05-23  7:31 UTC (permalink / raw)
  To: hsiangkao; +Cc: ComixHe, linux-erofs

In some cases, developer may need to integrate erofs-utils into their
proejct as a static library to reduce package dependencies and
have more finer control over the feature used by the project.

For exapmle, squashfuse provides a static library `libsquashfuse.a` and
exposes some useful functions, Appimage uses this static library to build
image. It could ensure that the executable image can be executed directly
on most linux platforms and the user doesn't need to install squashfuse
in order to execute the image.

Signed-off-by: ComixHe <heyuming@deepin.org>
---
 configure.ac     | 28 ++++++++++++++++++++++++++++
 dump/Makefile.am | 10 ++++++++++
 fsck/Makefile.am | 10 ++++++++++
 fuse/Makefile.am | 10 ++++++++++
 mkfs/Makefile.am | 10 ++++++++++
 5 files changed, 68 insertions(+)

diff --git a/configure.ac b/configure.ac
index 1989bca..16ddb7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,6 +147,30 @@ 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_ENABLE([static-dump],
+    [AS_HELP_STRING([--enable-static-dump],
+                    [build dump.erofs as a static library @<:@default=no@:>@])],
+    [enable_static_dump="$enableval"],
+    [enable_static_dump="no"])
+
+AC_ARG_ENABLE([static-mkfs],
+    [AS_HELP_STRING([--enable-static-mkfs],
+                    [build mkfs.erofs as a static library @<:@default=no@:>@])],
+    [enable_static_mkfs="$enableval"],
+    [enable_static_mkfs="no"])
+
+AC_ARG_ENABLE([static-fsck],
+    [AS_HELP_STRING([--enable-static-fsck],
+                    [build fsck.erofs as a static library @<:@default=no@:>@])],
+    [enable_static_fsck="$enableval"],
+    [enable_static_fsck="no"])
+
 AC_ARG_WITH(uuid,
    [AS_HELP_STRING([--without-uuid],
       [Ignore presence of libuuid and disable uuid support @<:@default=enabled@:>@])])
@@ -525,6 +549,10 @@ AM_CONDITIONAL([ENABLE_FUSE], [test "x${have_fuse}" = "xyes"])
 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_STATIC_FUSE], [test "x${enable_static_fuse}" = "xyes"])
+AM_CONDITIONAL([ENABLE_STATIC_MKFS], [test "x${enable_static_mkfs}" = "xyes"])
+AM_CONDITIONAL([ENABLE_STATIC_DUMP], [test "x${enable_static_dump}" = "xyes"])
+AM_CONDITIONAL([ENABLE_STATIC_FSCK], [test "x${enable_static_fsck}" = "xyes"])
 
 if test "x$have_uuid" = "xyes"; then
   AC_DEFINE([HAVE_LIBUUID], 1, [Define to 1 if libuuid is found])
diff --git a/dump/Makefile.am b/dump/Makefile.am
index 09c483e..da0df51 100644
--- a/dump/Makefile.am
+++ b/dump/Makefile.am
@@ -9,3 +9,13 @@ dump_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
 dump_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
 	${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} \
 	${libzstd_LIBS}
+
+if ENABLE_STATIC_DUMP
+lib_LTLIBRARIES     = libdumperofs.la
+libdumperofs_la_SOURCES = main.c
+libdumperofs_la_CFLAGS = -Wall -I$(top_srcdir)/include
+libdumperofs_la_CFLAGS += -Dmain=dumperofs_main -static
+libdumperofs_la_LIBADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
+	${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} \
+	${libzstd_LIBS}
+endif
diff --git a/fsck/Makefile.am b/fsck/Makefile.am
index 70eacc0..0916320 100644
--- a/fsck/Makefile.am
+++ b/fsck/Makefile.am
@@ -10,6 +10,16 @@ fsck_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
 	${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} \
 	${libzstd_LIBS}
 
+if ENABLE_STATIC_FSCK
+lib_LTLIBRARIES    = libfsckerofs.la
+libfsckerofs_la_SOURCES = main.c
+libfsckerofs_la_CFLAGS = -Wall -I$(top_srcdir)/include
+libfsckerofs_la_CFLAGS += -Dmain=fsckerofs_main -static
+libfsckerofs_la_LIBADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
+	${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} \
+	${libzstd_LIBS}
+endif
+
 if ENABLE_FUZZING
 noinst_PROGRAMS   = fuzz_erofsfsck
 fuzz_erofsfsck_SOURCES = main.c
diff --git a/fuse/Makefile.am b/fuse/Makefile.am
index 7eae5f6..120d3e1 100644
--- a/fuse/Makefile.am
+++ b/fuse/Makefile.am
@@ -8,3 +8,13 @@ erofsfuse_CFLAGS = -Wall -I$(top_srcdir)/include
 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}
+
+
+if ENABLE_STATIC_FUSE
+lib_LTLIBRARIES = liberofsfuse.la
+liberofsfuse_la_SOURCES = main.c
+liberofsfuse_la_CFLAGS  = -Wall -I$(top_srcdir)/include
+liberofsfuse_la_CFLAGS += -Dmain=erofsfuse_main -static ${libfuse2_CFLAGS} ${libfuse3_CFLAGS} ${libselinux_CFLAGS}
+liberofsfuse_la_LIBADD  = $(top_builddir)/lib/liberofs.la ${libfuse2_LIBS} ${libfuse3_LIBS} ${liblz4_LIBS} \
+	${libselinux_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libdeflate_LIBS} ${libzstd_LIBS}
+endif
diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am
index af97e39..6edcdda 100644
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -8,3 +8,13 @@ mkfs_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
 mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
 	${libuuid_LIBS} ${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} \
 	${libdeflate_LIBS} ${libzstd_LIBS}
+
+if ENABLE_STATIC_MKFS
+lib_LTLIBRARIES     = libmkerofs.la
+libmkerofs_la_SOURCES = main.c
+libmkerofs_la_CFLAGS = -Wall -I$(top_srcdir)/include
+libmkerofs_la_CFLAGS += -Dmain=mkerofs_main -static
+libmkerofs_la_LIBADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
+	${libuuid_LIBS} ${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} \
+	${libdeflate_LIBS} ${libzstd_LIBS}
+endif
-- 
2.45.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* Re: [PATCH] build: support building static library
@ 2024-06-06  4:55 ComixHe
  0 siblings, 0 replies; 16+ messages in thread
From: ComixHe @ 2024-06-06  4:55 UTC (permalink / raw)
  To: hsiangkao; +Cc: linux-erofs

According to your suggestions:

 > That is also fine with me, anyway, liberofsfuse is a very special
 > case for us, I'd like to just build a static library for
 > erofsfuse only (because liberofs will be exported as a dynamic
 > library in later versions, I don't want to rely on random libfuse
 > interface).
 >
 > For other usage, I'd suggest form some formal APIs in liberofs
 > instead.

I create a new patch which only for exporting 'liberofsfuse.a'.

Thanks,

He YuMing


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-06-11  9:23 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23  7:31 [PATCH] build: support building static library ComixHe
2024-05-23  8:05 ` Gao Xiang
2024-06-06  2:13   ` Chen Linxuan
2024-06-06  2:22     ` Gao Xiang
2024-06-06  2:25       ` Chen Linxuan
2024-06-06  2:45         ` Gao Xiang
2024-06-06  3:06           ` Chen Linxuan
2024-06-06  3:13             ` Gao Xiang
2024-06-06  3:17               ` Chen Linxuan
2024-06-06  3:22                 ` Gao Xiang
2024-06-06  4:18 ` [PATCH] build: support building static library liberofsfuse ComixHe
2024-06-06  6:31   ` Gao Xiang
2024-06-06  7:39   ` [PATCH v2] " ComixHe
2024-06-06  7:53     ` Gao Xiang
2024-06-11  9:23     ` Gao Xiang
  -- strict thread matches above, loose matches on Subject: below --
2024-06-06  4:55 [PATCH] build: support building static library ComixHe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.