1*54fd6939SJiyong Park# 2*54fd6939SJiyong Park# Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved. 3*54fd6939SJiyong Park# 4*54fd6939SJiyong Park# SPDX-License-Identifier: BSD-3-Clause 5*54fd6939SJiyong Park# 6*54fd6939SJiyong Park 7*54fd6939SJiyong Park# OS specific parts for builds in a Windows_NT environment. The 8*54fd6939SJiyong Park# environment variable OS is set to Windows_NT on all modern Windows platforms 9*54fd6939SJiyong Park 10*54fd6939SJiyong Park# Include generic windows command definitions. 11*54fd6939SJiyong Park 12*54fd6939SJiyong Parkifndef WINDOWS_MK 13*54fd6939SJiyong Park WINDOWS_MK := $(lastword $(MAKEFILE_LIST)) 14*54fd6939SJiyong Park 15*54fd6939SJiyong Park ECHO_BLANK_LINE := @cmd /c echo. 16*54fd6939SJiyong Park ECHO_QUIET := @rem 17*54fd6939SJiyong Park DIR_DELIM := $(strip \) 18*54fd6939SJiyong Park BIN_EXT := .exe 19*54fd6939SJiyong Park PATH_SEP := ; 20*54fd6939SJiyong Park 21*54fd6939SJiyong Park # For some Windows native commands there is a problem with the directory delimiter. 22*54fd6939SJiyong Park # Make uses / (slash) and the commands expect \ (backslash) 23*54fd6939SJiyong Park # We have to provide a means of translating these, so we define local functions. 24*54fd6939SJiyong Park 25*54fd6939SJiyong Park # ${1} is the file to be copied. 26*54fd6939SJiyong Park # ${2} is the destination file name. 27*54fd6939SJiyong Park define SHELL_COPY 28*54fd6939SJiyong Park $(eval tmp_from_file:=$(subst /,\,${1})) 29*54fd6939SJiyong Park $(eval tmp_to_file:=$(subst /,\,${2})) 30*54fd6939SJiyong Park copy "${tmp_from_file}" "${tmp_to_file}" 31*54fd6939SJiyong Park endef 32*54fd6939SJiyong Park 33*54fd6939SJiyong Park # ${1} is the directory to be copied. 34*54fd6939SJiyong Park # ${2} is the destination directory path. 35*54fd6939SJiyong Park define SHELL_COPY_TREE 36*54fd6939SJiyong Park $(eval tmp_from_dir:=$(subst /,\,${1})) 37*54fd6939SJiyong Park $(eval tmp_to_dir:=$(subst /,\,${2})) 38*54fd6939SJiyong Park xcopy /HIVE "${tmp_from_dir}" "${tmp_to_dir}" 39*54fd6939SJiyong Park endef 40*54fd6939SJiyong Park 41*54fd6939SJiyong Park # ${1} is the file to be deleted. 42*54fd6939SJiyong Park define SHELL_DELETE 43*54fd6939SJiyong Park $(eval tmp_del_file:=$(subst /,\,${*})) 44*54fd6939SJiyong Park -@if exist $(tmp_del_file) del /Q $(tmp_del_file) 45*54fd6939SJiyong Park endef 46*54fd6939SJiyong Park 47*54fd6939SJiyong Park # ${1} is a space delimited list of files to be deleted. 48*54fd6939SJiyong Park define SHELL_DELETE_ALL 49*54fd6939SJiyong Park $(eval $(foreach filename,$(wildcard ${1}),$(call DELETE_IF_THERE,${filename}))) 50*54fd6939SJiyong Park endef 51*54fd6939SJiyong Park 52*54fd6939SJiyong Park # ${1} is the directory to be generated. 53*54fd6939SJiyong Park # ${2} is optional, and allows prerequisites to be specified. 54*54fd6939SJiyong Park # Do nothing if $1 == $2, to ignore self dependencies. 55*54fd6939SJiyong Park define MAKE_PREREQ_DIR 56*54fd6939SJiyong Park ifneq (${1},${2}) 57*54fd6939SJiyong Park 58*54fd6939SJiyong Park${1} : ${2} 59*54fd6939SJiyong Park $(eval tmp_dir:=$(subst /,\,${1})) 60*54fd6939SJiyong Park -@if not exist "$(tmp_dir)" mkdir "${tmp_dir}" 61*54fd6939SJiyong Park 62*54fd6939SJiyong Park endif 63*54fd6939SJiyong Park endef 64*54fd6939SJiyong Park 65*54fd6939SJiyong Park # ${1} is the directory to be removed. 66*54fd6939SJiyong Park define SHELL_REMOVE_DIR 67*54fd6939SJiyong Park $(eval tmp_dir:=$(subst /,\,${1})) 68*54fd6939SJiyong Park -@if exist "$(tmp_dir)" rd /Q /S "$(tmp_dir)" 69*54fd6939SJiyong Park endef 70*54fd6939SJiyong Park 71*54fd6939SJiyong Parkendif 72*54fd6939SJiyong Park 73*54fd6939SJiyong Park# Because git is not available from CMD.EXE, we need to avoid 74*54fd6939SJiyong Park# the BUILD_STRING generation which uses git. 75*54fd6939SJiyong Park# For now we use "development build". 76*54fd6939SJiyong Park# This can be overridden from the command line or environment. 77*54fd6939SJiyong ParkBUILD_STRING ?= development build 78*54fd6939SJiyong Park 79*54fd6939SJiyong Park# The DOS echo shell command does not strip ' characters from the command 80*54fd6939SJiyong Park# parameters before printing. We therefore use an alternative method invoked 81*54fd6939SJiyong Park# by defining the MAKE_BUILD_STRINGS macro. 82*54fd6939SJiyong ParkBUILT_TIME_DATE_STRING = const char build_message[] = "Built : "${BUILD_MESSAGE_TIMESTAMP}; 83*54fd6939SJiyong ParkVERSION_STRING_MESSAGE = const char version_string[] = "${VERSION_STRING}"; 84*54fd6939SJiyong Parkdefine MAKE_BUILD_STRINGS 85*54fd6939SJiyong Park @echo $$(BUILT_TIME_DATE_STRING) $$(VERSION_STRING_MESSAGE) | \ 86*54fd6939SJiyong Park $$(CC) $$(TF_CFLAGS) $$(CFLAGS) -x c -c - -o $1 87*54fd6939SJiyong Parkendef 88*54fd6939SJiyong Park 89*54fd6939SJiyong ParkMSVC_NMAKE := nmake.exe 90*54fd6939SJiyong Park 91