diff --git a/src/Makefile.cfg b/src/Makefile.cfg
index 409cc4f22653141214eb1592e631a3a86f5944d8..23e6027981a94bcb652c31d68a92cdfb481c4244 100644
--- a/src/Makefile.cfg
+++ b/src/Makefile.cfg
@@ -1,3 +1,4 @@
+# vim: ft=make
 #
 # Makefile.cfg for SRB2
 #
@@ -7,6 +8,66 @@
 # 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
+
+# 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
+  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
@@ -358,30 +419,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)
 
diff --git a/src/d_netcmd.c b/src/d_netcmd.c
index 4f5c17c95b905c37b055cd40b06e549efb8bf1b8..592734067ffc629b4525251f6d8f207fa40faa60 100644
--- a/src/d_netcmd.c
+++ b/src/d_netcmd.c
@@ -3475,7 +3475,7 @@ static void Command_Version_f(void)
 #ifdef DEVELOP
 	CONS_Printf("Sonic Robo Blast 2 %s-%s (%s %s) ", compbranch, comprevision, compdate, comptime);
 #else
-	CONS_Printf("Sonic Robo Blast 2 %s (%s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision);
+	CONS_Printf("Sonic Robo Blast 2 %s (%s %s %s %s) ", VERSIONSTRING, compdate, comptime, comprevision, compbranch);
 #endif
 
 	// Base library