From 5675d068f8965387abac2857ff94be4394277e86 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 12 Apr 2016 23:32:52 +0200 Subject: [PATCH] m4/plugin.m4: Simplify, fix and cleanup M4 code Slightly more readable code and fix issue with --enable-$PLUGIN not biting properly in the generated Makefile. Signed-off-by: Joachim Nilsson --- m4/plugin.m4 | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/m4/plugin.m4 b/m4/plugin.m4 index c6708f54..94b6a459 100644 --- a/m4/plugin.m4 +++ b/m4/plugin.m4 @@ -1,7 +1,8 @@ # From https://github.com/collectd/collectd/blob/master/configure.ac # Dependency handling currently unused -m4_define([my_toupper], [m4_translit([$1], m4_defn([m4_cr_letters]), m4_defn([m4_cr_LETTERS]))]) +m4_define([toupper], [translit([$1], [a-z], [A-Z])]) +m4_define([sanitize], [translit([$1], [-], [_])]) # AC_PLUGIN(name, default, info) # ------------------------------------------------------------ @@ -9,16 +10,14 @@ AC_DEFUN([AC_PLUGIN],[ m4_divert_once([HELP_ENABLE], [ Optional Plugins:]) enable_plugin="no" - force="no" - AC_ARG_ENABLE([$1], AS_HELP_STRING([--enable-$1-plugin], [$3]), [ + define(pluggy, sanitize($1)) + define(PLUGGY, toupper(pluggy)) + AC_ARG_ENABLE([$1-plugin], AS_HELP_STRING([--enable-$1-plugin], [$3]), [ if test "x$enableval" = "xyes"; then enable_plugin="yes" - else if test "x$enableval" = "xforce"; then - enable_plugin="yes" - force="yes" else - enable_plugin="no (disabled on command line)" - fi; fi], [ + enable_plugin="no" + fi], [ if test "x$enable_all_plugins" = "xauto"; then if test "x$2" = "xyes"; then enable_plugin="yes" @@ -29,15 +28,7 @@ Optional Plugins:]) enable_plugin="$enable_all_plugins" fi]) if test "x$enable_plugin" = "xyes"; then - if test "x$2" = "xyes" || test "x$force" = "xyes"; then - AC_DEFINE([HAVE_PLUGIN_]my_toupper([$1]), 1, [Define to 1 if the $1 plugin is enabled.]) - if test "x$2" != "xyes"; then - dependency_warning="yes" - fi - else # User passed "yes" but dependency checking yielded "no" => Dependency problem. - dependency_error="yes" - enable_plugin="no (dependency error)" - fi + AC_DEFINE([HAVE_]PLUGGY[_PLUGIN], 1, [Define to 1 if the $1 plugin is enabled.]) fi - AM_CONDITIONAL([BUILD_PLUGIN_]my_toupper([$1]), test "x$enable_plugin" = "xyes") - enable_$1="$enable_plugin"])# AC_ARG_ENABLE + AM_CONDITIONAL([BUILD_]PLUGGY[_PLUGIN], test "x$enable_plugin" = "xyes") + enable_pluggy="$enable_plugin"])# AC_ARG_ENABLE