SDL: emscripten: obey enable-misc/SDL_MISC settings

From 85dff3e453a456ee4d778a4e515e6a04dbe91f63 Mon Sep 17 00:00:00 2001
From: pionere <[EMAIL REDACTED]>
Date: Wed, 16 Mar 2022 08:58:52 +0100
Subject: [PATCH] emscripten: obey enable-misc/SDL_MISC settings

---
 CMakeLists.txt | 9 +++++----
 configure      | 9 ++++++---
 configure.ac   | 9 ++++++---
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6c9b559dee6..cc2264a1610 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1175,10 +1175,11 @@ elseif(EMSCRIPTEN)
   # project. Uncomment at will for verbose cross-compiling -I/../ path info.
   target_compile_options(sdl-build-options INTERFACE "-Wno-warn-absolute-paths")
 
-  file(GLOB EMSRIPTEN_MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/emscripten/*.c)
-  set(SOURCE_FILES ${SOURCE_FILES} ${EMSRIPTEN_MISC_SOURCES})
-  set(HAVE_SDL_MISC TRUE)
-
+  if(SDL_MISC)
+    file(GLOB EMSRIPTEN_MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/emscripten/*.c)
+    set(SOURCE_FILES ${SOURCE_FILES} ${EMSRIPTEN_MISC_SOURCES})
+    set(HAVE_SDL_MISC TRUE)
+  endif()
   if(SDL_AUDIO)
     set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
     file(GLOB EM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/emscripten/*.c)
diff --git a/configure b/configure
index 18a9fc4a821..54a550c79b4 100755
--- a/configure
+++ b/configure
@@ -26683,8 +26683,11 @@ $as_echo "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h
         CheckClockGettime
         CheckEmscriptenGLES
 
-        SOURCES="$SOURCES $srcdir/src/misc/emscripten/*.c"
-        have_misc=yes
+        # Set up files for the misc library
+        if test x$enable_misc = xyes; then
+            SOURCES="$SOURCES $srcdir/src/misc/emscripten/*.c"
+            have_misc=yes
+        fi
 
          # Set up files for the power library
         if test x$enable_power = xyes; then
@@ -26695,7 +26698,7 @@ $as_echo "#define SDL_POWER_EMSCRIPTEN 1" >>confdefs.h
             have_power=yes
         fi
 
-        # Set up files for the power library
+        # Set up files for the joystick library
         if test x$enable_joystick = xyes; then
 
 $as_echo "#define SDL_JOYSTICK_EMSCRIPTEN 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac
index 0391c67b463..28d620d94fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4388,8 +4388,11 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
         CheckClockGettime
         CheckEmscriptenGLES
 
-        SOURCES="$SOURCES $srcdir/src/misc/emscripten/*.c"
-        have_misc=yes
+        # Set up files for the misc library
+        if test x$enable_misc = xyes; then
+            SOURCES="$SOURCES $srcdir/src/misc/emscripten/*.c"
+            have_misc=yes
+        fi
 
          # Set up files for the power library
         if test x$enable_power = xyes; then
@@ -4398,7 +4401,7 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
             have_power=yes
         fi
 
-        # Set up files for the power library
+        # Set up files for the joystick library
         if test x$enable_joystick = xyes; then
             AC_DEFINE(SDL_JOYSTICK_EMSCRIPTEN, 1, [ ])
             SOURCES="$SOURCES $srcdir/src/joystick/emscripten/*.c"