sdl2-compat: Split UNIX configuration into a separate header

From be424f79cf6adff1c8b5f38892c9b8d68a4c3562 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 31 Jan 2025 09:26:16 -0800
Subject: [PATCH] Split UNIX configuration into a separate header

This makes it more clear the scope of the configuration and makes it easier for us to customize based on the flavor of UNIX.
---
 include/SDL2/SDL_config.h      | 43 +-------------------
 include/SDL2/SDL_config_unix.h | 73 ++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 41 deletions(-)
 create mode 100644 include/SDL2/SDL_config_unix.h

diff --git a/include/SDL2/SDL_config.h b/include/SDL2/SDL_config.h
index 3cdcde8..698018a 100644
--- a/include/SDL2/SDL_config.h
+++ b/include/SDL2/SDL_config.h
@@ -47,6 +47,8 @@
 #include "SDL_config_emscripten.h"
 #elif defined(__NGAGE__)
 #include "SDL_config_ngage.h"
+#elif defined (__LINUX__) || defined(__FREEBSD__) || defined(__NETBSD__) || defined(__OPENBSD__) || defined(__SOLARIS__)
+#include "SDL_config_unix.h"
 #else
 /* This is a minimal configuration just to get SDL running on new platforms. */
 #include "SDL_config_minimal.h"
@@ -56,45 +58,4 @@
 #error Wrong SDL_config.h, check your include path?
 #endif
 
-
-/* DEFINES ADDED BY SDL2-COMPAT */
-
-#define STDC_HEADERS 1
-#define HAVE_CTYPE_H 1
-#define HAVE_LIMITS_H 1
-#define HAVE_MATH_H 1
-#define HAVE_SIGNAL_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_STDIO_H 1
-#define HAVE_STRING_H 1
-
-/* Some programs (incorrectly, probably) check defines that aren't available
-   with an SDL2 that doesn't have a configure-generated SDL_config.h, so force
-   a few that might be important. */
-#ifndef SDL_VIDEO_OPENGL
-#define SDL_VIDEO_OPENGL 1
-#endif
-#if defined(__WIN32__)
-#define SDL_VIDEO_DRIVER_WINDOWS 1
-#endif
-#if defined (__LINUX__) || defined(__FREEBSD__) || defined(__NETBSD__) || defined(__OPENBSD__) || defined(__SOLARIS__)
-#define SDL_VIDEO_DRIVER_X11 1
-#endif
-#if defined(__LINUX__)
-#define SDL_VIDEO_DRIVER_KMSDRM 1
-#define SDL_VIDEO_DRIVER_WAYLAND 1
-#endif
-#if defined(__MACOSX__)
-#define SDL_VIDEO_DRIVER_COCOA 1
-#endif
-#if defined(__IPHONEOS__) || defined(__TVOS__)
-#define SDL_VIDEO_DRIVER_UIKIT 1
-#endif
-#if defined(__ANDROID__)
-#define SDL_VIDEO_DRIVER_ANDROID 1
-#endif
-
-/* END DEFINES ADDED BY SDL2-COMPAT */
-
-
 #endif /* SDL_config_h_ */
diff --git a/include/SDL2/SDL_config_unix.h b/include/SDL2/SDL_config_unix.h
new file mode 100644
index 0000000..e3ae922
--- /dev/null
+++ b/include/SDL2/SDL_config_unix.h
@@ -0,0 +1,73 @@
+/*
+  Simple DirectMedia Layer
+  Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SDL_config_unix_h_
+#define SDL_config_unix_h_
+
+#include "SDL_platform.h"
+
+/* C datatypes */
+#if defined(__LP64__) || defined(_LP64) || defined(_WIN64)
+#define SIZEOF_VOIDP 8
+#else
+#define SIZEOF_VOIDP 4
+#endif
+
+#define HAVE_GCC_ATOMICS 1
+
+/* Useful headers */
+#define STDC_HEADERS 1
+#define HAVE_ALLOCA_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_FLOAT_H 1
+#define HAVE_ICONV_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_MALLOC_H 1
+#define HAVE_MATH_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_SIGNAL_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDIO_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_WCHAR_H 1
+
+#define SDL_VIDEO_DRIVER_X11 1
+
+#if defined(__LINUX__)
+#define SDL_VIDEO_DRIVER_KMSDRM 1
+#define SDL_VIDEO_DRIVER_WAYLAND 1
+#endif
+
+/* Enable OpenGL support */
+#define SDL_VIDEO_OPENGL 1
+#define SDL_VIDEO_OPENGL_ES 1
+
+/* Enable Vulkan support */
+#if defined(__LINUX__)
+#define SDL_VIDEO_VULKAN 1
+#endif
+
+#endif /* SDL_config_unix_h_ */