Skip to content

Commit 7272a97

Browse files
committed
configure: add --without-libarchive option
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 <tytso@mit.edu>
1 parent 1da249a commit 7272a97

File tree

5 files changed

+83
-10
lines changed

5 files changed

+83
-10
lines changed

configure

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ enable_rpath
930930
with_libiconv_prefix
931931
with_libintl_prefix
932932
enable_largefile
933+
with_libarchive
933934
enable_fuse2fs
934935
enable_lto
935936
enable_ubsan
@@ -1646,6 +1647,7 @@ Optional Packages:
16461647
--without-libiconv-prefix don't search for libiconv in includedir and libdir
16471648
--with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib
16481649
--without-libintl-prefix don't search for libintl in includedir and libdir
1650+
--without-libarchive disable use of libarchive
16491651
--with-multiarch=ARCH specify the multiarch triplet
16501652
--with-udev-rules-dir[=DIR]
16511653
Install udev rules into DIR.
@@ -13734,7 +13736,37 @@ if test "$ac_cv_func_dlopen" = yes ; then
1373413736
MAGIC_LIB=$DLOPEN_LIB
1373513737
fi
1373613738

13737-
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archive_read_new in -larchive" >&5
13739+
13740+
# Check whether --with-libarchive was given.
13741+
if test ${with_libarchive+y}
13742+
then :
13743+
withval=$with_libarchive; if test "$withval" = "no"
13744+
then
13745+
try_libarchive=""
13746+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling libarchive support" >&5
13747+
printf "%s\n" "Disabling libarchive support" >&6; }
13748+
elif test "$withval" = "direct"
13749+
then
13750+
try_libarchive="direct"
13751+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Testing for libarchive support (forced direct link)" >&5
13752+
printf "%s\n" "Testing for libarchive support (forced direct link)" >&6; }
13753+
else
13754+
try_libarchive="yes"
13755+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Testing for libarchive support (with dlopen)" >&5
13756+
printf "%s\n" "Testing for libarchive support (with dlopen)" >&6; }
13757+
fi
13758+
13759+
else $as_nop
13760+
try_libarchive="yes"
13761+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Try testing for libarchive support (with dlopen) by default" >&5
13762+
printf "%s\n" "Try testing for libarchive support (with dlopen) by default" >&6; }
13763+
13764+
fi
13765+
13766+
ARCHIVE_LIB=
13767+
if test -n "$try_libarchive"
13768+
then
13769+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archive_read_new in -larchive" >&5
1373813770
printf %s "checking for archive_read_new in -larchive... " >&6; }
1373913771
if test ${ac_cv_lib_archive_archive_read_new+y}
1374013772
then :
@@ -13772,7 +13804,7 @@ printf "%s\n" "$ac_cv_lib_archive_archive_read_new" >&6; }
1377213804
if test "x$ac_cv_lib_archive_archive_read_new" = xyes
1377313805
then :
1377413806
ARCHIVE_LIB=-larchive
13775-
ac_fn_c_check_header_compile "$LINENO" "archive.h" "ac_cv_header_archive_h" "$ac_includes_default"
13807+
ac_fn_c_check_header_compile "$LINENO" "archive.h" "ac_cv_header_archive_h" "$ac_includes_default"
1377613808
if test "x$ac_cv_header_archive_h" = xyes
1377713809
then :
1377813810
printf "%s\n" "#define HAVE_ARCHIVE_H 1" >>confdefs.h
@@ -13781,8 +13813,17 @@ fi
1378113813

1378213814
fi
1378313815

13784-
if test "$ac_cv_func_dlopen" = yes ; then
13785-
ARCHIVE_LIB=$DLOPEN_LIB
13816+
if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
13817+
ARCHIVE_LIB=$DLOPEN_LIB
13818+
13819+
printf "%s\n" "#define CONFIG_DLOPEN_LIBARCHIVE 1" >>confdefs.h
13820+
13821+
13822+
fi
13823+
if test "$ac_cv_header_archive_h" != "yes"
13824+
then
13825+
ARCHIVE_LIB=
13826+
fi
1378613827
fi
1378713828

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

