virt-result.m4: Colourize summary printings

The LIBVIRT_RESULT function takes two or three arguments. The
first one is the name of the result (aka CHECK_NAME). It is
printed before the colon character. The rest of the arguments is
printed after the character. To produce colourized output a
couple of changes needs to be made.

Firstly, we need to print the CHECK_NAME using "echo -n" so that
the new line is not appended at the end of the message. To
achieve this, AS_MESSAGE_N function is introduced. It's a
verbatim copy of AS_MESSAGE (which is just another alias to
AC_MSG_NOTICE) except it doesn't put '\n' at the EOL.

The alias is defined at /usr/share/autoconf-*/autoconf/general.m4
and the AS_MESSAGE is then defined at
/usr/share/autoconf-2.69/m4sugar/m4sh.m4.

Secondly, the rest of the arguments are printed colourized and to
achieve that and also keep printing them into the log file the
_AS_ECHO and COLORIZE_RESULT functions need to be called.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2019-09-07 13:11:59 +02:00
parent c98174ce08
commit 4b3ab5d213

View File

@ -31,12 +31,27 @@ dnl eg
dnl
dnl LIBVIRT_RESULT([yajl], [yes], [-I/opt/yajl/include -lyajl])
dnl
m4_defun_init([_AS_ECHO_LOG_N],
[AS_REQUIRE([_AS_LINENO_PREPARE])],
[_AS_ECHO_N([$as_me:${as_lineno-$LINENO}: $1], AS_MESSAGE_LOG_FD)])
m4_defun_init([AS_MESSAGE_N],
[AS_REQUIRE([_AS_ME_PREPARE])],
[m4_ifval(AS_MESSAGE_LOG_FD,
[{ _AS_ECHO_LOG_N([$1])
_AS_ECHO_N([$as_me: $1], [$2]);}],
[_AS_ECHO_N([$as_me: $1], [$2])])[]])
AC_DEFUN([LIBVIRT_RESULT], [
STR=`printf "%20s: " "$1"`
if test "$2" = "no" || test -z "$3" ; then
STR=`printf "%20s: %s" "$1" "$2"`
VAL=`printf "%s" "$2"`
else
STR=`printf "%20s: %s (%s)" "$1" "$2" "$3"`
VAL=`printf "%s (%s)" "$2" "$3"`
fi
AC_MSG_NOTICE([$STR])
AS_MESSAGE_N([$STR])
_AS_ECHO([$VAL], AS_MESSAGE_LOG_FD)
COLORIZE_RESULT([$VAL])
])