xref: /optee_os/mk/cc-option.mk (revision 32f2546819a079c5a349638295c8ed1b6388c3ef)
1331ebf7eSJerome Forissier_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)
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
10*32f25468SJerome Forissier_ld-option-supported = $(if $(shell $(LD$(sm)) -v $(1) 2>/dev/null >/dev/null || echo "Not supported"),,1)
11*32f25468SJerome Forissier_ld-opt-cached-var-name = $(subst =,~,$(subst $(empty) $(empty),,$(strip cached-ld-option-$(1)-$(LD$(sm)))))
12*32f25468SJerome Forissierdefine _ld-option
13*32f25468SJerome Forissier$(eval _var_name := $(call _ld-opt-cached-var-name,$(1)))
14*32f25468SJerome Forissier$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _ld-option-supported,$(1)),$($(_var_name))))
15*32f25468SJerome Forissier$(if $($(_var_name)),$(1),$(2))
16*32f25468SJerome Forissierendef
17*32f25468SJerome Forissierld-option = $(strip $(call _ld-option,$(1),$(2)))
18