From 602519db1272bc3eee8b71f05f97fe3c9c8bc2d9 Mon Sep 17 00:00:00 2001 From: CismonX Date: Sat, 12 Jul 2025 12:53:16 +0800 Subject: [PATCH] build: misc refactor EX_DEP(): - Do not generate feature check code if `feat-names` is empty. - Improve docs. others: - Reuse `$host_os` for system type check result. --- configure.ac | 10 +++++----- m4/configure_ext.m4 | 14 ++++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 0cf4d05..6bbed6c 100644 --- a/configure.ac +++ b/configure.ac @@ -23,11 +23,11 @@ LT_INIT([disable-static dlopen]) AC_CANONICAL_HOST AS_CASE(["${host_os}"], [linux*], [ - AS_VAR_SET([host_os_is_linux], [yes]) + AS_VAR_SET([host_os], [linux]) ], [freebsd*], [ - AS_VAR_SET([host_os_is_freebsd], [yes]) + AS_VAR_SET([host_os], [freebsd]) ], [ - AC_MSG_ERROR(m4_normalize([Unsupported platform "${host_os}".])) + AC_MSG_ERROR([Unsupported platform "${host_os}".]) ]) # -- Checks for programs -- @@ -54,7 +54,7 @@ EX_FEAT([bookmarkfs-mount], [NE], [the mount.bookmarkfs program], [ EX_FEAT([sandbox], [YDE], [sandboxing]) -AS_VAR_IF([host_os_is_linux], [yes], [ +AS_VAR_IF([host_os], [linux], [ EX_FEAT([sandbox-landlock], [YD], [using Landlock for sandboxing]) ]) @@ -95,7 +95,7 @@ AX_PTHREAD EX_DEP([fuse3], [>= 3.5], [fuse3 library], , [bookmarkfs-mount]) -AS_VAR_IF([host_os_is_linux], [yes], [ +AS_VAR_IF([host_os], [linux], [ EX_DEP([libseccomp], [>= 2.5], [libseccomp library], , [sandbox]) ]) diff --git a/m4/configure_ext.m4 b/m4/configure_ext.m4 index a6c07ad..e153dd4 100644 --- a/m4/configure_ext.m4 +++ b/m4/configure_ext.m4 @@ -48,33 +48,35 @@ AC_DEFUN([EX_FEAT], [ ]) dnl -dnl EX_DEP(pkg-name, version, pkg-desc, [action-if-found], -dnl [required-by-features]...) +dnl EX_DEP(pkg-name, version, pkg-desc, [action-if-found], [feat-names]...) dnl dnl Check whether a package exists with `pkg-config`, dnl and provide an option to specify the package's custom install location. dnl +dnl If at least one feature specified in `feat-names` is enabled, +dnl automatically enable checking the package, and fail if not found. +dnl AC_DEFUN([EX_DEP], [ AC_ARG_WITH([$1], m4_normalize([ AS_HELP_STRING([--with-m4_translit([$1], [_], [-])[[=PKGCONFIGDIR]]], [pkg-config search path for $3]) ]), , [ AS_VAR_SET([with_$1], [no]) - m4_foreach([feat_name_], [m4_shiftn(4, $@)], [ + m4_ifnblank([$5], m4_foreach([feat_name_], [m4_shiftn(4, $@)], [ AS_VAR_IF([enable_]m4_translit(feat_name_, [-], [_]), [yes], [ AS_VAR_SET([with_$1], [yes]) ]) - ]) + ])) ]) AS_VAR_IF([with_$1], [no], [ - m4_foreach([feat_name_], [m4_shiftn(4, $@)], [ + m4_ifnblank([$5], m4_foreach([feat_name_], [m4_shiftn(4, $@)], [ AS_VAR_IF([enable_]m4_translit(feat_name_, [-], [_]), [yes], [ AC_MSG_ERROR(m4_normalize([ Bad option '[--without-]feat_name_'. The $3 is mandatory for AS_VAR_GET([desc_]m4_translit(feat_name_, [-], [_])). ])) ]) - ]) + ])) ], [ AS_VAR_SET([old_pkg_config_path_], ["${PKG_CONFIG_PATH}"]) AS_VAR_IF([with_$1], [yes], , [