build: refactor feature variable exporting

- Remove EX_AMCOND() and EX_FEAT_EXPORT(), instead add flags to
  EX_FEAT() to check whether a feature should be exported.
- Only mark a feature to be exported with AM_CONDITIONAL() when
  it is checked within either */Makefile.am or tests/atlocal.in.
- Only add a feature to test/atlocal.in when it is checked by
  ATX_FEAT_*().
- Move feature "bookmarkfs-util" after features that may enable it,
  so that its enable status can be correctly displayed.
This commit is contained in:
CismonX 2025-07-12 12:52:28 +08:00
parent 300e3d889a
commit 296b85cbe9
No known key found for this signature in database
GPG key ID: 3094873E29A482FB
3 changed files with 51 additions and 81 deletions

View file

@ -39,59 +39,60 @@ AC_PROG_MAKE_SET
# -- Checks for features --
EX_FEAT([bookmarkfs-util], [no], [the BookmarkFS utility library], , [1])
EX_FEAT([bookmarkctl], [NE], [the bookmarkctl program])
EX_FEAT([bookmarkctl], [no], [the bookmarkctl program], , [1])
EX_FEAT([bookmarkfs-fsck], [no], [the fsck.bookmarkfs program], [
EX_FEAT([bookmarkfs-fsck], [NE], [the fsck.bookmarkfs program], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
AS_VAR_SET([enable_interactive_fsck], [yes])
], [1])
EX_FEAT([bookmarkfs-mkfs], [no], [the mkfs.bookmarkfs program], , [1])
EX_FEAT([bookmarkfs-mount], [no], [the mount.bookmarkfs program], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
], [1])
EX_FEAT([sandbox], [yes], [sandboxing])
AS_VAR_IF([host_os_is_linux], [yes], [
EX_FEAT([sandbox-landlock], [yes], [Landlock features for sandboxing])
])
EX_FEAT([xxhash-inline], [yes], [using xxhash as a header-only library])
EX_FEAT([bookmarkfs-mkfs], [NE], [the mkfs.bookmarkfs program])
EX_FEAT([bookmarkfs-debug], [no], [debugging features for BookmarkFS])
EX_FEAT([bookmarkfs-mount], [NE], [the mount.bookmarkfs program], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
])
EX_FEAT([backend-firefox], [no], [Firefox backend], [
EX_FEAT([sandbox], [YDE], [sandboxing])
AS_VAR_IF([host_os_is_linux], [yes], [
EX_FEAT([sandbox-landlock], [YD], [using Landlock for sandboxing])
])
EX_FEAT([xxhash-inline], [YD], [using xxhash as a header-only library])
EX_FEAT([bookmarkfs-debug], [ND], [debugging features for BookmarkFS])
EX_FEAT([backend-firefox], [NE], [Firefox backend], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
AS_VAR_SET([enable_backend_firefox_write], [yes])
], [1])
])
EX_FEAT([backend-firefox-write], , [write support for the Firefox backend])
EX_FEAT([backend-firefox-write], [DE], [write support for the Firefox backend])
EX_FEAT([backend-chromium], [no], [Chromium backend], [
EX_FEAT([backend-chromium], [NE], [Chromium backend], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
AS_VAR_SET([enable_backend_chromium_write], [yes])
], [1])
])
EX_FEAT([backend-chromium-write], , [write support for the Chromium backend])
EX_FEAT([backend-chromium-write], [DE],
[write support for the Chromium backend])
EX_FEAT([native-watcher], [yes], [platform-specific file watcher])
EX_FEAT([native-watcher], [YD], [platform-specific file watcher])
EX_FEAT([interactive-fsck], , [interactive features for fsck.bookmarkfs])
EX_FEAT([interactive-fsck], [DE], [interactive features for fsck.bookmarkfs])
EX_FEAT([fsck-handler-tcl], [no], [Tcl-based fsck handler], , [1])
EX_FEAT([fsck-handler-tcl], [NE], [Tcl-based fsck handler])
EX_FEAT([bookmarkfs-util], [E], [the BookmarkFS utility library], [
EX_DEP([bookmarkfs_util], [>= 0.1], [BookmarkFS utility library], [
AS_VAR_SET([enable_bookmarkfs_util], [no])
])
])
# -- Checks for libraries --
AX_PTHREAD
EX_DEP([bookmarkfs_util], [>= 0.1], [BookmarkFS utility library], [
AS_VAR_SET([enable_bookmarkfs_util], [no])
])
EX_DEP([fuse3], [>= 3.5], [fuse3 library], , [bookmarkfs-mount])
AS_VAR_IF([host_os_is_linux], [yes], [
@ -118,12 +119,6 @@ EX_DEP([libxxhash], [>= 0.8], [xxHash library], [
])
], [bookmarkfs-util])
EX_AMCOND([bookmarkfs-util], [bookmarkctl], [bookmarkfs-fsck],
[bookmarkfs-mkfs], [bookmarkfs-mount], [sandbox], [backend-firefox],
[backend-firefox-write], [backend-chromium], [backend-chromium-write],
[interactive-fsck], [fsck-handler-tcl])
EX_FEAT_EXPORT([bookmarkfs-debug], [sandbox-landlock], [native-watcher])
# -- Checks for compiler builtins and attributes --
AX_GCC_BUILTIN([__builtin_ctz])

