From 657a6da583d090abd530180b8cb1c5102baf6b0e Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Fri, 20 Sep 2019 14:27:29 +0200 Subject: [PATCH] [build] Clean the windows targets --- Makefile | 42 ++----------------------------- build/platform.sdl.windows.mak | 2 +- build/rules.mk | 45 ++++++++++++++++++++++++++++++++++ build/targets.sdl.mak | 1 - build/targets.sdl.windows.mak | 4 --- build/toolchain.mingw.mak | 7 ------ build/toolchain.windows.mak | 16 +++++++----- 7 files changed, 58 insertions(+), 59 deletions(-) create mode 100644 build/rules.mk delete mode 100644 build/targets.sdl.mak delete mode 100644 build/targets.sdl.windows.mak delete mode 100644 build/toolchain.mingw.mak diff --git a/Makefile b/Makefile index 1b06f6bb2..12dba43d0 100644 --- a/Makefile +++ b/Makefile @@ -172,46 +172,8 @@ default: $(DEFAULT) $(foreach extension,$(extensions),$(foreach executable,$(executables),$(eval $(call rules_for_targets,$(executable),$(extension))))) -# Define standard compilation rules - -$(eval $(call rule_for, \ - AS, %.o, %.s, \ - $$(CC) $$(SFLAGS) -c $$< -o $$@ \ -)) - -$(eval $(call rule_for, \ - CC, %.o, %.c, \ - $$(CC) $$(SFLAGS) $$(CFLAGS) -c $$< -o $$@, \ - with_local_version \ -)) - -$(eval $(call rule_for, \ - CXX, %.o, %.cpp, \ - $$(CXX) $$(SFLAGS) $$(CXXFLAGS) -c $$< -o $$@, \ - with_local_version \ -)) - -$(eval $(call rule_for, \ - OCC, %.o, %.m, \ - $$(CC) $$(SFLAGS) $$(CFLAGS) -c $$< -o $$@ \ -)) - -ifeq ($(OS),Windows_NT) -# Work around command-line length limit -# On Msys2 the max command line is 32 000 characters. Our standard LD command -# can be longer than that because we have quite a lot of object files. To work -# around this issue, we write the object list in a "target.objs" file, and tell -# the linker to read its arguments from this file. -$(eval $(call rule_for, \ - LD, %.$$(EXE), , \ - echo $$^ > $$@.objs && $$(LD) @$$@.objs $$(LDFLAGS) -o $$@ && rm $$@.objs \ -)) -else -$(eval $(call rule_for, \ - LD, %.$$(EXE), , \ - $$(LD) $$^ $$(LDFLAGS) -o $$@ \ -)) -endif +# Load standard build rules +include build/rules.mk .PHONY: workshop_python_emulator workshop_python_emulator: diff --git a/build/platform.sdl.windows.mak b/build/platform.sdl.windows.mak index 40320cd9d..1d71772f4 100644 --- a/build/platform.sdl.windows.mak +++ b/build/platform.sdl.windows.mak @@ -1,2 +1,2 @@ -TOOLCHAIN ?= windows +TOOLCHAIN = windows EXE = exe diff --git a/build/rules.mk b/build/rules.mk new file mode 100644 index 000000000..6261f20d6 --- /dev/null +++ b/build/rules.mk @@ -0,0 +1,45 @@ +# Define standard compilation rules + +$(eval $(call rule_for, \ + AS, %.o, %.s, \ + $$(CC) $$(SFLAGS) -c $$< -o $$@ \ +)) + +$(eval $(call rule_for, \ + CC, %.o, %.c, \ + $$(CC) $$(SFLAGS) $$(CFLAGS) -c $$< -o $$@, \ + with_local_version \ +)) + +$(eval $(call rule_for, \ + CXX, %.o, %.cpp, \ + $$(CXX) $$(SFLAGS) $$(CXXFLAGS) -c $$< -o $$@, \ + with_local_version \ +)) + +$(eval $(call rule_for, \ + OCC, %.o, %.m, \ + $$(CC) $$(SFLAGS) $$(CFLAGS) -c $$< -o $$@ \ +)) + +ifeq ($(OS),Windows_NT) +# Work around command-line length limit +# On Msys2 the max command line is 32 000 characters. Our standard LD command +# can be longer than that because we have quite a lot of object files. To work +# around this issue, we write the object list in a "target.objs" file, and tell +# the linker to read its arguments from this file. +$(eval $(call rule_for, \ + LD, %.$$(EXE), , \ + echo $$^ > $$@.objs && $$(LD) @$$@.objs $$(LDFLAGS) -o $$@ && rm $$@.objs \ +)) +else +$(eval $(call rule_for, \ + LD, %.$$(EXE), , \ + $$(LD) $$^ $$(LDFLAGS) -o $$@ \ +)) +endif + +$(eval $(call rule_for, \ + WINDRES, %.o, %.rc, \ + $$(WINDRES) $$< -O coff -o $$@ \ +)) diff --git a/build/targets.sdl.mak b/build/targets.sdl.mak deleted file mode 100644 index b322b42c6..000000000 --- a/build/targets.sdl.mak +++ /dev/null @@ -1 +0,0 @@ --include build/targets.sdl.$(MODEL).mak diff --git a/build/targets.sdl.windows.mak b/build/targets.sdl.windows.mak deleted file mode 100644 index 51f8c7518..000000000 --- a/build/targets.sdl.windows.mak +++ /dev/null @@ -1,4 +0,0 @@ -$(eval $(call rule_for, \ - WINDRES, %.o, %.rc, \ - $$(WINDRES) $$< -O coff -o $$@ \ -)) diff --git a/build/toolchain.mingw.mak b/build/toolchain.mingw.mak deleted file mode 100644 index 50004be72..000000000 --- a/build/toolchain.mingw.mak +++ /dev/null @@ -1,7 +0,0 @@ -CC = gcc -CXX = g++ -LD = g++ -EXE = exe - -SFLAGS += -D_USE_MATH_DEFINES -LDFLAGS += -static -mwindows diff --git a/build/toolchain.windows.mak b/build/toolchain.windows.mak index f8ff215c6..cac778f6d 100644 --- a/build/toolchain.windows.mak +++ b/build/toolchain.windows.mak @@ -1,7 +1,13 @@ -CC = x86_64-w64-mingw32-gcc -CXX = x86_64-w64-mingw32-g++ -LD = x86_64-w64-mingw32-g++ -EXE = exe +ifeq ($(OS),Windows_NT) +MINGW_TOOLCHAIN_PREFIX= +else +MINGW_TOOLCHAIN_PREFIX=x86_64-w64-mingw32- +endif + +CC = $(MINGW_TOOLCHAIN_PREFIX)gcc +CXX = $(MINGW_TOOLCHAIN_PREFIX)g++ +LD = $(MINGW_TOOLCHAIN_PREFIX)g++ +WINDRES = $(MINGW_TOOLCHAIN_PREFIX)windres SFLAGS += -D_USE_MATH_DEFINES LDFLAGS += -static @@ -12,5 +18,3 @@ ifeq ($(DEBUG),0) # downside of not defining "-mwindows" is that you lose stdout and stderr. LDFLAGS += -mwindows endif - -WINDRES = x86_64-w64-mingw32-windres