1*7c3d14c8STreehugger Robot# Library Utility Functions 2*7c3d14c8STreehugger Robot# 3*7c3d14c8STreehugger Robot# This should be included following 'lib_info.mk'. 4*7c3d14c8STreehugger Robot 5*7c3d14c8STreehugger Robot# Function: GetCNAVar variable-name platform-key config arch 6*7c3d14c8STreehugger Robot# 7*7c3d14c8STreehugger Robot# Get a per-config-and-arch variable value. 8*7c3d14c8STreehugger RobotGetCNAVar = $(strip \ 9*7c3d14c8STreehugger Robot $(or $($(2).$(1).$(3).$(4)), \ 10*7c3d14c8STreehugger Robot $($(2).$(1).$(3)), \ 11*7c3d14c8STreehugger Robot $($(2).$(1).$(4)), \ 12*7c3d14c8STreehugger Robot $($(2).$(1)))) 13*7c3d14c8STreehugger Robot 14*7c3d14c8STreehugger Robot# Function: SelectFunctionDir config arch function-name optimized 15*7c3d14c8STreehugger Robot# 16*7c3d14c8STreehugger Robot# Choose the appropriate implementation directory to use for 'function-name' in 17*7c3d14c8STreehugger Robot# the configuration 'config' and on given arch. 18*7c3d14c8STreehugger RobotSelectFunctionDir = $(strip \ 19*7c3d14c8STreehugger Robot $(call Set,Tmp.SelectFunctionDir,$(call SelectFunctionDirs,$(1),$(2),$(3),$(4)))\ 20*7c3d14c8STreehugger Robot $(if $(call streq,1,$(words $(Tmp.SelectFunctionDir))),\ 21*7c3d14c8STreehugger Robot $(Tmp.SelectFunctionDir),\ 22*7c3d14c8STreehugger Robot $(error SelectFunctionDir: invalid function name "$(3)" ($(strip\ 23*7c3d14c8STreehugger Robot $(if $(call streq,0,$(words $(Tmp.SelectFunctionDir))),\ 24*7c3d14c8STreehugger Robot no such function,\ 25*7c3d14c8STreehugger Robot function implemented in multiple directories!!!)))))) 26*7c3d14c8STreehugger Robot 27*7c3d14c8STreehugger Robot# Helper functions that select the entire list of subdirs where a function is 28*7c3d14c8STreehugger Robot# defined with a certain specificity. 29*7c3d14c8STreehugger RobotSelectFunctionDirs_Opt_ConfigAndArch = $(strip \ 30*7c3d14c8STreehugger Robot $(foreach key,$(AvailableIn.$(3)),\ 31*7c3d14c8STreehugger Robot $(if $(and $(call streq,Optimized,$($(key).Implementation)),\ 32*7c3d14c8STreehugger Robot $(call contains,$($(key).OnlyConfigs),$(1)),\ 33*7c3d14c8STreehugger Robot $(call contains,$($(key).OnlyArchs),$(2))),$(key),))) 34*7c3d14c8STreehugger RobotSelectFunctionDirs_Opt_Config = $(strip \ 35*7c3d14c8STreehugger Robot $(foreach key,$(AvailableIn.$(3)),\ 36*7c3d14c8STreehugger Robot $(if $(and $(call streq,Optimized,$($(key).Implementation)),\ 37*7c3d14c8STreehugger Robot $(call contains,$($(key).OnlyConfigs),$(1))),$(key),))) 38*7c3d14c8STreehugger RobotSelectFunctionDirs_Opt_Arch = $(strip \ 39*7c3d14c8STreehugger Robot $(foreach key,$(AvailableIn.$(3)),\ 40*7c3d14c8STreehugger Robot $(if $(and $(call streq,Optimized,$($(key).Implementation)),\ 41*7c3d14c8STreehugger Robot $(call contains,$($(key).OnlyArchs),$(2))),$(key),))) 42*7c3d14c8STreehugger RobotSelectFunctionDirs_Gen = $(strip \ 43*7c3d14c8STreehugger Robot $(foreach key,$(AvailableIn.$(3)),\ 44*7c3d14c8STreehugger Robot $(if $(call streq,Generic,$($(key).Implementation)),$(key)))) 45*7c3d14c8STreehugger Robot 46*7c3d14c8STreehugger Robot# Helper function to select the right set of dirs in generic priority order. 47*7c3d14c8STreehugger RobotSelectFunctions_Gen = \ 48*7c3d14c8STreehugger Robot $(or $(call SelectFunctionDirs_Gen,$(1),$(2),$(3)),\ 49*7c3d14c8STreehugger Robot $(call SelectFunctionDirs_Opt_ConfigAndArch,$(1),$(2),$(3)), \ 50*7c3d14c8STreehugger Robot $(call SelectFunctionDirs_Opt_Config,$(1),$(2),$(3)), \ 51*7c3d14c8STreehugger Robot $(call SelectFunctionDirs_Opt_Arch,$(1),$(2),$(3))) 52*7c3d14c8STreehugger Robot 53*7c3d14c8STreehugger Robot# Helper function to select the right set of dirs in optimized priority order. 54*7c3d14c8STreehugger RobotSelectFunctions_Opt = \ 55*7c3d14c8STreehugger Robot $(or $(call SelectFunctionDirs_Opt_ConfigAndArch,$(1),$(2),$(3)), \ 56*7c3d14c8STreehugger Robot $(call SelectFunctionDirs_Opt_Config,$(1),$(2),$(3)), \ 57*7c3d14c8STreehugger Robot $(call SelectFunctionDirs_Opt_Arch,$(1),$(2),$(3)), \ 58*7c3d14c8STreehugger Robot $(call SelectFunctionDirs_Gen,$(1),$(2),$(3))) 59*7c3d14c8STreehugger Robot 60*7c3d14c8STreehugger Robot# Helper function to select the right set of dirs (which should be exactly one) 61*7c3d14c8STreehugger Robot# for a function. 62*7c3d14c8STreehugger RobotSelectFunctionDirs = \ 63*7c3d14c8STreehugger Robot $(if $(call streq,1,$(4)),\ 64*7c3d14c8STreehugger Robot $(call SelectFunctions_Opt,$(1),$(2),$(3)),\ 65*7c3d14c8STreehugger Robot $(call SelectFunctions_Gen,$(1),$(2),$(3))) 66