]> www.infradead.org Git - mtd-utils.git/commitdiff
Unify handling of configure switches
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Sun, 28 Feb 2021 14:34:12 +0000 (15:34 +0100)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Mon, 19 Feb 2024 08:04:00 +0000 (09:04 +0100)
Remove the strict check of the with or enable value and use the
generated variable instead of our own.

Also, don't use WITH_GETRANDOM as an implicit WITH_UBIHEALTHD, split
the two autoconf/automake variables and handle them separately.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Makefile.am
configure.ac
ubi-utils/Makemodule.am

index 11647bac1e7463ee5c4bb2209caf4e5c16e82603..887ce9382e53ed00ae06443818aeb6b50663375a 100644 (file)
@@ -27,10 +27,6 @@ if WITH_CRYPTO
 AM_CPPFLAGS += -DWITH_CRYPTO
 endif
 
-if WITH_GETRANDOM
-AM_CPPFLAGS += -DWITH_GETRANDOM
-endif
-
 sbin_PROGRAMS =
 sbin_SCRIPTS =
 check_PROGRAMS =
index e81d0bb80779f50e6cb4833ae1dd4274706a50d4..d2c5c54c01ff0a9ec57d27796b160ab123fac7f3 100644 (file)
@@ -6,14 +6,9 @@ AC_INIT([mtd-utils], [RELEASE], [linux-mtd@lists.infradead.org], mtd-utils)
 
 AC_ARG_ENABLE([unit-tests],
        [AS_HELP_STRING([--enable-unit-tests], [Compile unit test programs])],
-       [case "${enableval}" in
-       yes) AM_CONDITIONAL([UNIT_TESTS], [true]) ;;
-       no)  AM_CONDITIONAL([UNIT_TESTS], [false]) ;;
-       *) AC_MSG_ERROR([bad value ${enableval} for --enable-unit-tests]) ;;
-       esac],
-       [AM_CONDITIONAL([UNIT_TESTS], [false])])
+       [], [enable_unit_tests="no"])
 
-AM_COND_IF([UNIT_TESTS], [: ${CFLAGS=""}], [])
+AS_IF([test "x$enable_unit_tests" = "xyes"], [: ${CFLAGS=""}], [])
 
 
 AC_CONFIG_MACRO_DIR([m4])
@@ -62,68 +57,28 @@ AC_SUBST([WARN_CFLAGS])
 
 ###### handle configure switches, select dependencies ######
 
-need_clock_gettime="no"
-need_pthread="no"
-need_uuid="no"
-need_cmocka="no"
-
-AM_COND_IF([UNIT_TESTS], [
-       need_cmocka="yes"
-])
-
-
-AC_ARG_ENABLE([tests],
-       [AS_HELP_STRING([--disable-tests], [Compile test programs])],
-       [case "${enableval}" in
-       yes) AM_CONDITIONAL([BUILD_TESTS], [true]) ;;
-       no)  AM_CONDITIONAL([BUILD_TESTS], [false]) ;;
-       *) AC_MSG_ERROR([bad value ${enableval} for --disable-tests]) ;;
-       esac],
-       [AM_CONDITIONAL([BUILD_TESTS], [true])])
-
-AM_COND_IF([BUILD_TESTS], [
-       need_clock_gettime="yes"
-       need_pthread="yes"
-])
+AC_ARG_WITH([tests],
+       [AS_HELP_STRING([--without-tests], [Compile test programs])],
+       [], [with_tests="yes"])
 
 AC_DEFINE_DIR(TESTBINDIR, libexecdir/mtd-utils,
              [Path where test and debug programs will be installed])
 
 AC_ARG_ENABLE([ubihealthd],
        [AS_HELP_STRING([--enable-ubihealthd], [Build the ubihealthd program])],
-       [need_getrandom="${enableval}"],[need_getrandom="auto"])
+       [], [enable_ubihealthd="yes"])
 
