blob: 622346a117b59d87ec393a3ea208b6498d22f77c [file] [log] [blame]
Jerome Forissier331ebf72020-05-26 15:21:00 +02001_cc-option-supported = $(if $(shell $(CC$(sm)) $(1) -c -x c /dev/null -o /dev/null 2>/dev/null >/dev/null || echo "Not supported"),,1)
2_cc-opt-cached-var-name = $(subst =,~,$(strip cached-cc-option-$(1)-$(subst $(empty) $(empty),,$(CC$(sm)))))
3define _cc-option
4$(eval _var_name := $(call _cc-opt-cached-var-name,$(1)))
5$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _cc-option-supported,$(1)),$($(_var_name))))
6$(if $($(_var_name)),$(1),$(2))
7endef
8cc-option = $(strip $(call _cc-option,$(1),$(2)))
9
Jerome Forissier79f882f2020-11-20 09:46:30 +010010_ld-option-supported = $(if $(shell ($(LD$(sm)) -v $(1) 2>&1 || echo warning) | grep warning),,1)
Jerome Forissier32f25462020-05-28 11:34:00 +020011_ld-opt-cached-var-name = $(subst =,~,$(subst $(empty) $(empty),,$(strip cached-ld-option-$(1)-$(LD$(sm)))))
12define _ld-option
13$(eval _var_name := $(call _ld-opt-cached-var-name,$(1)))
14$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _ld-option-supported,$(1)),$($(_var_name))))
15$(if $($(_var_name)),$(1),$(2))
16endef
17ld-option = $(strip $(call _ld-option,$(1),$(2)))