View file

@ -8,24 +8,29 @@ dnl This file is offered as-is, without any warranty.
dnl
dnl
dnl EX_FEAT(feature, [default-value], description, [action-if-enabled],
dnl [no-ac-define])
dnl EX_FEAT(feat-name, flags, feat-desc, [action-if-enabled])
dnl
dnl Provide an option to enable or disable a feature.
dnl
dnl flags:
dnl - N: Disable this feature by default
dnl - Y: Enable this feature by default
dnl - D: When enabled, define a macro for this feature in config.h
dnl - E: When enabled, export this feature with AM_CONDITIONAL()
dnl
AC_DEFUN([EX_FEAT], [
m4_pushdef([arg_action_], m4_if([$2], [no], [enable], [disable]))
m4_pushdef([op_], m4_if(m4_index([$2], [N]), [-1], [disable], [enable]))
m4_pushdef([feat_name_], m4_translit([$1], [-], [_]))
AC_MSG_CHECKING(m4_normalize([if $3 is enabled]))
AC_ARG_ENABLE([$1], m4_normalize([
AS_HELP_STRING([--]arg_action_[-$1], arg_action_ [$3])
]), , m4_ifnblank([$2], [
AS_VAR_SET([enable_]feat_name_, [$2])
]))
AC_ARG_ENABLE([$1], [AS_HELP_STRING([--]op_[-$1], op_ [$3])], , [
m4_if(m4_index([$2], [Y]), [-1], , [
AS_VAR_SET([enable_]feat_name_, [yes])
])
])
AS_VAR_IF([enable_]feat_name_, [yes], [
AC_MSG_RESULT([yes])
$4
m4_ifblank([$5], [
m4_if(m4_index([$2], [D]), [-1], , [
AC_DEFINE(m4_if(m4_substr(feat_name_, 0, 10), [bookmarkfs], ,
[BOOKMARKFS_])[]m4_toupper(feat_name_),
[1], [Define to 1 if $3 is enabled.])
@ -33,8 +38,12 @@ AC_DEFUN([EX_FEAT], [
], [
AC_MSG_RESULT([no])
])
m4_if(m4_index([$2], [E]), [-1], , [
AM_CONDITIONAL(m4_translit(feat_name_, [a-z], [A-Z]),
[test x$enable_]feat_name_[ != xno])
])
AS_VAR_SET([desc_]feat_name_, ["$3"])
m4_popdef([arg_action_])
m4_popdef([op_])
m4_popdef([feat_name_])
])
@ -76,34 +85,3 @@ AC_DEFUN([EX_DEP], [
AS_VAR_SET([PKG_CONFIG_PATH], ["${old_pkg_config_path_}"])
])
])
dnl
dnl EX_AMCOND([features]...)
dnl
dnl Export feature flags to Makefile templates.
dnl
AC_DEFUN([EX_AMCOND], [
m4_foreach([feat_name_], [$@], [
AM_CONDITIONAL(m4_translit(feat_name_, [-a-z], [_A-Z]),
[test x$enable_]m4_translit(feat_name_, [-], [_])[ != xno])
])
])
dnl
dnl EX_FEAT_EXPORT([features]...)
dnl
dnl Export feature flags to Autoconf output variables,
dnl similar to the ones set by AM_CONTITIONAL() (`xxx_TRUE` only).
dnl
AC_DEFUN([EX_FEAT_EXPORT], [
m4_foreach([feat_name_], [$@], [
m4_pushdef([out_var_], m4_translit(feat_name_, [-a-z], [_A-Z])[_TRUE])
AS_VAR_IF([enable_]m4_translit(feat_name_, [-], [_]), [yes], [
AC_SUBST(out_var_, [''])
], [
AC_SUBST(out_var_, ['#'])
])
AM_SUBST_NOTMAKE(out_var_)
m4_popdef([out_var_])
])
])

View file

@ -17,12 +17,9 @@ buildsrcdir="$top_builddir/src"
@BOOKMARKFS_MKFS_TRUE@ feat_bookmarkfs_mkfs=y
@BOOKMARKFS_MOUNT_TRUE@ feat_bookmarkfs_mount=y
@SANDBOX_TRUE@ feat_sandbox=y
@SANDBOX_LANDLOCK_TRUE@ feat_sandbox_landlock=y
@BOOKMARKFS_DEBUG_TRUE@ feat_bookmarkfs_debug=y
@BACKEND_FIREFOX_TRUE@ feat_backend_firefox=y
@BACKEND_FIREFOX_WRITE_TRUE@ feat_backend_firefox_write=y
@BACKEND_CHROMIUM_TRUE@ feat_backend_chromium=y
@BACKEND_CHROMIUM_WRITE_TRUE@ feat_backend_chromium_write=y
@INTERACTIVE_FSCK_TRUE@ feat_interactive_fsck=y
@NATIVE_WATCHER_TRUE@ feat_native_watcher=y
@FSCK_HANDLER_TCL_TRUE@ feat_fsck_handler_tcl=y