lib_util.mk revision 78cfbc57c62949e16fa7b4a69775aa6450343a00
178cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# Library Utility Functions 278cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# 378cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# This should be included following 'lib_info.mk'. 478cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar 578cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# Function: SelectFunctionDir config arch function-name optimized 678cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# 778cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# Choose the appropriate implementation directory to use for 'function-name' in 878cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# the configuration 'config' and on given arch. 978cfbc57c62949e16fa7b4a69775aa6450343a00Daniel DunbarSelectFunctionDir = $(strip \ 1078cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call Set,Tmp.SelectFunctionDir,$(call SelectFunctionDirs,$(1),$(2),$(3),$(4)))\ 1178cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(if $(call streq,1,$(words $(Tmp.SelectFunctionDir))),\ 1278cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(Tmp.SelectFunctionDir),\ 1378cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(error SelectFunctionDir: invalid function name "$(3)" ($(strip\ 1478cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(if $(call streq,0,$(words $(Tmp.SelectFunctionDir))),\ 1578cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar no such function,\ 1678cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar function implemented in multiple directories!!!)))))) 1778cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar 1878cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# Helper functions that select the entire list of subdirs where a function is 1978cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# defined with a certain specificity. 2078cfbc57c62949e16fa7b4a69775aa6450343a00Daniel DunbarSelectFunctionDirs_Opt_ConfigAndArch = $(strip \ 2178cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(foreach key,$(AvailableIn.$(3)),\ 2278cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(if $(and $(call streq,Optimized,$($(key).Target)),\ 2378cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call contains,$($(key).OnlyConfigs),$(1)),\ 2478cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call contains,$($(key).OnlyArchs),$(2))),$(key),))) 2578cfbc57c62949e16fa7b4a69775aa6450343a00Daniel DunbarSelectFunctionDirs_Opt_Config = $(strip \ 2678cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(foreach key,$(AvailableIn.$(3)),\ 2778cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(if $(and $(call streq,Optimized,$($(key).Target)),\ 2878cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call contains,$($(key).OnlyConfigs),$(1))),$(key),))) 2978cfbc57c62949e16fa7b4a69775aa6450343a00Daniel DunbarSelectFunctionDirs_Opt_Arch = $(strip \ 3078cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(foreach key,$(AvailableIn.$(3)),\ 3178cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(if $(and $(call streq,Optimized,$($(key).Target)),\ 3278cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call contains,$($(key).OnlyArchs),$(2))),$(key),))) 3378cfbc57c62949e16fa7b4a69775aa6450343a00Daniel DunbarSelectFunctionDirs_Gen = $(strip \ 3478cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(foreach key,$(AvailableIn.$(3)),\ 3578cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(if $(call streq,Generic,$($(key).Target)),$(key)))) 3678cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar 3778cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# Helper function to select the right set of dirs in generic priority order. 3878cfbc57c62949e16fa7b4a69775aa6450343a00Daniel DunbarSelectFunctions_Gen = \ 3978cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(or $(call SelectFunctionDirs_Gen,$(1),$(2),$(3)),\ 4078cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call SelectFunctionDirs_Opt_ConfigAndArch,$(1),$(2),$(3)), \ 4178cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call SelectFunctionDirs_Opt_Config,$(1),$(2),$(3)), \ 4278cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call SelectFunctionDirs_Opt_Arch,$(1),$(2),$(3))) 4378cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar 4478cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# Helper function to select the right set of dirs in optimized priority order. 4578cfbc57c62949e16fa7b4a69775aa6450343a00Daniel DunbarSelectFunctions_Opt = \ 4678cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(or $(call SelectFunctionDirs_Opt_ConfigAndArch,$(1),$(2),$(3)), \ 4778cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call SelectFunctionDirs_Opt_Config,$(1),$(2),$(3)), \ 4878cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call SelectFunctionDirs_Opt_Arch,$(1),$(2),$(3)), \ 4978cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call SelectFunctionDirs_Gen,$(1),$(2),$(3))) 5078cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar 5178cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# Helper function to select the right set of dirs (which should be exactly one) 5278cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar# for a function. 5378cfbc57c62949e16fa7b4a69775aa6450343a00Daniel DunbarSelectFunctionDirs = \ 5478cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(if $(call streq,1,$(4)),\ 5578cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call SelectFunctions_Opt,$(1),$(2),$(3)),\ 5678cfbc57c62949e16fa7b4a69775aa6450343a00Daniel Dunbar $(call SelectFunctions_Gen,$(1),$(2),$(3))) 57