1 dnl Configure Paths for Alsa
2 dnl Christopher Lansdown (lansdoct@cs.alfred.edu)
4 dnl AM_PATH_ALSA(MINIMUM-VERSION)
5 dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate.
6 dnl enables arguments --with-alsa-prefix= --with-alsa-enc-prefix= --disable-alsatest
10 dnl Get the clfags and libraries for alsa
12 AC_ARG_WITH(alsa-prefix,[ --with-alsa-prefix=PFX Prefix where Alsa library is installed(optional)],
13 [alsa_prefix="$withval"], [alsa_prefix=""])
14 AC_ARG_WITH(alsa-inc-prefix, [ --with-alsa-inc-prefix=PFX Prefix where include libraries are (optional)],
15 [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
16 AC_ARG_ENABLE(alsatest, [ --disable-alsatest Do not try to compile and run a test Alsa program], [enable_alsatest=no], [enable_alsatest=yes])
18 dnl Add any special include directories
19 AC_MSG_CHECKING(for ALSA CFLAGS)
20 if test "$alsa_inc_prefix" != "" ; then
21 ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
22 CFLAGS="-I$alsa_inc_prefix"
24 AC_MSG_RESULT($ALSA_CFLAGS)
26 dnl add any special lib dirs
27 AC_MSG_CHECKING(for ALSA LDFLAGS)
28 if test "$alsa_prefix" != "" ; then
29 ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
33 dnl add the alsa library
34 ALSA_LIBS="$ALSA_LIBS -lasound -lm"
36 AC_MSG_RESULT($ALSA_LIBS)
38 dnl Check for the presence of the library
39 dnl if test $enable_alsatest = yes; then
40 dnl AC_MSG_CHECKING(for working libasound)
42 dnl #include <sys/asoundlib.h>
49 dnl [AC_MSG_RESULT("present")],
50 dnl [AC_MSG_RESULT("not found. ")
51 dnl AC_MSG_ERROR(Fatal error: Install alsa-lib package or use --with-alsa-prefix option...)],
52 dnl [AC_MSG_RESULT(unsopported)
53 dnl AC_MSG_ERROR(Cross-compiling isn't supported...)]
57 dnl Check for a working version of libasound that is of the right version.
58 min_alsa_version=ifelse([$1], ,0.1.1,$1)
59 AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
61 alsa_min_major_version=`echo $min_alsa_version | \
62 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
63 alsa_min_minor_version=`echo $min_alsa_version | \
64 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
65 alsa_min_micro_version=`echo $min_alsa_version | \
66 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
71 #include <sys/asoundlib.h>
75 /* ensure backward compatibility */
76 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
77 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
79 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
80 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
82 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
83 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
86 # if(SND_LIB_MAJOR > $alsa_min_major_version)
89 # if(SND_LIB_MAJOR < $alsa_min_major_version)
93 # if(SND_LIB_MINOR > $alsa_min_minor_version)
96 # if(SND_LIB_MINOR < $alsa_min_minor_version)
100 # if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
108 [AC_MSG_RESULT(found.)],
109 [AC_MSG_RESULT(not present.)
110 AC_MSG_ERROR(Sufficiently new version of libasound not found.)]
114 dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
115 AC_CHECK_LIB([asound], [snd_cards],,
116 [AC_MSG_ERROR(No linkable libasound was found.)]
119 dnl That should be it. Now just export out symbols:
120 AC_SUBST(ALSA_CFLAGS)