commit 82b5a4c63304894fd8967a87d71d3f89afe0235a
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Tue Dec 23 18:37:31 2025 -0700
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Tue Dec 23 18:37:31 2025 -0700
makefile updates to avoid stale object file problems
---
platform/3ds/Makefile | 2 +-
platform/SDL1_2/Makefile | 2 +-
platform/SDL2Desktop/Makefile | 34 ++++++++++++++++++++++++++++++--
platform/SDL2Desktop/source/SDL2Host.cpp | 8 ++++----
platform/bittboy/Makefile | 2 +-
platform/funkey-s/Makefile | 2 +-
platform/gcw0/Makefile | 4 ++--
platform/libretro/Makefile | 4 ++--
platform/miyoomini/Makefile | 2 +-
platform/switch/Makefile | 2 +-
platform/vita/Makefile | 2 +-
platform/wiiu/Makefile | 2 +-
platform/windows/Makefile | 1 +
test/Makefile | 1 +
14 files changed, 50 insertions(+), 18 deletions(-)
diff --git a/platform/3ds/Makefile b/platform/3ds/Makefile
index 97fbe29..dc29bcc 100644
--- a/platform/3ds/Makefile
+++ b/platform/3ds/Makefile
@@ -66,7 +66,7 @@ CC = $(CXX)
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
-CFLAGS := -g -Wall -Ofast -mword-relocations \
+CFLAGS := -g -Wall -Ofast -mword-relocations -MMD -MP \
-fomit-frame-pointer -ffunction-sections \
$(ARCH)
diff --git a/platform/SDL1_2/Makefile b/platform/SDL1_2/Makefile
index ded00cc..c91668b 100644
--- a/platform/SDL1_2/Makefile
+++ b/platform/SDL1_2/Makefile
@@ -20,7 +20,7 @@ IMITATE := miyoomini
#---------------------------------------------------------------------------------
CC = $(CXX)
-CFLAGS := -g -Wall -ffunction-sections -DVER_STR=\"$(APP_VERSION)\" \
+CFLAGS := -g -Wall -ffunction-sections -MMD -MP -DVER_STR=\"$(APP_VERSION)\" \
$(DEFINES)
CFLAGS += $(INCLUDE)
diff --git a/platform/SDL2Desktop/Makefile b/platform/SDL2Desktop/Makefile
index 13892b0..8af8396 100644
--- a/platform/SDL2Desktop/Makefile
+++ b/platform/SDL2Desktop/Makefile
@@ -17,6 +17,7 @@ INCLUDES := ${INCLUDES}
CC = $(CXX)
CFLAGS := -g -Wall -Wno-deprecated -ffunction-sections -std=c++17 \
+ -MMD -MP \
$(DEFINES)
CFLAGS += $(INCLUDE) -DVER_STR=\"$(APP_VERSION)\"
@@ -24,9 +25,38 @@ CFLAGS += $(INCLUDE) -DVER_STR=\"$(APP_VERSION)\"
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
#-std=gnu++11 was used before... not sure of difference
-LIBS := -lSDL2
+# SDL2 flags via pkg-config or sdl2-config with sensible fallbacks (Homebrew paths)
+SDL2_CFLAGS := $(shell pkg-config --cflags sdl2 2>/dev/null)
+SDL2_LIBS := $(shell pkg-config --libs sdl2 2>/dev/null)
-LDFLAGS := $(LIBS)
+ifeq ($(strip $(SDL2_CFLAGS)),)
+SDL2_CFLAGS := $(shell sdl2-config --cflags 2>/dev/null)
+SDL2_LIBS := $(shell sdl2-config --libs 2>/dev/null)
+endif
+
+ifeq ($(strip $(SDL2_CFLAGS)),)
+UNAME_S := $(shell uname -s)
+UNAME_M := $(shell uname -m)
+ifeq ($(UNAME_S),Darwin)
+ifeq ($(UNAME_M),arm64)
+# Add parent include dir so #include <SDL2/SDL.h> resolves
+SDL2_CFLAGS := -I/opt/homebrew/include
+SDL2_LIBS := -L/opt/homebrew/lib -lSDL2
+else
+SDL2_CFLAGS := -I/usr/local/include
+SDL2_LIBS := -L/usr/local/lib -lSDL2
+endif
+endif
+endif
+
+# Add include flags for SDL2 to both C and C++ compiles
+CFLAGS += $(SDL2_CFLAGS)
+CXXFLAGS += $(SDL2_CFLAGS)
+
+# Keep legacy LIBS but prefer SDL2_LIBS for correctness
+LIBS ?= -lSDL2
+
+LDFLAGS := $(LIBS) $(SDL2_LIBS)
#---------------------------------------------------------------------------------
diff --git a/platform/SDL2Desktop/source/SDL2Host.cpp b/platform/SDL2Desktop/source/SDL2Host.cpp
index 35dd687..3d5870d 100644
--- a/platform/SDL2Desktop/source/SDL2Host.cpp
+++ b/platform/SDL2Desktop/source/SDL2Host.cpp
@@ -22,8 +22,8 @@ using namespace std;
// sdl
#include <SDL2/SDL.h>
-/*#define WINDOW_SIZE_X 1280
-#define WINDOW_SIZE_Y 720*/
+#define WINDOW_SIZE_X 1280
+#define WINDOW_SIZE_Y 720
#define WINDOW_FLAGS 0
@@ -61,8 +61,8 @@ Host::Host(int windowWidth, int windowHeight)
SDL_Log("Display #%d: current display mode is %dx%dpx @ %dhz.", 0, current.w, current.h, current.refresh_rate);
}
- int WINDOW_SIZE_X=windowWidth == 0 ? current.w : windowWidth;
- int WINDOW_SIZE_Y=windowHeight == 0 ? current.h : windowHeight;
+ //int WINDOW_SIZE_X=current.w;
+ //int WINDOW_SIZE_Y=current.h;
struct stat st = {0};
diff --git a/platform/bittboy/Makefile b/platform/bittboy/Makefile
index 99dfff4..476bc77 100644
--- a/platform/bittboy/Makefile
+++ b/platform/bittboy/Makefile
@@ -22,7 +22,7 @@ CXX = $(BIN_BASE)arm-linux-g++
CC = $(CXX)
-CFLAGS := -g -Wall -Ofast -ffunction-sections -Iinc -D_BITTBOY -DVER_STR=\"$(APP_VERSION)\" -march=armv5te -mtune=arm926ej-s \
+CFLAGS := -g -Wall -Ofast -ffunction-sections -MMD -MP -Iinc -D_BITTBOY -DVER_STR=\"$(APP_VERSION)\" -march=armv5te -mtune=arm926ej-s \
$(DEFINES)
CFLAGS += $(INCLUDE)
diff --git a/platform/funkey-s/Makefile b/platform/funkey-s/Makefile
index 2df4e9f..b27f045 100644
--- a/platform/funkey-s/Makefile
+++ b/platform/funkey-s/Makefile
@@ -17,7 +17,7 @@ INCLUDES := ${INCLUDES}
CC = /opt/funkey-toolchain-shared/bin/arm-linux-g++
CXX = /opt/funkey-toolchain-shared/bin/arm-linux-g++
-CFLAGS := -Wall -Ofast -fno-PIC -ffunction-sections -flto -DVER_STR=\"$(APP_VERSION)\" \
+CFLAGS := -Wall -Ofast -fno-PIC -ffunction-sections -flto -MMD -MP -DVER_STR=\"$(APP_VERSION)\" \
$(DEFINES)
CFLAGS += $(INCLUDE)
diff --git a/platform/gcw0/Makefile b/platform/gcw0/Makefile
index d90dea1..8f442f0 100644
--- a/platform/gcw0/Makefile
+++ b/platform/gcw0/Makefile
@@ -18,12 +18,12 @@ INCLUDES := ${INCLUDES}
ifeq ($(GKD), 1)
CC = /opt/gcw0-toolchain-static/bin/mipsel-linux-g++
CXX = /opt/gcw0-toolchain-static/bin/mipsel-linux-g++
-CFLAGS := -Wall -Ofast -fdata-sections -ffunction-sections -fno-PIC -mno-shared -mno-abicalls -fno-PIC -flto -DVER_STR=\"$(APP_VERSION)\" $(DEFINES) -DGKD
+CFLAGS := -Wall -Ofast -fdata-sections -ffunction-sections -fno-PIC -mno-shared -mno-abicalls -fno-PIC -flto -MMD -MP -DVER_STR=\"$(APP_VERSION)\" $(DEFINES) -DGKD
else
CC = /opt/gcw0-toolchain/bin/mipsel-linux-g++
CXX = /opt/gcw0-toolchain/bin/mipsel-linux-g++
-CFLAGS := -Wall -Ofast -fdata-sections -ffunction-sections -fno-PIC -mno-shared -mplt -flto -DVER_STR=\"$(APP_VERSION)\" $(DEFINES) -D_GCW0
+CFLAGS := -Wall -Ofast -fdata-sections -ffunction-sections -fno-PIC -mno-shared -mplt -flto -MMD -MP -DVER_STR=\"$(APP_VERSION)\" $(DEFINES) -D_GCW0
endif
diff --git a/platform/libretro/Makefile b/platform/libretro/Makefile
index be0f1b4..1033395 100644
--- a/platform/libretro/Makefile
+++ b/platform/libretro/Makefile
@@ -168,8 +168,8 @@ CC = $(CXX)
OBJECTS := $(SOURCES_C:.c=.o) $(SOURCES_CXX:.cpp=.o)
-CFLAGS += $(fpic) -Wall -D__LIBRETRO__ -DMINIZ_NO_TIME -ffunction-sections -std=gnu++17 -fno-rtti $(INCFLAGS)
-CXXFLAGS += $(fpic) -Wall -D__LIBRETRO__ -DMINIZ_NO_TIME -ffunction-sections -std=gnu++17 -fno-rtti $(INCFLAGS)
+CFLAGS += $(fpic) -Wall -D__LIBRETRO__ -DMINIZ_NO_TIME -ffunction-sections -MMD -MP -std=gnu++17 -fno-rtti $(INCFLAGS)
+CXXFLAGS += $(fpic) -Wall -D__LIBRETRO__ -DMINIZ_NO_TIME -ffunction-sections -MMD -MP -std=gnu++17 -fno-rtti $(INCFLAGS)
all: $(TARGET)
diff --git a/platform/miyoomini/Makefile b/platform/miyoomini/Makefile
index fc83fa9..10bbd2c 100644
--- a/platform/miyoomini/Makefile
+++ b/platform/miyoomini/Makefile
@@ -33,7 +33,7 @@ endif
CC = $(CXX)
-CFLAGS := -Wall -Ofast -ffunction-sections -DVER_STR=\"$(APP_VERSION)\" -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve \
+CFLAGS := -Wall -Ofast -ffunction-sections -MMD -MP -DVER_STR=\"$(APP_VERSION)\" -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve \
$(DEFINES)
ifeq ($(TOOLCHAIN),union)
diff --git a/platform/switch/Makefile b/platform/switch/Makefile
index f55f295..859ccc5 100644
--- a/platform/switch/Makefile
+++ b/platform/switch/Makefile
@@ -50,7 +50,7 @@ CC = $(CXX)
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE
-CFLAGS := -g -Wall -O2 -ffunction-sections -DVER_STR=\"$(APP_VERSION)\" \
+CFLAGS := -g -Wall -O2 -ffunction-sections -MMD -MP -DVER_STR=\"$(APP_VERSION)\" \
$(ARCH) $(DEFINES)
CFLAGS += $(INCLUDE) -D__SWITCH__
diff --git a/platform/vita/Makefile b/platform/vita/Makefile
index 7cbf7eb..067870e 100644
--- a/platform/vita/Makefile
+++ b/platform/vita/Makefile
@@ -24,7 +24,7 @@ PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
CXX = $(PREFIX)-g++
STRIP := $(PREFIX)-strip
-CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -D__VITA__ -DMINIZ_NO_TIME -DVER_STR=\"$(APP_VERSION)\" $(INCLUDE)
+CFLAGS = -g -Wl,-q -O2 -ftree-vectorize -MMD -MP -D__VITA__ -DMINIZ_NO_TIME -DVER_STR=\"$(APP_VERSION)\" $(INCLUDE)
CXXFLAGS = $(CFLAGS) -fno-exceptions -std=gnu++17 -fpermissive
ASFLAGS = $(CFLAGS)
diff --git a/platform/wiiu/Makefile b/platform/wiiu/Makefile
index ee56665..4d10658 100644
--- a/platform/wiiu/Makefile
+++ b/platform/wiiu/Makefile
@@ -33,7 +33,7 @@ LIBRARIES := SDL2_gfx SDL2_image SDL2_mixer SDL2_ttf sdl2 \
#-------------------------------------------------------------------------------
CC = $(CXX)
-CFLAGS := -g -Wall -O2 -ffunction-sections -DVER_STR=\"$(APP_VERSION)\" \
+CFLAGS := -g -Wall -O2 -ffunction-sections -MMD -MP -DVER_STR=\"$(APP_VERSION)\" \
-ffast-math \
$(MACHDEP)
diff --git a/platform/windows/Makefile b/platform/windows/Makefile
index 6a0beff..ef62c01 100644
--- a/platform/windows/Makefile
+++ b/platform/windows/Makefile
@@ -17,6 +17,7 @@ INCLUDES := ${INCLUDES}
CC = $(CXX)
CFLAGS := -g -Wall -Wno-deprecated -ffunction-sections -std=c++17 \
+ -MMD -MP \
$(DEFINES)
CFLAGS += $(INCLUDE) -DVER_STR=\"$(APP_VERSION)\"
diff --git a/test/Makefile b/test/Makefile
index 966cd1e..a09c8bb 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -17,6 +17,7 @@ INCLUDES := ../source ../include ../libs/z8lua ../libs/utf8-util ../libs/lodep
CC = $(CXX)
CFLAGS := -g -Wall -Wno-deprecated -ffunction-sections -std=c++17 \
+ -MMD -MP \
$(DEFINES)
CFLAGS += $(INCLUDE) -DVER_STR=\"$(APP_VERSION)\"