mpd_auto.m4 4.38 KB
Newer Older
1
dnl Parameters: varname1, description
2
AC_DEFUN([MPD_AUTO_ENABLED], [
3 4
	if test x$[]enable_$1 = xauto; then
		AC_MSG_NOTICE([auto-detected $2])
5
		enable_$1=yes
6 7 8
	fi
])

9
dnl Parameters: varname1, description, errmsg
10
AC_DEFUN([MPD_AUTO_DISABLED], [
11 12 13 14 15
	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])
16 17 18
	fi
])

19 20 21 22
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], [
23 24
	if test x$[]enable_$1 != xno && test x$[]found_$1 = xno; then
                MPD_AUTO_DISABLED([$1], [$2], [$3])
25 26 27
	fi
])

28 29 30 31
dnl Evaluate a check's result.  Abort if the feature was requested
dnl explicitly but is unavailable.
dnl
dnl Parameters: varname1, description, errmsg
32
AC_DEFUN([MPD_AUTO_RESULT], [
33 34
	if test x$[]enable_$1 = xno; then
		found_$1=no
35 36
	fi

37 38
	if test x$[]found_$1 = xyes; then
                MPD_AUTO_ENABLED([$1], [$2])
39
	else
40
                MPD_AUTO_DISABLED([$1], [$2], [$3])
41 42
	fi
])
43

44 45 46
dnl Invoke a check if its configuration is "yes" or "auto" and call
dnl MPD_AUTO_RESULT.
dnl
47 48
dnl Parameters: varname1, description, errmsg, check
AC_DEFUN([MPD_AUTO], [
49
	if test x$[]enable_$1 != xno; then
50
		$4
51
	fi
52 53
	MPD_AUTO_RESULT([$1], [$2], [$3])
])
54

55 56 57
dnl Wrapper for MPD_AUTO and PKG_CHECK_MODULES.
dnl
dnl Parameters: varname1, varname2, pkgname, description, errmsg
58 59 60 61 62
AC_DEFUN([MPD_AUTO_PKG], [
	MPD_AUTO([$1], [$4], [$5],
		[PKG_CHECK_MODULES([$2], [$3],
			[found_$1=yes],
			[found_$1=no])])
63
])
64 65 66 67 68

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], [
69 70
	MPD_AUTO([$1], [$8], [$9],
		[PKG_CHECK_MODULES([$2], [$3],
71
			[found_$1=yes],
72
			AC_CHECK_LIB($4, $5,
73 74
				[found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'],
				[found_$1=no],
75
				[$6]))])
76
])
77 78 79 80 81 82 83 84

dnl Wrapper for AC_CHECK_LIB.
dnl
dnl Parameters: varname1, varname2, libname, symname, libs, cflags, description, errmsg
AC_DEFUN([MPD_AUTO_LIB], [
	AC_SUBST([$2_LIBS], [])
	AC_SUBST([$2_CFLAGS], [])

85 86
	MPD_AUTO([$1], [$7], [$8],
		[AC_CHECK_LIB($3, $4,
87 88
			[found_$1=yes $2_LIBS='$5' $2_CFLAGS='$6'],
			[found_$1=no],
89
			[$5])])
90
])
91

92 93 94 95 96 97
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
98 99 100 101 102
AC_DEFUN([MPD_FORMAT_DEFAULT],
	[ifelse([$1], [], [auto],
		index([$1], [$]), [-1], [$1],
		[auto])])

103
dnl Wrapper for AC_ARG_ENABLE, AC_DEFINE and AM_CONDITIONAL
104
dnl
105 106
dnl Parameters: varname1, varname2, description, default, check
AC_DEFUN([MPD_ARG_ENABLE], [
107 108
	AC_ARG_ENABLE(translit([$1], [_], [-]),
		AS_HELP_STRING([--enable-]translit([$1], [_], [-]),
109 110
			[enable $3 (default: ]MPD_FORMAT_DEFAULT([$4])[)]),,
		[enable_$1=]ifelse([$4], [], [auto], [$4]))
111

112
	$5
113

114
	MPD_DEFINE_CONDITIONAL(enable_$1, ENABLE_$2, [$3])
115 116
])

117 118 119 120 121 122 123 124 125
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])
	])
])

126 127 128 129 130 131 132 133 134 135
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)
	])
])

136 137 138 139
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], [
140
	MPD_ARG_ENABLE([$1], [$2], [$8], [$10], [
141 142 143
		$11
		MPD_AUTO_PKG_LIB($1, $2, $3, $4, $5, $6, $7, $8, $9)
	])
144 145
])

146 147 148 149 150 151 152 153 154 155
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)
	])
])

156 157 158 159 160 161 162
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])])
])