Skip to content

Commit c11279c

Browse files
committed
qb: auto-disable microphone on pre-10.7 macOS targets
audio/drivers/coreaudio_mic_macos.m uses C11 <stdatomic.h>, which requires a 10.6/10.7-era SDK or newer. On Xcode 3.1 / 10.4-10.5 / PowerPC the header doesn't exist and the driver fails to compile: coreaudio_mic_macos.m:27:23: error: stdatomic.h: No such file or directory Detect the target macOS version in config.libs.sh and clear HAVE_MICROPHONE when it's pre-10.7, unless the user explicitly passed --enable-microphone. Target version is taken from $MACOSX_DEPLOYMENT_TARGET when set (authoritative for cross-builds, e.g. someone on a modern macOS host targeting 10.5 via an older SDK), falling back to sw_vers for native builds. Both tools have been available since 10.4. Modern macOS builds are unaffected — they continue to compile the microphone driver as before.
1 parent c0c9349 commit c11279c

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

qb/config.libs.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,36 @@ if [ "$OS" = 'Darwin' ]; then
262262
check_lib '' CORETEXT "-framework CoreText" CTFontCreateWithName
263263
add_opt CRTSWITCHRES no
264264

265+
# The microphone driver (audio/drivers/coreaudio_mic_macos.m) uses
266+
# C11 <stdatomic.h>, which requires a 10.6/10.7-era SDK or newer.
267+
# On Xcode 3.1 / 10.4-10.5 / PowerPC the header doesn't exist and
268+
# the driver cannot be compiled. Detect pre-10.7 targets and
269+
# auto-disable microphone support unless the user passed
270+
# --enable-microphone explicitly.
271+
#
272+
# MACOSX_DEPLOYMENT_TARGET (set by the invoker or the toolchain)
273+
# takes priority over sw_vers, because on a cross-build the host
274+
# OS version may be newer than the target.
275+
if [ "${USER_MICROPHONE:-}" != 'yes' ] && [ "$HAVE_MICROPHONE" != 'no' ]; then
276+
macos_target_ver="${MACOSX_DEPLOYMENT_TARGET:-}"
277+
if [ -z "$macos_target_ver" ] && command -v sw_vers >/dev/null 2>&1; then
278+
macos_target_ver="$(sw_vers -productVersion 2>/dev/null)"
279+
fi
280+
if [ -n "$macos_target_ver" ]; then
281+
mt_major=$(printf %s "$macos_target_ver" | cut -d. -f1)
282+
mt_minor=$(printf %s "$macos_target_ver" | cut -d. -f2)
283+
[ -z "$mt_major" ] && mt_major=0
284+
[ -z "$mt_minor" ] && mt_minor=0
285+
if [ "$mt_major" -lt 10 ] || \
286+
{ [ "$mt_major" -eq 10 ] && [ "$mt_minor" -lt 7 ]; }; then
287+
HAVE_MICROPHONE=no
288+
die : "Notice: macOS target $macos_target_ver is pre-10.7; disabling microphone (requires C11 <stdatomic.h>). Override with --enable-microphone."
289+
fi
290+
unset mt_major mt_minor
291+
fi
292+
unset macos_target_ver
293+
fi
294+
265295
if [ "$HAVE_METAL" = yes ] || [ "$HAVE_VULKAN" = yes ]; then
266296
check_lib '' COCOA_METAL "-framework AppKit" NSApplicationMain
267297
else

0 commit comments

Comments
 (0)