Jerome Forissier | 331ebf7 | 2020-05-26 15:21:00 +0200 | [diff] [blame] | 1 | _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))))) |
| 3 | define _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)) |
| 7 | endef |
| 8 | cc-option = $(strip $(call _cc-option,$(1),$(2))) |
| 9 | |
Jerome Forissier | 79f882f | 2020-11-20 09:46:30 +0100 | [diff] [blame] | 10 | _ld-option-supported = $(if $(shell ($(LD$(sm)) -v $(1) 2>&1 || echo warning) | grep warning),,1) |
Jerome Forissier | 32f2546 | 2020-05-28 11:34:00 +0200 | [diff] [blame] | 11 | _ld-opt-cached-var-name = $(subst =,~,$(subst $(empty) $(empty),,$(strip cached-ld-option-$(1)-$(LD$(sm))))) |
| 12 | define _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)) |
| 16 | endef |
| 17 | ld-option = $(strip $(call _ld-option,$(1),$(2))) |