From 1a8ec7975c20e1d652cbbdb7a9e366192e41c05f Mon Sep 17 00:00:00 2001
From: GoldenTails <milestailsprower101n2@gmail.com>
Date: Sat, 28 Aug 2021 15:39:34 -0500
Subject: [PATCH] Makefile: Improve gcc detection

Wasn't working for me until I fixed it.
Turns out gcc really doesn't like giving its name out.
Most of the time it reads argv[0].
---
 src/Makefile.d/detect.mk | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk
index 9c8a0a227d..f458b044cf 100644
--- a/src/Makefile.d/detect.mk
+++ b/src/Makefile.d/detect.mk
@@ -71,13 +71,17 @@ latest_gcc_version:=10.2
 # manually set. And don't bother if this is a clean only
 # run.
 ifeq (,$(call Wildvar,GCC% destructive))
-version:=$(shell $(CC) --version)
+
+# can't use $(CC) --version here since that uses argv[0] to display the name
+# also gcc outputs the information to stderr, so I had to do 2>&1
+# this program really doesn't like identifying itself
+version:=$(shell $(CC) -v 2>&1)
 
 # check if this is in fact GCC
-ifneq (,$(or $(findstring gcc,$(version)),\
-	$(findstring GCC,$(version))))
+ifneq (,$(findstring gcc version,$(version)))
 
-version:=$(shell $(CC) -dumpversion)
+# in stark contrast to the name, gcc will give me a nicely formatted version number for free
+version:=$(shell $(CC) -dumpfullversion)
 
 # Turn version into words of major, minor
 v:=$(subst ., ,$(version))
-- 
GitLab