configure.ac

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,10 +1301,39 @@ AC_SUBST(MAGIC_LIB)
13011301
dnl
13021302
dnl libarchive
13031303
dnl
1304-
AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
1305-
AC_CHECK_HEADERS([archive.h])])
1306-
if test "$ac_cv_func_dlopen" = yes ; then
1307-
ARCHIVE_LIB=$DLOPEN_LIB
1304+
AC_ARG_WITH([libarchive],
1305+
AS_HELP_STRING([--without-libarchive],[disable use of libarchive]),
1306+
[if test "$withval" = "no"
1307+
then
1308+
try_libarchive=""
1309+
AC_MSG_RESULT([Disabling libarchive support])
1310+
elif test "$withval" = "direct"
1311+
then
1312+
try_libarchive="direct"
1313+
AC_MSG_RESULT([Testing for libarchive support (forced direct link)])
1314+
else
1315+
try_libarchive="yes"
1316+
AC_MSG_RESULT([Testing for libarchive support (with dlopen)])
1317+
fi]
1318+
,
1319+
try_libarchive="yes"
1320+
AC_MSG_RESULT([Try testing for libarchive support (with dlopen) by default])
1321+
)
1322+
ARCHIVE_LIB=
1323+
if test -n "$try_libarchive"
1324+
then
1325+
AC_CHECK_LIB(archive, archive_read_new, [ARCHIVE_LIB=-larchive
1326+
AC_CHECK_HEADERS([archive.h])])
1327+
if test "$ac_cv_func_dlopen" = yes -a "$try_libarchive" != "direct"; then
1328+
ARCHIVE_LIB=$DLOPEN_LIB
1329+
AC_DEFINE(CONFIG_DLOPEN_LIBARCHIVE, 1,
1330+
[Define to 1 if using dlopen to access libarchive])
1331+
1332+
fi
1333+
if test "$ac_cv_header_archive_h" != "yes"
1334+
then
1335+
ARCHIVE_LIB=
1336+
fi
13081337
fi
13091338
AC_SUBST(ARCHIVE_LIB)
13101339
dnl

lib/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
/* Define to 1 for features for use by ext4 developers */
1313
#undef CONFIG_DEVELOPER_FEATURES
1414

15+
/* Define to 1 if using dlopen to access libarchive */
16+
#undef CONFIG_DLOPEN_LIBARCHIVE
17+
1518
/* Define to 1 if debugging ext3/4 journal code */
1619
#undef CONFIG_JBD_DEBUG
1720

misc/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ mke2fs.static: $(MKE2FS_OBJS) $(STATIC_DEPLIBS) $(STATIC_LIBE2P) $(DEPSTATIC_LIB
290290
$(Q) $(CC) $(LDFLAGS_STATIC) -o mke2fs.static $(MKE2FS_OBJS) \
291291
$(STATIC_LIBS) $(STATIC_LIBE2P) \
292292
$(STATIC_LIBBLKID) $(STATIC_LIBUUID) $(LIBINTL) $(SYSLIBS) \
293-
$(LIBMAGIC)
293+
$(LIBMAGIC) $(LIBARCHIVE)
294294

295295
mke2fs.profiled: $(MKE2FS_OBJS) $(PROFILED_DEPLIBS) \
296296
$(PROFILED_LIBE2P) $(PROFILED_DEPLIBBLKID) $(PROFILED_DEPLIBUUID)

misc/create_inode_libarchive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int (*dl_archive_read_open_filename)(struct archive *,
5151
static int (*dl_archive_read_support_filter_all)(struct archive *);
5252
static int (*dl_archive_read_support_format_all)(struct archive *);
5353

54-
#ifdef HAVE_DLOPEN
54+
#ifdef CONFIG_DLOPEN_LIBARCHIVE
5555
#include <dlfcn.h>
5656

5757
static void *libarchive_handle;

0 commit comments

Comments
 (0)