| 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_LIBTOOL = $(host_toolchain)libtool |
| 11 |
default_host_INSTALL_NAME_TOOL = $(host_toolchain)install_name_tool |
| 12 |
default_host_OTOOL = $(host_toolchain)otool |
| 13 |
default_host_NM = $(host_toolchain)nm |
| 14 |
default_host_OBJCOPY = $(host_toolchain)objcopy |
| 15 |
|
| 16 |
define add_host_tool_func |
| 17 |
ifneq ($(filter $(origin $1),undefined default),) |
| 18 |
# Do not consider the well-known var $1 if it is undefined or is taking a value |
| 19 |
# that is predefined by "make" (e.g. the make variable "CC" has a predefined |
| 20 |
# value of "cc") |
| 21 |
$(host_os)_$1?=$$(default_host_$1) |
| 22 |
$(host_arch)_$(host_os)_$1?=$$($(host_os)_$1) |
| 23 |
$(host_arch)_$(host_os)_$(release_type)_$1?=$$($(host_os)_$1) |
| 24 |
else |
| 25 |
$(host_os)_$1=$(or $($1),$($(host_os)_$1),$(default_host_$1)) |
| 26 |
$(host_arch)_$(host_os)_$1=$(or $($1),$($(host_arch)_$(host_os)_$1),$$($(host_os)_$1)) |
| 27 |
$(host_arch)_$(host_os)_$(release_type)_$1=$(or $($1),$($(host_arch)_$(host_os)_$(release_type)_$1),$$($(host_os)_$1)) |
| 28 |
endif |
| 29 |
host_$1=$$($(host_arch)_$(host_os)_$1) |
| 30 |
endef |
| 31 |
|
| 32 |
define add_host_flags_func |
| 33 |
$(host_arch)_$(host_os)_$1 += $($(host_os)_$1) |
| 34 |
$(host_arch)_$(host_os)_$(release_type)_$1 += $($(host_os)_$(release_type)_$1) |
| 35 |
host_$1 = $$($(host_arch)_$(host_os)_$1) |
| 36 |
host_$(release_type)_$1 = $$($(host_arch)_$(host_os)_$(release_type)_$1) |
| 37 |
endef |
| 38 |
|
| 39 |
$(foreach tool,CC CXX AR RANLIB STRIP LIBTOOL NM OBJCOPY OTOOL INSTALL_NAME_TOOL DSYMUTIL,$(eval $(call add_host_tool_func,$(tool)))) |
| 40 |
$(foreach flags,CFLAGS CXXFLAGS ARFLAGS CPPFLAGS LDFLAGS, $(eval $(call add_host_flags_func,$(flags)))) |