From deb7bf35b71566636029b35c4a17cb8fd4d241a1 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 17 Jun 2020 22:49:12 -0700 Subject: [PATCH 01/10] Detect the compiler version and set the correct GCC flag If the version is not supported by the Makefile, the flag for the latest version supported is set instead. (cherry picked from commit bf90fbb91f28af30ff79523681e7f73e60121535) --- src/Makefile.cfg | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index a3baeedda..7a0455aa8 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -1,3 +1,4 @@ +# vim: ft=make # # Makefile.cfg for SRB2 # @@ -7,6 +8,42 @@ # and other things # +# See the following variable don't start with 'GCC'. This is +# to avoid a false positive with the version detection... + +SUPPORTED_GCC_VERSIONS:=\ + 91\ + 81 82 83\ + 71 72\ + 61 62 63 64\ + 51 52 53 54\ + 40 41 42 43 44 45 46 47 48 49 + +LATEST_GCC_VERSION=9.1 + +# Automatically set version flag, but not if one was manually set +ifeq (,$(filter GCC%,$(.VARIABLES))) + ifneq (,$(findstring GCC,$(shell $(CC) --version))) # if it's GCC + version:=$(shell $(CC) -dumpversion) + + # Turn version into words of major, minor + v:=$(subst ., ,$(version)) + # concat. major minor + v:=$(word 1,$(v))$(word 2,$(v)) + + # If this version is not in the list, default to the latest supported + ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) + $(info\ + Your compiler version, GCC $(version) is not supported by the Makefile.\ + The Makefile will assume GCC $(LATEST_GCC_VERSION).) + GCC$(subst .,,$(LATEST_GCC_VERSION))=1 + else + $(info Detected GCC $(version) (GCC$(v))) + GCC$(v)=1 + endif + endif +endif + ifdef GCC91 GCC83=1 endif From 6de79f13771513082ad5f31d48f5e3cf772e7912 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 17 Jun 2020 22:52:19 -0700 Subject: [PATCH 02/10] Makefile: Move the PREFIX stuff up so version detection can take advantage of (cherry picked from commit 489bb81d0065299ffea09b20cfa06dbbedcf247a) --- src/Makefile.cfg | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 7a0455aa8..f7bae027b 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -21,6 +21,30 @@ SUPPORTED_GCC_VERSIONS:=\ LATEST_GCC_VERSION=9.1 +# gcc or g++ +ifdef PREFIX + CC=$(PREFIX)-gcc + CXX=$(PREFIX)-g++ + OBJCOPY=$(PREFIX)-objcopy + OBJDUMP=$(PREFIX)-objdump + STRIP=$(PREFIX)-strip + WINDRES=$(PREFIX)-windres +else + OBJCOPY=objcopy + OBJDUMP=objdump + STRIP=strip + WINDRES=windres +endif + +# because Apple screws with us on this +# need to get bintools from homebrew +ifdef MACOSX + CC=clang + CXX=clang + OBJCOPY=gobjcopy + OBJDUMP=gobjdump +endif + # Automatically set version flag, but not if one was manually set ifeq (,$(filter GCC%,$(.VARIABLES))) ifneq (,$(findstring GCC,$(shell $(CC) --version))) # if it's GCC @@ -500,30 +524,6 @@ ifdef ARCHNAME BIN:=$(BIN)/$(ARCHNAME) endif -# gcc or g++ -ifdef PREFIX - CC=$(PREFIX)-gcc - CXX=$(PREFIX)-g++ - OBJCOPY=$(PREFIX)-objcopy - OBJDUMP=$(PREFIX)-objdump - STRIP=$(PREFIX)-strip - WINDRES=$(PREFIX)-windres -else - OBJCOPY=objcopy - OBJDUMP=objdump - STRIP=strip - WINDRES=windres -endif - -# because Apple screws with us on this -# need to get bintools from homebrew -ifdef MACOSX - CC=clang - CXX=clang - OBJCOPY=gobjcopy - OBJDUMP=gobjdump -endif - OBJDUMP_OPTS?=--wide --source --line-numbers LD=$(CC) From 5ec649c8521a85e7ef82ee94fc0c91f19bc95673 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 17 Jun 2020 22:58:11 -0700 Subject: [PATCH 03/10] Forgot a comma (cherry picked from commit 193c45aa2f555b56f548f70e7fa0d74a1ce4e412) --- src/Makefile.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index f7bae027b..363bf56cf 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -58,7 +58,7 @@ ifeq (,$(filter GCC%,$(.VARIABLES))) # If this version is not in the list, default to the latest supported ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) $(info\ - Your compiler version, GCC $(version) is not supported by the Makefile.\ + Your compiler version, GCC $(version), is not supported by the Makefile.\ The Makefile will assume GCC $(LATEST_GCC_VERSION).) GCC$(subst .,,$(LATEST_GCC_VERSION))=1 else From 61f35c91a7f4dd0cae3661e6ae2061d73ec0595b Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 11 Jul 2020 12:45:35 -0700 Subject: [PATCH 04/10] It's not always GCC, but it probably is gcc (I hope) (cherry picked from commit 4e1d54c3322c17276e532ab4d9e875a8c8ebc399) --- src/Makefile.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index 363bf56cf..a1d9d21ee 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -47,7 +47,7 @@ endif # Automatically set version flag, but not if one was manually set ifeq (,$(filter GCC%,$(.VARIABLES))) - ifneq (,$(findstring GCC,$(shell $(CC) --version))) # if it's GCC + ifneq (,$(findstring gcc,$(shell $(CC) --version))) # if it's GCC version:=$(shell $(CC) -dumpversion) # Turn version into words of major, minor From 6c7f95e74928cd7137133f6e8530a41ca3f86884 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 24 Jul 2020 02:32:10 -0700 Subject: [PATCH 05/10] Add missing GCC version flags to the Makefile (cherry picked from commit 00943e9e82ff46a97a2bc1e3179ce47e53345cc3) --- src/Makefile.cfg | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index a1d9d21ee..dbec2944c 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -12,11 +12,12 @@ # to avoid a false positive with the version detection... SUPPORTED_GCC_VERSIONS:=\ - 91\ - 81 82 83\ - 71 72\ + 101 102\ + 91 92 93\ + 81 82 83 84\ + 71 72 73 74 75\ 61 62 63 64\ - 51 52 53 54\ + 51 52 53 54 55\ 40 41 42 43 44 45 46 47 48 49 LATEST_GCC_VERSION=9.1 @@ -68,7 +69,27 @@ ifeq (,$(filter GCC%,$(.VARIABLES))) endif endif +ifdef GCC102 +GCC101=1 +endif + +ifdef GCC101 +GCC93=1 +endif + +ifdef GCC93 +GCC92=1 +endif + +ifdef GCC92 +GCC91=1 +endif + ifdef GCC91 +GCC84=1 +endif + +ifdef GCC84 GCC83=1 endif @@ -81,6 +102,18 @@ GCC81=1 endif ifdef GCC81 +GCC75=1 +endif + +ifdef GCC75 +GCC74=1 +endif + +ifdef GCC74 +GCC73=1 +endif + +ifdef GCC73 GCC72=1 endif @@ -105,6 +138,10 @@ GCC61=1 endif ifdef GCC61 +GCC55=1 +endif + +ifdef GCC55 GCC54=1 endif From 655c694bbcffe2f3aa0b53f3a8bddedb7434937a Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 24 Jul 2020 02:33:39 -0700 Subject: [PATCH 06/10] Update LATEST_GCC_VERSION too (cherry picked from commit 4059c6a654a5785199cf0d6dd998bf113b57cd0f) --- src/Makefile.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index dbec2944c..c3abdea2b 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -20,7 +20,7 @@ SUPPORTED_GCC_VERSIONS:=\ 51 52 53 54 55\ 40 41 42 43 44 45 46 47 48 49 -LATEST_GCC_VERSION=9.1 +LATEST_GCC_VERSION=10.2 # gcc or g++ ifdef PREFIX From 8c7f9f85fedf0ba2a1e219ef0ae02a1ae7f7759c Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 15 Aug 2020 21:29:02 -0700 Subject: [PATCH 07/10] Is it GCC is it gcc, is it???? (cherry picked from commit ef2bff6383b16385f9874e1c9c6b66c9df794f5b) --- src/Makefile.cfg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index c3abdea2b..dcbbe027e 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -48,7 +48,9 @@ endif # Automatically set version flag, but not if one was manually set ifeq (,$(filter GCC%,$(.VARIABLES))) - ifneq (,$(findstring gcc,$(shell $(CC) --version))) # if it's GCC + version:=$(shell $(CC) --version) + # check if this is in fact GCC + ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version)))) version:=$(shell $(CC) -dumpversion) # Turn version into words of major, minor From 00ff94caa21f36ab39056b11694bde06ce4c8529 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 18 Aug 2020 16:45:00 -0700 Subject: [PATCH 08/10] Makefile: Make WARNINGMODE the default, optionally disable with RELAXWARNINGS (cherry picked from commit 9495e6354fed1028c6fc502cc9d946cfdd0b7896) --- src/Makefile | 3 ++- src/Makefile.cfg | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Makefile b/src/Makefile index b417a38e4..171225dc7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -60,7 +60,8 @@ # Compile with GCC 4.6x version, add 'GCC46=1' # Compile a profile version, add 'PROFILEMODE=1' # Compile a debug version, add 'DEBUGMODE=1' -# Compile with extra warnings, add 'WARNINGMODE=1' +# Compile with less warnings, add 'RELAXWARNINGS=1' +# Generate compiler errors for most compiler warnings, add 'ERRORMODE=1' # Compile without NASM's tmap.nas, add 'NOASM=1' # Compile without 3D hardware support, add 'NOHW=1' # Compile with GDBstubs, add 'RDB=1' diff --git a/src/Makefile.cfg b/src/Makefile.cfg index dcbbe027e..e45265cab 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -214,10 +214,7 @@ WFLAGS=-Wall ifndef GCC295 #WFLAGS+=-Wno-packed endif -ifdef ERRORMODE -WARNINGMODE=1 -endif -ifdef WARNINGMODE +ifndef RELAXWARNINGS WFLAGS+=-W #WFLAGS+=-Wno-sign-compare ifndef GCC295 From 1dca1a3f47bc9923628f069d9ea8abff44b7dcd5 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 18 Aug 2020 18:01:59 -0700 Subject: [PATCH 09/10] Makefile: automatically detect system to compile for, if no system was specified This should work for mingw and linux so far. (cherry picked from commit f92026f98b168f4556d50d3dde403ab6bfd97ff3) --- src/Makefile | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/Makefile b/src/Makefile index 171225dc7..b342ec7a3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -81,6 +81,57 @@ # ############################################################################# +ALL_SYSTEMS=\ + PANDORA\ + LINUX64\ + MINGW64\ + HAIKU\ + DUMMY\ + DJGPPDOS\ + MINGW\ + UNIX\ + LINUX\ + SOLARIS\ + FREEBSD\ + MACOSX\ + SDL\ + +# check for user specified system +ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) +ifeq ($(OS),Windows_NT) # all windows are Windows_NT... + + $(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) + + # go for a 32-bit sdl mingw exe by default + MINGW=1 + SDL=1 + +else # if you on the *nix + + system:=$(shell uname -s) + + ifeq ($(system),Linux) + new_system=LINUX + else + + $(error \ + Could not automatically detect your system,\ + try specifying a system manually) + + endif + + ifeq ($(shell getconf LONG_BIT),64) + system+=64-bit + new_system:=$(new_system)64 + endif + + $(info Detected $(system) ($(new_system))...) + $(new_system)=1 + +endif +endif + + # SRB2 data files D_DIR?=../bin/Resources D_FILES=$(D_DIR)/srb2.srb \ From 5755bab29aca3f0899ecfdfc694f61209cc63a4b Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 20 Aug 2020 20:19:50 -0700 Subject: [PATCH 10/10] Makefile: add WINDOWSHELL=1 for the Windows detect (cherry picked from commit 6f51c68c7248d616ad16f66b72cfcc36b7c952f5) --- src/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile b/src/Makefile index b342ec7a3..23b391fab 100644 --- a/src/Makefile +++ b/src/Makefile @@ -105,6 +105,7 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... # go for a 32-bit sdl mingw exe by default MINGW=1 SDL=1 + WINDOWSHELL=1 else # if you on the *nix