1 dnl Configure Paths for Alsa
2 dnl Some modifications by Richard Boulton <richard-alsa@tartarus.org>
3 dnl Christopher Lansdown <lansdoct@cs.alfred.edu>
4 dnl Jaroslav Kysela <perex@suse.cz>
5 dnl Last modification: alsa.m4,v 1.22 2002/05/27 11:14:20 tiwai Exp
6 dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
7 dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate.
8 dnl enables arguments --with-alsa-prefix=
9 dnl --with-alsa-enc-prefix=
10 dnl --disable-alsatest (this has no effect, as yet)
12 dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified,
13 dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result.
15 AC_DEFUN(AM_PATH_ALSA,
16 [dnl Save the original CFLAGS, LDFLAGS, and LIBS
17 alsa_save_CFLAGS="$CFLAGS"
18 alsa_save_LDFLAGS="$LDFLAGS"
19 alsa_save_LIBS="$LIBS"
23 dnl Get the cflags and libraries for alsa
25 AC_ARG_WITH(alsa-prefix,
26 [ --with-alsa-prefix=PFX Prefix where Alsa library is installed(optional)],
27 [alsa_prefix="$withval"], [alsa_prefix=""])
29 AC_ARG_WITH(alsa-inc-prefix,
30 [ --with-alsa-inc-prefix=PFX Prefix where include libraries are (optional)],
31 [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
33 dnl FIXME: this is not yet implemented
34 AC_ARG_ENABLE(alsatest,
35 [ --disable-alsatest Do not try to compile and run a test Alsa program],
37 [enable_alsatest=yes])
39 dnl Add any special include directories
40 AC_MSG_CHECKING(for ALSA CFLAGS)
41 if test "$alsa_inc_prefix" != "" ; then
42 ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
43 CFLAGS="$CFLAGS -I$alsa_inc_prefix"
45 AC_MSG_RESULT($ALSA_CFLAGS)
47 dnl add any special lib dirs
48 AC_MSG_CHECKING(for ALSA LDFLAGS)
49 if test "$alsa_prefix" != "" ; then
50 ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
51 LDFLAGS="$LDFLAGS $ALSA_LIBS"
54 dnl add the alsa library
55 ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl -lpthread"
56 LIBS=`echo $LIBS | sed 's/-lm//'`
57 LIBS=`echo $LIBS | sed 's/-ldl//'`
58 LIBS=`echo $LIBS | sed 's/-lpthread//'`
59 LIBS=`echo $LIBS | sed 's/ //'`
60 LIBS="$ALSA_LIBS $LIBS"
61 AC_MSG_RESULT($ALSA_LIBS)
63 dnl Check for a working version of libasound that is of the right version.
64 min_alsa_version=ifelse([$1], ,0.1.1,$1)
65 AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
67 alsa_min_major_version=`echo $min_alsa_version | \
68 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
69 alsa_min_minor_version=`echo $min_alsa_version | \
70 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
71 alsa_min_micro_version=`echo $min_alsa_version | \
72 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
77 #include <alsa/asoundlib.h>
79 /* ensure backward compatibility */
80 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
81 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
83 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
84 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
86 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
87 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
90 # if(SND_LIB_MAJOR > $alsa_min_major_version)
93 # if(SND_LIB_MAJOR < $alsa_min_major_version)
97 # if(SND_LIB_MINOR > $alsa_min_minor_version)
100 # if(SND_LIB_MINOR < $alsa_min_minor_version)
104 # if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
111 [AC_MSG_RESULT(found.)],
112 [AC_MSG_RESULT(not present.)
113 ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)])
118 dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
119 AC_CHECK_LIB([asound], [snd_ctl_open],,
120 [ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)])
124 if test "x$alsa_found" = "xyes" ; then
125 ifelse([$2], , :, [$2])
126 LIBS=`echo $LIBS | sed 's/-lasound//g'`
127 LIBS=`echo $LIBS | sed 's/ //'`
128 LIBS="-lasound $LIBS"
130 if test "x$alsa_found" = "xno" ; then
131 ifelse([$3], , :, [$3])
132 CFLAGS="$alsa_save_CFLAGS"
133 LDFLAGS="$alsa_save_LDFLAGS"
134 LIBS="$alsa_save_LIBS"
139 dnl That should be it. Now just export out symbols:
140 AC_SUBST(ALSA_CFLAGS)