Annotation of /trunk/xmms/gentoo-m4/alsa.m4
Parent Directory | Revision Log
Revision 153 -
(hide annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 4338 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 4338 byte(s)
-import
1 | niro | 153 | 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.24 2004/09/15 18:48:07 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 | ||
11 | dnl | ||
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. | ||
14 | dnl | ||
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" | ||
20 | alsa_found=yes | ||
21 | |||
22 | dnl | ||
23 | dnl Get the cflags and libraries for alsa | ||
24 | dnl | ||
25 | AC_ARG_WITH(alsa-prefix, | ||
26 | [ --with-alsa-prefix=PFX Prefix where Alsa library is installed(optional)], | ||
27 | [alsa_prefix="$withval"], [alsa_prefix=""]) | ||
28 | |||
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=""]) | ||
32 | |||
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], | ||
36 | [enable_alsatest="$enableval"], | ||
37 | [enable_alsatest=yes]) | ||
38 | |||
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" | ||
44 | fi | ||
45 | AC_MSG_RESULT($ALSA_CFLAGS) | ||
46 | |||
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" | ||
52 | fi | ||
53 | |||
54 | dnl add the alsa library | ||
55 | ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl -lpthread" | ||
56 | LIBS="$ALSA_LIBS $LIBS" | ||
57 | AC_MSG_RESULT($ALSA_LIBS) | ||
58 | |||
59 | dnl Check for a working version of libasound that is of the right version. | ||
60 | min_alsa_version=ifelse([$1], ,0.1.1,$1) | ||
61 | AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version) | ||
62 | no_alsa="" | ||
63 | alsa_min_major_version=`echo $min_alsa_version | \ | ||
64 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | ||
65 | alsa_min_minor_version=`echo $min_alsa_version | \ | ||
66 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | ||
67 | alsa_min_micro_version=`echo $min_alsa_version | \ | ||
68 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | ||
69 | |||
70 | AC_LANG_SAVE | ||
71 | AC_LANG_C | ||
72 | AC_TRY_COMPILE([ | ||
73 | #include <alsa/asoundlib.h> | ||
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 | [AC_MSG_RESULT(found.)], | ||
108 | [AC_MSG_RESULT(not present.) | ||
109 | ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)]) | ||
110 | alsa_found=no] | ||
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 | if test "x$enable_alsatest" = "xyes"; then | ||
116 | AC_CHECK_LIB([asound], [snd_ctl_open],, | ||
117 | [ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)]) | ||
118 | alsa_found=no] | ||
119 | ) | ||
120 | fi | ||
121 | |||
122 | if test "x$alsa_found" = "xyes" ; then | ||
123 | ifelse([$2], , :, [$2]) | ||
124 | LIBS=`echo $LIBS | sed 's/-lasound//g'` | ||
125 | LIBS=`echo $LIBS | sed 's/ //'` | ||
126 | LIBS="-lasound $LIBS" | ||
127 | fi | ||
128 | if test "x$alsa_found" = "xno" ; then | ||
129 | ifelse([$3], , :, [$3]) | ||
130 | CFLAGS="$alsa_save_CFLAGS" | ||
131 | LDFLAGS="$alsa_save_LDFLAGS" | ||
132 | LIBS="$alsa_save_LIBS" | ||
133 | ALSA_CFLAGS="" | ||
134 | ALSA_LIBS="" | ||
135 | fi | ||
136 | |||
137 | dnl That should be it. Now just export out symbols: | ||
138 | AC_SUBST(ALSA_CFLAGS) | ||
139 | AC_SUBST(ALSA_LIBS) | ||
140 | ]) | ||
141 |