Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 1 | # |
Chris Kay | 2c09bf6 | 2024-04-09 16:30:52 +0000 | [diff] [blame] | 2 | # Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved. |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 3 | # |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | # SPDX-License-Identifier: BSD-3-Clause |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 5 | # |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 6 | |
| 7 | # Trusted Firmware shell command definitions for a Unix style environment. |
| 8 | |
| 9 | ifndef UNIX_MK |
| 10 | UNIX_MK := $(lastword $(MAKEFILE_LIST)) |
| 11 | |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 12 | DIR_DELIM := / |
| 13 | PATH_SEP := : |
| 14 | |
| 15 | # These defines provide Unix style equivalents of the shell commands |
| 16 | # required by the Trusted Firmware build environment. |
| 17 | |
| 18 | # ${1} is the file to be copied. |
| 19 | # ${2} is the destination file name. |
| 20 | define SHELL_COPY |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 21 | $(q)cp -f "${1}" "${2}" |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 22 | endef |
| 23 | |
| 24 | # ${1} is the directory to be copied. |
| 25 | # ${2} is the destination directory path. |
| 26 | define SHELL_COPY_TREE |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 27 | $(q)cp -rf "${1}" "${2}" |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 28 | endef |
| 29 | |
| 30 | # ${1} is the file to be deleted. |
| 31 | define SHELL_DELETE |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 32 | -$(q)rm -f "${1}" |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 33 | endef |
| 34 | |
| 35 | # ${1} is a space delimited list of files to be deleted. |
| 36 | # Note that we do not quote ${1}, as multiple parameters may be passed. |
| 37 | define SHELL_DELETE_ALL |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 38 | -$(q)rm -rf ${1} |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 39 | endef |
| 40 | |
| 41 | # ${1} is the directory to be generated. |
| 42 | # ${2} is optional, and allows a prerequisite to be specified. |
Evan Lloyd | 4c3055f | 2017-04-07 16:58:57 +0100 | [diff] [blame] | 43 | # Do nothing if $1 == $2, to ignore self dependencies. |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 44 | define MAKE_PREREQ_DIR |
Evan Lloyd | 4c3055f | 2017-04-07 16:58:57 +0100 | [diff] [blame] | 45 | ifneq (${1},${2}) |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 46 | |
| 47 | ${1} : ${2} |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 48 | $(q)mkdir -p "${1}" |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 49 | |
Evan Lloyd | 4c3055f | 2017-04-07 16:58:57 +0100 | [diff] [blame] | 50 | endif |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 51 | endef |
| 52 | |
| 53 | define SHELL_REMOVE_DIR |
Chris Kay | 1870c72 | 2024-05-02 17:52:37 +0000 | [diff] [blame] | 54 | -$(q)rm -rf "${1}" |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 55 | endef |
| 56 | |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 57 | nul := /dev/null |
| 58 | |
Chris Kay | 2c09bf6 | 2024-04-09 16:30:52 +0000 | [diff] [blame] | 59 | which = $(shell command -v $(call escape-shell,$(1)) 2>$(nul)) |
Evan Lloyd | 26c6cb4 | 2015-12-02 18:33:55 +0000 | [diff] [blame] | 60 | endif |