configure.ac: fail when ALSA is enabled but not found
This patch adds a small autoconf M4 library which deals with auto-detected features. The default for those features is "auto", which is like the old default: if the library is present on the system, enable the feature, disable otherwise. If the user explicitly enables that feature (--enable-alsa), and the library is not present, configure must fail, because it cannot fulfill the request.
This commit is contained in:
13
configure.ac
13
configure.ac
@@ -515,7 +515,7 @@ dnl
|
|||||||
AC_ARG_ENABLE(alsa,
|
AC_ARG_ENABLE(alsa,
|
||||||
AS_HELP_STRING([--disable-alsa],
|
AS_HELP_STRING([--disable-alsa],
|
||||||
[disable ALSA support (default: enable)]),,
|
[disable ALSA support (default: enable)]),,
|
||||||
enable_alsa=yes)
|
enable_alsa=auto)
|
||||||
|
|
||||||
AC_ARG_ENABLE(ao,
|
AC_ARG_ENABLE(ao,
|
||||||
AS_HELP_STRING([--enable-ao],
|
AS_HELP_STRING([--enable-ao],
|
||||||
@@ -687,10 +687,15 @@ fi
|
|||||||
|
|
||||||
AM_CONDITIONAL(HAVE_MVP, test x$enable_mvp = xyes)
|
AM_CONDITIONAL(HAVE_MVP, test x$enable_mvp = xyes)
|
||||||
|
|
||||||
if test x$enable_alsa = xyes; then
|
if test x$enable_alsa != xno; then
|
||||||
PKG_CHECK_MODULES(ALSA, [alsa >= 0.9.0],
|
PKG_CHECK_MODULES(ALSA, [alsa >= 0.9.0],
|
||||||
AC_DEFINE(HAVE_ALSA, 1, [Define to enable ALSA support]),
|
found_alsa=yes, found_alsa=no)
|
||||||
enable_alsa=no)
|
fi
|
||||||
|
|
||||||
|
MPD_AUTO_RESULT([alsa], [ALSA output plugin], [libasound not found])
|
||||||
|
|
||||||
|
if test x$enable_alsa = xyes; then
|
||||||
|
AC_DEFINE(HAVE_ALSA, 1, [Define to enable ALSA support])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_ALSA, test x$enable_alsa = xyes)
|
AM_CONDITIONAL(HAVE_ALSA, test x$enable_alsa = xyes)
|
||||||
|
40
m4/mpd_auto.m4
Normal file
40
m4/mpd_auto.m4
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
AC_DEFUN([MPD_AUTO_ENABLED], [
|
||||||
|
var="enable_$1"
|
||||||
|
feature="$2"
|
||||||
|
|
||||||
|
if eval "test x`echo '$'$var` = xauto"; then
|
||||||
|
AC_MSG_NOTICE([auto-detected $feature])
|
||||||
|
eval "$var=yes"
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([MPD_AUTO_DISABLED], [
|
||||||
|
var="enable_$1"
|
||||||
|
feature="$2"
|
||||||
|
msg="$3"
|
||||||
|
|
||||||
|
if eval "test x`echo '$'$var` = xauto"; then
|
||||||
|
AC_MSG_WARN([$msg -- disabling $feature])
|
||||||
|
eval "$var=no"
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([$msg])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([MPD_AUTO_RESULT], [
|
||||||
|
name="$1"
|
||||||
|
var="enable_$1"
|
||||||
|
found="found_$name"
|
||||||
|
feature="$2"
|
||||||
|
msg="$3"
|
||||||
|
|
||||||
|
if eval "test x`echo '$'$var` = xno"; then
|
||||||
|
eval "$found=no"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if eval "test x`echo '$'$found` = xyes"; then
|
||||||
|
MPD_AUTO_ENABLED([$name], [$feature])
|
||||||
|
else
|
||||||
|
MPD_AUTO_DISABLED([$name], [$feature], [$msg])
|
||||||
|
fi
|
||||||
|
])
|
Reference in New Issue
Block a user