mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-17 01:54:22 +00:00

Grouped targets are a feature introduced with GNU Make 4.3 which enable rules with multiple targets to communicate that all of the targets of that rule are built simultaneously, rather than independently. For example, without grouped targets the following rule may be executed twice: a.txt b.txt: touch a.txt b.txt # $ remake -j2 a.txt b.txt # touch a.txt b.txt # touch a.txt b.txt In this example, both `a.txt` and `b.txt` are touched twice, when the rule should only be executed once. Instead, this rule can use a grouped target: a.txt b.txt &: touch a.txt b.txt # $ remake -j2 a.txt b.txt # touch a.txt b.txt # remake: 'b.txt' is up to date. In this case, both `a.txt` and `b.txt` are created once only, as Make now knows that the recipe will create both files. Note that pattern rules with multiple targets always behave this way. Previously, we assumed that the grouped target feature was available, but on systems still packaging Make 4.2, most prominently Ubuntu 20.04, this is not the case. This change adds a check to ensure that we do not use grouped targets if they are unavailable. Change-Id: Ifd9da35421ae11468d7a25d3cbc76f6036921749 Signed-off-by: Chris Kay <chris.kay@arm.com>
129 lines
2.7 KiB
Makefile
129 lines
2.7 KiB
Makefile
#
|
||
# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
|
||
#
|
||
# SPDX-License-Identifier: BSD-3-Clause
|
||
#
|
||
|
||
space :=
|
||
space := $(space) $(space)
|
||
comma := ,
|
||
|
||
null := <20>
|
||
|
||
compat-path = $(subst $(space),$(null),$(1))
|
||
decompat-path = $(subst $(null), ,$(1))
|
||
|
||
absolute-path = $(call decompat-path,$(abspath $(call compat-path,$(1))))
|
||
real-path = $(call decompat-path,$(realpath $(call compat-path,$(1))))
|
||
|
||
file-name = $(call decompat-path,$(notdir $(call compat-path,$(1))))
|
||
directory-name = $(call decompat-path,$(dir $(call compat-path,$(1))))
|
||
|
||
escape-shell = '$(subst ','\'',$(1))'
|
||
|
||
#
|
||
# The grouped-target symbol. Grouped targets are not supported on versions of
|
||
# GNU Make <= 4.2, which was most recently packaged with Ubuntu 20.04.
|
||
#
|
||
|
||
& := $(if $(filter grouped-target,$(.FEATURES)),&)
|
||
|
||
#
|
||
# Upper-case a string value.
|
||
#
|
||
# Parameters:
|
||
#
|
||
# - $(1): The string to upper-case.
|
||
#
|
||
# Example usage:
|
||
#
|
||
# $(call uppercase,HeLlO wOrLd) # "HELLO WORLD"
|
||
#
|
||
|
||
uppercase = $(shell echo $(call escape-shell,$(1)) | tr '[:lower:]' '[:upper:]')
|
||
|
||
#
|
||
# Lower-case a string value.
|
||
#
|
||
# Parameters:
|
||
#
|
||
# - $(1): The string to lower-case.
|
||
#
|
||
# Example usage:
|
||
#
|
||
# $(call lowercase,HeLlO wOrLd) # "hello world"
|
||
#
|
||
|
||
lowercase = $(shell echo $(call escape-shell,$(1)) | tr '[:upper:]' '[:lower:]')
|
||
|
||
#
|
||
# Determine the "truthiness" of a value.
|
||
#
|
||
# Parameters:
|
||
#
|
||
# - $(1): The value to determine the truthiness of.
|
||
#
|
||
# A value is considered to be falsy if it is:
|
||
#
|
||
# - empty, or
|
||
# - equal to "0", "N", "NO", "F" or "FALSE" after upper-casing.
|
||
#
|
||
# If the value is truthy then the value is returned as-is, otherwise no value
|
||
# is returned.
|
||
#
|
||
# Example usage:
|
||
#
|
||
# truthy := y
|
||
# truthy-bool := $(call bool,$(truthy)) # "y"
|
||
#
|
||
# falsy := n
|
||
# falsy-bool := $(call bool,$(falsy)) # <empty>
|
||
#
|
||
|
||
bool = $(filter-out 0 n no f false,$(call lowercase,$(1)))
|
||
|
||
#
|
||
# Determine the "truthiness" of a value, returning 0 or 1.
|
||
#
|
||
# Parameters:
|
||
#
|
||
# - $(1): The value to determine the truthiness of.
|
||
#
|
||
# A value is considered to be falsy if it is:
|
||
#
|
||
# - empty, or
|
||
# - equal to "0", "N", "NO", "F" or "FALSE" after upper-casing.
|
||
#
|
||
# If the value is truthy then the value is returned as-is, otherwise no value
|
||
# is returned.
|
||
#
|
||
# Example usage:
|
||
#
|
||
# truthy := y
|
||
# truthy-bool := $(call bool,$(truthy)) # "1"
|
||
#
|
||
# falsy := n
|
||
# falsy-bool := $(call bool,$(falsy)) # "0"
|
||
#
|
||
|
||
bool-01 = $(if $(call bool,$(1)),1,0)
|
||
|
||
#
|
||
# Determine whether a variable is defined or not.
|
||
#
|
||
# Parameters:
|
||
#
|
||
# - $(1): The variable to check.
|
||
#
|
||
# Example usage:
|
||
#
|
||
# xyz-defined := $(call defined,xyz) # <empty>
|
||
#
|
||
# xyz :=
|
||
# xyz-defined := $(call defined,xyz) # <non-empty>
|
||
#
|
||
# xyz := hello
|
||
# xyz-defined := $(call defined,xyz) # <non-empty>
|
||
#
|
||
|
||
defined = $(call bool,$(filter-out undefined,$(origin $(1))))
|