diff --git a/Makefile.mex b/Makefile.mex
index 48a5a990ed69e56dba028a3f0798369853194c97..275fc77f2b9a68aacc9431792b8da90a2f894000 100644
--- a/Makefile.mex
+++ b/Makefile.mex
@@ -107,10 +107,7 @@ endif
 
 # C Compiler support
 ifeq (,$(findstring $(basename $(CC)),cc c99 gcc icc icx))
-  $(error genlib: Unsupported compiler: $(CC))
-endif
-ifneq ($(basename $(CC)),$(findstring $(basename $(CC)),cc gcc))
-  MEXOPTS+= CC=$(CC)
+  $(error mexargs: Unsupported compiler: $(CC))
 endif
 
 # Determine compiler family