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 <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-04-12 23:32:52 +02:00
parent 4baf2611f6
commit 5675d068f8
+10 -19
View File
@@ -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