OSDN Git Service

- Fix the old function prototype in pcm_plugin.h
[android-x86/external-alsa-lib.git] / utils / alsa.m4
1 dnl Configure Paths for Alsa
2 dnl Christopher Lansdown (lansdoct@cs.alfred.edu)
3 dnl 29/10/1998
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
7 dnl
8 AC_DEFUN(AM_PATH_ALSA,
9 [dnl
10 dnl Get the clfags and libraries for alsa
11 dnl
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])
17
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"
23 fi
24 AC_MSG_RESULT($ALSA_CFLAGS)
25
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"
30         LIBS="-L$alsa_prefix"
31 fi
32
33 dnl add the alsa library
34 ALSA_LIBS="$ALSA_LIBS -lasound -lm"
35 LDFLAGS="$ALSA_LIBS"
36 AC_MSG_RESULT($ALSA_LIBS)
37
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)
41 dnl   AC_TRY_RUN([
42 dnl #include <sys/asoundlib.h>
43 dnl void main(void)
44 dnl {
45 dnl   snd_cards();
46 dnl   exit(0);
47 dnl }
48 dnl ],
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...)]
54 dnl  )
55 dnl fi
56
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)
60 no_alsa=""
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/'`
67
68 AC_LANG_SAVE
69 AC_LANG_C
70 AC_TRY_COMPILE([
71 #include <sys/asoundlib.h>
72 ], [
73 void main(void)
74 {
75 /* ensure backward compatibility */
76 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
77 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
78 #endif
79 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
80 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
81 #endif
82 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
83 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
84 #endif
85
86 #  if(SND_LIB_MAJOR > $alsa_min_major_version)
87   exit(0);
88 #  else
89 #    if(SND_LIB_MAJOR < $alsa_min_major_version)
90 #       error not present
91 #    endif
92
93 #   if(SND_LIB_MINOR > $alsa_min_minor_version)
94   exit(0);
95 #   else
96 #     if(SND_LIB_MINOR < $alsa_min_minor_version)
97 #          error not present
98 #      endif
99
100 #      if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
101 #        error not present
102 #      endif
103 #    endif
104 #  endif
105 exit(0);
106 }
107 ],
108   [AC_MSG_RESULT(found.)],
109   [AC_MSG_RESULT(not present.)
110    AC_MSG_ERROR(Sufficiently new version of libasound not found.)]
111 )
112 AC_LANG_RESTORE
113
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.)]
117 )
118
119 dnl That should be it.  Now just export out symbols:
120 AC_SUBST(ALSA_CFLAGS)
121 AC_SUBST(ALSA_LIBS)
122 ])
123