comparison acinclude.m4 @ 939:c7c04f811994

Date: Tue, 01 Jun 2004 15:27:44 +0300 From: Martin_Storsj Subject: Update for dynamic loading of ALSA I sent you a patch a few months ago which enables SDL to load ALSA dynamically. Now I've finally got time to tweak this yet some more. I've added code from alsa.m4 (from alsa's dev package) to acinclude.m4, and made the detection of the alsa library name a bit better. I've also fixed up the loading versioned symbols with dlvsym, so that it falls back to dlsym. I wouldn't say the configure script is complete yet, but this is how far I've come this time, and I'm no expert at those things.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 21 Aug 2004 04:20:00 +0000
parents 05c551e5bc64
children 3bb035750537
comparison
equal deleted inserted replaced
938:fa2ce068b0b6 939:c7c04f811994
16 * Original: $old 16 * Original: $old
17 */ 17 */
18 __EOF__ 18 __EOF__
19 cat >>$new <$old 19 cat >>$new <$old
20 ]) 20 ])
21
22 #
23 # --- alsa.m4 ---
24 #
25 dnl Configure Paths for Alsa
26 dnl Some modifications by Richard Boulton <richard-alsa@tartarus.org>
27 dnl Christopher Lansdown <lansdoct@cs.alfred.edu>
28 dnl Jaroslav Kysela <perex@suse.cz>
29 dnl Last modification: alsa.m4,v 1.22 2002/05/27 11:14:20 tiwai Exp
30 dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
31 dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate.
32 dnl enables arguments --with-alsa-prefix=
33 dnl --with-alsa-enc-prefix=
34 dnl --disable-alsatest (this has no effect, as yet)
35 dnl
36 dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified,
37 dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result.
38 dnl
39 AC_DEFUN(AM_PATH_ALSA,
40 [dnl Save the original CFLAGS, LDFLAGS, and LIBS
41 alsa_save_CFLAGS="$CFLAGS"
42 alsa_save_LDFLAGS="$LDFLAGS"
43 alsa_save_LIBS="$LIBS"
44 alsa_found=yes
45
46 dnl
47 dnl Get the cflags and libraries for alsa
48 dnl
49 AC_ARG_WITH(alsa-prefix,
50 [ --with-alsa-prefix=PFX Prefix where Alsa library is installed(optional)],
51 [alsa_prefix="$withval"], [alsa_prefix=""])
52
53 AC_ARG_WITH(alsa-inc-prefix,
54 [ --with-alsa-inc-prefix=PFX Prefix where include libraries are (optional)],
55 [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
56
57 dnl FIXME: this is not yet implemented
58 AC_ARG_ENABLE(alsatest,
59 [ --disable-alsatest Do not try to compile and run a test Alsa program],
60 [enable_alsatest=no],
61 [enable_alsatest=yes])
62
63 dnl Add any special include directories
64 AC_MSG_CHECKING(for ALSA CFLAGS)
65 if test "$alsa_inc_prefix" != "" ; then
66 ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
67 CFLAGS="$CFLAGS -I$alsa_inc_prefix"
68 fi
69 AC_MSG_RESULT($ALSA_CFLAGS)
70
71 dnl add any special lib dirs
72 AC_MSG_CHECKING(for ALSA LDFLAGS)
73 if test "$alsa_prefix" != "" ; then
74 ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
75 LDFLAGS="$LDFLAGS $ALSA_LIBS"
76 fi
77
78 dnl add the alsa library
79 ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl -lpthread"
80 LIBS=`echo $LIBS | sed 's/-lm//'`
81 LIBS=`echo $LIBS | sed 's/-ldl//'`
82 LIBS=`echo $LIBS | sed 's/-lpthread//'`
83 LIBS=`echo $LIBS | sed 's/ //'`
84 LIBS="$ALSA_LIBS $LIBS"
85 AC_MSG_RESULT($ALSA_LIBS)
86
87 dnl Check for a working version of libasound that is of the right version.
88 min_alsa_version=ifelse([$1], ,0.1.1,$1)
89 AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
90 no_alsa=""
91 alsa_min_major_version=`echo $min_alsa_version | \
92 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
93 alsa_min_minor_version=`echo $min_alsa_version | \
94 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
95 alsa_min_micro_version=`echo $min_alsa_version | \
96 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
97
98 AC_LANG_SAVE
99 AC_LANG_C
100 AC_TRY_COMPILE([
101 #include <alsa/asoundlib.h>
102 ], [
103 /* ensure backward compatibility */
104 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
105 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
106 #endif
107 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
108 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
109 #endif
110 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
111 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
112 #endif
113
114 # if(SND_LIB_MAJOR > $alsa_min_major_version)
115 exit(0);
116 # else
117 # if(SND_LIB_MAJOR < $alsa_min_major_version)
118 # error not present
119 # endif
120
121 # if(SND_LIB_MINOR > $alsa_min_minor_version)
122 exit(0);
123 # else
124 # if(SND_LIB_MINOR < $alsa_min_minor_version)
125 # error not present
126 # endif
127
128 # if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
129 # error not present
130 # endif
131 # endif
132 # endif
133 exit(0);
134 ],
135 [AC_MSG_RESULT(found.)],
136 [AC_MSG_RESULT(not present.)
137 ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)])
138 alsa_found=no]
139 )
140 AC_LANG_RESTORE
141
142 dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
143 AC_CHECK_LIB([asound], [snd_ctl_open],,
144 [ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)])
145 alsa_found=no]
146 )
147
148 CFLAGS="$alsa_save_CFLAGS"
149 LDFLAGS="$alsa_save_LDFLAGS"
150 LIBS="$alsa_save_LIBS"
151 if test "x$alsa_found" = "xyes" ; then
152 ifelse([$2], , :, [$2])
153 else
154 ifelse([$3], , :, [$3])
155 CFLAGS="$alsa_save_CFLAGS"
156 LDFLAGS="$alsa_save_LDFLAGS"
157 LIBS="$alsa_save_LIBS"
158 ALSA_CFLAGS=""
159 ALSA_LIBS=""
160 fi
161
162 dnl That should be it. Now just export out symbols:
163 AC_SUBST(ALSA_CFLAGS)
164 AC_SUBST(ALSA_LIBS)
165 ])
166
167
21 168
22 # 169 #
23 # --- esd.m4 --- 170 # --- esd.m4 ---
24 # 171 #
25 # Configure paths for ESD 172 # Configure paths for ESD