aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am12
-rw-r--r--configure.ac152
-rw-r--r--jffsX-utils/compr.c4
-rw-r--r--jffsX-utils/compr.h3
-rw-r--r--jffsX-utils/compr_lzo.c2
-rw-r--r--jffsX-utils/mkfs.jffs2.c12
-rw-r--r--ubifs-utils/mkfs.ubifs/compr.c22
-rw-r--r--ubifs-utils/mkfs.ubifs/mkfs.ubifs.c16
8 files changed, 92 insertions, 131 deletions
diff --git a/Makefile.am b/Makefile.am
index dd14d96..299a5fb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,16 +3,16 @@ ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = $(WARN_CFLAGS) -D_GNU_SOURCE -std=gnu99 -I$(top_srcdir)/include \
-include $(top_builddir)/include/config.h
-if WITHOUT_XATTR
-AM_CPPFLAGS += -DWITHOUT_XATTR
+if WITH_XATTR
+AM_CPPFLAGS += -DWITH_XATTR
endif
-if WITHOUT_LZO
-AM_CPPFLAGS += -DWITHOUT_LZO
+if WITH_LZO
+AM_CPPFLAGS += -DWITH_LZO
endif
-if WITHOUT_ZSTD
-AM_CPPFLAGS += -DWITHOUT_ZSTD
+if WITH_ZSTD
+AM_CPPFLAGS += -DWITH_ZSTD
endif
if WITH_SELINUX
diff --git a/configure.ac b/configure.ac
index 7448b3e..fdd9c3c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,11 +66,7 @@ need_clock_gettime="no"
need_pthread="no"
need_uuid="no"
need_zlib="no"
-need_lzo="no"
-need_zstd="no"
-need_xattr="no"
need_cmocka="no"
-need_selinux="no"
need_openssl="no"
AM_COND_IF([UNIT_TESTS], [
@@ -128,53 +124,31 @@ AC_ARG_WITH([ubifs],
AM_COND_IF([BUILD_UBIFS], [
need_uuid="yes"
- need_xattr="yes"
need_zlib="yes"
- need_lzo="yes"
- need_zstd="yes"
need_openssl="yes"
AS_VAR_IF([need_getrandom], [auto], [need_getrandom="yes"])
])
AM_COND_IF([BUILD_JFFSX], [
- need_xattr="yes"
need_zlib="yes"
- need_lzo="yes"
])
AC_ARG_WITH([xattr],
- [AS_HELP_STRING([--without-xattr],
- [Disable support forextended file attributes])],
- [case "${withval}" in
- yes) ;;
- no) need_xattr="no" ;;
- *) AC_MSG_ERROR([bad value ${withval} for --without-xattr]) ;;
- esac])
+ [AS_HELP_STRING([--with-xattr], [Support extended file attributes])],
+ [], [with_xattr="check"])
AC_ARG_WITH([lzo],
- [AS_HELP_STRING([--without-lzo], [Disable support for LZO compression])],
- [case "${withval}" in
- yes) ;;
- no) need_lzo="no" ;;
- *) AC_MSG_ERROR([bad value ${withval} for --without-lzo]) ;;
- esac])
+ [AS_HELP_STRING([--with-lzo], [Support LZO compression])],
+ [], [with_lzo="check"])
AC_ARG_WITH([zstd],
- [AS_HELP_STRING([--without-zstd], [Disable support for ZSTD compression])],
- [case "${withval}" in
- yes) ;;
- no) need_zstd="no" ;;
- *) AC_MSG_ERROR([bad value ${withval} for --without-zstd]) ;;
- esac])
+ [AS_HELP_STRING([--with-zstd], [Support for ZSTD compression])],
+ [], [with_zstd="check"])
AC_ARG_WITH([selinux],
[AS_HELP_STRING([--with-selinux],
- [Enable support for selinux extended attributes])],
- [case "${withval}" in
- yes) need_selinux="yes";;
- no) ;;
- *) AC_MSG_ERROR([bad value ${withval} for --with-selinux]) ;;
- esac])
+ [Support for selinux extended attributes])],
+ [], [with_selinux="check"])
AC_ARG_WITH([crypto],
[AS_HELP_STRING([--without-crypto],
@@ -191,11 +165,7 @@ clock_gettime_missing="no"
pthread_missing="no"
uuid_missing="no"
zlib_missing="no"
-lzo_missing="no"
-zstd_missing="no"
-xattr_missing="no"
cmocka_missing="no"
-selinux_missing="no"
openssl_missing="no"
getrandom_missing="no"
@@ -203,10 +173,6 @@ if test "x$need_zlib" = "xyes"; then
PKG_CHECK_MODULES(ZLIB, [zlib], [], [zlib_missing="yes"])
fi
-if test "x$need_selinux" = "xyes"; then
- PKG_CHECK_MODULES(LIBSELINUX, [libselinux], [], [selinux_missing="yes"])
-fi
-
if test "x$need_uuid" = "xyes"; then
PKG_CHECK_MODULES(UUID, [uuid], [], [uuid_missing="yes"])
fi
@@ -220,29 +186,52 @@ if test "x$need_pthread" = "xyes"; then
AX_PTHREAD([], [pthread_missing="yes"])
fi
-if test "x$need_lzo" = "xyes"; then
- AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
- AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
- AC_CHECK_LIB([lzo2], [lzo1x_1_15_compress], [LZO_LIBS="-llzo2"],
- [AC_CHECK_LIB([lzo],[lzo1x_1_15_compress],[LZO_LIBS="-llzo"],
- [lzo_missing="yes"]
- )]
- )
-fi
-
-if test "x$need_zstd" = "xyes"; then
- PKG_CHECK_MODULES([ZSTD], [libzstd],, zstd_missing="yes")
-fi
-
-if test "x$need_xattr" = "xyes"; then
- AC_CHECK_HEADERS([sys/xattr.h], [], [xattr_missing="yes"])
- AC_CHECK_HEADERS([sys/acl.h], [], [xattr_missing="yes"])
-fi
+AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
+AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
-if test "x$need_selinux" = "xyes"; then
- AC_CHECK_HEADERS([selinux/selinux.h], [], [selinux_missing="yes"])
- AC_CHECK_HEADERS([selinux/label.h], [], [selinux_missing="yes"])
-fi
+AS_IF([test -z "$LZO_LIBS" -a "x$with_lzo" != "xno"], [
+ AC_CHECK_LIB([lzo2], [lzo1x_1_15_compress], [LZO_LIBS="-llzo2"],
+ [AC_CHECK_LIB([lzo],[lzo1x_1_15_compress],
+ [LZO_LIBS="-llzo"],
+ []
+ )]
+ )
+], [])
+
+AS_IF([test -z "$LZO_LIBS"], [AS_IF([test "x$with_lzo" != "xcheck"],
+ [AC_MSG_ERROR([cannot find liblzo])],
+ [with_lzo="no"])],
+ [with_lzo="yes"])
+
+AS_IF([test "x$with_zstd" != "xno"], [
+ PKG_CHECK_MODULES(ZSTD, [libzstd], [with_zstd="yes"],
+ [AS_IF([test "x$with_zstd" != "xcheck"],
+ [AC_MSG_ERROR([cannot find zstd])],
+ [with_zstd="no"])])
+], [])
+
+AS_IF([test "x$with_xattr" != "xno"], [
+ have_xattr="yes"
+
+ AC_CHECK_HEADERS([sys/xattr.h], [], [have_xattr="no"])
+ AC_CHECK_HEADERS([sys/acl.h], [], [have_xattr="no"])
+
+ AS_IF([test "x$with_xattr" != "xcheck" -a "x$have_xattr" = "xno"],
+ [AC_MSG_ERROR([cannot find xattr/acl headers])],
+ [with_xattr="$have_xattr"])
+], [])
+
+AS_IF([test "x$with_selinux" != "xno"], [
+ have_selinux="yes"
+
+ PKG_CHECK_MODULES(LIBSELINUX, [libselinux], [], [have_selinux="no"])
+ AC_CHECK_HEADERS([selinux/selinux.h], [], [have_selinux="no"])
+ AC_CHECK_HEADERS([selinux/label.h], [], [have_selinux="no"])
+
+ AS_IF([test "x$with_selinux" != "xcheck" -a "x$have_selinux" = "xno"],
+ [AC_MSG_ERROR([cannot find SELinux libraries])],
+ [with_selinux="$have_selinux"])
+], [])
if test "x$need_openssl" = "xyes"; then
AC_CHECK_HEADER(openssl/rand.h)
@@ -288,33 +277,6 @@ if test "x$zlib_missing" = "xyes"; then
dep_missing="yes"
fi
-if test "x$lzo_missing" = "xyes"; then
- AC_MSG_WARN([cannot find LZO library required for mkfs programs])
- AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
- AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.jffs2])
- AC_MSG_NOTICE([mtd-utils can optionally be built without LZO support])
- dep_missing="yes"
-fi
-
-if test "x$zstd_missing" = "xyes"; then
- AC_MSG_WARN([cannot find ZSTD library required for mkfs program])
- AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
- AC_MSG_NOTICE([mtd-utils can optionally be built without ZSTD support])
- dep_missing="yes"
-fi
-
-if test "x$xattr_missing" = "xyes"; then
- AC_MSG_WARN([cannot find headers for extended attributes])
- AC_MSG_WARN([disabling XATTR support])
- need_xattr="no"
-fi
-
-if test "x$selinux_missing" = "xyes"; then
- AC_MSG_WARN([cannot find headers for selinux library])
- AC_MSG_WARN([disabling SELINUX support])
- need_selinux="no"
-fi
-
if test "x$openssl_missing" = "xyes"; then
AC_MSG_WARN([cannot find headers for OpenSSL library])
AC_MSG_WARN([disabling OpenSSL support])
@@ -339,10 +301,10 @@ fi
##### generate output #####
-AM_CONDITIONAL([WITHOUT_LZO], [test "x$need_lzo" != "xyes"])
-AM_CONDITIONAL([WITHOUT_ZSTD], [test "x$need_zstd" != "xyes"])
-AM_CONDITIONAL([WITHOUT_XATTR], [test "x$need_xattr" != "xyes"])
-AM_CONDITIONAL([WITH_SELINUX], [test "x$need_selinux" = "xyes"])
+AM_CONDITIONAL([WITH_LZO], [test "x$with_lzo" = "xyes"])
+AM_CONDITIONAL([WITH_ZSTD], [test "x$with_zstd" = "xyes"])
+AM_CONDITIONAL([WITH_XATTR], [test "x$with_xattr" = "xyes"])
+AM_CONDITIONAL([WITH_SELINUX], [test "x$with_selinux" = "xyes"])
AM_CONDITIONAL([WITH_CRYPTO], [test "x$need_openssl" = "xyes"])
AM_CONDITIONAL([WITH_GETRANDOM], [test "x$need_getrandom" = "xyes"])
diff --git a/jffsX-utils/compr.c b/jffsX-utils/compr.c
index cb4432e..42d8a70 100644
--- a/jffsX-utils/compr.c
+++ b/jffsX-utils/compr.c
@@ -517,7 +517,7 @@ int jffs2_compressors_init(void)
#ifdef CONFIG_JFFS2_RTIME
jffs2_rtime_init();
#endif
-#ifdef CONFIG_JFFS2_LZO
+#ifdef WITH_LZO
jffs2_lzo_init();
#endif
return 0;
@@ -531,7 +531,7 @@ int jffs2_compressors_exit(void)
#ifdef CONFIG_JFFS2_ZLIB
jffs2_zlib_exit();
#endif
-#ifdef CONFIG_JFFS2_LZO
+#ifdef WITH_LZO
jffs2_lzo_exit();
#endif
return 0;
diff --git a/jffsX-utils/compr.h b/jffsX-utils/compr.h
index a21e935..0806f4d 100644
--- a/jffsX-utils/compr.h
+++ b/jffsX-utils/compr.h
@@ -18,7 +18,6 @@
#define CONFIG_JFFS2_ZLIB
#define CONFIG_JFFS2_RTIME
-#define CONFIG_JFFS2_LZO
#define JFFS2_RUBINMIPS_PRIORITY 10
#define JFFS2_DYNRUBIN_PRIORITY 20
@@ -111,7 +110,7 @@ void jffs2_zlib_exit(void);
int jffs2_rtime_init(void);
void jffs2_rtime_exit(void);
#endif
-#ifdef CONFIG_JFFS2_LZO
+#ifdef WITH_LZO
int jffs2_lzo_init(void);
void jffs2_lzo_exit(void);
#endif
diff --git a/jffsX-utils/compr_lzo.c b/jffsX-utils/compr_lzo.c
index 56aa1b4..337ebe9 100644
--- a/jffsX-utils/compr_lzo.c
+++ b/jffsX-utils/compr_lzo.c
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <string.h>
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
#include <asm/types.h>
#include <linux/jffs2.h>
#include <lzo/lzo1x.h>
diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
index bd67634..b9dd96b 100644
--- a/jffsX-utils/mkfs.jffs2.c
+++ b/jffsX-utils/mkfs.jffs2.c
@@ -65,7 +65,7 @@
#include <ctype.h>
#include <time.h>
#include <getopt.h>
-#ifndef WITHOUT_XATTR
+#ifdef WITH_XATTR
#include <sys/xattr.h>
#include <sys/acl.h>
#endif
@@ -978,7 +978,7 @@ static void write_special_file(struct filesystem_entry *e)
padword();
}
-#ifndef WITHOUT_XATTR
+#ifdef WITH_XATTR
typedef struct xattr_entry {
struct xattr_entry *next;
uint32_t xid;
@@ -1209,7 +1209,7 @@ static void write_xattr_entry(struct filesystem_entry *e)
}
}
-#else /* WITHOUT_XATTR */
+#else /* WITH_XATTR */
#define write_xattr_entry(x)
#endif
@@ -1380,7 +1380,7 @@ static struct option long_options[] = {
{"test-compression", 0, NULL, 't'},
{"compressor-priority", 1, NULL, 'y'},
{"incremental", 1, NULL, 'i'},
-#ifndef WITHOUT_XATTR
+#ifdef WITH_XATTR
{"with-xattr", 0, NULL, 1000 },
{"with-selinux", 0, NULL, 1001 },
{"with-posix-acl", 0, NULL, 1002 },
@@ -1420,7 +1420,7 @@ static const char helptext[] =
" -q, --squash Squash permissions and owners making all files be owned by root\n"
" -U, --squash-uids Squash owners making all files be owned by root\n"
" -P, --squash-perms Squash permissions on all files\n"
-#ifndef WITHOUT_XATTR
+#ifdef WITH_XATTR
" --with-xattr stuff all xattr entries into image\n"
" --with-selinux stuff only SELinux Labels into jffs2 image\n"
" --with-posix-acl stuff only POSIX ACL entries into jffs2 image\n"
@@ -1745,7 +1745,7 @@ int main(int argc, char **argv)
sys_errmsg_die("cannot open (incremental) file");
}
break;
-#ifndef WITHOUT_XATTR
+#ifdef WITH_XATTR
case 1000: /* --with-xattr */
enable_xattr |= (1 << JFFS2_XPREFIX_USER)
| (1 << JFFS2_XPREFIX_SECURITY)
diff --git a/ubifs-utils/mkfs.ubifs/compr.c b/ubifs-utils/mkfs.ubifs/compr.c
index 06c35ca..07f6d4a 100644
--- a/ubifs-utils/mkfs.ubifs/compr.c
+++ b/ubifs-utils/mkfs.ubifs/compr.c
@@ -24,11 +24,11 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
#include <lzo/lzo1x.h>
#endif
#include <linux/types.h>
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
#include <zstd.h>
#endif
@@ -41,7 +41,7 @@
static void *lzo_mem;
static unsigned long long errcnt = 0;
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
static struct ubifs_info *c = &info_;
#endif
@@ -92,7 +92,7 @@ static int zlib_deflate(void *in_buf, size_t in_len, void *out_buf,
return 0;
}
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
{
@@ -112,7 +112,7 @@ static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
}
#endif
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
static ZSTD_CCtx *zctx;
static int zstd_compress(void *in_buf, size_t in_len, void *out_buf,
@@ -140,7 +140,7 @@ static int no_compress(void *in_buf, size_t in_len, void *out_buf,
static char *zlib_buf;
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
static int favor_lzo_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len, int *type)
{
@@ -198,7 +198,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,
return MKFS_UBIFS_COMPR_NONE;
}
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
{
switch (type) {
#else
@@ -213,7 +213,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,
case MKFS_UBIFS_COMPR_ZLIB:
ret = zlib_deflate(in_buf, in_len, out_buf, out_len);
break;
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
case MKFS_UBIFS_COMPR_ZSTD:
ret = zstd_compress(in_buf, in_len, out_buf, out_len);
break;
@@ -236,7 +236,7 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,
int init_compression(void)
{
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
lzo_mem = NULL;
#else
lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
@@ -248,7 +248,7 @@ int init_compression(void)
if (!zlib_buf)
goto err;
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
zctx = ZSTD_createCCtx();
if (!zctx)
goto err;
@@ -265,7 +265,7 @@ void destroy_compression(void)
{
free(zlib_buf);
free(lzo_mem);
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
ZSTD_freeCCtx(zctx);
#endif
if (errcnt)
diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
index 8f8d40b..5d3b80c 100644
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
@@ -26,7 +26,7 @@
#include <crc32.h>
#include "common.h"
#include <sys/types.h>
-#ifndef WITHOUT_XATTR
+#ifdef WITH_XATTR
#include <sys/xattr.h>
#endif
@@ -35,7 +35,7 @@
#include <selinux/label.h>
#endif
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
#include <zstd.h>
#endif
@@ -539,7 +539,7 @@ static void select_default_compr(void)
return;
}
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
c->default_compr = UBIFS_COMPR_ZLIB;
#else
c->default_compr = UBIFS_COMPR_LZO;
@@ -683,11 +683,11 @@ static int get_options(int argc, char**argv)
c->default_compr = UBIFS_COMPR_NONE;
else if (strcmp(optarg, "zlib") == 0)
c->default_compr = UBIFS_COMPR_ZLIB;
-#ifndef WITHOUT_ZSTD
+#ifdef WITH_ZSTD
else if (strcmp(optarg, "zstd") == 0)
c->default_compr = UBIFS_COMPR_ZSTD;
#endif
-#ifndef WITHOUT_LZO
+#ifdef WITH_LZO
else if (strcmp(optarg, "favor_lzo") == 0) {
c->default_compr = UBIFS_COMPR_LZO;
c->favor_lzo = 1;
@@ -699,7 +699,7 @@ static int get_options(int argc, char**argv)
return err_msg("bad compressor name");
break;
case 'X':
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
return err_msg("built without LZO support");
#else
c->favor_percent = strtol(optarg, &endp, 0);
@@ -1288,7 +1288,7 @@ out:
return ret;
}
-#ifdef WITHOUT_XATTR
+#ifndef WITH_XATTR
static inline int create_inum_attr(ino_t inum, const char *name)
{
(void)inum;
@@ -1858,7 +1858,7 @@ static int add_file(const char *path_name, struct stat *st, ino_t inum,
out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
if (c->default_compr == UBIFS_COMPR_NONE &&
!c->encrypted && (flags & FS_COMPR_FL))
-#ifdef WITHOUT_LZO
+#ifndef WITH_LZO
use_compr = UBIFS_COMPR_ZLIB;
#else
use_compr = UBIFS_COMPR_LZO;