1dnl Configure Paths for Alsa 2dnl Some modifications by Richard Boulton <richard-alsa@tartarus.org> 3dnl Christopher Lansdown <lansdoct@cs.alfred.edu> 4dnl Jaroslav Kysela <perex@suse.cz> 5dnl Modified for TiMidity++ by URABE, Shyouhei <root@mput.dip.jp> 6dnl Original : alsa.m4,v 1.22 2002/05/27 11:14:20 tiwai Exp 7dnl This version: alsa.m4, 2002/10/08 22:30:18 JST 8dnl AM_PATH_ALSA([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 9dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate. 10dnl enables arguments --with-alsa-prefix= 11dnl --with-alsa-enc-prefix= 12dnl --disable-alsatest (this has no effect, as yet) 13dnl 14dnl For backwards compatibility, if ACTION_IF_NOT_FOUND is not specified, 15dnl and the alsa libraries are not found, a fatal AC_MSG_ERROR() will result. 16dnl 17AC_DEFUN([AM_PATH_ALSA], 18[dnl Save the original CFLAGS, LDFLAGS, and LIBS 19alsa_save_CFLAGS="$CFLAGS" 20alsa_save_LDFLAGS="$LDFLAGS" 21alsa_save_LIBS="$LIBS" 22alsa_found=yes 23 24dnl 25dnl Get the cflags and libraries for alsa 26dnl 27AC_ARG_WITH(alsa-prefix, 28 AS_HELP_STRING([--with-alsa-prefix=PFX], 29 [Prefix where Alsa library is installed(optional)]), 30 [alsa_prefix="$withval"], [alsa_prefix=""]) 31 32AC_ARG_WITH(alsa-inc-prefix, 33 AS_HELP_STRING([--with-alsa-inc-prefix=PFX], 34 [Prefix where include libraries are (optional)]), 35 [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""]) 36 37dnl FIXME: this is not yet implemented 38AC_ARG_ENABLE(alsatest, 39 AS_HELP_STRING([--disable-alsatest], 40 [Do not try to compile and run a test Alsa program]), 41 [enable_alsatest=no], [enable_alsatest=yes]) 42 43dnl Add any special include directories 44AC_MSG_CHECKING(for ALSA CFLAGS) 45if test "$alsa_inc_prefix" != "" ; then 46 ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix" 47 CFLAGS="$CFLAGS -I$alsa_inc_prefix" 48fi 49AC_MSG_RESULT($ALSA_CFLAGS) 50 51dnl add any special lib dirs 52AC_MSG_CHECKING(for ALSA LDFLAGS) 53if test "$alsa_prefix" != "" ; then 54 ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix" 55 LDFLAGS="$LDFLAGS $ALSA_LIBS" 56fi 57 58dnl add the alsa library 59ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl -lpthread" 60LIBS=`echo $LIBS | sed 's/-lm//'` 61LIBS=`echo $LIBS | sed 's/-ldl//'` 62LIBS=`echo $LIBS | sed 's/-lpthread//'` 63LIBS=`echo $LIBS | sed 's/ //'` 64LIBS="$ALSA_LIBS $LIBS" 65AC_MSG_RESULT($ALSA_LIBS) 66 67dnl Check for a working version of libasound that is of the right version. 68min_alsa_version=ifelse([$1], ,0.1.1,$1) 69AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version) 70no_alsa="" 71 alsa_min_major_version=`echo $min_alsa_version | \ 72 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 73 alsa_min_minor_version=`echo $min_alsa_version | \ 74 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 75 alsa_min_micro_version=`echo $min_alsa_version | \ 76 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 77 78dnl This is the test program. 79AC_DEFUN([MPUT_ALSA_TRY],[ 80/* ensure backward compatibility */ 81#if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR) 82#define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR 83#endif 84#if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR) 85#define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR 86#endif 87#if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR) 88#define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR 89#endif 90 91# if(SND_LIB_MAJOR > $alsa_min_major_version) 92 exit(0); 93# else 94# if(SND_LIB_MAJOR < $alsa_min_major_version) 95# error not present 96# endif 97 98# if(SND_LIB_MINOR > $alsa_min_minor_version) 99 exit(0); 100# else 101# if(SND_LIB_MINOR < $alsa_min_minor_version) 102# error not present 103# endif 104 105# if(SND_LIB_SUBMINOR < $alsa_min_micro_version) 106# error not present 107# endif 108# endif 109# endif 110exit(0); 111])dnl macro MPUT_ALSA_TRY 112 113AC_LANG_SAVE 114AC_LANG_C 115AC_TRY_COMPILE([ 116#include <alsa/asoundlib.h> 117], 118 MPUT_ALSA_TRY(), 119 [AC_MSG_RESULT(found.)], 120 [AC_TRY_COMPILE([ 121#include <sys/asoundlib.h> 122], 123 MPUT_ALSA_TRY(), 124 [AC_MSG_RESULT(found.)], 125 [AC_MSG_RESULT(not present.) 126 ifelse([$3], ,[AC_MSG_RESULT(libasound was not found anywhere.)]) 127 alsa_found=no]) 128 ifelse([$3], ,[AC_MSG_RESULT(Sufficiently new version of libasound not found.)]) 129]) 130AC_LANG_RESTORE 131 132dnl Now that we know we have the right version, why not see if we 133dnl have the library and not just the headers. 134AC_CHECK_LIB([asound],[snd_ctl_open], , 135 [ifelse([$3], ,[AC_MSG_RESULT(No linkable libasound was found.)]) 136 alsa_found=no 137]) 138 139if test "x$alsa_found" = "xyes" ; then 140 ifelse([$2], , :, [$2]) 141 LIBS=`echo $LIBS | sed 's/-lasound//g'` 142 LIBS=`echo $LIBS | sed 's/ //'` 143 LIBS="-lasound $LIBS" 144else 145 ifelse([$3], , :, [$3]) 146 CFLAGS="$alsa_save_CFLAGS" 147 LDFLAGS="$alsa_save_LDFLAGS" 148 LIBS="$alsa_save_LIBS" 149 ALSA_CFLAGS="" 150 ALSA_LIBS="" 151fi 152 153dnl That should be it. Now just export out symbols: 154AC_SUBST(ALSA_CFLAGS) 155AC_SUBST(ALSA_LIBS) 156]) 157