[build] `LDFLAGS` in `./Makefile` should be additive
heysokam opened this issue · 2 comments
heysokam commented
As per the title.
All starting declarations of LDFLAGS
for all systems should say LDFLAGS +=
and not LDFLAGS =
like they do now, to allow passing custom linking flags from Makefile.local
, just like the CFLAGS
variable does.
Note: I would apply the changes and send a PR myself, but I already have a fork and GitHub is not allowing me to create another.
Here is a .patch file to make things easier.
diff --git a/Makefile b/Makefile
index d8eb7ed..f11818a 100644
--- a/Makefile
+++ b/Makefile
@@ -418,7 +418,7 @@ ifdef MINGW
BINEXT = .exe
- LDFLAGS = -mwindows -Wl,--dynamicbase -Wl,--nxcompat
+ LDFLAGS += -mwindows -Wl,--dynamicbase -Wl,--nxcompat
LDFLAGS += -Wl,--gc-sections -fvisibility=hidden
LDFLAGS += -lwsock32 -lgdi32 -lwinmm -lole32 -lws2_32 -lpsapi -lcomctl32
LDFLAGS += -flto
@@ -479,15 +479,15 @@ ifeq ($(COMPILE_PLATFORM),darwin)
ARCHEXT = .$(ARCH)
- LDFLAGS =
+ LDFLAGS +=
ifeq ($(ARCH),x86_64)
BASE_CFLAGS += -arch x86_64
- LDFLAGS = -arch x86_64
+ LDFLAGS += -arch x86_64
endif
ifeq ($(ARCH),aarch64)
BASE_CFLAGS += -arch arm64
- LDFLAGS = -arch arm64
+ LDFLAGS += -arch arm64
endif
ifeq ($(USE_LOCAL_HEADERS),1)
@@ -554,7 +554,7 @@ else
SHLIBCFLAGS = -fPIC -fvisibility=hidden
SHLIBLDFLAGS = -shared $(LDFLAGS)
- LDFLAGS = -lm
+ LDFLAGS += -lm
LDFLAGS += -Wl,--gc-sections -fvisibility=hidden
ifeq ($(USE_SDL),1)
heysokam commented
Edited the text to add a diff of the changes.