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