# 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], [-], [_])])

# AC_PLUGIN(name, default, info)
# ------------------------------------------------------------
AC_DEFUN([AC_PLUGIN],[
    m4_divert_once([HELP_ENABLE], [
Optional Plugins:])
    enable_plugin="no"
    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
             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.])
    fi
    AM_CONDITIONAL([BUILD_]PLUGGY[_PLUGIN], test "x$enable_plugin" = "xyes")
    enable_pluggy="$enable_plugin"])

# 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)
# ------------------------------------------------------------
AC_DEFUN([AC_PLUGIN],[
    m4_divert_once([HELP_ENABLE], [
Optional Plugins:])
    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"
    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.])
    fi
    AM_CONDITIONAL([BUILD_]PLUGGY[_PLUGIN], test "x$enable_plugin" = "xyes")
    enable_pluggy="$enable_plugin"])

Fix default handling in M4 macro AC_PLUGIN()
Fix default handling in M4 macro AC_PLUGIN()

The AC_PLUGIN() could not properly handle if a plugin is to be enabled
by default.  This patch adds support for outputting the correct help
text.

Signed-off-by: Joachim Nilsson <583c295fd7602c168ad814279bbc3894ba65f5d6@gmail.com>
