acinclude.m4
changeset 939 c7c04f811994
parent 886 05c551e5bc64
child 947 3bb035750537
     1.1 --- a/acinclude.m4	Sat Aug 21 03:55:12 2004 +0000
     1.2 +++ b/acinclude.m4	Sat Aug 21 04:20:00 2004 +0000
     1.3 @@ -20,6 +20,153 @@
     1.4  ])
     1.5  
     1.6  #
     1.7 +# --- alsa.m4 ---
     1.8 +#
     1.9 +dnl Configure Paths for Alsa
    1.10 +dnl Some modifications by Richard Boulton <richard-alsa@tartarus.org>
    1.11 +dnl Christopher Lansdown <lansdoct@cs.alfred.edu>
    1.12 +dnl Jaroslav Kysela <perex@suse.cz>
    1.13 +dnl Last modification: alsa.m4,v 1.22 2002/05/27 11:14:20 tiwai Exp
    1.14 +dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
    1.15 +dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate.
    1.16 +dnl enables arguments --with-alsa-prefix=
    1.17 +dnl                   --with-alsa-enc-prefix=
    1.18 +dnl                   --disable-alsatest  (this has no effect, as yet)
    1.19 +dnl
    1.20 +dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified,
    1.21 +dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result.
    1.22 +dnl
    1.23 +AC_DEFUN(AM_PATH_ALSA,
    1.24 +[dnl Save the original CFLAGS, LDFLAGS, and LIBS
    1.25 +alsa_save_CFLAGS="$CFLAGS"
    1.26 +alsa_save_LDFLAGS="$LDFLAGS"
    1.27 +alsa_save_LIBS="$LIBS"
    1.28 +alsa_found=yes
    1.29 +
    1.30 +dnl
    1.31 +dnl Get the cflags and libraries for alsa
    1.32 +dnl
    1.33 +AC_ARG_WITH(alsa-prefix,
    1.34 +[  --with-alsa-prefix=PFX  Prefix where Alsa library is installed(optional)],
    1.35 +[alsa_prefix="$withval"], [alsa_prefix=""])
    1.36 +
    1.37 +AC_ARG_WITH(alsa-inc-prefix,
    1.38 +[  --with-alsa-inc-prefix=PFX  Prefix where include libraries are (optional)],
    1.39 +[alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
    1.40 +
    1.41 +dnl FIXME: this is not yet implemented
    1.42 +AC_ARG_ENABLE(alsatest,
    1.43 +[  --disable-alsatest      Do not try to compile and run a test Alsa program],
    1.44 +[enable_alsatest=no],
    1.45 +[enable_alsatest=yes])
    1.46 +
    1.47 +dnl Add any special include directories
    1.48 +AC_MSG_CHECKING(for ALSA CFLAGS)
    1.49 +if test "$alsa_inc_prefix" != "" ; then
    1.50 +	ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
    1.51 +	CFLAGS="$CFLAGS -I$alsa_inc_prefix"
    1.52 +fi
    1.53 +AC_MSG_RESULT($ALSA_CFLAGS)
    1.54 +
    1.55 +dnl add any special lib dirs
    1.56 +AC_MSG_CHECKING(for ALSA LDFLAGS)
    1.57 +if test "$alsa_prefix" != "" ; then
    1.58 +	ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
    1.59 +	LDFLAGS="$LDFLAGS $ALSA_LIBS"
    1.60 +fi
    1.61 +
    1.62 +dnl add the alsa library
    1.63 +ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl -lpthread"
    1.64 +LIBS=`echo $LIBS | sed 's/-lm//'`
    1.65 +LIBS=`echo $LIBS | sed 's/-ldl//'`
    1.66 +LIBS=`echo $LIBS | sed 's/-lpthread//'`
    1.67 +LIBS=`echo $LIBS | sed 's/  //'`
    1.68 +LIBS="$ALSA_LIBS $LIBS"
    1.69 +AC_MSG_RESULT($ALSA_LIBS)
    1.70 +
    1.71 +dnl Check for a working version of libasound that is of the right version.
    1.72 +min_alsa_version=ifelse([$1], ,0.1.1,$1)
    1.73 +AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
    1.74 +no_alsa=""
    1.75 +    alsa_min_major_version=`echo $min_alsa_version | \
    1.76 +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
    1.77 +    alsa_min_minor_version=`echo $min_alsa_version | \
    1.78 +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
    1.79 +    alsa_min_micro_version=`echo $min_alsa_version | \
    1.80 +           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
    1.81 +
    1.82 +AC_LANG_SAVE
    1.83 +AC_LANG_C
    1.84 +AC_TRY_COMPILE([
    1.85 +#include <alsa/asoundlib.h>
    1.86 +], [
    1.87 +/* ensure backward compatibility */
    1.88 +#if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
    1.89 +#define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
    1.90 +#endif
    1.91 +#if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
    1.92 +#define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
    1.93 +#endif
    1.94 +#if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
    1.95 +#define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
    1.96 +#endif
    1.97 +
    1.98 +#  if(SND_LIB_MAJOR > $alsa_min_major_version)
    1.99 +  exit(0);
   1.100 +#  else
   1.101 +#    if(SND_LIB_MAJOR < $alsa_min_major_version)
   1.102 +#       error not present
   1.103 +#    endif
   1.104 +
   1.105 +#   if(SND_LIB_MINOR > $alsa_min_minor_version)
   1.106 +  exit(0);
   1.107 +#   else
   1.108 +#     if(SND_LIB_MINOR < $alsa_min_minor_version)
   1.109 +#          error not present
   1.110 +#      endif
   1.111 +
   1.112 +#      if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
   1.113 +#        error not present
   1.114 +#      endif
   1.115 +#    endif
   1.116 +#  endif
   1.117 +exit(0);
   1.118 +],
   1.119 +  [AC_MSG_RESULT(found.)],
   1.120 +  [AC_MSG_RESULT(not present.)
   1.121 +   ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)])
   1.122 +   alsa_found=no]
   1.123 +)
   1.124 +AC_LANG_RESTORE
   1.125 +
   1.126 +dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
   1.127 +AC_CHECK_LIB([asound], [snd_ctl_open],,
   1.128 +	[ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)])
   1.129 +	 alsa_found=no]
   1.130 +)
   1.131 +
   1.132 +CFLAGS="$alsa_save_CFLAGS"
   1.133 +LDFLAGS="$alsa_save_LDFLAGS"
   1.134 +LIBS="$alsa_save_LIBS"
   1.135 +if test "x$alsa_found" = "xyes" ; then
   1.136 +   ifelse([$2], , :, [$2])
   1.137 +else
   1.138 +   ifelse([$3], , :, [$3])
   1.139 +   CFLAGS="$alsa_save_CFLAGS"
   1.140 +   LDFLAGS="$alsa_save_LDFLAGS"
   1.141 +   LIBS="$alsa_save_LIBS"
   1.142 +   ALSA_CFLAGS=""
   1.143 +   ALSA_LIBS=""
   1.144 +fi
   1.145 +
   1.146 +dnl That should be it.  Now just export out symbols:
   1.147 +AC_SUBST(ALSA_CFLAGS)
   1.148 +AC_SUBST(ALSA_LIBS)
   1.149 +])
   1.150 +
   1.151 +
   1.152 +
   1.153 +#
   1.154  # --- esd.m4 ---
   1.155  #
   1.156  # Configure paths for ESD