From 8f3e2dd2dd42a18bb9d064f5961efb72d2e88497 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 9963d38ce22ee50327103774613b596df529518a) --- 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 c9463d90b6854df545dd9997510a4874b21e1ddc 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 2a059632a1e6b93c7de44c0b36d68a5f88372fc0) --- 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 599add9ad46acf65268cdf6f9e56a778217b4e77 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 6cddbf7afb4c1c4b220a168da8d9c14d2a96786c) --- 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 ccefaa77e9868e252c04409bbf275607833455f7 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 38ce80317de8a342727efa182d1fa4c22cd64382) --- 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 6e102db9c546648573aca697c6b5da6e1067912a 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 f939cf973b7e609e5358c299bbb7a449b61d7ce1) --- 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 ec8cab9a3a944eb1c592e260d88aa767c2c36e5b 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 4931d82393778f376186199401e7e6b5df14aa3f) --- 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 ce894b783784db1b1280ece048db5f78bc7f0155 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 246e71a463c88c3bbc5334f9d07caca2e1577f79) --- 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 e415b4b4755ffa1f79126f91b985cc6a7528bc78 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 538c27f2faad49af1473c78b7e650834f6d6e019 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 e4622cfeb3eea71135cc1a204cde87d0a9fa4ed1 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