diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk index 91a198160..da3f0fc31 100644 --- a/package/pkg-utils.mk +++ b/package/pkg-utils.mk @@ -13,24 +13,20 @@ # as this macro is used a lot it matters # This works by creating translation character pairs (E.G. a:A b:B) # and then looping though all of them running $(subst from,to,text) -[FROM] := a b c d e f g h i j k l m n o p q r s t u v w x y z . - +[FROM] := a b c d e f g h i j k l m n o p q r s t u v w x y z - . [TO] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ _ -UPPERCASE = $(strip $(eval __tmp := $1) \ - $(foreach c, $(join $(addsuffix :,$([FROM])),$([TO])), \ - $(eval __tmp := \ - $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),\ - $(__tmp)))) \ - $(__tmp)) - -# LOWERCASE macro -- transforms its arguments to lowercase -# The above non-tr implementation is not needed, because LOWERCASE is not -# called very often - -define LOWERCASE -$(shell echo $1 | tr '[:upper:]' '[:lower:]') +define caseconvert-helper +$(1) = $$(strip \ + $$(eval __tmp := $$(1))\ + $(foreach c, $(2),\ + $$(eval __tmp := $$(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),$$(__tmp))))\ + $$(__tmp)) endef +$(eval $(call caseconvert-helper,UPPERCASE,$(join $(addsuffix :,$([FROM])),$([TO])))) +$(eval $(call caseconvert-helper,LOWERCASE,$(join $(addsuffix :,$([TO])),$([FROM])))) + # # Manipulation of .config files based on the Kconfig # infrastructure. Used by the Busybox package, the Linux kernel