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

AC_DEFUN([MPD_AUTO_DISABLED], [
9 10 11 12 13
	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])
14 15 16
	fi
])

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

26
AC_DEFUN([MPD_AUTO_RESULT], [
27 28
	if test x$[]enable_$1 = xno; then
		found_$1=no
29 30
	fi

31 32
	if test x$[]found_$1 = xyes; then
                MPD_AUTO_ENABLED([$1], [$2])
33
	else
34
                MPD_AUTO_DISABLED([$1], [$2], [$3])
35 36
	fi
])
37

38 39
dnl Parameters: varname1, description, errmsg, check
AC_DEFUN([MPD_AUTO], [
40
	if test x$[]enable_$1 != xno; then
41
		$4
42
	fi
43 44
	MPD_AUTO_RESULT([$1], [$2], [$3])
])
45

46 47 48 49 50
AC_DEFUN([MPD_AUTO_PKG], [
	MPD_AUTO([$1], [$4], [$5],
		[PKG_CHECK_MODULES([$2], [$3],
			[found_$1=yes],
			[found_$1=no])])
51
])
52 53 54 55 56

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], [
57 58
	MPD_AUTO([$1], [$8], [$9],
		[PKG_CHECK_MODULES([$2], [$3],
59
			[found_$1=yes],
60
			AC_CHECK_LIB($4, $5,
61 62
				[found_$1=yes $2_LIBS='$6' $2_CFLAGS='$7'],
				[found_$1=no],
63
				[$6]))])
64
])
65 66 67 68 69 70 71 72

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], [])

73 74
	MPD_AUTO([$1], [$7], [$8],
		[AC_CHECK_LIB($3, $4,
75 76
			[found_$1=yes $2_LIBS='$5' $2_CFLAGS='$6'],
			[found_$1=no],
77
			[$5])])
78
])
79

80 81 82 83 84
AC_DEFUN([MPD_FORMAT_DEFAULT],
	[ifelse([$1], [], [auto],
		index([$1], [$]), [-1], [$1],
		[auto])])

85
dnl Wrapper for AC_ARG_ENABLE, AC_DEFINE and AM_CONDITIONAL
86
dnl
87 88
dnl Parameters: varname1, varname2, description, default, check
AC_DEFUN([MPD_ARG_ENABLE], [
89 90
	AC_ARG_ENABLE(translit([$1], [_], [-]),
		AS_HELP_STRING([--enable-]translit([$1], [_], [-]),
91 92
			[enable $3 (default: ]MPD_FORMAT_DEFAULT([$4])[)]),,
		[enable_$1=]ifelse([$4], [], [auto], [$4]))
93

94
	$5
95

96
	MPD_DEFINE_CONDITIONAL(enable_$1, ENABLE_$2, [$3])
97 98
])

99 100 101 102 103 104 105 106 107 108
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)
	])
])

109 110 111 112
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], [
113
	MPD_ARG_ENABLE([$1], [$2], [$8], [$10], [
114 115 116
		$11
		MPD_AUTO_PKG_LIB($1, $2, $3, $4, $5, $6, $7, $8, $9)
	])
117 118
])

119 120 121 122 123 124 125 126 127 128
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)
	])
])

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