Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 1 | # |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 2 | # Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved. |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +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 | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 5 | # |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 6 | |
| 7 | # OS specific parts for builds in a Windows_NT environment. The |
| 8 | # environment variable OS is set to Windows_NT on all modern Windows platforms |
| 9 | |
| 10 | # Include generic windows command definitions. |
| 11 | |
| 12 | ifndef WINDOWS_MK |
| 13 | WINDOWS_MK := $(lastword $(MAKEFILE_LIST)) |
| 14 | |
| 15 | ECHO_BLANK_LINE := @cmd /c echo. |
Antonio Nino Diaz | ffd122b | 2018-10-19 15:44:30 +0100 | [diff] [blame] | 16 | ECHO_QUIET := @rem |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 17 | DIR_DELIM := $(strip \) |
Evan Lloyd | 004c9a5 | 2015-12-03 11:35:40 +0000 | [diff] [blame] | 18 | BIN_EXT := .exe |
| 19 | PATH_SEP := ; |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 20 | |
| 21 | # For some Windows native commands there is a problem with the directory delimiter. |
| 22 | # Make uses / (slash) and the commands expect \ (backslash) |
| 23 | # We have to provide a means of translating these, so we define local functions. |
| 24 | |
| 25 | # ${1} is the file to be copied. |
| 26 | # ${2} is the destination file name. |
| 27 | define SHELL_COPY |
| 28 | $(eval tmp_from_file:=$(subst /,\,${1})) |
| 29 | $(eval tmp_to_file:=$(subst /,\,${2})) |
| 30 | copy "${tmp_from_file}" "${tmp_to_file}" |
| 31 | endef |
| 32 | |
| 33 | # ${1} is the directory to be copied. |
| 34 | # ${2} is the destination directory path. |
| 35 | define SHELL_COPY_TREE |
| 36 | $(eval tmp_from_dir:=$(subst /,\,${1})) |
| 37 | $(eval tmp_to_dir:=$(subst /,\,${2})) |
| 38 | xcopy /HIVE "${tmp_from_dir}" "${tmp_to_dir}" |
| 39 | endef |
| 40 | |
| 41 | # ${1} is the file to be deleted. |
| 42 | define SHELL_DELETE |
| 43 | $(eval tmp_del_file:=$(subst /,\,${*})) |
| 44 | -@if exist $(tmp_del_file) del /Q $(tmp_del_file) |
| 45 | endef |
| 46 | |
| 47 | # ${1} is a space delimited list of files to be deleted. |
| 48 | define SHELL_DELETE_ALL |
| 49 | $(eval $(foreach filename,$(wildcard ${1}),$(call DELETE_IF_THERE,${filename}))) |
| 50 | endef |
| 51 | |
| 52 | # ${1} is the directory to be generated. |
| 53 | # ${2} is optional, and allows prerequisites to be specified. |
Evan Lloyd | 4c3055f | 2017-04-07 16:58:57 +0100 | [diff] [blame] | 54 | # Do nothing if $1 == $2, to ignore self dependencies. |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 55 | define MAKE_PREREQ_DIR |
Evan Lloyd | 4c3055f | 2017-04-07 16:58:57 +0100 | [diff] [blame] | 56 | ifneq (${1},${2}) |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 57 | |
| 58 | ${1} : ${2} |
| 59 | $(eval tmp_dir:=$(subst /,\,${1})) |
| 60 | -@if not exist "$(tmp_dir)" mkdir "${tmp_dir}" |
| 61 | |
Evan Lloyd | 4c3055f | 2017-04-07 16:58:57 +0100 | [diff] [blame] | 62 | endif |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 63 | endef |
| 64 | |
| 65 | # ${1} is the directory to be removed. |
| 66 | define SHELL_REMOVE_DIR |
| 67 | $(eval tmp_dir:=$(subst /,\,${1})) |
| 68 | -@if exist "$(tmp_dir)" rd /Q /S "$(tmp_dir)" |
| 69 | endef |
| 70 | |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 71 | nul := nul |
| 72 | |
| 73 | which = $(shell where $(1) 2>$(nul)) |
Evan Lloyd | a71d259 | 2015-12-02 18:56:06 +0000 | [diff] [blame] | 74 | endif |
| 75 | |
Evan Lloyd | cf6e9d4 | 2015-12-03 12:58:52 +0000 | [diff] [blame] | 76 | # Because git is not available from CMD.EXE, we need to avoid |
| 77 | # the BUILD_STRING generation which uses git. |
| 78 | # For now we use "development build". |
| 79 | # This can be overridden from the command line or environment. |
| 80 | BUILD_STRING ?= development build |
| 81 | |
| 82 | # The DOS echo shell command does not strip ' characters from the command |
| 83 | # parameters before printing. We therefore use an alternative method invoked |
| 84 | # by defining the MAKE_BUILD_STRINGS macro. |
| 85 | BUILT_TIME_DATE_STRING = const char build_message[] = "Built : "${BUILD_MESSAGE_TIMESTAMP}; |
| 86 | VERSION_STRING_MESSAGE = const char version_string[] = "${VERSION_STRING}"; |
Harrison Mutai | 16b49ff | 2022-08-16 13:24:39 +0100 | [diff] [blame] | 87 | VERSION_MESSAGE = const char version[] = "${VERSION}"; |
Evan Lloyd | cf6e9d4 | 2015-12-03 12:58:52 +0000 | [diff] [blame] | 88 | define MAKE_BUILD_STRINGS |
Harrison Mutai | 5b5a475 | 2023-09-26 15:07:24 +0100 | [diff] [blame] | 89 | $$(file >$1.in,$$(TF_CFLAGS) $$(CFLAGS)) |
Harrison Mutai | e999cb9 | 2022-08-23 16:44:39 +0100 | [diff] [blame] | 90 | @echo $$(BUILT_TIME_DATE_STRING) $$(VERSION_STRING_MESSAGE) $$(VERSION_MESSAGE) | \ |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 91 | $($(ARCH)-cc) @$1.in -x c -c - -o $1 |
Evan Lloyd | cf6e9d4 | 2015-12-03 12:58:52 +0000 | [diff] [blame] | 92 | endef |
| 93 | |
Sami Mujawar | e7cdc3f | 2020-04-30 12:41:57 +0100 | [diff] [blame] | 94 | MSVC_NMAKE := nmake.exe |