+AS_CASE(["$systems"], [*" alsa "*], [
+ AC_CHECK_LIB(asound, snd_pcm_open,
+ [api="$api -D__LINUX_ALSA__"
+ req="$req alsa"
+ need_pthread=yes
+ found="$found ALSA"
+ LIBS="-lasound $LIBS"],
+ AS_CASE(["$required"], [*" alsa "*],
+ AC_MSG_ERROR([ALSA support requires the asound library!])))
+])
+
+AS_CASE(["$systems"], [*" pulse "*], [
+ AC_CHECK_LIB(pulse-simple, pa_simple_flush,
+ [api="$api -D__LINUX_PULSE__"
+ req="$req libpulse-simple"
+ need_pthread=yes
+ found="$found PulseAudio"
+ LIBS="-lpulse-simple $LIBS"],
+ AS_CASE(["$required"], [*" pulse "*],
+ AC_MSG_ERROR([PulseAudio support requires the pulse-simple library!])))
+])
+
+AS_CASE(["$systems"], [*" oss "*], [
+ # libossaudio not required on some platforms (e.g. linux) so we
+ # don't break things if it's not found, but issue a warning when we
+ # are not sure (i.e. not on linux)
+ AS_CASE([$host], [*-*-linux*], [], [*], [need_ossaudio=yes])
+ AC_CHECK_LIB(ossaudio, main, [have_ossaudio=true],
+ AS_CASE(["$required"], [*" oss "*],
+ AS_IF([test "x$need_ossaudio" = xyes],
+ AC_MSG_WARN([RtAudio may require the ossaudio library]))))
+
+ # linux systems may have soundcard.h but *not* have OSS4 installed,
+ # we have to actually check if it exports OSS4 symbols
+ AC_CHECK_DECL(SNDCTL_SYSINFO,
+ [api="$api -D__LINUX_OSS__"
+ need_pthread=yes
+ found="$found OSS"],
+ AS_CASE(["$required"], [*" oss "*],
+ AC_MSG_ERROR([sys/soundcard.h not found]))
+ [],
+ [#include <sys/soundcard.h>])
+])
+
+AS_CASE(["$systems"], [*" jack "*], [
+ AC_CHECK_LIB(jack, jack_client_open,
+ [api="$api -D__UNIX_JACK__"
+ req="$req jack"
+ need_pthread=yes
+ found="$found JACK"
+ LIBS="-ljack $LIBS"],
+ AS_CASE(["$required"], [*" jack "*],
+ AC_MSG_ERROR([JACK support requires the jack library!])))
+])
+
+AS_CASE(["$systems"], [*" core "*], [
+ AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
+ [api="$api -D__MACOSX_CORE__"
+ need_pthread=yes
+ found="$found CoreAudio",
+ LIBS="$LIBS -framework CoreAudio -framework CoreFoundation"],
+ AS_CASE(["$required"], [*" core "*],
+ AC_MSG_ERROR([CoreAudio header files not found!])))
+])
+
+AS_CASE(["$systems"], [*" asio "*], [
+ api="$api -D__WINDOWS_ASIO__"
+ use_asio=yes
+ CPPFLAGS="-I$srcdir/include $CPPFLAGS"
+ need_ole32=yes
+ found="$found ASIO"
+])
+
+AS_CASE(["$systems"], [*" dsound "*], [
+ AC_CHECK_HEADERS(windows.h)
+ AC_CHECK_HEADERS(mmsystem.h mmreg.h dsound.h, [], [],
+[#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif])
+ AS_IF([test "x$ac_cv_header_windows_h" = xyes \
+ && test "x$ac_cv_header_mmsystem_h" = xyes \
+ && test "x$ac_cv_header_mmreg_h" = xyes \
+ && test "x$ac_cv_header_dsound_h" = xyes],
+ [api="$api -D__WINDOWS_DS__"
+ need_ole32=yes
+ found="$found DirectSound"
+ LIBS="-ldsound -lwinmm $LIBS"])
+])
+
+AS_CASE(["$systems"], [*" wasapi "*], [
+ AC_CHECK_HEADERS(windows.h)
+ AC_CHECK_HEADERS(audioclient.h avrt.h mmdeviceapi.h, [], [],
+[#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif])
+ AS_IF([test "x$ac_cv_header_windows_h" = xyes \
+ && test "x$ac_cv_header_audioclient_h" = xyes \
+ && test "x$ac_cv_header_avrt_h" = xyes \
+ && test "x$ac_cv_header_mmdeviceapi_h" = xyes],
+ [api="$api -D__WINDOWS_WASAPI__"
+ CPPFLAGS="-I$srcdir/include $CPPFLAGS"
+ need_ole32=yes
+ found="$found WASAPI"
+ LIBS="-lwinmm -lksuser -lmfplat -lmfuuid -lwmcodecdspuuid $LIBS"])
+])
+
+AS_IF([test -n "$need_ole32"], [LIBS="-lole32 $LIBS"])
+
+AS_IF([test -n "$need_pthread"],[
+ AC_MSG_CHECKING([for pthread])
+ AC_CHECK_LIB(pthread, pthread_create, ,
+ AC_MSG_ERROR([RtAudio requires the pthread library!]))])
+
+AC_MSG_CHECKING([for audio API])
+
+# Error case: no known realtime systems found.
+AS_IF([test x"$api" = "x"], [
+ AC_MSG_RESULT([none])
+ AC_MSG_ERROR([No known system type found for realtime support!])
+], [
+ AC_MSG_RESULT([$found])
+])
+
+AM_CONDITIONAL( ASIO, [test "x${use_asio}" = "xyes" ])
+
+CPPFLAGS="$CPPFLAGS $api"
+
+AC_OUTPUT