ec- / Quake3e

Improved Quake III Arena engine
GNU General Public License v2.0
1.15k stars 148 forks source link

[build] `LDFLAGS` in `./Makefile` should be additive #264

Closed heysokam closed 4 months ago

heysokam commented 5 months ago

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 5 months ago

Edited the text to add a diff of the changes.

ec- commented 4 months ago

Applied in https://github.com/ec-/Quake3e/commit/93cb4701f3ca8e38849cd3fcb270be77b4aec331