Skip to content

Commit

Permalink
configure: add --without-libarchive option
Browse files Browse the repository at this point in the history
Teach configure the --without-libarchive option, which forcibly
disables use of the libarchive library.

The option --with-libarchive=direct will disable the use of dlopen,
and will link mke2fs with -larchive directly.  This doesn't work when
building mke2f.static, since -larchive has a large number of
depedencies, and even "pkgconf --libs --static libarchive" doesn't
provide all of the appropriate library dependencies.  :-(

Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
tytso committed Apr 29, 2024
1 parent 1da249a commit 7272a97
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 10 deletions.
49 changes: 45 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ enable_rpath
with_libiconv_prefix
with_libintl_prefix
enable_largefile
with_libarchive
enable_fuse2fs
enable_lto
enable_ubsan
Expand Down Expand Up @@ -1646,6 +1647,7 @@ Optional Packages:
--without-libiconv-prefix don't search for libiconv in includedir and libdir
--with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib
--without-libintl-prefix don't search for libintl in includedir and libdir
--without-libarchive disable use of libarchive
--with-multiarch=ARCH specify the multiarch triplet
--with-udev-rules-dir[=DIR]
Install udev rules into DIR.
Expand Down Expand Up @@ -13734,7 +13736,37 @@ if test "$ac_cv_func_dlopen" = yes ; then
MAGIC_LIB=$DLOPEN_LIB
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archive_read_new in -larchive" >&5

# Check whether --with-libarchive was given.
if test ${with_libarchive+y}
then :
withval=$with_libarchive; if test "$withval" = "no"
then
try_libarchive=""
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling libarchive support" >&5
printf "%s\n" "Disabling libarchive support" >&6; }
elif test "$withval" = "direct"
then
try_libarchive="direct"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Testing for libarchive support (forced direct link)" >&5
printf "%s\n" "Testing for libarchive support (forced direct link)" >&6; }
else
try_libarchive="yes"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Testing for libarchive support (with dlopen)" >&5
printf "%s\n" "Testing for libarchive support (with dlopen)" >&6; }
fi

else $as_nop
try_libarchive="yes"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Try testing for libarchive support (with dlopen) by default" >&5
printf "%s\n" "Try testing for libarchive support (with dlopen) by default" >&6; }

fi

ARCHIVE_LIB=
if test -n "$try_libarchive"
then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archive_read_new in -larchive" >&5
printf %s "checking for archive_read_new in -larchive... " >&6; }
if test ${ac_cv_lib_archive_archive_read_new+y}
then :
Expand Down Expand Up @@ -13772,7 +13804,7 @@ printf "%s\n" "$ac_cv_lib_archive_archive_read_new" >&6; }
if test "x$ac_cv_lib_archive_archive_read_new" = xyes
then :
ARCHIVE_LIB=-larchive
ac_fn_c_check_header_compile "$LINENO" "archive.h" "ac_cv_header_archive_h" "$ac_includes_default"
ac_fn_c_check_header_compile "$LINENO" "archive.h" "ac_cv_header_archive_h" "$ac_includes_default"
if test "x$ac_cv_header_archive_h" = xyes
then :
printf "%s\n" "#define HAVE_ARCHIVE_H 1" >>confdefs.h
Expand All @@ -13781,8 +13813,17 @@ fi

fi

if test "$ac_cv_func_dlopen" = yes ; then
ARCHIVE_LIB=$DLOPEN_LIB
if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
ARCHIVE_LIB=$DLOPEN_LIB

printf "%s\n" "#define CONFIG_DLOPEN_LIBARCHIVE 1" >>confdefs.h


fi
if test "$ac_cv_header_archive_h" != "yes"
then
ARCHIVE_LIB=
fi
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
Expand Down
37 changes: 33 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1301,10 +1301,39 @@ AC_SUBST(MAGIC_LIB)
dnl
dnl libarchive
dnl
AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
AC_CHECK_HEADERS([archive.h])])
if test "$ac_cv_func_dlopen" = yes ; then
ARCHIVE_LIB=$DLOPEN_LIB
AC_ARG_WITH([libarchive],
AS_HELP_STRING([--without-libarchive],[disable use of libarchive]),
[if test "$withval" = "no"
then
try_libarchive=""
AC_MSG_RESULT([Disabling libarchive support])
elif test "$withval" = "direct"
then
try_libarchive="direct"
AC_MSG_RESULT([Testing for libarchive support (forced direct link)])
else
try_libarchive="yes"
AC_MSG_RESULT([Testing for libarchive support (with dlopen)])
fi]
,
try_libarchive="yes"
AC_MSG_RESULT([Try testing for libarchive support (with dlopen) by default])
)
ARCHIVE_LIB=
if test -n "$try_libarchive"
then
AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
AC_CHECK_HEADERS([archive.h])])
if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
ARCHIVE_LIB=$DLOPEN_LIB
AC_DEFINE(CONFIG_DLOPEN_LIBARCHIVE, 1,
[Define to 1 if using dlopen to access libarchive])

fi
if test "$ac_cv_header_archive_h" != "yes"
then
ARCHIVE_LIB=
fi
fi
AC_SUBST(ARCHIVE_LIB)
dnl
Expand Down
3 changes: 3 additions & 0 deletions lib/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/* Define to 1 for features for use by ext4 developers */
#undef CONFIG_DEVELOPER_FEATURES

/* Define to 1 if using dlopen to access libarchive */
#undef CONFIG_DLOPEN_LIBARCHIVE

/* Define to 1 if debugging ext3/4 journal code */
#undef CONFIG_JBD_DEBUG

Expand Down
2 changes: 1 addition & 1 deletion misc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ mke2fs.static: $(MKE2FS_OBJS) $(STATIC_DEPLIBS) $(STATIC_LIBE2P) $(DEPSTATIC_LIB
$(Q) $(CC) $(LDFLAGS_STATIC) -o mke2fs.static $(MKE2FS_OBJS) \
$(STATIC_LIBS) $(STATIC_LIBE2P) \
$(STATIC_LIBBLKID) $(STATIC_LIBUUID) $(LIBINTL) $(SYSLIBS) \
$(LIBMAGIC)
$(LIBMAGIC) $(LIBARCHIVE)

mke2fs.profiled: $(MKE2FS_OBJS) $(PROFILED_DEPLIBS) \
$(PROFILED_LIBE2P) $(PROFILED_DEPLIBBLKID) $(PROFILED_DEPLIBUUID)
Expand Down
2 changes: 1 addition & 1 deletion misc/create_inode_libarchive.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int (*dl_archive_read_open_filename)(struct archive *,
static int (*dl_archive_read_support_filter_all)(struct archive *);
static int (*dl_archive_read_support_format_all)(struct archive *);

#ifdef HAVE_DLOPEN
#ifdef CONFIG_DLOPEN_LIBARCHIVE
#include <dlfcn.h>

static void *libarchive_handle;
Expand Down

0 comments on commit 7272a97

Please sign in to comment.