-AC_ARG_ENABLE([lsmtd],
-       [AS_HELP_STRING([--disable-lsmtd], [Do not build the lsmtd program])],
-       [case "${enableval}" in
-       yes) AM_CONDITIONAL([BUILD_LSMTD], [true]) ;;
-       no)  AM_CONDITIONAL([BUILD_LSMTD], [false]) ;;
-       *) AC_MSG_ERROR([bad value ${enableval} for --disable-lsmtd]) ;;
-       esac],
-       [AM_CONDITIONAL([BUILD_LSMTD], [true])])
+AC_ARG_WITH([lsmtd],
+       [AS_HELP_STRING([--without-lsmtd], [Do not build the lsmtd program])],
+       [], [with_lsmtd="yes"])
 
 AC_ARG_WITH([jffs],
        [AS_HELP_STRING([--without-jffs], [Disable jffsX utilities])],
-       [case "${withval}" in
-       yes) AM_CONDITIONAL([BUILD_JFFSX], [true]) ;;
-       no)  AM_CONDITIONAL([BUILD_JFFSX], [false]) ;;
-       *) AC_MSG_ERROR([bad value ${withval} for --without-jffs]) ;;
-       esac],
-       [AM_CONDITIONAL([BUILD_JFFSX], [true])])
+       [], [with_jffs="yes"])
 
 AC_ARG_WITH([ubifs],
        [AS_HELP_STRING([--without-ubifs], [Disable ubifs utilities])],
-       [case "${withval}" in
-       yes) AM_CONDITIONAL([BUILD_UBIFS], [true]) ;;
-       no)  AM_CONDITIONAL([BUILD_UBIFS], [false]) ;;
-       *) AC_MSG_ERROR([bad value ${withval} for --without-ubifs]) ;;
-       esac],
-       [AM_CONDITIONAL([BUILD_UBIFS], [true])])
-
-AM_COND_IF([BUILD_UBIFS], [
-       need_uuid="yes"
-       AS_VAR_IF([need_getrandom], [auto], [need_getrandom="yes"])
-])
+       [], [with_ubifs="yes"])
 
 AC_ARG_WITH([zlib],
        [AS_HELP_STRING([--with-zlib], [Support zlib deflate compression])],
@@ -152,12 +107,36 @@ AC_ARG_WITH([crypto],
 
 ##### search for dependencies #####
 
+need_clock_gettime="no"
+need_pthread="no"
+need_uuid="no"
+need_cmocka="no"
+need_getrandom="no"
+
 clock_gettime_missing="no"
 pthread_missing="no"
 uuid_missing="no"
 cmocka_missing="no"
 getrandom_missing="no"
 
+AS_IF([test "x$enable_unit_tests" = "xyes"], [
+       need_cmocka="yes"
+])
+
+AS_IF([test "x$with_tests" = "xyes"], [
+       need_clock_gettime="yes"
+       need_pthread="yes"
+])
+
+AS_IF([test "x$enable_ubihealthd" = "xyes"], [
+       need_getrandom="yes"
+])
+
+AS_IF([test "x$with_ubifs" = "xyes"], [
+       need_uuid="yes"
+       need_getrandom="yes"
+])
+
 AS_IF([test "x$with_zlib" != "xno"], [
        PKG_CHECK_MODULES(ZLIB, [zlib], [with_zlib="yes"],
                                [AS_IF([test "x$with_zlib" != "xcheck"],
@@ -270,7 +249,7 @@ fi
 
 if test "x$getrandom_missing" = "xyes"; then
        AC_MSG_WARN([cannot find headers for getrandom() function])
-       AC_MSG_WARN([disabling UBIFS ubihealthd support])
+       AC_MSG_NOTICE([mkfs.ubifs, ubihealthd can optionally be disabled])
        need_getrandom="no"
 fi
 
@@ -292,7 +271,13 @@ 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$with_crypto" = "xyes"])
-AM_CONDITIONAL([WITH_GETRANDOM], [test "x$need_getrandom" = "xyes"])
+AM_CONDITIONAL([WITH_UBIHEALTHD], [test "x$enable_ubihealthd" = "xyes"])
+
+AM_CONDITIONAL([BUILD_UBIFS], [test "x$with_ubifs" = "xyes"])
+AM_CONDITIONAL([BUILD_JFFSX], [test "x$with_jffs" = "xyes"])
+AM_CONDITIONAL([BUILD_LSMTD], [test "x$with_lsmtd" = "xyes"])
+AM_CONDITIONAL([BUILD_TESTS], [test "x$with_tests" = "xyes"])
+AM_CONDITIONAL([UNIT_TESTS], [test "x$enable_unit_tests" = "xyes"])
 
 AC_CHECK_SIZEOF([off_t])
 AC_CHECK_SIZEOF([loff_t])
index 7183ec3c20444df80d0f766c5f0b88c100db5f83..66c0238f67ae0bf934523e94b6fc2f9057023610 100644 (file)
@@ -40,16 +40,14 @@ ubirsvol_LDADD = libmtd.a libubi.a
 ubiblock_SOURCES = ubi-utils/ubiblock.c
 ubiblock_LDADD = libmtd.a libubi.a
 
-if WITH_GETRANDOM
 ubihealthd_SOURCES = ubi-utils/ubihealthd.c
 ubihealthd_LDADD = libmtd.a libubi.a
-endif
 
 sbin_PROGRAMS += \
        ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \
        ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol ubiblock ubiscan
 
-if WITH_GETRANDOM
+if WITH_UBIHEALTHD
 sbin_PROGRAMS += ubihealthd
 endif