xref: /optee_os/mk/cc-option.mk (revision 092db7fbba04072db5aa28cb11b0b0840e4c532f)
1*092db7fbSJerome Forissier_cc-option-supported = $(if $(shell $(CC$(sm)) -Werror $(1) -c -x c /dev/null -o /dev/null 2>/dev/null >/dev/null || echo "Not supported"),,1)
2331ebf7eSJerome Forissier_cc-opt-cached-var-name = $(subst =,~,$(strip cached-cc-option-$(1)-$(subst $(empty) $(empty),,$(CC$(sm)))))
3331ebf7eSJerome Forissierdefine _cc-option
4331ebf7eSJerome Forissier$(eval _var_name := $(call _cc-opt-cached-var-name,$(1)))
5331ebf7eSJerome Forissier$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _cc-option-supported,$(1)),$($(_var_name))))
6331ebf7eSJerome Forissier$(if $($(_var_name)),$(1),$(2))
7331ebf7eSJerome Forissierendef
8331ebf7eSJerome Forissiercc-option = $(strip $(call _cc-option,$(1),$(2)))
9331ebf7eSJerome Forissier
1079f882fcSJerome Forissier_ld-option-supported = $(if $(shell ($(LD$(sm)) -v $(1) 2>&1 || echo warning) | grep warning),,1)
1132f25468SJerome Forissier_ld-opt-cached-var-name = $(subst =,~,$(subst $(empty) $(empty),,$(strip cached-ld-option-$(1)-$(LD$(sm)))))
1232f25468SJerome Forissierdefine _ld-option
1332f25468SJerome Forissier$(eval _var_name := $(call _ld-opt-cached-var-name,$(1)))
1432f25468SJerome Forissier$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _ld-option-supported,$(1)),$($(_var_name))))
1532f25468SJerome Forissier$(if $($(_var_name)),$(1),$(2))
1632f25468SJerome Forissierendef
1732f25468SJerome Forissierld-option = $(strip $(call _ld-option,$(1),$(2)))
18