Sdl12-compat: added standalone makefiles for darwin and mingw to make my life easier

From 21a14568442e30c130db855f9213d8d83a82cb58 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Tue, 23 Feb 2021 14:01:20 +0300
Subject: [PATCH] added standalone makefiles for darwin and mingw to make my
 life easier

also renamed NMakefile to Makefile.vc
---
 src/Makefile.darwin            | 44 ++++++++++++++++++++++++++++++++++
 src/Makefile.mingw             | 44 ++++++++++++++++++++++++++++++++++
 src/{NMakefile => Makefile.vc} |  2 +-
 3 files changed, 89 insertions(+), 1 deletion(-)
 create mode 100644 src/Makefile.darwin
 create mode 100644 src/Makefile.mingw
 rename src/{NMakefile => Makefile.vc} (96%)

diff --git a/src/Makefile.darwin b/src/Makefile.darwin
new file mode 100644
index 0000000..acac1a5
--- /dev/null
+++ b/src/Makefile.darwin
@@ -0,0 +1,44 @@
+# 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
+
+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.50
+LDLIBS  = -Wl,-framework,AppKit
+# this is needed for x86_64 - cross-gcc might not add it.
+#LDLIBS += -Wl,-lbundle1.o
+
+DYLIB = libSDL-1.2.0.dylib
+
+OBJ = SDL12_compat.o SDL12_compat_objc.o
+
+.SUFFIXES:
+.SUFFIXES: .o .c .m
+
+all: $(DYLIB)
+
+$(DYLIB): $(OBJ)
+	$(LD) -o $@ $(LDFLAGS) $(OBJ) $(LDLIBS)
+.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.mingw b/src/Makefile.mingw
new file mode 100644
index 0000000..e65cf9e
--- /dev/null
+++ b/src/Makefile.mingw
@@ -0,0 +1,44 @@
+# 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
+
+CFLAGS  = -O3 -Wall
+LDFLAGS = -shared -Wl,--no-undefined
+LDFLAGS+= -nostdlib
+LDFLAGS+= -Wl,--enable-auto-image-base
+LDLIBS  = -lkernel32 -luser32
+
+DLL = SDL.dll
+
+OBJ = SDL12_compat.o version.o
+
+.SUFFIXES:
+.SUFFIXES: .o .c .rc
+
+all: $(DLL)
+
+$(DLL): $(OBJ)
+	$(LD) -o $@ $(LDFLAGS) $(OBJ) $(LDLIBS)
+
+.c.o:
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -o $@ -c $<
+.rc.o:
+	$(RC) -o $@ $<
+
+distclean: clean
+	$(RM) $(DLL)
+clean:
+	$(RM) *.o
diff --git a/src/NMakefile b/src/Makefile.vc
similarity index 96%
rename from src/NMakefile
rename to src/Makefile.vc
index f20fe96..bdfe142 100644
--- a/src/NMakefile
+++ b/src/Makefile.vc
@@ -1,5 +1,5 @@
 # Makefile for Win32 using MSVC:
-#	nmake /f NMakefile
+#	nmake /f Makefile.vc
 
 # change INCLUDES so it points to SDL2 headers directory:
 INCLUDES = -Iinclude