Fixes to properly conditionally compile architecture-dependent code
[platform/upstream/gstreamer.git] / acinclude.m4
1 # CFLAGS and library paths for XMMS
2 # written 15 December 1999 by Ben Gertzfield <che@debian.org>
3
4 dnl Usage:
5 dnl AM_PATH_XMMS([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
6 dnl
7 dnl Example:
8 dnl AM_PATH_XMMS(0.9.5.1, , AC_MSG_ERROR([*** XMMS >= 0.9.5.1 not installed - please install first ***]))
9 dnl
10 dnl Defines XMMS_CFLAGS, XMMS_LIBS, XMMS_DATA_DIR, XMMS_PLUGIN_DIR, 
11 dnl XMMS_VISUALIZATION_PLUGIN_DIR, XMMS_INPUT_PLUGIN_DIR, 
12 dnl XMMS_OUTPUT_PLUGIN_DIR, XMMS_GENERAL_PLUGIN_DIR, XMMS_EFFECT_PLUGIN_DIR,
13 dnl and XMMS_VERSION for your plugin pleasure.
14 dnl
15
16 dnl XMMS_TEST_VERSION(AVAILABLE-VERSION, NEEDED-VERSION [, ACTION-IF-OKAY [, ACTION-IF-NOT-OKAY]])
17 AC_DEFUN(XMMS_TEST_VERSION, [
18
19 # Determine which version number is greater. Prints 2 to stdout if      
20 # the second number is greater, 1 if the first number is greater,       
21 # 0 if the numbers are equal.                                           
22                                                                         
23 # Written 15 December 1999 by Ben Gertzfield <che@debian.org>           
24 # Revised 15 December 1999 by Jim Monty <monty@primenet.com>            
25                                                                         
26     AC_PROG_AWK
27     xmms_got_version=[` $AWK '                                          \
28 BEGIN {                                                                 \
29     print vercmp(ARGV[1], ARGV[2]);                                     \
30 }                                                                       \
31                                                                         \
32 function vercmp(ver1, ver2,    ver1arr, ver2arr,                        \
33                                ver1len, ver2len,                        \
34                                ver1int, ver2int, len, i, p) {           \
35                                                                         \
36     ver1len = split(ver1, ver1arr, /\./);                               \
37     ver2len = split(ver2, ver2arr, /\./);                               \
38                                                                         \
39     len = ver1len > ver2len ? ver1len : ver2len;                        \
40                                                                         \
41     for (i = 1; i <= len; i++) {                                        \
42         p = 1000 ^ (len - i);                                           \
43         ver1int += ver1arr[i] * p;                                      \
44         ver2int += ver2arr[i] * p;                                      \
45     }                                                                   \
46                                                                         \
47     if (ver1int < ver2int)                                              \
48         return 2;                                                       \
49     else if (ver1int > ver2int)                                         \
50         return 1;                                                       \
51     else                                                                \
52         return 0;                                                       \
53 }' $1 $2`]                                                              
54
55     if test $xmms_got_version -eq 2; then       # failure
56         ifelse([$4], , :, $4)                   
57     else                                        # success!
58         ifelse([$3], , :, $3)
59     fi
60 ])
61
62 AC_DEFUN(AM_PATH_XMMS,
63 [
64 AC_ARG_WITH(xmms-prefix,[  --with-xmms-prefix=PFX  Prefix where XMMS is installed (optional)],
65         xmms_config_prefix="$withval", xmms_config_prefix="")
66 AC_ARG_WITH(xmms-exec-prefix,[  --with-xmms-exec-prefix=PFX Exec prefix where XMMS is installed (optional)],
67         xmms_config_exec_prefix="$withval", xmms_config_exec_prefix="")
68
69 if test x$xmms_config_exec_prefix != x; then
70     xmms_config_args="$xmms_config_args --exec-prefix=$xmms_config_exec_prefix"
71     if test x${XMMS_CONFIG+set} != xset; then
72         XMMS_CONFIG=$xmms_config_exec_prefix/bin/xmms-config
73     fi
74 fi
75
76 if test x$xmms_config_prefix != x; then
77     xmms_config_args="$xmms_config_args --prefix=$xmms_config_prefix"
78     if test x${XMMS_CONFIG+set} != xset; then
79         XMMS_CONFIG=$xmms_config_prefix/bin/xmms-config
80     fi
81 fi
82
83 AC_PATH_PROG(XMMS_CONFIG, xmms-config, no)
84 min_xmms_version=ifelse([$1], ,0.9.5.1, $1)
85
86 if test "$XMMS_CONFIG" = "no"; then
87     no_xmms=yes
88 else
89     XMMS_CFLAGS=`$XMMS_CONFIG $xmms_config_args --cflags`
90     XMMS_LIBS=`$XMMS_CONFIG $xmms_config_args --libs`
91     XMMS_VERSION=`$XMMS_CONFIG $xmms_config_args --version`
92     XMMS_DATA_DIR=`$XMMS_CONFIG $xmms_config_args --data-dir`
93     XMMS_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --plugin-dir`
94     XMMS_VISUALIZATION_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args \
95                                         --visualization-plugin-dir`
96     XMMS_INPUT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --input-plugin-dir`
97     XMMS_OUTPUT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --output-plugin-dir`
98     XMMS_EFFECT_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --effect-plugin-dir`
99     XMMS_GENERAL_PLUGIN_DIR=`$XMMS_CONFIG $xmms_config_args --general-plugin-dir`
100
101     XMMS_TEST_VERSION($XMMS_VERSION, $min_xmms_version, ,no_xmms=version)
102 fi
103
104 AC_MSG_CHECKING(for XMMS - version >= $min_xmms_version)
105
106 if test "x$no_xmms" = x; then
107     AC_MSG_RESULT(yes)
108     ifelse([$2], , :, [$2])
109 else
110     AC_MSG_RESULT(no)
111
112     if test "$XMMS_CONFIG" = "no" ; then
113         echo "*** The xmms-config script installed by XMMS could not be found."
114         echo "*** If XMMS was installed in PREFIX, make sure PREFIX/bin is in"
115         echo "*** your path, or set the XMMS_CONFIG environment variable to the"
116         echo "*** full path to xmms-config."
117     else
118         if test "$no_xmms" = "version"; then
119             echo "*** An old version of XMMS, $XMMS_VERSION, was found."
120             echo "*** You need a version of XMMS newer than $min_xmms_version."
121             echo "*** The latest version of XMMS is always available from"
122             echo "*** http://www.xmms.org/"
123             echo "***"
124
125             echo "*** If you have already installed a sufficiently new version, this error"
126             echo "*** probably means that the wrong copy of the xmms-config shell script is"
127             echo "*** being found. The easiest way to fix this is to remove the old version"
128             echo "*** of XMMS, but you can also set the XMMS_CONFIG environment to point to the"
129             echo "*** correct copy of xmms-config. (In this case, you will have to"
130             echo "*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf"
131             echo "*** so that the correct libraries are found at run-time)"
132         fi
133     fi
134     XMMS_CFLAGS=""
135     XMMS_LIBS=""
136     ifelse([$3], , :, [$3])
137 fi
138 AC_SUBST(XMMS_CFLAGS)
139 AC_SUBST(XMMS_LIBS)
140 AC_SUBST(XMMS_VERSION)
141 AC_SUBST(XMMS_DATA_DIR)
142 AC_SUBST(XMMS_PLUGIN_DIR)
143 AC_SUBST(XMMS_VISUALIZATION_PLUGIN_DIR)
144 AC_SUBST(XMMS_INPUT_PLUGIN_DIR)
145 AC_SUBST(XMMS_OUTPUT_PLUGIN_DIR)
146 AC_SUBST(XMMS_GENERAL_PLUGIN_DIR)
147 AC_SUBST(XMMS_EFFECT_PLUGIN_DIR)
148 ])
149
150
151 dnl Perform a check for a feature for GStreamer
152 dnl Richard Boulton <richard-alsa@tartarus.org>
153 dnl Last modification: 25/06/2001
154 dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
155 dnl                   DEPENDENT-PLUGINS, TEST-FOR-FEATURE,
156 dnl                   DISABLE-BY-DEFAULT, ACTION-IF-USE, ACTION-IF-NOTUSE)
157 dnl
158 dnl This macro adds a command line argument to enable the user to enable
159 dnl or disable a feature, and if the feature is enabled, performs a supplied
160 dnl test to check if the feature is available.
161 dnl
162 dnl The test should define HAVE_<FEATURE-NAME> to "yes" or "no" depending
163 dnl on whether the feature is available.
164 dnl
165 dnl The macro will set USE_<<FEATURE-NAME> to "yes" or "no" depending on
166 dnl whether the feature is to be used.
167 dnl
168 dnl The macro will call AM_CONDITIONAL(USE_<<FEATURE-NAME>, ...) to allow
169 dnl the feature to control what is built in Makefile.ams.  If you want
170 dnl additional actions resulting from the test, you can add them with the
171 dnl ACTION-IF-USE and ACTION-IF-NOTUSE parameters.
172 dnl 
173 dnl FEATURE-NAME        is the name of the feature, and should be in
174 dnl                     purely upper case characters.
175 dnl FEATURE-DESCRIPTION is used to describe the feature in help text for
176 dnl                     the command line argument.
177 dnl DEPENDENT-PLUGINS   lists any plugins which depend on this feature.
178 dnl TEST-FOR-FEATURE    is a test which sets HAVE_<FEATURE-NAME> to "yes"
179 dnl                     or "no" depending on whether the feature is
180 dnl                     available.
181 dnl DISABLE-BY-DEFAULT  if "disabled", the feature is disabled by default,
182 dnl                     if any other value, the feature is enabled by default.
183 dnl ACTION-IF-USE       any extra actions to perform if the feature is to be
184 dnl                     used.
185 dnl ACTION-IF-NOTUSE    any extra actions to perform if the feature is not to
186 dnl                     be used.
187 dnl
188 AC_DEFUN(GST_CHECK_FEATURE,
189 [dnl
190 builtin(define, [gst_endisable], ifelse($5, [disabled], [enable], [disable]))dnl
191 AC_ARG_ENABLE(translit([$1], A-Z, a-z),
192   [  ]builtin(format, --%-26s gst_endisable %s, gst_endisable-translit([$1], A-Z, a-z), [$2]ifelse([$3],,,: [$3])),
193   [ case "${enableval}" in
194       yes) USE_[$1]=yes ;;
195       no) USE_[$1]=no ;;
196       *) AC_MSG_ERROR(bad value ${enableval} for --enable-translit([$1], A-Z, a-z)) ;;
197     esac],
198   [ USE_$1=]ifelse($5, [disabled], [no], [yes]))           dnl DEFAULT
199
200 dnl *** If it's enabled
201 if test x$USE_[$1] = xyes; then
202   gst_check_save_LIBS=$LIBS
203   gst_check_save_LDFLAGS=$LDFLAGS
204   gst_check_save_CFLAGS=$CFLAGS
205   gst_check_save_CPPFLAGS=$CPPFLAGS
206   gst_check_save_CXXFLAGS=$CXXFLAGS
207   HAVE_[$1]=no
208   $4
209   LIBS=$gst_check_save_LIBS
210   LDFLAGS=$gst_check_save_LDFLAGS
211   CFLAGS=$gst_check_save_CFLAGS
212   CPPFLAGS=$gst_check_save_CPPFLAGS
213   CXXFLAGS=$gst_check_save_CXXFLAGS
214
215   dnl If it isn't found, unset USE_[$1]
216   if test x$HAVE_[$1] = xno; then
217     USE_[$1]=no
218   fi
219 fi
220 dnl *** Warn if it's disabled or not found
221 if test x$USE_[$1] = xyes; then
222   ifelse([$6], , :, [$6])
223 else
224   ifelse([$3], , :, [AC_MSG_WARN(
225 ***** NOTE: These plugins won't be built: [$3]
226 )])
227   ifelse([$7], , :, [$7])
228 fi
229 dnl *** Define the conditional as appropriate
230 AM_CONDITIONAL(USE_[$1], test x$USE_[$1] = xyes)
231 ])
232
233 dnl Use a -config program which accepts --cflags and --libs parameters
234 dnl to set *_CFLAGS and *_LIBS and check existence of a feature.
235 dnl Richard Boulton <richard-alsa@tartarus.org>
236 dnl Last modification: 26/06/2001
237 dnl GST_CHECK_CONFIGPROG(FEATURE-NAME, CONFIG-PROG-FILENAME, MODULES)
238 dnl
239 dnl This check was written for GStreamer: it should be renamed and checked
240 dnl for portability if you decide to use it elsewhere.
241 dnl
242 AC_DEFUN(GST_CHECK_CONFIGPROG,
243 [
244   AC_PATH_PROG([$1]_CONFIG, [$2], no)
245   if test x$[$1]_CONFIG = xno; then
246     [$1]_LIBS=
247     [$1]_CFLAGS=
248     HAVE_[$1]=no
249   else
250     [$1]_LIBS=`[$2] --libs [$3]`
251     [$1]_CFLAGS=`[$2] --cflags [$3]`
252     HAVE_[$1]=yes
253   fi
254   AC_SUBST([$1]_LIBS)
255   AC_SUBST([$1]_CFLAGS)
256 ])
257
258
259 dnl Perform a check for existence of ARTSC
260 dnl Richard Boulton <richard-alsa@tartarus.org>
261 dnl Last modification: 26/06/2001
262 dnl GST_CHECK_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
263 dnl                   DEPENDENT-PLUGINS, TEST-FOR-FEATURE)
264 dnl
265 dnl This check was written for GStreamer: it should be renamed and checked
266 dnl for portability if you decide to use it elsewhere.
267 dnl
268 AC_DEFUN(GST_CHECK_ARTSC,
269 [
270   AC_PATH_PROG(ARTSC_CONFIG, artsc-config, no)
271   if test x$ARTSC_CONFIG = xno; then
272     AC_MSG_WARN([Couldn't find artsc-config])
273     HAVE_ARTSC=no
274     ARTSC_LIBS=
275     ARTSC_CFLAGS=
276   else
277     ARTSC_LIBS=`artsc-config --libs`
278     ARTSC_CFLAGS=`artsc-config --cflags`
279     dnl AC_CHECK_HEADER uses CPPFLAGS, but not CFLAGS.
280     dnl FIXME: Ensure only suitable flags result from artsc-config --cflags
281     CPPFLAGS="$CPPFLAGS $ARTSC_CFLAGS"
282     AC_CHECK_HEADER(artsc.h, HAVE_ARTSC=yes, HAVE_ARTSC=no)
283   fi
284   AC_SUBST(ARTSC_LIBS)
285   AC_SUBST(ARTSC_CFLAGS)
286 ])
287
288 dnl sidplay stuff (taken from xmms)
289 AC_DEFUN(AC_FIND_FILE,
290 [
291   $3=NO
292   for i in $2; do
293     for j in $1; do
294       if test -r "$i/$j"; then
295         $3=$i
296         break 2
297       fi
298     done
299   done
300 ])
301
302 AC_DEFUN(AC_PATH_LIBSIDPLAY,
303 [
304 AC_MSG_CHECKING([for SIDPLAY includes and library])
305 ac_sidplay_cflags=NO
306 ac_sidplay_library=NO
307 sidplay_cflags=""
308 sidplay_library=""
309
310 AC_ARG_WITH(sidplay-includes,
311   [  --with-sidplay-includes=DIR
312                           where the sidplay includes are located],
313   [ac_sidplay_cflags="$withval"
314   ])
315
316 AC_ARG_WITH(sidplay-library,
317   [  --with-sidplay-library=DIR
318                           where the sidplay library is installed],
319   [ac_sidplay_library="$withval"
320   ])
321
322 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then
323 #search common locations
324
325 AC_CACHE_VAL(ac_cv_have_sidplay,
326 [
327 sidplay_incdirs="$ac_sidplay_cflags /usr/include /usr/local/include /usr/lib/sidplay/include /usr/local/lib/sidplay/include"
328 AC_FIND_FILE(sidplay/sidtune.h,$sidplay_incdirs,sidplay_foundincdir)
329 ac_sidplay_cflags=$sidplay_foundincdir
330
331 sidplay_libdirs="$ac_sidplay_library /usr/lib /usr/local/lib /usr/lib/sidplay /usr/local/lib/sidplay"
332 AC_FIND_FILE(libsidplay.so libsidplay.so.1 libsidplay.so.1.36 libsidplay.so.1.37,$sidplay_libdirs,sidplay_foundlibdir)
333 ac_sidplay_library=$sidplay_foundlibdir
334
335 if test "$ac_sidplay_cflags" = NO || test "$ac_sidplay_library" = NO; then
336   ac_cv_have_sidplay="have_sidplay=no"
337   ac_sidplay_notfound=""
338   if test "$ac_sidplay_cflags" = NO; then
339     if test "$ac_sidplay_library" = NO; then
340       ac_sidplay_notfound="(headers and library)";
341     else
342       ac_sidplay_notfound="(headers)";
343     fi
344   else
345     ac_sidplay_notfound="(library)";
346   fi
347   eval "$ac_cv_have_sidplay"
348   AC_MSG_RESULT([$have_sidplay])
349 else
350   have_sidplay=yes
351 fi
352
353 ])  dnl AC_CACHE_VAL(ac_cv_have_sidplay,
354 else
355   have_sidplay=yes
356 fi  dnl if (have_to_search)
357
358 eval "$ac_cv_have_sidplay"
359
360 if test "$have_sidplay" != yes; then
361   AC_MSG_RESULT([$have_sidplay]);
362 else
363   ac_cv_have_sidplay="have_sidplay=yes \
364     ac_sidplay_cflags=$ac_sidplay_cflags ac_sidplay_library=$ac_sidplay_library"
365   AC_MSG_RESULT([library $ac_sidplay_library, headers $ac_sidplay_cflags])
366   
367   sidplay_library=$ac_sidplay_library
368   sidplay_cflags=$ac_sidplay_cflags
369   
370   SIDPLAY_LIBS="-L$sidplay_library -lsidplay"
371   all_libraries="$SIDPLAY_LIBS $all_libraries"
372   SIDPLAY_CFLAGS="-I$sidplay_cflags"
373   all_includes="$SIDPLAY_CFLAGS $all_includes"
374 fi
375
376 dnl Test compilation.
377
378 AC_MSG_CHECKING([whether -lsidplay works])
379 ac_cxxflags_safe=$CXXFLAGS
380 ac_ldflags_safe=$LDFLAGS
381 ac_libs_safe=$LIBS
382
383 CXXFLAGS="$CXXFLAGS -I$sidplay_cflags"
384 LDFLAGS="$LDFLAGS -L$sidplay_library"
385 LIBS="-lsidplay"
386
387 AC_CACHE_VAL(ac_cv_sidplay_works,
388 [
389   AC_LANG_CPLUSPLUS
390   AC_TRY_RUN([
391     #include <sidplay/player.h>
392              
393     int main()
394     {
395       sidTune tune = sidTune(0);
396     }
397     ],
398     ac_cv_sidplay_works="yes",
399     ac_cv_sidplay_works="no",
400     ac_cv_sidplay_works="no")
401   AC_LANG_C
402 ])
403
404 CXXFLAGS="$ac_cxxflags_safe"
405 LDFLAGS="$ac_ldflags_safe"
406 LIBS="$ac_libs_safe"
407
408 AC_MSG_RESULT([$ac_cv_sidplay_works])
409 if test "$ac_cv_sidplay_works" != yes; then
410   have_sidplay=no
411 fi
412
413 dnl
414
415 AC_SUBST(SIDPLAY_CFLAGS)
416 AC_SUBST(SIDPLAY_LIBS)
417
418 AC_SUBST(sidplay_library)
419 AC_SUBST(sidplay_cflags)
420
421 ])
422 dnl Configure Paths for Alsa
423 dnl Some modifications by Richard Boulton <richard-alsa@tartarus.org>
424 dnl Christopher Lansdown <lansdoct@cs.alfred.edu>
425 dnl Jaroslav Kysela <perex@suse.cz>
426 dnl Last modification: 07/01/2001
427 dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
428 dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate.
429 dnl enables arguments --with-alsa-prefix=
430 dnl                   --with-alsa-enc-prefix=
431 dnl                   --disable-alsatest  (this has no effect, as yet)
432 dnl
433 dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified,
434 dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result.
435 dnl
436 AC_DEFUN(AM_PATH_ALSA,
437 [dnl Save the original CFLAGS, LDFLAGS, and LIBS
438 alsa_save_CFLAGS="$CFLAGS"
439 alsa_save_LDFLAGS="$LDFLAGS"
440 alsa_save_LIBS="$LIBS"
441 alsa_found=yes
442
443 dnl
444 dnl Get the cflags and libraries for alsa
445 dnl
446 AC_ARG_WITH(alsa-prefix,
447 [  --with-alsa-prefix=PFX  Prefix where Alsa library is installed(optional)],
448 [alsa_prefix="$withval"], [alsa_prefix=""])
449
450 AC_ARG_WITH(alsa-inc-prefix,
451 [  --with-alsa-inc-prefix=PFX  Prefix where include libraries are (optional)],
452 [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
453
454 dnl FIXME: this is not yet implemented
455 AC_ARG_ENABLE(alsatest,
456 [  --disable-alsatest      Do not try to compile and run a test Alsa program],
457 [enable_alsatest=no],
458 [enable_alsatest=yes])
459
460 dnl Add any special include directories
461 AC_MSG_CHECKING(for ALSA CFLAGS)
462 if test "$alsa_inc_prefix" != "" ; then
463         ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
464         CFLAGS="$CFLAGS -I$alsa_inc_prefix"
465 fi
466 AC_MSG_RESULT($ALSA_CFLAGS)
467
468 dnl add any special lib dirs
469 AC_MSG_CHECKING(for ALSA LDFLAGS)
470 if test "$alsa_prefix" != "" ; then
471         ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
472         LDFLAGS="$LDFLAGS $ALSA_LIBS"
473 fi
474
475 dnl add the alsa library
476 ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl"
477 LIBS=`echo $LIBS | sed 's/-lm//'`
478 LIBS=`echo $LIBS | sed 's/-ldl//'`
479 LIBS=`echo $LIBS | sed 's/  //'`
480 LIBS="$ALSA_LIBS $LIBS"
481 AC_MSG_RESULT($ALSA_LIBS)
482
483 dnl Check for a working version of libasound that is of the right version.
484 min_alsa_version=ifelse([$1], ,0.1.1,$1)
485 AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
486 no_alsa=""
487     alsa_min_major_version=`echo $min_alsa_version | \
488            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
489     alsa_min_minor_version=`echo $min_alsa_version | \
490            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
491     alsa_min_micro_version=`echo $min_alsa_version | \
492            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
493
494 AC_LANG_SAVE
495 AC_LANG_C
496 AC_TRY_COMPILE([
497 #include <sys/asoundlib.h>
498 ], [
499 void main(void)
500 {
501 /* ensure backward compatibility */
502 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
503 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
504 #endif
505 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
506 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
507 #endif
508 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
509 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
510 #endif
511
512 #  if(SND_LIB_MAJOR > $alsa_min_major_version)
513   exit(0);
514 #  else
515 #    if(SND_LIB_MAJOR < $alsa_min_major_version)
516 #       error not present
517 #    endif
518
519 #   if(SND_LIB_MINOR > $alsa_min_minor_version)
520   exit(0);
521 #   else
522 #     if(SND_LIB_MINOR < $alsa_min_minor_version)
523 #          error not present
524 #      endif
525
526 #      if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
527 #        error not present
528 #      endif
529 #    endif
530 #  endif
531 exit(0);
532 }
533 ],
534   [AC_MSG_RESULT(found.)],
535   [AC_MSG_RESULT(not present.)
536    ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)])
537    alsa_found=no]
538 )
539 AC_LANG_RESTORE
540
541 dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
542 AC_CHECK_LIB([asound], [snd_seq_create_event],,
543         [ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)])
544          alsa_found=no]
545 )
546
547 if test "x$alsa_found" = "xyes" ; then
548    ifelse([$2], , :, [$2])
549    LIBS=`echo $LIBS | sed 's/-lasound//g'`
550    LIBS=`echo $LIBS | sed 's/  //'`
551    LIBS="-lasound $LIBS"
552 fi
553 if test "x$alsa_found" = "xno" ; then
554    ifelse([$3], , :, [$3])
555    CFLAGS="$alsa_save_CFLAGS"
556    LDFLAGS="$alsa_save_LDFLAGS"
557    LIBS="$alsa_save_LIBS"
558    ALSA_CFLAGS=""
559    ALSA_LIBS=""
560 fi
561
562 dnl That should be it.  Now just export out symbols:
563 AC_SUBST(ALSA_CFLAGS)
564 AC_SUBST(ALSA_LIBS)
565 ])
566