1ifneq ($(host),$(build)) 2host_toolchain:=$(host)- 3endif 4 5default_host_CC = $(host_toolchain)gcc 6default_host_CXX = $(host_toolchain)g++ 7default_host_AR = $(host_toolchain)ar 8default_host_RANLIB = $(host_toolchain)ranlib 9default_host_STRIP = $(host_toolchain)strip 10default_host_LIBTOOL = $(host_toolchain)libtool 11default_host_INSTALL_NAME_TOOL = $(host_toolchain)install_name_tool 12default_host_OTOOL = $(host_toolchain)otool 13default_host_NM = $(host_toolchain)nm 14 15define add_host_tool_func 16ifneq ($(filter $(origin $1),undefined default),) 17# Do not consider the well-known var $1 if it is undefined or is taking a value 18# that is predefined by "make" (e.g. the make variable "CC" has a predefined 19# value of "cc") 20$(host_os)_$1?=$$(default_host_$1) 21$(host_arch)_$(host_os)_$1?=$$($(host_os)_$1) 22$(host_arch)_$(host_os)_$(release_type)_$1?=$$($(host_os)_$1) 23else 24$(host_os)_$1=$(or $($1),$($(host_os)_$1),$(default_host_$1)) 25$(host_arch)_$(host_os)_$1=$(or $($1),$($(host_arch)_$(host_os)_$1),$$($(host_os)_$1)) 26$(host_arch)_$(host_os)_$(release_type)_$1=$(or $($1),$($(host_arch)_$(host_os)_$(release_type)_$1),$$($(host_os)_$1)) 27endif 28host_$1=$$($(host_arch)_$(host_os)_$1) 29endef 30 31define add_host_flags_func 32$(host_arch)_$(host_os)_$1 += $($(host_os)_$1) 33$(host_arch)_$(host_os)_$(release_type)_$1 += $($(host_os)_$(release_type)_$1) 34host_$1 = $$($(host_arch)_$(host_os)_$1) 35host_$(release_type)_$1 = $$($(host_arch)_$(host_os)_$(release_type)_$1) 36endef 37 38$(foreach tool,CC CXX AR RANLIB STRIP NM LIBTOOL OTOOL INSTALL_NAME_TOOL,$(eval $(call add_host_tool_func,$(tool)))) 39$(foreach flags,CFLAGS CXXFLAGS CPPFLAGS LDFLAGS, $(eval $(call add_host_flags_func,$(flags)))) 40