build: rename autoconf helper macros

These macros are supposed to be reusable for other projects.
Also, a shorter name improves the readability of the config script.
This commit is contained in:
CismonX 2025-03-14 07:44:51 +08:00
parent 2ce0be8a18
commit f6e3b743d1
No known key found for this signature in database
GPG key ID: 3094873E29A482FB
3 changed files with 42 additions and 50 deletions

View file

@ -40,76 +40,70 @@ AC_PROG_MAKE_SET
# -- Checks for features --
BOOKMARKFS_FEAT([bookmarkfs-util], [no], [the BookmarkFS utility library])
EX_FEAT([bookmarkfs-util], [no], [the BookmarkFS utility library])
BOOKMARKFS_FEAT([bookmarkctl], [no], [the bookmarkctl program])
EX_FEAT([bookmarkctl], [no], [the bookmarkctl program])
BOOKMARKFS_FEAT([bookmarkfs-fsck], [no], [the fsck.bookmarkfs program], [
EX_FEAT([bookmarkfs-fsck], [no], [the fsck.bookmarkfs program], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
])
BOOKMARKFS_FEAT([bookmarkfs-mkfs], [no], [the mkfs.bookmarkfs program])
EX_FEAT([bookmarkfs-mkfs], [no], [the mkfs.bookmarkfs program])
BOOKMARKFS_FEAT([bookmarkfs-mount], [no], [the mount.bookmarkfs program], [
EX_FEAT([bookmarkfs-mount], [no], [the mount.bookmarkfs program], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
])
BOOKMARKFS_FEAT([sandbox], [yes], [sandboxing], [
EX_FEAT([sandbox], [yes], [sandboxing], [
AC_DEFINE([BOOKMARKFS_SANDBOX], [1],
[Define to 1 if sandboxing is enabled.])
])
AS_VAR_IF([host_os_is_linux], [yes], [
BOOKMARKFS_FEAT([sandbox-landlock], [yes],
[Linux Landlock features for sandboxing],
[
EX_FEAT([sandbox-landlock], [yes], [Landlock features for sandboxing], [
AC_DEFINE([BOOKMARKFS_SANDBOX_LANDLOCK], [1],
[Define to 1 if Landlock is enabled for sandboxing.])
])
])
BOOKMARKFS_FEAT([xxhash-inline], [no],
[using xxhash as a header-only library],
[
EX_FEAT([xxhash-inline], [no], [using xxhash as a header-only library], [
AC_DEFINE([BOOKMARKFS_XXHASH_INLINE], [1],
[Define to 1 if using xxhash as a header-only library.])
])
BOOKMARKFS_FEAT([bookmarkfs-debug], [no],
[debugging features for BookmarkFS],
[
EX_FEAT([bookmarkfs-debug], [no], [debugging features for BookmarkFS], [
AC_DEFINE([BOOKMARKFS_DEBUG], [1],
[Define to 1 if BookmarkFS debugging is enabled.])
])
BOOKMARKFS_FEAT([backend-firefox], [no], [Firefox backend], [
EX_FEAT([backend-firefox], [no], [Firefox backend], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
])
BOOKMARKFS_FEAT([backend-firefox-write], [yes],
EX_FEAT([backend-firefox-write], [yes],
[write support for the Firefox backend],
[
AC_DEFINE([BOOKMARKFS_BACKEND_FIREFOX_WRITE], [1],
[Define to 1 if the Firefox backend supports writing.])
])
BOOKMARKFS_FEAT([backend-chromium], [no], [Chromium backend], [
EX_FEAT([backend-chromium], [no], [Chromium backend], [
AS_VAR_SET([enable_bookmarkfs_util], [yes])
])
BOOKMARKFS_FEAT([backend-chromium-write], [yes],
EX_FEAT([backend-chromium-write], [yes],
[write support for the Chromium backend],
[
AC_DEFINE([BOOKMARKFS_BACKEND_CHROMIUM_WRITE], [1],
[Define to 1 if the Chromium backend supports writing.])
])
BOOKMARKFS_FEAT([native-watcher], [yes], [platform-specific file watcher], [
EX_FEAT([native-watcher], [yes], [platform-specific file watcher], [
AC_DEFINE([BOOKMARKFS_NATIVE_WATCHER], [1],
[Define to 1 if platform-specific file watcher is enabled.])
])
BOOKMARKFS_FEAT([interactive-fsck], [yes],
EX_FEAT([interactive-fsck], [yes],
[interactive features for fsck.bookmarkfs],
[
AS_VAR_IF([enable_bookmarkfs_fsck], [no], [
@ -120,49 +114,47 @@ BOOKMARKFS_FEAT([interactive-fsck], [yes],
])
])
BOOKMARKFS_FEAT([fsck-handler-tcl], [no], [Tcl-based fsck handler])
EX_FEAT([fsck-handler-tcl], [no], [Tcl-based fsck handler])
# -- Checks for libraries --
AX_PTHREAD
BOOKMARKFS_DEP([bookmarkfs], [>= 0.1], [BookmarkFS utility library], [
EX_DEP([bookmarkfs], [>= 0.1], [BookmarkFS utility library], [
AS_VAR_SET([enable_bookmarkfs_util], [no])
])
BOOKMARKFS_DEP([fuse3], [>= 3.5], [fuse3 library], , [bookmarkfs-mount])
EX_DEP([fuse3], [>= 3.5], [fuse3 library], , [bookmarkfs-mount])
AS_VAR_IF([host_os_is_linux], [yes], [
BOOKMARKFS_DEP([libseccomp], [>= 2.5], [libseccomp library], , [sandbox])
EX_DEP([libseccomp], [>= 2.5], [libseccomp library], , [sandbox])
])
BOOKMARKFS_DEP([sqlite3], [>= 3.35], [SQLite3 library], , [backend-firefox])
EX_DEP([sqlite3], [>= 3.35], [SQLite3 library], , [backend-firefox])
BOOKMARKFS_DEP([jansson], [>= 2.14], [Jansson library], , [backend-chromium])
EX_DEP([jansson], [>= 2.14], [Jansson library], , [backend-chromium])
BOOKMARKFS_DEP([nettle], [>= 3.4], [Nettle library], ,
EX_DEP([nettle], [>= 3.4], [Nettle library], ,
[backend-firefox-write], [backend-chromium-write])
BOOKMARKFS_DEP([readline], [>= 6.0], [GNU Readline library], ,
[interactive-fsck])
EX_DEP([readline], [>= 6.0], [GNU Readline library], , [interactive-fsck])
BOOKMARKFS_DEP([tcl], [>= 8.6], [Tcl library], , [fsck-handler-tcl])
EX_DEP([tcl], [>= 8.6], [Tcl library], , [fsck-handler-tcl])
BOOKMARKFS_DEP([liburiparser], [>= 0.9], [uriparser library], ,
EX_DEP([liburiparser], [>= 0.9], [uriparser library], ,
[backend-firefox-write])
BOOKMARKFS_DEP([libxxhash], [>= 0.8], [xxHash library], [
EX_DEP([libxxhash], [>= 0.8], [xxHash library], [
AS_VAR_IF([enable_xxhash_inline], [yes], [
AS_VAR_SET([LIBXXHASH_LIBS])
])
], [bookmarkfs-util])
BOOKMARKFS_AMCOND([bookmarkfs-util], [bookmarkctl], [bookmarkfs-fsck],
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])
BOOKMARKFS_FEAT_EXPORT([bookmarkfs-debug], [sandbox-landlock],
[native-watcher])
EX_FEAT_EXPORT([bookmarkfs-debug], [sandbox-landlock], [native-watcher])
# -- Checks for compiler builtins and attributes --

View file

@ -8,12 +8,12 @@ dnl This file is offered as-is, without any warranty.
dnl
dnl
dnl BOOKMARKFS_FEAT(feature, default-value, description,
dnl [action-if-enabled], [action-if-disabled])
dnl EX_FEAT(feature, default-value, description, [action-if-enabled],
dnl [action-if-disabled])
dnl
dnl Provides an option to enable or disable a feature.
dnl Provide an option to enable or disable a feature.
dnl
AC_DEFUN([BOOKMARKFS_FEAT], [
AC_DEFUN([EX_FEAT], [
m4_pushdef([arg_action_], m4_if([$2], [no], [enable], [disable]))
m4_pushdef([feat_name_], m4_translit([$1], [-], [_]))
AC_MSG_CHECKING(m4_normalize([if $3 is enabled]))
@ -35,13 +35,13 @@ AC_DEFUN([BOOKMARKFS_FEAT], [
])
dnl
dnl BOOKMARKFS_DEP(pkg-name, version, pkg-desc, [action-if-found],
dnl [required-by-features]...)
dnl EX_DEP(pkg-name, version, pkg-desc, [action-if-found],
dnl [required-by-features]...)
dnl
dnl Checks if a package exists with `pkg-config`, and provides option for
dnl the config script to specify the package's custom install location.
dnl Check whether a package exists with `pkg-config`,
dnl and provide an option to specify the package's custom install location.
dnl
AC_DEFUN([BOOKMARKFS_DEP], [
AC_DEFUN([EX_DEP], [
m4_pushdef([with_var_], [with_]m4_translit([$1], [-], [_]))
AC_ARG_WITH([$1], m4_normalize([
AS_HELP_STRING([--with-$1[[=PKGCONFIGDIR]]],
@ -76,11 +76,11 @@ AC_DEFUN([BOOKMARKFS_DEP], [
])
dnl
dnl BOOKMARKFS_AMCOND([features]...)
dnl EX_AMCOND([features]...)
dnl
dnl Export feature flags to Makefile templates.
dnl
AC_DEFUN([BOOKMARKFS_AMCOND], [
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])
@ -88,12 +88,12 @@ AC_DEFUN([BOOKMARKFS_AMCOND], [
])
dnl
dnl BOOKMARKFS_FEAT_EXPORT([features]...)
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([BOOKMARKFS_FEAT_EXPORT], [
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], [

View file

@ -16,7 +16,7 @@ dnl
dnl ATX_FEAT_VAR(feature)
dnl
dnl Expands to the shell variable indicating whether the given feature
dnl is defined by BOOKMARKFS_FEAT() and enabled during `configure`.
dnl is defined by EX_FEAT() and enabled during `configure`.
dnl
dnl A non-empty value indicates that the feature is enabled.
dnl