2010-01-18 14:48:56 +08:00
|
|
|
# Library Utility Functions
|
|
|
|
#
|
|
|
|
# This should be included following 'lib_info.mk'.
|
|
|
|
|
2010-01-18 14:49:33 +08:00
|
|
|
# Function: GetCNAVar variable-name platform-key config arch
|
|
|
|
#
|
|
|
|
# Get a per-config-and-arch variable value.
|
|
|
|
GetCNAVar = $(strip \
|
|
|
|
$(or $($(2).$(1).$(3).$(4)), \
|
|
|
|
$($(2).$(1).$(3)), \
|
|
|
|
$($(2).$(1).$(4)), \
|
|
|
|
$($(2).$(1))))
|
|
|
|
|
2010-01-18 14:48:56 +08:00
|
|
|
# Function: SelectFunctionDir config arch function-name optimized
|
|
|
|
#
|
|
|
|
# Choose the appropriate implementation directory to use for 'function-name' in
|
|
|
|
# the configuration 'config' and on given arch.
|
|
|
|
SelectFunctionDir = $(strip \
|
|
|
|
$(call Set,Tmp.SelectFunctionDir,$(call SelectFunctionDirs,$(1),$(2),$(3),$(4)))\
|
|
|
|
$(if $(call streq,1,$(words $(Tmp.SelectFunctionDir))),\
|
|
|
|
$(Tmp.SelectFunctionDir),\
|
|
|
|
$(error SelectFunctionDir: invalid function name "$(3)" ($(strip\
|
|
|
|
$(if $(call streq,0,$(words $(Tmp.SelectFunctionDir))),\
|
|
|
|
no such function,\
|
|
|
|
function implemented in multiple directories!!!))))))
|
|
|
|
|
|
|
|
# Helper functions that select the entire list of subdirs where a function is
|
|
|
|
# defined with a certain specificity.
|
|
|
|
SelectFunctionDirs_Opt_ConfigAndArch = $(strip \
|
|
|
|
$(foreach key,$(AvailableIn.$(3)),\
|
2010-01-18 14:49:09 +08:00
|
|
|
$(if $(and $(call streq,Optimized,$($(key).Implementation)),\
|
2010-01-18 14:48:56 +08:00
|
|
|
$(call contains,$($(key).OnlyConfigs),$(1)),\
|
|
|
|
$(call contains,$($(key).OnlyArchs),$(2))),$(key),)))
|
|
|
|
SelectFunctionDirs_Opt_Config = $(strip \
|
|
|
|
$(foreach key,$(AvailableIn.$(3)),\
|
2010-01-18 14:49:09 +08:00
|
|
|
$(if $(and $(call streq,Optimized,$($(key).Implementation)),\
|
2010-01-18 14:48:56 +08:00
|
|
|
$(call contains,$($(key).OnlyConfigs),$(1))),$(key),)))
|
|
|
|
SelectFunctionDirs_Opt_Arch = $(strip \
|
|
|
|
$(foreach key,$(AvailableIn.$(3)),\
|
2010-01-18 14:49:09 +08:00
|
|
|
$(if $(and $(call streq,Optimized,$($(key).Implementation)),\
|
2010-01-18 14:48:56 +08:00
|
|
|
$(call contains,$($(key).OnlyArchs),$(2))),$(key),)))
|
|
|
|
SelectFunctionDirs_Gen = $(strip \
|
|
|
|
$(foreach key,$(AvailableIn.$(3)),\
|
2010-01-18 14:49:09 +08:00
|
|
|
$(if $(call streq,Generic,$($(key).Implementation)),$(key))))
|
2010-01-18 14:48:56 +08:00
|
|
|
|
|
|
|
# Helper function to select the right set of dirs in generic priority order.
|
|
|
|
SelectFunctions_Gen = \
|
|
|
|
$(or $(call SelectFunctionDirs_Gen,$(1),$(2),$(3)),\
|
|
|
|
$(call SelectFunctionDirs_Opt_ConfigAndArch,$(1),$(2),$(3)), \
|
|
|
|
$(call SelectFunctionDirs_Opt_Config,$(1),$(2),$(3)), \
|
|
|
|
$(call SelectFunctionDirs_Opt_Arch,$(1),$(2),$(3)))
|
|
|
|
|
|
|
|
# Helper function to select the right set of dirs in optimized priority order.
|
|
|
|
SelectFunctions_Opt = \
|
|
|
|
$(or $(call SelectFunctionDirs_Opt_ConfigAndArch,$(1),$(2),$(3)), \
|
|
|
|
$(call SelectFunctionDirs_Opt_Config,$(1),$(2),$(3)), \
|
|
|
|
$(call SelectFunctionDirs_Opt_Arch,$(1),$(2),$(3)), \
|
|
|
|
$(call SelectFunctionDirs_Gen,$(1),$(2),$(3)))
|
|
|
|
|
|
|
|
# Helper function to select the right set of dirs (which should be exactly one)
|
|
|
|
# for a function.
|
|
|
|
SelectFunctionDirs = \
|
|
|
|
$(if $(call streq,1,$(4)),\
|
|
|
|
$(call SelectFunctions_Opt,$(1),$(2),$(3)),\
|
|
|
|
$(call SelectFunctions_Gen,$(1),$(2),$(3)))
|