From 1f4acb322a01737692cbcfed30125385ba2b849f Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 10 Apr 2023 16:33:03 +0200 Subject: [PATCH] m4: simplify and fix issue with AC_PLUGIN() going out of bounds Signed-off-by: Joachim Wiberg --- m4/plugin.m4 | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/m4/plugin.m4 b/m4/plugin.m4 index e0959205..9a45e0db 100644 --- a/m4/plugin.m4 +++ b/m4/plugin.m4 @@ -1,8 +1,6 @@ # From https://github.com/collectd/collectd/blob/master/configure.ac # Dependency handling currently unused -define([toupper], [translit([$1], [a-z], [A-Z])]) -define([sanitize], [translit([$1], [-], [_])]) define([enadis], [ifelse([$1], [yes], [disable], [enable])]) # AC_PLUGIN(name, default, info) @@ -10,27 +8,25 @@ define([enadis], [ifelse([$1], [yes], [disable], [enable])]) AC_DEFUN([AC_PLUGIN],[ m4_divert_once([HELP_ENABLE], [ Optional Plugins:]) +define(PLUGGY, m4_translit([$1],[a-z-][A-Z-]))dnl +AC_ARG_ENABLE([$1-plugin], AS_HELP_STRING([--enadis($2)-$1-plugin], [$3]), [ + if test "x$enableval" = "xyes"; then + enable_plugin="yes" + else enable_plugin="no" - define(pluggy, sanitize($1)) - define(PLUGGY, toupper(pluggy)) - AC_ARG_ENABLE([$1-plugin], AS_HELP_STRING([--enadis($2)-$1-plugin], [$3]), [ - if test "x$enableval" = "xyes"; then - enable_plugin="yes" + fi], [ + if test "x$enable_all_plugins" = "xauto"; then + if test "x$2" = "xyes"; then + enable_plugin="yes" else - enable_plugin="no" - fi], [ - if test "x$enable_all_plugins" = "xauto"; then - if test "x$2" = "xyes"; then - enable_plugin="yes" - else - enable_plugin="no" - fi - else - enable_plugin="$enable_all_plugins" - fi]) - if test "x$enable_plugin" = "xyes"; then - AC_DEFINE([HAVE_]PLUGGY[_PLUGIN], 1, [Define to 1 if the $1 plugin is enabled.]) - plugins="$1 $plugins" + enable_plugin="no" fi - AM_CONDITIONAL([BUILD_]PLUGGY[_PLUGIN], test "x$enable_plugin" = "xyes") - enable_pluggy="$enable_plugin"]) + else + enable_plugin="$enable_all_plugins" + fi]) + if test "x$enable_plugin" = "xyes"; then + AC_DEFINE(HAVE_[]m4_translit($1,[-a-z],[_A-Z])_PLUGIN, 1, [Define to 1 if the $1 plugin is enabled.]) + plugins="$1 $plugins" + fi + +AM_CONDITIONAL(BUILD_[]m4_translit($1,[-a-z],[_A-Z])_PLUGIN, test "x$enable_plugin" = "xyes")])