🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
4.4 KiB

  1. 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.23 2004/01/16 18:14:22 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-inc-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. dnl
  22. dnl Get the cflags and libraries for alsa
  23. dnl
  24. AC_ARG_WITH(alsa-prefix,
  25. [ --with-alsa-prefix=PFX Prefix where Alsa library is installed(optional)],
  26. [alsa_prefix="$withval"], [alsa_prefix=""])
  27. AC_ARG_WITH(alsa-inc-prefix,
  28. [ --with-alsa-inc-prefix=PFX Prefix where include libraries are (optional)],
  29. [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
  30. dnl FIXME: this is not yet implemented
  31. AC_ARG_ENABLE(alsatest,
  32. [ --disable-alsatest Do not try to compile and run a test Alsa program],
  33. [enable_alsatest="$enableval"],
  34. [enable_alsatest=yes])
  35. dnl Add any special include directories
  36. AC_MSG_CHECKING(for ALSA CFLAGS)
  37. if test "$alsa_inc_prefix" != "" ; then
  38. ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
  39. CFLAGS="$CFLAGS -I$alsa_inc_prefix"
  40. fi
  41. AC_MSG_RESULT($ALSA_CFLAGS)
  42. dnl add any special lib dirs
  43. AC_MSG_CHECKING(for ALSA LDFLAGS)
  44. if test "$alsa_prefix" != "" ; then
  45. ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
  46. LDFLAGS="$LDFLAGS $ALSA_LIBS"
  47. fi
  48. dnl add the alsa library
  49. ALSA_LIBS="$ALSA_LIBS -lasound -lm -ldl -lpthread"
  50. LIBS=`echo $LIBS | sed 's/-lm//'`
  51. LIBS=`echo $LIBS | sed 's/-ldl//'`
  52. LIBS=`echo $LIBS | sed 's/-lpthread//'`
  53. LIBS=`echo $LIBS | sed 's/ //'`
  54. LIBS="$ALSA_LIBS $LIBS"
  55. AC_MSG_RESULT($ALSA_LIBS)
  56. dnl Check for a working version of libasound that is of the right version.
  57. min_alsa_version=ifelse([$1], ,0.1.1, $1)
  58. AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
  59. no_alsa=""
  60. alsa_min_major_version=`echo $min_alsa_version | \
  61. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  62. alsa_min_minor_version=`echo $min_alsa_version | \
  63. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  64. alsa_min_micro_version=`echo $min_alsa_version | \
  65. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  66. AC_LANG_PUSH([C])
  67. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  68. #include <alsa/asoundlib.h>
  69. ]], [[
  70. /* ensure backward compatibility */
  71. #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
  72. #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
  73. #endif
  74. #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
  75. #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
  76. #endif
  77. #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
  78. #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
  79. #endif
  80. # if(SND_LIB_MAJOR > $alsa_min_major_version)
  81. exit(0);
  82. # else
  83. # if(SND_LIB_MAJOR < $alsa_min_major_version)
  84. # error not present
  85. # endif
  86. # if(SND_LIB_MINOR > $alsa_min_minor_version)
  87. exit(0);
  88. # else
  89. # if(SND_LIB_MINOR < $alsa_min_minor_version)
  90. # error not present
  91. # endif
  92. # if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
  93. # error not present
  94. # endif
  95. # endif
  96. # endif
  97. exit(0);
  98. ]])],
  99. [AC_MSG_RESULT(found.)],
  100. [AC_MSG_RESULT(not present.)
  101. ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)])
  102. alsa_found=no]
  103. )
  104. AC_LANG_POP([C])
  105. dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
  106. if test "x$enable_alsatest" = "xyes"; then
  107. AC_CHECK_LIB([asound], [snd_ctl_open],,
  108. [ifelse([$3], , [AC_MSG_ERROR(No linkable libasound was found.)])
  109. alsa_found=no]
  110. )
  111. fi
  112. if test "x$alsa_found" = "xyes" ; then
  113. ifelse([$2], , :, [$2])
  114. LIBS=`echo $LIBS | sed 's/-lasound//g'`
  115. LIBS=`echo $LIBS | sed 's/ //'`
  116. LIBS="-lasound $LIBS"
  117. fi
  118. if test "x$alsa_found" = "xno" ; then
  119. ifelse([$3], , :, [$3])
  120. CFLAGS="$alsa_save_CFLAGS"
  121. LDFLAGS="$alsa_save_LDFLAGS"
  122. LIBS="$alsa_save_LIBS"
  123. ALSA_CFLAGS=""
  124. ALSA_LIBS=""
  125. fi
  126. dnl That should be it. Now just export out symbols:
  127. AC_SUBST(ALSA_CFLAGS)
  128. AC_SUBST(ALSA_LIBS)
  129. ])