Instead of checking the compiler executable name, inspect the compiler's
version output. This also works when there are symlinks involved or the
executable name has additional text such as version numbers.
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #774
CXXFLAGS += -DCC_VERSION=$(CC_VERSION)
GOCFLAGS += -DCC_VERSION=$(CC_VERSION)
+CC_NAME := $(shell $(CC) -v 2>&1 | grep -E "\\w+ version" | sed 's/\s.*$$//')
+
# ensure $(BUILD_DIR)/kconfig, $(BUILD_DIR)/include and $(BUILD_DIR)/include/uk exists
$(call mk_sub_build_dir,kconfig)
$(call mk_sub_build_dir,include)
# test if GCC is set as a compiler
define have_gcc =
-$(if $(filter %gcc,$(CC)),y,n)
+$(if $(filter gcc,$(CC_NAME)),y,n)
endef
# test if CLANG is set as a compiler
define have_clang =
-$(if $(filter %clang,$(CC)),y,n)
+$(if $(filter clang,$(CC_NAME)),y,n)
endef
# test whether GCC version is greater than or equal to the minimum requirement