acinclude/alsa.m4
author Ryan C. Gordon <icculus@icculus.org>
Mon, 29 Oct 2018 20:00:03 -0400
changeset 12369 68c87b40b434
parent 3342 3da232c5980a
permissions -rw-r--r--
winmain: Don't use SDL_malloc (or SDL_stack_alloc, which might be malloc).

Otherwise, we are using the allocator before the app can set up its own hooks.

Now we use VirtualAlloc, and WideCharToMultiByte (because SDL_iconv uses
SDL_malloc, too!) to get ready to call into SDL_main.

This also makes console_wmain() call into the same routines as everything
else, so we don't have to deal with those allocations, too. Hopefully we
end up with the same results from GetCommandLine() as we do in wargv.

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