m4/mpd_auto.m4: reduce "eval" bloat

Don't assign bash variables; instead, use the m4 parameters directly.
This commit is contained in:
Max Kellermann 2014-11-21 14:39:33 +01:00
parent ccf78448aa
commit cdbdcec715

View File

@ -1,23 +1,16 @@
AC_DEFUN([MPD_AUTO_ENABLED], [ AC_DEFUN([MPD_AUTO_ENABLED], [
var="enable_$1" if test x$[]enable_$1 = xauto; then
feature="$2" AC_MSG_NOTICE([auto-detected $2])
enable_$1=no
if eval "test x`echo '$'$var` = xauto"; then
AC_MSG_NOTICE([auto-detected $feature])
eval "$var=yes"
fi fi
]) ])
AC_DEFUN([MPD_AUTO_DISABLED], [ AC_DEFUN([MPD_AUTO_DISABLED], [
var="enable_$1" if test x$[]enable_$1 = xauto; then
feature="$2" AC_MSG_WARN([$3 -- disabling $2])
msg="$3" enable_$1=no
elif test x$[]enable_$1 = xyes; then
if eval "test x`echo '$'$var` = xauto"; then AC_MSG_ERROR([$2: $3])
AC_MSG_WARN([$msg -- disabling $feature])
eval "$var=no"
elif eval "test x`echo '$'$var` = xyes"; then
AC_MSG_ERROR([$feature: $msg])
fi fi
]) ])
@ -25,40 +18,28 @@ dnl Check whether a prerequisite for a feature was found. This is
dnl very similar to MPD_AUTO_RESULT, but does not finalize the dnl very similar to MPD_AUTO_RESULT, but does not finalize the
dnl detection; it assumes that more checks will follow. dnl detection; it assumes that more checks will follow.
AC_DEFUN([MPD_AUTO_PRE], [ AC_DEFUN([MPD_AUTO_PRE], [
name="$1" if test x$[]enable_$1 != xno && test x$[]found_$1 = xno; then
var="enable_$1" MPD_AUTO_DISABLED([$1], [$2], [$3])
found="found_$name"
feature="$2"
msg="$3"
if eval "test x`echo '$'$var` != xno" && eval "test x`echo '$'$found` = xno"; then
MPD_AUTO_DISABLED([$name], [$feature], [$msg])
fi fi
]) ])
AC_DEFUN([MPD_AUTO_RESULT], [ AC_DEFUN([MPD_AUTO_RESULT], [
name="$1" if test x$[]enable_$1 = xno; then
var="enable_$1" found_$1=no
found="found_$name"
feature="$2"
msg="$3"
if eval "test x`echo '$'$var` = xno"; then
eval "$found=no"
fi fi
if eval "test x`echo '$'$found` = xyes"; then if test x$[]found_$1 = xyes; then
MPD_AUTO_ENABLED([$name], [$feature]) MPD_AUTO_ENABLED([$1], [$2])
else else
MPD_AUTO_DISABLED([$name], [$feature], [$msg]) MPD_AUTO_DISABLED([$1], [$2], [$3])
fi fi
]) ])
AC_DEFUN([MPD_AUTO_PKG], [ AC_DEFUN([MPD_AUTO_PKG], [
if eval "test x`echo '$'enable_$1` != xno"; then if test x$[]enable_$1 != xno; then
PKG_CHECK_MODULES([$2], [$3], PKG_CHECK_MODULES([$2], [$3],
[eval "found_$1=yes"], [found_$1=yes],
[eval "found_$1=no"]) [found_$1=no])
fi fi
MPD_AUTO_RESULT([$1], [$4], [$5]) MPD_AUTO_RESULT([$1], [$4], [$5])
@ -68,12 +49,12 @@ dnl Check with pkg-config first, fall back to AC_CHECK_LIB.
dnl dnl
dnl Parameters: varname1, varname2, pkgname, libname, symname, libs, cflags, description, errmsg dnl Parameters: varname1, varname2, pkgname, libname, symname, libs, cflags, description, errmsg
AC_DEFUN([MPD_AUTO_PKG_LIB], [ AC_DEFUN([MPD_AUTO_PKG_LIB], [
if eval "test x`echo '$'enable_$1` != xno"; then if test x$[]enable_$1 != xno; then
PKG_CHECK_MODULES([$2], [$3], PKG_CHECK_MODULES([$2], [$3],
[eval "found_$1=yes"], [found_$1=yes],
AC_CHECK_LIB($4, $5, AC_CHECK_LIB($4, $5,
[eval "found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'"], [found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'],
[eval "found_$1=no"], [found_$1=no],
[$6])) [$6]))
fi fi
@ -87,10 +68,10 @@ AC_DEFUN([MPD_AUTO_LIB], [
AC_SUBST([$2_LIBS], []) AC_SUBST([$2_LIBS], [])
AC_SUBST([$2_CFLAGS], []) AC_SUBST([$2_CFLAGS], [])
if eval "test x`echo '$'enable_$1` != xno"; then if test x$[]enable_$1 != xno; then
AC_CHECK_LIB($3, $4, AC_CHECK_LIB($3, $4,
[eval "found_$1=yes $2_LIBS='$5' $2_CFLAGS='$6'"], [found_$1=yes $2_LIBS='$5' $2_CFLAGS='$6'],
[eval "found_$1=no"], [found_$1=no],
[$5]) [$5])
fi fi