From 5a9553cb300148a5ec918b4816d2564d287beb2e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sat, 2 Mar 2019 23:15:08 +0000 Subject: [PATCH] Makefile fixes and added link-time optimisation Noticed the mistakes while compiling with Clang on Arch. --- Makefile | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index fd8d7d21..313a031a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ ifeq ($(RELEASE), 1) - CXXFLAGS = -O3 -s + CXXFLAGS = -O3 -flto + LDFLAGS = -s FILENAME_DEF = release else CXXFLAGS = -O0 -g @@ -34,17 +35,13 @@ ifeq ($(WINDOWS), 1) LIBS += -lkernel32 endif -CXXFLAGS += -std=c++98 `sdl2-config --cflags` `pkg-config freetype2 --cflags` -MMD -MP -MF $@.d -LIBS += `pkg-config freetype2 --libs` +CXXFLAGS += -std=c++98 `pkg-config sdl2 --cflags` `pkg-config freetype2 --cflags` -MMD -MP -MF $@.d ifeq ($(STATIC), 1) - CXXFLAGS += `sdl2-config --static-libs` -static - LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 - ifeq ($(WINDOWS), 1) - LIBS += -lRpcrt4 -lDwrite -lusp10 - endif + LDFLAGS += -static + LIBS += `pkg-config sdl2 --libs --static` `pkg-config freetype2 --libs --static` -lfreetype else - CXXFLAGS += `sdl2-config --libs` + LIBS += `pkg-config sdl2 --libs` `pkg-config freetype2 --libs` endif # For an accurate result to the original's code, compile in alphabetical order @@ -206,7 +203,8 @@ all: build/$(FILENAME) build/$(FILENAME): $(OBJECTS) @mkdir -p $(@D) - @$(CXX) $(CXXFLAGS) $^ -o $@ $(LIBS) + @echo Linking + @$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS) @echo Finished compiling: $@ obj/$(FILENAME)/%.o: src/%.cpp