sdl12-compat: fix build against recently broken SDL2 headers,

From 71ac21122df59432bea59b7019a2e2f7165b2d67 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 26 Jul 2021 17:50:50 +0300
Subject: [PATCH] fix build against recently broken SDL2 headers,

i.e. at least SDL_config_windows.h defined HAVE_IMMINTRIN_H without
much checking.  we actually do not need immintrin.h in sdl12-compat
therefore disabled its use in standalone makefiles.

some whitespace tidy-ups.
---
 src/Makefile.darwin | 1 +
 src/Makefile.linux  | 1 +
 src/Makefile.mingw  | 1 +
 src/Makefile.os2    | 5 +++--
 src/Makefile.vc     | 1 +
 src/Makefile.w32    | 3 ++-
 src/SDL12_compat.c  | 7 +++----
 7 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/Makefile.darwin b/src/Makefile.darwin
index 019448e..ddd8687 100644
--- a/src/Makefile.darwin
+++ b/src/Makefile.darwin
@@ -12,6 +12,7 @@ endif
 LD = $(CC)
 
 CPPFLAGS = -DNDEBUG -D_THREAD_SAFE
+CPPFLAGS+= -DSDL_DISABLE_IMMINTRIN_H
 
 CFLAGS  = -mmacosx-version-min=10.6 -fPIC -O3 -Wall
 LDFLAGS = -mmacosx-version-min=10.6 -dynamiclib -Wl,-undefined,error -Wl,-single_module
diff --git a/src/Makefile.linux b/src/Makefile.linux
index f85ca96..8a83f5e 100644
--- a/src/Makefile.linux
+++ b/src/Makefile.linux
@@ -8,6 +8,7 @@ CC=gcc
 LD = $(CC)
 
 CPPFLAGS = -DNDEBUG -D_THREAD_SAFE -D_REENTRANT
+CPPFLAGS+= -DSDL_DISABLE_IMMINTRIN_H
 
 CFLAGS  = -fPIC -O3 -Wall
 LDFLAGS = -shared -Wl,-soname,libSDL-1.2.so.0
diff --git a/src/Makefile.mingw b/src/Makefile.mingw
index 1130a9c..94b5b42 100644
--- a/src/Makefile.mingw
+++ b/src/Makefile.mingw
@@ -14,6 +14,7 @@ endif
 LD = $(CC)
 
 CPPFLAGS = -DDLL_EXPORT -DNDEBUG
+CPPFLAGS+= -DSDL_DISABLE_IMMINTRIN_H
 
 CFLAGS  = -O3 -Wall
 LDFLAGS = -nostdlib -shared -Wl,--no-undefined -Wl,--enable-auto-image-base -Wl,--out-implib,$(LIB)
diff --git a/src/Makefile.os2 b/src/Makefile.os2
index 4f117c0..9b8bdfd 100644
--- a/src/Makefile.os2
+++ b/src/Makefile.os2
@@ -1,5 +1,5 @@
 #  OpenWatcom makefile to build SDL for OS/2
-
+#
 !ifndef %WATCOM
 !error Environment variable WATCOM is not specified!
 !endif
@@ -8,7 +8,7 @@ DLLNAME = SDL12
 VERSION = 1.2.50
 
 # change SDL2INC to point to the SDL2 headers
-SDL2INC = C:\SDL2DEV\h\SDL2
+SDL2INC = include
 INCPATH = -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h" -I"$(SDL2INC)"
 LIBNAME = $(DLLNAME)
 
@@ -17,6 +17,7 @@ LIBFILE = $(LIBNAME).lib
 LNKFILE = $(LIBNAME).lnk
 
 CFLAGS_DEF=-bt=os2 -d0 -zq -bm -5s -fp5 -fpi87 -sg -oteanbmier $(INCPATH)
+CFLAGS_DEF+= -DSDL_DISABLE_IMMINTRIN_H
 CFLAGS_DLL=$(CFLAGS_DEF) -bd
 
 # Special flags for building SDL
diff --git a/src/Makefile.vc b/src/Makefile.vc
index 8a2cd8e..d234e15 100644
--- a/src/Makefile.vc
+++ b/src/Makefile.vc
@@ -8,6 +8,7 @@
 INCLUDES = -Iinclude
 
 CPPFLAGS = -DNDEBUG -DDLL_EXPORT
+CPPFLAGS = $(CPPFLAGS) -DSDL_DISABLE_IMMINTRIN_H
 
 CC = cl
 LD = link
diff --git a/src/Makefile.w32 b/src/Makefile.w32
index bd5bf39..af1f65f 100644
--- a/src/Makefile.w32
+++ b/src/Makefile.w32
@@ -1,5 +1,5 @@
 #  OpenWatcom makefile to build SDL for Win32
-
+#
 !ifndef %WATCOM
 !error Environment variable WATCOM is not specified!
 !endif
@@ -17,6 +17,7 @@ LIBFILE = $(LIBNAME).lib
 LNKFILE = $(LIBNAME).lnk
 
 CFLAGS_DEF=-bt=nt -d0 -zq -bm -5s -fp5 -fpi87 -sg -oteanbmier $(INCPATH)
+CFLAGS_DEF+= -DSDL_DISABLE_IMMINTRIN_H
 # we override the DECLSPEC define in begin_code.h, because we are using
 # an exports file to remove the _cdecl '_' prefix from the symbol names
 CFLAGS_DLL=$(CFLAGS_DEF) -bd -DDLL_EXPORT -DDECLSPEC=
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 62b4503..89663af 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -166,7 +166,7 @@ SDL20_MostSignificantBitIndex32(Uint32 x)
 #endif
 }
 
-/* SDL_truncf needs SDL >=2.0.14 (and breaks Watcom), so copy it here */
+/* SDL_truncf needs SDL >=2.0.14, so copy it here. */
 static float SDL20_truncf(float x)
 {
     return (x < 0.0f) ? SDL20_ceilf(x) : SDL20_floorf(x);
@@ -2227,7 +2227,7 @@ AdjustOpenGLLogicalScalingPoint(int *x, int *y)
     *x = SDL_max(SDL_min(adjusted_x, OpenGLLogicalScalingWidth), 0);
     *y = SDL_max(SDL_min(adjusted_y, OpenGLLogicalScalingHeight), 0);
 }
-    
+
 /* Scale a vector (e.g. relative mouse movement) to the logical scaling size */
 static void
 AdjustOpenGLLogicalScalingVector(int *x, int *y, float *rx, float *ry)
@@ -2266,7 +2266,6 @@ AdjustOpenGLLogicalScalingVector(int *x, int *y, float *rx, float *ry)
         *ry = float_y - trunc_y;
     }
 }
-    
 
 static Uint8 MouseButtonState20to12(const Uint32 state20)
 {
@@ -2635,7 +2634,7 @@ Keysym20to12(const SDL_Keycode keysym20)
     FIXME("map some of the SDLK12_WORLD keys");
     return SDLK12_UNKNOWN;
 }
-#else
+#else /* https://github.com/libsdl-org/sdl12-compat/pull/97 */
 # define KeysymFromSDL2(_ev20) Scancode20toKeysym12((_ev20)->key.keysym.scancode)
 static SDL12Key
 Scancode20toKeysym12(const SDL_Scancode scancode20)