blob: 93e1fcc19a8555a86048454d85ddb11178ac5105 [file] [log] [blame]
Evan Lloyd26c6cb42015-12-02 18:33:55 +00001#
Chris Kay2c09bf62024-04-09 16:30:52 +00002# Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
Evan Lloyd26c6cb42015-12-02 18:33:55 +00003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Evan Lloyd26c6cb42015-12-02 18:33:55 +00005#
Evan Lloyd26c6cb42015-12-02 18:33:55 +00006
7# Trusted Firmware shell command definitions for a Unix style environment.
8
9ifndef UNIX_MK
10 UNIX_MK := $(lastword $(MAKEFILE_LIST))
11
12 ECHO_BLANK_LINE := echo
Antonio Nino Diazffd122b2018-10-19 15:44:30 +010013 ECHO_QUIET := @\#
Evan Lloyd26c6cb42015-12-02 18:33:55 +000014
15 DIR_DELIM := /
16 PATH_SEP := :
17
18 # These defines provide Unix style equivalents of the shell commands
19 # required by the Trusted Firmware build environment.
20
21 # ${1} is the file to be copied.
22 # ${2} is the destination file name.
23 define SHELL_COPY
24 ${Q}cp -f "${1}" "${2}"
25 endef
26
27 # ${1} is the directory to be copied.
28 # ${2} is the destination directory path.
29 define SHELL_COPY_TREE
30 ${Q}cp -rf "${1}" "${2}"
31 endef
32
33 # ${1} is the file to be deleted.
34 define SHELL_DELETE
35 -${Q}rm -f "${1}"
36 endef
37
38 # ${1} is a space delimited list of files to be deleted.
39 # Note that we do not quote ${1}, as multiple parameters may be passed.
40 define SHELL_DELETE_ALL
41 -${Q}rm -rf ${1}
42 endef
43
44 # ${1} is the directory to be generated.
45 # ${2} is optional, and allows a prerequisite to be specified.
Evan Lloyd4c3055f2017-04-07 16:58:57 +010046 # Do nothing if $1 == $2, to ignore self dependencies.
Evan Lloyd26c6cb42015-12-02 18:33:55 +000047 define MAKE_PREREQ_DIR
Evan Lloyd4c3055f2017-04-07 16:58:57 +010048 ifneq (${1},${2})
Evan Lloyd26c6cb42015-12-02 18:33:55 +000049
50${1} : ${2}
51 ${Q}mkdir -p "${1}"
52
Evan Lloyd4c3055f2017-04-07 16:58:57 +010053 endif
Evan Lloyd26c6cb42015-12-02 18:33:55 +000054 endef
55
56 define SHELL_REMOVE_DIR
57 -${Q}rm -rf "${1}"
58 endef
59
Chris Kayc8a47ba2023-10-20 09:17:33 +000060 nul := /dev/null
61
Chris Kay2c09bf62024-04-09 16:30:52 +000062 which = $(shell command -v $(call escape-shell,$(1)) 2>$(nul))
Evan Lloyd26c6cb42015-12-02 18:33:55 +000063endif