From c438953aa2593c30201b17562328f46d97252ac4 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 26 Jul 2025 13:50:20 -0400
Subject: [PATCH] sunaudio: don't compile in the sun audio backend if
sys/audioio.h is missing.
Newer Solaris-based releases, like OpenIndiana, don't include this, using
Open Sound System, or something layered over OSS like PulseAudio, instead.
Fixes #13405.
(cherry picked from commit cf1eb95fb1b761cd0c5b544fc9ae7472542b559d)
---
CMakeLists.txt | 12 ++++++++----
configure | 16 +++++++++++++---
configure.ac | 12 ++++++++----
3 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a018debf48e7a..132d0aafa001d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1470,10 +1470,14 @@ elseif(EMSCRIPTEN)
elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
if(SDL_AUDIO)
if(SYSV5 OR SOLARIS OR HPUX)
- set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
- file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
- list(APPEND SOURCE_FILES ${SUN_AUDIO_SOURCES})
- set(HAVE_SDL_AUDIO TRUE)
+ # Newer Solaris-based systems, like OpenIndiana, don't have this interface anymore. Check for the header first.
+ check_include_file(sys/audioio HAVE_SYS_AUDIOIO_H)
+ if(HAVE_SYS_AUDIOIO_H)
+ set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
+ file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
+ list(APPEND SOURCE_FILES ${SUN_AUDIO_SOURCES})
+ set(HAVE_SDL_AUDIO TRUE)
+ endif()
elseif(NETBSD)
set(SDL_AUDIO_DRIVER_NETBSD 1)
file(GLOB NETBSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/netbsd/*.c)
diff --git a/configure b/configure
index 3b401e6acc002..6a4bf7ca24fcc 100755
--- a/configure
+++ b/configure
@@ -28741,12 +28741,22 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
if test x$enable_audio = xyes; then
case $ARCH in
sysv5|solaris|hpux)
+ ac_fn_c_check_header_compile "$LINENO" "audio/audiolib.h" "ac_cv_header_audio_audiolib_h" "$ac_includes_default"
+if test "x$ac_cv_header_audio_audiolib_h" = xyes
+then :
+ have_sys_audiolib=yes
+else $as_nop
+ have_sys_audiolib=no
+fi
+
+ if test x$have_sys_audiolib = xyes; then
printf "%s\n" "#define SDL_AUDIO_DRIVER_SUNAUDIO 1" >>confdefs.h
- SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
- SUMMARY_audio="${SUMMARY_audio} sun"
- have_audio=yes
+ SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
+ SUMMARY_audio="${SUMMARY_audio} sun"
+ have_audio=yes
+ fi
;;
netbsd) # Don't use this on OpenBSD, it's busted.
diff --git a/configure.ac b/configure.ac
index 543600172c5a9..13a06f39e67a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3869,10 +3869,14 @@ case "$host" in
if test x$enable_audio = xyes; then
case $ARCH in
sysv5|solaris|hpux)
- AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
- SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
- SUMMARY_audio="${SUMMARY_audio} sun"
- have_audio=yes
+ dnl Newer Solaris-based systems, like OpenIndiana, don't have this interface anymore. Check for the header first.
+ AC_CHECK_HEADER(audio/audiolib.h,have_sys_audiolib=yes,have_sys_audiolib=no)
+ if test x$have_sys_audiolib = xyes; then
+ AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
+ SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
+ SUMMARY_audio="${SUMMARY_audio} sun"
+ have_audio=yes
+ fi
;;
netbsd) # Don't use this on OpenBSD, it's busted.
AC_DEFINE(SDL_AUDIO_DRIVER_NETBSD, 1, [ ])