Commit 65e9415b98cbd96809702b6814b62004aa383631

pionere 2022-01-10T17:00:32

sync handling of subsystems - add DUMMY-define in case the subsystem is enabled but not available (filesystem/misc/locale) - add missing PSP/VITA-filesystem defines - sync the order of filesystems in SDL_config.h.cmake/in - add option to disable locale subsystem in configure

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e0895e..20119d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2568,19 +2568,19 @@ if(NOT HAVE_SDL_LOADSO)
   set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
 endif()
 if(NOT HAVE_SDL_FILESYSTEM)
-  set(SDL_FILESYSTEM_DISABLED 1)
+  set(SDL_FILESYSTEM_DUMMY 1)
   file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c)
   set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
 endif()
 if(NOT HAVE_SDL_LOCALE)
-  set(SDL_LOCALE_DISABLED 1)
+  set(SDL_LOCALE_DUMMY 1)
   file(GLOB LOCALE_SOURCES ${SDL2_SOURCE_DIR}/src/locale/dummy/*.c)
   set(SOURCE_FILES ${SOURCE_FILES} ${LOCALE_SOURCES})
 endif()
 if(NOT HAVE_SDL_MISC)
-  set(SDL_MISC_DISABLED 1)
-  file(GLOB LOCALE_SOURCES ${SDL2_SOURCE_DIR}/src/misc/dummy/*.c)
-  set(SOURCE_FILES ${SOURCE_FILES} ${LOCALE_SOURCES})
+  set(SDL_MISC_DUMMY 1)
+  file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/dummy/*.c)
+  set(SOURCE_FILES ${SOURCE_FILES} ${MISC_SOURCES})
 endif()
 
 # We always need to have threads and timers around
diff --git a/configure b/configure
index f0f27a2..70f786c 100755
--- a/configure
+++ b/configure
@@ -823,6 +823,7 @@ enable_threads
 enable_timers
 enable_file
 enable_misc
+enable_locale
 enable_loadso
 enable_cpuinfo
 enable_assembly
@@ -1601,6 +1602,7 @@ Optional Features:
   --enable-timers         Enable the timer subsystem [default=yes]
   --enable-file           Enable the file subsystem [default=yes]
   --enable-misc           Enable the misc subsystem [default=yes]
+  --enable-locale         Enable the locale subsystem [default=yes]
   --enable-loadso         Enable the shared object loading subsystem
                           [default=yes]
   --enable-cpuinfo        Enable the cpuinfo subsystem [default=yes]
@@ -18116,6 +18118,20 @@ $as_echo "#define SDL_MISC_DISABLED 1" >>confdefs.h
 else
     SUMMARY_modules="${SUMMARY_modules} misc"
 fi
+# Check whether --enable-locale was given.
+if test "${enable_locale+set}" = set; then :
+  enableval=$enable_locale;
+else
+  enable_locale=yes
+fi
+
+if test x$enable_locale != xyes; then
+
+$as_echo "#define SDL_LOCALE_DISABLED 1" >>confdefs.h
+
+else
+    SUMMARY_modules="${SUMMARY_modules} locale"
+fi
 # Check whether --enable-threads was given.
 if test "${enable_threads+set}" = set; then :
   enableval=$enable_threads;
@@ -25839,10 +25855,11 @@ $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
             SOURCES="$SOURCES $srcdir/src/misc/unix/*.c"
             have_misc=yes
         fi
-
-        SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
-        have_locale=yes
-
+        # Set up files for the locale library
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
+            have_locale=yes
+        fi
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
           case $ARCH in
@@ -26060,9 +26077,10 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
             have_misc=yes
         fi
         # Use the Windows locale APIs.
-        SOURCES="$SOURCES $srcdir/src/locale/windows/*.c"
-        have_locale=yes
-
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/windows/*.c"
+            have_locale=yes
+        fi
         # Set up files for the video library
         if test x$enable_video = xyes; then
 
@@ -26351,9 +26369,10 @@ $as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h
             have_misc=yes
         fi
         # Set up files for the locale library
-        SOURCES="$SOURCES $srcdir/src/locale/haiku/*.cc"
-        have_locale=yes
-
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/haiku/*.cc"
+            have_locale=yes
+        fi
         # The Haiku platform requires special setup.
         SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
@@ -26379,9 +26398,10 @@ $as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h
             have_misc=yes
         fi
         # Set up files for the locale library
-        SOURCES="$SOURCES $srcdir/src/locale/macosx/*.m"
-        have_locale=yes
-
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/macosx/*.m"
+            have_locale=yes
+        fi
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
 
@@ -26515,9 +26535,10 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h
             have_misc=yes
         fi
         # Set up files for the locale library
-        SOURCES="$SOURCES $srcdir/src/locale/macosx/*.m"
-        have_locale=yes
-
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/macosx/*.m"
+            have_locale=yes
+        fi
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
 
@@ -26683,8 +26704,10 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
             have_timers=yes
         fi
         # Set up files for the locale library
-        SOURCES="$SOURCES $srcdir/src/locale/emscripten/*.c"
-        have_locale=yes
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/emscripten/*.c"
+            have_locale=yes
+        fi
         ;;
     *-*-riscos*)
         ARCH=riscos
@@ -26757,8 +26780,10 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
             SOURCES="$SOURCES $srcdir/src/core/os2/geniconv/*.c"
         fi
         # Use the Unix locale APIs.
-        SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
-        have_locale=yes
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
+            have_locale=yes
+        fi
         # Set up files for the video library
         if test x$enable_video = xyes; then
 
@@ -26856,9 +26881,19 @@ INSTALL_SDL2_CONFIG=$enable_sdl2_config
 # Verify that we have all the platform specific files we need
 
 if test x$have_misc != xyes; then
+    if test x$enable_misc = xyes; then
+
+$as_echo "#define SDL_MISC_DUMMY 1" >>confdefs.h
+
+    fi
     SOURCES="$SOURCES $srcdir/src/misc/dummy/*.c"
 fi
 if test x$have_locale != xyes; then
+    if test x$enable_locale = xyes; then
+
+$as_echo "#define SDL_LOCALE_DUMMY 1" >>confdefs.h
+
+    fi
     SOURCES="$SOURCES $srcdir/src/locale/dummy/*.c"
 fi
 if test x$have_joystick != xyes; then
@@ -26904,7 +26939,7 @@ fi
 if test x$have_filesystem != xyes; then
     if test x$enable_filesystem = xyes; then
 
-$as_echo "#define SDL_FILESYSTEM_DISABLED 1" >>confdefs.h
+$as_echo "#define SDL_FILESYSTEM_DUMMY 1" >>confdefs.h
 
     fi
     SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
diff --git a/configure.ac b/configure.ac
index 8b9388e..87ecb19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -535,6 +535,14 @@ if test x$enable_misc != xyes; then
 else
     SUMMARY_modules="${SUMMARY_modules} misc"
 fi
+AC_ARG_ENABLE(locale,
+[AS_HELP_STRING([--enable-locale], [Enable the locale subsystem [default=yes]])],
+              , enable_locale=yes)
+if test x$enable_locale != xyes; then
+    AC_DEFINE(SDL_LOCALE_DISABLED, 1, [ ])
+else
+    SUMMARY_modules="${SUMMARY_modules} locale"
+fi
 AC_ARG_ENABLE(loadso,
 [AS_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [default=yes]])],
               , enable_loadso=yes)
@@ -3728,10 +3736,11 @@ case "$host" in
             SOURCES="$SOURCES $srcdir/src/misc/unix/*.c"
             have_misc=yes
         fi
-
-        SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
-        have_locale=yes
-
+        # Set up files for the locale library
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
+            have_locale=yes
+        fi
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
           case $ARCH in
@@ -3915,9 +3924,10 @@ case "$host" in
             have_misc=yes
         fi
         # Use the Windows locale APIs.
-        SOURCES="$SOURCES $srcdir/src/locale/windows/*.c"
-        have_locale=yes
-
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/windows/*.c"
+            have_locale=yes
+        fi
         # Set up files for the video library
         if test x$enable_video = xyes; then
             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS, 1, [ ])
@@ -4106,9 +4116,10 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
             have_misc=yes
         fi
         # Set up files for the locale library
-        SOURCES="$SOURCES $srcdir/src/locale/haiku/*.cc"
-        have_locale=yes
-
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/haiku/*.cc"
+            have_locale=yes
+        fi
         # The Haiku platform requires special setup.
         SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
@@ -4134,9 +4145,10 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
             have_misc=yes
         fi
         # Set up files for the locale library
-        SOURCES="$SOURCES $srcdir/src/locale/macosx/*.m"
-        have_locale=yes
-
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/macosx/*.m"
+            have_locale=yes
+        fi
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
@@ -4248,9 +4260,10 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
             have_misc=yes
         fi
         # Set up files for the locale library
-        SOURCES="$SOURCES $srcdir/src/locale/macosx/*.m"
-        have_locale=yes
-
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/macosx/*.m"
+            have_locale=yes
+        fi
         # Set up files for the audio library
         if test x$enable_audio = xyes; then
             AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ])
@@ -4388,8 +4401,10 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
             have_timers=yes
         fi
         # Set up files for the locale library
-        SOURCES="$SOURCES $srcdir/src/locale/emscripten/*.c"
-        have_locale=yes
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/emscripten/*.c"
+            have_locale=yes
+        fi
         ;;
     *-*-riscos*)
         ARCH=riscos
@@ -4456,8 +4471,10 @@ dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
             SOURCES="$SOURCES $srcdir/src/core/os2/geniconv/*.c"
         fi
         # Use the Unix locale APIs.
-        SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
-        have_locale=yes
+        if test x$enable_locale = xyes; then
+            SOURCES="$SOURCES $srcdir/src/locale/unix/*.c"
+            have_locale=yes
+        fi
         # Set up files for the video library
         if test x$enable_video = xyes; then
             AC_DEFINE(SDL_VIDEO_DRIVER_OS2, 1, [ ])
@@ -4534,9 +4551,15 @@ AC_SUBST([INSTALL_SDL2_CONFIG], [$enable_sdl2_config])
 # Verify that we have all the platform specific files we need
 
 if test x$have_misc != xyes; then
+    if test x$enable_misc = xyes; then
+        AC_DEFINE(SDL_MISC_DUMMY, 1, [ ])
+    fi
     SOURCES="$SOURCES $srcdir/src/misc/dummy/*.c"
 fi
 if test x$have_locale != xyes; then
+    if test x$enable_locale = xyes; then
+        AC_DEFINE(SDL_LOCALE_DUMMY, 1, [ ])
+    fi
     SOURCES="$SOURCES $srcdir/src/locale/dummy/*.c"
 fi
 if test x$have_joystick != xyes; then
@@ -4571,7 +4594,7 @@ if test x$have_timers != xyes; then
 fi
 if test x$have_filesystem != xyes; then
     if test x$enable_filesystem = xyes; then
-        AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ])
+        AC_DEFINE(SDL_FILESYSTEM_DUMMY, 1, [ ])
     fi
     SOURCES="$SOURCES $srcdir/src/filesystem/dummy/*.c"
 fi
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index af135c9..9a1bf67 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -493,6 +493,12 @@
 #cmakedefine SDL_FILESYSTEM_VITA @SDL_FILESYSTEM_VITA@
 #cmakedefine SDL_FILESYSTEM_PSP @SDL_FILESYSTEM_PSP@
 
+/* Enable misc subsystem */
+#cmakedefine SDL_MISC_DUMMY @SDL_MISC_DUMMY@
+
+/* Enable locale subsystem */
+#cmakedefine SDL_LOCALE_DUMMY @SDL_LOCALE_DUMMY@
+
 /* Enable assembly routines */
 #cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
 #cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 5ef2c15..195b988 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -447,16 +447,24 @@
 #undef SDL_POWER_HARDWIRED
 
 /* Enable system filesystem support */
+#undef SDL_FILESYSTEM_ANDROID
 #undef SDL_FILESYSTEM_HAIKU
 #undef SDL_FILESYSTEM_COCOA
 #undef SDL_FILESYSTEM_DUMMY
+#undef SDL_FILESYSTEM_RISCOS
 #undef SDL_FILESYSTEM_UNIX
 #undef SDL_FILESYSTEM_WINDOWS
 #undef SDL_FILESYSTEM_NACL
-#undef SDL_FILESYSTEM_ANDROID
 #undef SDL_FILESYSTEM_EMSCRIPTEN
 #undef SDL_FILESYSTEM_OS2
-#undef SDL_FILESYSTEM_RISCOS
+#undef SDL_FILESYSTEM_VITA
+#undef SDL_FILESYSTEM_PSP
+
+/* Enable misc subsystem */
+#undef SDL_MISC_DUMMY
+
+/* Enable locale subsystem */
+#undef SDL_LOCALE_DUMMY
 
 /* Enable assembly routines */
 #undef SDL_ASSEMBLY_ROUTINES