diff --git a/src/Makefile.cfg b/src/Makefile.cfg
index c3abdea2b01a843cca97a1a74d418fd5b61590b4..dcbbe027ee7b1600458f5156b639e9c6ab8b0e75 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