From 621dd8468ff1ccc915498c5ee8db824ab286193e Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Mon, 14 Mar 2016 15:07:14 -0600 Subject: [PATCH] Makefile.inc: Add toupper, tolower, and ws_to_under macros Add a few additional macros that can be used throughout the coreboot makefiles. tolower: returns the value in all lowercase toupper: returns the value in all uppercase ws_to_under: returns the value with any whitespace changed to underscores Change-Id: Icd0e6586481d8f229af0e899e0c94ef7c5c672c3 Signed-off-by: Martin Roth Reviewed-on: https://review.coreboot.org/14093 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh Reviewed-by: Stefan Reinauer --- Makefile.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile.inc b/Makefile.inc index a07f92a800..a70ff5c2ce 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -94,7 +94,7 @@ $(foreach supported_arch,$(ARCH_SUPPORTED), \ $(eval rmodules_$(supported_arch)-generic-ccopts += -D__RMODULE__)) ####################################################################### -# Helper functions for math and various file placement matters. +# Helper functions for math, strings, and various file placement matters. # macros work on all formats understood by printf(1) # values are space separated if using more than one value # @@ -108,6 +108,9 @@ $(foreach supported_arch,$(ARCH_SUPPORTED), \ # int-eq: 1 if the two values are equal. 0 otherwise # int-align: align $1 to $2 units # file-size: returns the filesize of the given file +# tolower: returns the value in all lowercase +# toupper: returns the value in all uppercase +# ws_to_under: returns the value with any whitespace changed to underscores _toint=$(shell printf "%d" $1) _int-add2=$(shell expr $(call _toint,$1) + $(call _toint,$2)) int-add=$(if $(filter 1,$(words $1)),$(strip $1),$(call int-add,$(call _int-add2,$(word 1,$1),$(word 2,$1)) $(wordlist 3,$(words $1),$1))) @@ -121,6 +124,9 @@ int-gt=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(wor int-eq=$(if $(filter 1,$(words $1)),$(strip $1),$(shell expr $(call _toint,$(word 1,$1)) = $(call _toint,$(word 2,$1)))) int-align=$(shell A=$(call _toint,$1) B=$(call _toint,$2); expr $$A + \( \( $$B - \( $$A % $$B \) \) % $$B \) ) file-size=$(shell cat $1 | wc -c) +tolower=$(shell echo '$1' | tr '[:upper:]' '[:lower:]') +toupper=$(shell echo '$1' | tr '[:lower:]' '[:upper:]') +ws_to_under=$(shell echo '$1' | tr ' \t' '_') ####################################################################### # Helper functions for ramstage postprocess