blob: 5bb18066912e7246caced9caa5606495b3722808 [file] [log] [blame]
Chris Kay4731c002024-04-09 16:30:52 +00001#
2# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7space :=
8space := $(space) $(space)
9comma := ,
10
11null :=
12
13compat-path = $(subst $(space),$(null),$(1))
14decompat-path = $(subst $(null), ,$(1))
15
16absolute-path = $(call decompat-path,$(abspath $(call compat-path,$(1))))
17real-path = $(call decompat-path,$(realpath $(call compat-path,$(1))))
18
19file-name = $(call decompat-path,$(notdir $(call compat-path,$(1))))
20directory-name = $(call decompat-path,$(dir $(call compat-path,$(1))))
21
22escape-shell = '$(subst ','\'',$(1))'
Chris Kay3af4eb52024-05-29 22:09:26 +000023
24#
25# Upper-case a string value.
26#
27# Parameters:
28#
29# - $(1): The string to upper-case.
30#
31# Example usage:
32#
33# $(call uppercase,HeLlO wOrLd) # "HELLO WORLD"
34#
35
36uppercase = $(shell echo $(call escape-shell,$(1)) | tr '[:lower:]' '[:upper:]')
37
38#
39# Lower-case a string value.
40#
41# Parameters:
42#
43# - $(1): The string to lower-case.
44#
45# Example usage:
46#
47# $(call lowercase,HeLlO wOrLd) # "hello world"
48#
49
50lowercase = $(shell echo $(call escape-shell,$(1)) | tr '[:upper:]' '[:lower:]')