sdl2-compat: Added in the standalone makefiles from sdl12-compat. Untested!

From 18f6d53036bd4f6804085468d7b06c615369cd56 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sat, 26 Nov 2022 19:53:29 -0500
Subject: [PATCH] Added in the standalone makefiles from sdl12-compat.
 Untested!

---
 src/Makefile.darwin | 47 +++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.linux  | 40 ++++++++++++++++++++++++++++++++++++++
 src/Makefile.mingw  | 47 +++++++++++++++++++++++++++++++++++++++++++++
 src/Makefile.vc     | 42 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 176 insertions(+)
 create mode 100644 src/Makefile.darwin
 create mode 100644 src/Makefile.linux
 create mode 100644 src/Makefile.mingw
 create mode 100644 src/Makefile.vc

diff --git a/src/Makefile.darwin b/src/Makefile.darwin
new file mode 100644
index 0000000..fdda739
--- /dev/null
+++ b/src/Makefile.darwin
@@ -0,0 +1,47 @@
+# GNU Makefile for Mac OS X to build SDL12-compat.
+#
+
+# change INCLUDES so it points to SDL2 headers directory:
+INCLUDES = -Iinclude
+
+ifeq ($(CROSS),)
+CC = gcc
+else
+CC = $(CROSS)-gcc
+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
+#LDFLAGS+= -Wl,-headerpad_max_install_names
+LDFLAGS+= -Wl,-install_name,"/usr/local/lib/$(DYLIB)"
+LDFLAGS+= -Wl,-compatibility_version,1.0 -Wl,-current_version,12.61
+LDLIBS  = -Wl,-framework,AppKit
+# this is needed for x86_64 - cross-gcc might not add it.
+#LDLIBS += -Wl,-lbundle1.o
+
+DYLIB = libSDL2-2.0.0.dylib
+
+OBJ = sdl2_compat.o sdl2_compat_objc.o
+
+.SUFFIXES:
+.SUFFIXES: .o .c .m
+
+all: $(DYLIB)
+
+$(DYLIB): $(OBJ)
+	$(LD) -o $@ $(LDFLAGS) $(OBJ) $(LDLIBS)
+	ln -sf $(DYLIB) libSDL.dylib
+
+.c.o:
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $@ -c $<
+.m.o:
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $@ -c $<
+
+distclean: clean
+	$(RM) *.dylib
+clean:
+	$(RM) *.o
diff --git a/src/Makefile.linux b/src/Makefile.linux
new file mode 100644
index 0000000..d882d16
--- /dev/null
+++ b/src/Makefile.linux
@@ -0,0 +1,40 @@
+# GNU Makefile for Linux (Unix) to build SDL12-compat.
+#
+
+# change INCLUDES so it points to SDL2 headers directory:
+INCLUDES = -Iinclude
+
+CC = gcc
+LD = $(CC)
+
+CPPFLAGS = -DNDEBUG -D_THREAD_SAFE -D_REENTRANT
+CPPFLAGS+= -DSDL_DISABLE_IMMINTRIN_H
+
+CFLAGS  = -fPIC -O3 -Wall
+LDFLAGS = -shared -Wl,-soname,libSDL2-2.0.so.0
+# make sure this is supported:
+LDFLAGS+= -Wl,--no-undefined
+LDLIBS  = -ldl
+
+SHLIB = libSDL2-2.0.so.0.0.0
+
+OBJ = sdl2_compat.o
+
+.SUFFIXES:
+.SUFFIXES: .o .c
+
+all: $(SHLIB)
+
+$(SHLIB): $(OBJ)
+	$(LD) -o $@ $(LDFLAGS) $(OBJ) $(LDLIBS)
+	ln -sf $(SHLIB) libSDL2-2.0.so
+	ln -sf $(SHLIB) libSDL2-2.0.so.0
+	ln -sf $(SHLIB) libSDL2.so
+
+.c.o:
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $@ -c $<
+
+distclean: clean
+	$(RM) *.so*
+clean:
+	$(RM) *.o
diff --git a/src/Makefile.mingw b/src/Makefile.mingw
new file mode 100644
index 0000000..6b8855a
--- /dev/null
+++ b/src/Makefile.mingw
@@ -0,0 +1,47 @@
+# GNU Makefile for Windows to build SDL12-compat.
+#
+
+# change INCLUDES so it points to SDL2 headers directory:
+INCLUDES = -Iinclude
+
+ifeq ($(CROSS),)
+CC = gcc
+RC = windres
+else
+CC = $(CROSS)-gcc
+RC = $(CROSS)-windres
+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)
+LDLIBS  = -lkernel32 -luser32
+# libgcc is needed for 32 bit (x86) builds:
+LDLIBS += -static-libgcc -lgcc
+
+LIB = libSDL2.dll.a
+DLL = SDL2.dll
+
+OBJ = sdl2_compat.o version.o
+
+.SUFFIXES:
+.SUFFIXES: .o .c .rc
+
+all: $(DLL)
+
+$(LIB): $(DLL)
+$(DLL): $(OBJ)
+	$(LD) -o $@ $(LDFLAGS) $(OBJ) $(LDLIBS)
+
+.c.o:
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $@ -c $<
+.rc.o:
+	$(RC) -o $@ $<
+
+distclean: clean
+	$(RM) $(DLL) $(LIB)
+clean:
+	$(RM) *.o
diff --git a/src/Makefile.vc b/src/Makefile.vc
new file mode 100644
index 0000000..e78ecc8
--- /dev/null
+++ b/src/Makefile.vc
@@ -0,0 +1,42 @@
+# Makefile for Win32 using MSVC:
+#	nmake /f Makefile.vc
+#
+# If you specifically want to build for x86:
+#	nmake /f Makefile.vc CPU=x86
+
+# change INCLUDES so it points to SDL2 headers directory:
+INCLUDES = -Iinclude
+
+CPPFLAGS = -DNDEBUG -DDLL_EXPORT
+CPPFLAGS = $(CPPFLAGS) -DSDL_DISABLE_IMMINTRIN_H
+
+CC = cl
+LD = link
+RC = rc
+
+CFLAGS = /nologo /O2 /MD /W3 /GS-
+LDFLAGS = /nologo /DLL /NODEFAULTLIB /RELEASE
+LDLIBS = kernel32.lib user32.lib
+
+!if "$(CPU)" == "x86"
+CFLAGS = $(CFLAGS) /arch:SSE
+!endif
+
+DLLNAME = SDL2.dll
+IMPNAME = SDL2.lib
+
+OBJ = sdl2_compat.obj version.res
+
+all: $(DLLNAME)
+
+$(DLLNAME): $(OBJ)
+	$(LD) /OUT:$@ $(LDFLAGS) $(OBJ) $(LDLIBS)
+
+.c.obj:
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) /Fo$@ -c $<
+.rc.res:
+	$(RC) /r /Fo$@ $<
+
+distclean: clean
+clean:
+	-del *.obj *.res *.exp *.manifest $(DLLNAME) $(IMPNAME)