aboutsummaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--m4/faad.m473
-rw-r--r--m4/mpd_auto.m4176
-rw-r--r--m4/mpd_define_conditional.m48
-rw-r--r--m4/mpd_func.m42
-rw-r--r--m4/mpd_with_flags.m423
-rw-r--r--m4/pretty_print.m412
6 files changed, 153 insertions, 141 deletions
diff --git a/m4/faad.m4 b/m4/faad.m4
deleted file mode 100644
index 9dcb1ccab..000000000
--- a/m4/faad.m4
+++ /dev/null
@@ -1,73 +0,0 @@
-AC_DEFUN([AM_PATH_FAAD],
-[dnl ##
-dnl faad
-dnl ##
-
-AC_ARG_ENABLE(aac,
- AS_HELP_STRING([--disable-aac],
- [disable AAC support (default: enable)]),,
- enable_aac=yes)
-
-if test x$enable_aac = xyes; then
- FAAD_LIBS="-lfaad"
- FAAD_CFLAGS=""
-
- oldcflags=$CFLAGS
- oldlibs=$LIBS
- oldcppflags=$CPPFLAGS
- CFLAGS="$CFLAGS $FAAD_CFLAGS"
- LIBS="$LIBS $FAAD_LIBS"
- CPPFLAGS=$CFLAGS
- AC_CHECK_HEADER(faad.h,,enable_aac=no)
- if test x$enable_aac = xyes; then
- AC_CHECK_DECL(FAAD2_VERSION,,enable_aac=no,[#include <faad.h>])
- fi
- if test x$enable_aac = xyes; then
- AC_CHECK_LIB(faad,NeAACDecInit2,,enable_aac=no)
- fi
- if test x$enable_aac = xyes; then
- AC_MSG_CHECKING(that FAAD2 can even be used)
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
-#include <faad.h>
-
-int main() {
- char buffer;
- NeAACDecHandle decoder;
- NeAACDecFrameInfo frameInfo;
- NeAACDecConfigurationPtr config;
- unsigned char channels;
- long sampleRate;
- long bufferlen = 0;
-
- decoder = NeAACDecOpen();
- config = NeAACDecGetCurrentConfiguration(decoder);
- config->outputFormat = FAAD_FMT_16BIT;
- NeAACDecSetConfiguration(decoder,config);
- NeAACDecInit(decoder,&buffer,bufferlen,&sampleRate,&channels);
- NeAACDecInit2(decoder,&buffer,bufferlen,&sampleRate,&channels);
- NeAACDecDecode(decoder,&frameInfo,&buffer,bufferlen);
- NeAACDecClose(decoder);
-
- return 0;
-}
-])],AC_MSG_RESULT(yes),[AC_MSG_RESULT(no);enable_aac=no])
- fi
- if test x$enable_aac = xyes; then
- AC_DEFINE(HAVE_FAAD,1,[Define to use FAAD2 for AAC decoding])
- else
- AC_MSG_WARN([faad2 lib needed for MP4/AAC support -- disabling MP4/AAC support])
- fi
- CFLAGS=$oldcflags
- LIBS=$oldlibs
- CPPFLAGS=$oldcppflags
-fi
-
-if test x$enable_aac = xno; then
- FAAD_LIBS=""
- FAAD_CFLAGS=""
-fi
-
-AC_SUBST(FAAD_CFLAGS)
-AC_SUBST(FAAD_LIBS)
-
-])
diff --git a/m4/mpd_auto.m4 b/m4/mpd_auto.m4
index ff922fadc..56957c854 100644
--- a/m4/mpd_auto.m4
+++ b/m4/mpd_auto.m4
@@ -1,23 +1,18 @@
+dnl Parameters: varname1, description
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"
+ if test x$[]enable_$1 = xauto; then
+ AC_MSG_NOTICE([auto-detected $2])
+ enable_$1=yes
fi
])
+dnl Parameters: varname1, description, errmsg
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"
- elif eval "test x`echo '$'$var` = xyes"; then
- AC_MSG_ERROR([$feature: $msg])
+ if test x$[]enable_$1 = xauto; then
+ AC_MSG_WARN([$3 -- disabling $2])
+ enable_$1=no
+ elif test x$[]enable_$1 = xyes; then
+ AC_MSG_ERROR([$2: $3])
fi
])
@@ -25,59 +20,59 @@ 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 detection; it assumes that more checks will follow.
AC_DEFUN([MPD_AUTO_PRE], [
- name="$1"
- var="enable_$1"
- 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])
+ if test x$[]enable_$1 != xno && test x$[]found_$1 = xno; then
+ MPD_AUTO_DISABLED([$1], [$2], [$3])
fi
])
+dnl Evaluate a check's result. Abort if the feature was requested
+dnl explicitly but is unavailable.
+dnl
+dnl Parameters: varname1, description, errmsg
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"
+ if test x$[]enable_$1 = xno; then
+ found_$1=no
fi
- if eval "test x`echo '$'$found` = xyes"; then
- MPD_AUTO_ENABLED([$name], [$feature])
+ if test x$[]found_$1 = xyes; then
+ MPD_AUTO_ENABLED([$1], [$2])
else
- MPD_AUTO_DISABLED([$name], [$feature], [$msg])
+ MPD_AUTO_DISABLED([$1], [$2], [$3])
fi
])
-AC_DEFUN([MPD_AUTO_PKG], [
- if eval "test x`echo '$'enable_$1` != xno"; then
- PKG_CHECK_MODULES([$2], [$3],
- [eval "found_$1=yes"],
- [eval "found_$1=no"])
+dnl Invoke a check if its configuration is "yes" or "auto" and call
+dnl MPD_AUTO_RESULT.
+dnl
+dnl Parameters: varname1, description, errmsg, check
+AC_DEFUN([MPD_AUTO], [
+ if test x$[]enable_$1 != xno; then
+ $4
fi
+ MPD_AUTO_RESULT([$1], [$2], [$3])
+])
- MPD_AUTO_RESULT([$1], [$4], [$5])
+dnl Wrapper for MPD_AUTO and PKG_CHECK_MODULES.
+dnl
+dnl Parameters: varname1, varname2, pkgname, description, errmsg
+AC_DEFUN([MPD_AUTO_PKG], [
+ MPD_AUTO([$1], [$4], [$5],
+ [PKG_CHECK_MODULES([$2], [$3],
+ [found_$1=yes],
+ [found_$1=no])])
])
dnl Check with pkg-config first, fall back to AC_CHECK_LIB.
dnl
dnl Parameters: varname1, varname2, pkgname, libname, symname, libs, cflags, description, errmsg
AC_DEFUN([MPD_AUTO_PKG_LIB], [
- if eval "test x`echo '$'enable_$1` != xno"; then
- PKG_CHECK_MODULES([$2], [$3],
- [eval "found_$1=yes"],
+ MPD_AUTO([$1], [$8], [$9],
+ [PKG_CHECK_MODULES([$2], [$3],
+ [found_$1=yes],
AC_CHECK_LIB($4, $5,
- [eval "found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'"],
- [eval "found_$1=no"],
- [$6]))
- fi
-
- MPD_AUTO_RESULT([$1], [$8], [$9])
+ [found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'],
+ [found_$1=no],
+ [$6]))])
])
dnl Wrapper for AC_CHECK_LIB.
@@ -87,12 +82,81 @@ AC_DEFUN([MPD_AUTO_LIB], [
AC_SUBST([$2_LIBS], [])
AC_SUBST([$2_CFLAGS], [])
- if eval "test x`echo '$'enable_$1` != xno"; then
- AC_CHECK_LIB($3, $4,
- [eval "found_$1=yes $2_LIBS='$5' $2_CFLAGS='$6'"],
- [eval "found_$1=no"],
- [$5])
- fi
+ MPD_AUTO([$1], [$7], [$8],
+ [AC_CHECK_LIB($3, $4,
+ [found_$1=yes $2_LIBS='$5' $2_CFLAGS='$6'],
+ [found_$1=no],
+ [$5])])
+])
+
+dnl Convert the given string into a string for the "default value" in
+dnl the help text. If the string is a literal, then it is returned
+dnl as-is; if it contains a variable reference, just "auto" is
+dnl emitted.
+dnl
+dnl Parameters: varname1
+AC_DEFUN([MPD_FORMAT_DEFAULT],
+ [ifelse([$1], [], [auto],
+ index([$1], [$]), [-1], [$1],
+ [auto])])
+
+dnl Wrapper for AC_ARG_ENABLE, AC_DEFINE and AM_CONDITIONAL
+dnl
+dnl Parameters: varname1, varname2, description, default, check
+AC_DEFUN([MPD_ARG_ENABLE], [
+ AC_ARG_ENABLE(translit([$1], [_], [-]),
+ AS_HELP_STRING([--enable-]translit([$1], [_], [-]),
+ [enable $3 (default: ]MPD_FORMAT_DEFAULT([$4])[)]),,
+ [enable_$1=]ifelse([$4], [], [auto], [$4]))
+
+ $5
- MPD_AUTO_RESULT([$1], [$7], [$8])
+ MPD_DEFINE_CONDITIONAL(enable_$1, ENABLE_$2, [$3])
+])
+
+dnl Wrapper for MPD_ARG_ENABLE and MPD_AUTO
+dnl
+dnl Parameters: varname1, varname2, description, errmsg, default, check
+AC_DEFUN([MPD_ENABLE_AUTO], [
+ MPD_ARG_ENABLE([$1], [$2], [$3], [$5], [
+ MPD_AUTO([$1], [$3], [$4], [$6])
+ ])
+])
+
+dnl Wrapper for AC_ARG_ENABLE and MPD_AUTO_PKG
+dnl
+dnl Parameters: varname1, varname2, pkg, description, errmsg, default, pre
+AC_DEFUN([MPD_ENABLE_AUTO_PKG], [
+ MPD_ARG_ENABLE([$1], [$2], [$4], [$6], [
+ $7
+ MPD_AUTO_PKG($1, $2, $3, $4, $5)
+ ])
+])
+
+dnl Wrapper for AC_ARG_ENABLE and MPD_AUTO_PKG_LIB
+dnl
+dnl Parameters: varname1, varname2, pkg, libname, symname, libs, cflags, description, errmsg, default, pre
+AC_DEFUN([MPD_ENABLE_AUTO_PKG_LIB], [
+ MPD_ARG_ENABLE([$1], [$2], [$8], [$10], [
+ $11
+ MPD_AUTO_PKG_LIB($1, $2, $3, $4, $5, $6, $7, $8, $9)
+ ])
+])
+
+dnl Wrapper for AC_ARG_ENABLE and MPD_AUTO_LIB
+dnl
+dnl Parameters: varname1, varname2, libname, symname, libs, cflags, description, errmsg, default, pre
+AC_DEFUN([MPD_ENABLE_AUTO_LIB], [
+ MPD_ARG_ENABLE([$1], [$2], [$7], [$9], [
+ $10
+ MPD_AUTO_LIB($1, $2, $3, $4, $5, $6, $7, $8)
+ ])
+])
+
+dnl Wrapper for MPD_ENABLE_AUTO_PKG and MPD_DEPENDS
+dnl
+dnl Parameters: varname1, varname2, pkg, description, errmsg, default, dep_variable, dep_errmsg
+AC_DEFUN([MPD_ENABLE_AUTO_PKG_DEPENDS], [
+ MPD_ENABLE_AUTO_PKG([$1], [$2], [$3], [$4], [$5], [$6],
+ [MPD_DEPENDS([enable_$1], [$7], [$8])])
])
diff --git a/m4/mpd_define_conditional.m4 b/m4/mpd_define_conditional.m4
new file mode 100644
index 000000000..4bc849984
--- /dev/null
+++ b/m4/mpd_define_conditional.m4
@@ -0,0 +1,8 @@
+dnl Wrapper for AC_DEFINE and AM_CONDITIONAL
+dnl
+dnl Parameters: varname1, varname2, description
+AC_DEFUN([MPD_DEFINE_CONDITIONAL], [dnl
+ AM_CONDITIONAL($2, test x$[]$1 = xyes)
+ if test x$[]$1 = xyes; then
+ AC_DEFINE($2, 1, [Define to enable $3])
+ fi])
diff --git a/m4/mpd_func.m4 b/m4/mpd_func.m4
index 5f2bf8f3d..757cd3b6f 100644
--- a/m4/mpd_func.m4
+++ b/m4/mpd_func.m4
@@ -6,7 +6,7 @@ AC_DEFUN([MPD_OPTIONAL_FUNC], [
AC_ARG_ENABLE([$1],
AS_HELP_STRING([--enable-$1],
[use the function "$1" (default: auto)]),
- [test xenable_$1 = xyes && AC_DEFINE([$3], 1, [Define to use $1])],
+ [test x$[]enable_$1 = xyes && AC_DEFINE([$3], 1, [Define to use $1])],
[AC_CHECK_FUNC([$2],
[AC_DEFINE([$3], 1, [Define to use $1])],)])
])
diff --git a/m4/mpd_with_flags.m4 b/m4/mpd_with_flags.m4
new file mode 100644
index 000000000..4f82b7973
--- /dev/null
+++ b/m4/mpd_with_flags.m4
@@ -0,0 +1,23 @@
+dnl Run code with the specified CFLAGS/CXXFLAGS and LIBS appended.
+dnl Restores the old values afterwards.
+dnl
+dnl Parameters: cflags, libs, code
+AC_DEFUN([MPD_WITH_FLAGS], [
+ ac_save_CFLAGS="$[]CFLAGS"
+ ac_save_CXXFLAGS="$[]CXXFLAGS"
+ ac_save_LIBS="$[]LIBS"
+ CFLAGS="$[]CFLAGS $1"
+ CXXFLAGS="$[]CXXFLAGS $1"
+ LIBS="$[]LIBS $2"
+ $3
+ CFLAGS="$[]ac_save_CFLAGS"
+ CXXFLAGS="$[]ac_save_CXXFLAGS"
+ LIBS="$[]ac_save_LIBS"
+])
+
+dnl Run code with the specified library's CFLAGS/CXXFLAGS and LIBS
+dnl appended. Restores the old values afterwards.
+dnl
+dnl Parameters: libname, code
+AC_DEFUN([MPD_WITH_LIBRARY],
+ [MPD_WITH_FLAGS([$[]$1_CFLAGS], [$[]$1_LIBS], [$2])])
diff --git a/m4/pretty_print.m4 b/m4/pretty_print.m4
index 687dceefe..75df7228e 100644
--- a/m4/pretty_print.m4
+++ b/m4/pretty_print.m4
@@ -1,16 +1,6 @@
AC_DEFUN([results], [
- dnl This is a hack to allow "with" names, otherwise "enable".
- num=`expr $1 : 'with'`
- if test "$num" != "0"; then
- var="`echo '$'$1`"
- else
- var="`echo '$'enable_$1`"
- fi
-
printf '('
- if eval "test x$var = xyes"; then
- printf '+'
- elif test -n "$3" && eval "test x$var = x$3"; then
+ if test x$[]enable_$1 = xyes; then
printf '+'
else
printf '-'