blob: 4fd819a541e8a5246c37a7367398530ce38d961c [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
Evan Lloyd26c6cb42015-12-02 18:33:55 +000012 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 Kay1870c722024-05-02 17:52:37 +000021 $(q)cp -f "${1}" "${2}"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000022 endef
23
24 # ${1} is the directory to be copied.
25 # ${2} is the destination directory path.
26 define SHELL_COPY_TREE
Chris Kay1870c722024-05-02 17:52:37 +000027 $(q)cp -rf "${1}" "${2}"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000028 endef
29
30 # ${1} is the file to be deleted.
31 define SHELL_DELETE
Chris Kay1870c722024-05-02 17:52:37 +000032 -$(q)rm -f "${1}"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000033 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 Kay1870c722024-05-02 17:52:37 +000038 -$(q)rm -rf ${1}
Evan Lloyd26c6cb42015-12-02 18:33:55 +000039 endef
40
41 # ${1} is the directory to be generated.
42 # ${2} is optional, and allows a prerequisite to be specified.
Evan Lloyd4c3055f2017-04-07 16:58:57 +010043 # Do nothing if $1 == $2, to ignore self dependencies.
Evan Lloyd26c6cb42015-12-02 18:33:55 +000044 define MAKE_PREREQ_DIR
Evan Lloyd4c3055f2017-04-07 16:58:57 +010045 ifneq (${1},${2})
Evan Lloyd26c6cb42015-12-02 18:33:55 +000046
47${1} : ${2}
Chris Kay1870c722024-05-02 17:52:37 +000048 $(q)mkdir -p "${1}"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000049
Evan Lloyd4c3055f2017-04-07 16:58:57 +010050 endif
Evan Lloyd26c6cb42015-12-02 18:33:55 +000051 endef
52
53 define SHELL_REMOVE_DIR
Chris Kay1870c722024-05-02 17:52:37 +000054 -$(q)rm -rf "${1}"
Evan Lloyd26c6cb42015-12-02 18:33:55 +000055 endef
56
Chris Kayc8a47ba2023-10-20 09:17:33 +000057 nul := /dev/null
58
Chris Kay2c09bf62024-04-09 16:30:52 +000059 which = $(shell command -v $(call escape-shell,$(1)) 2>$(nul))
Evan Lloyd26c6cb42015-12-02 18:33:55 +000060endif