blob: 8ac82460f03ddec15b624c89bae3619bf5c34e11 [file] [log] [blame]
Evan Lloyda71d2592015-12-02 18:56:06 +00001#
2# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# Redistributions of source code must retain the above copyright notice, this
8# list of conditions and the following disclaimer.
9#
10# Redistributions in binary form must reproduce the above copyright notice,
11# this list of conditions and the following disclaimer in the documentation
12# and/or other materials provided with the distribution.
13#
14# Neither the name of ARM nor the names of its contributors may be used
15# to endorse or promote products derived from this software without specific
16# prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29#
30#
31
32# OS specific parts for builds in a Windows_NT environment. The
33# environment variable OS is set to Windows_NT on all modern Windows platforms
34
35# Include generic windows command definitions.
36
37ifndef WINDOWS_MK
38 WINDOWS_MK := $(lastword $(MAKEFILE_LIST))
39
40 ECHO_BLANK_LINE := @cmd /c echo.
Evan Lloyda71d2592015-12-02 18:56:06 +000041 DIR_DELIM := $(strip \)
Evan Lloyd004c9a52015-12-03 11:35:40 +000042 BIN_EXT := .exe
43 PATH_SEP := ;
Evan Lloyda71d2592015-12-02 18:56:06 +000044
45 # For some Windows native commands there is a problem with the directory delimiter.
46 # Make uses / (slash) and the commands expect \ (backslash)
47 # We have to provide a means of translating these, so we define local functions.
48
49 # ${1} is the file to be copied.
50 # ${2} is the destination file name.
51 define SHELL_COPY
52 $(eval tmp_from_file:=$(subst /,\,${1}))
53 $(eval tmp_to_file:=$(subst /,\,${2}))
54 copy "${tmp_from_file}" "${tmp_to_file}"
55 endef
56
57 # ${1} is the directory to be copied.
58 # ${2} is the destination directory path.
59 define SHELL_COPY_TREE
60 $(eval tmp_from_dir:=$(subst /,\,${1}))
61 $(eval tmp_to_dir:=$(subst /,\,${2}))
62 xcopy /HIVE "${tmp_from_dir}" "${tmp_to_dir}"
63 endef
64
65 # ${1} is the file to be deleted.
66 define SHELL_DELETE
67 $(eval tmp_del_file:=$(subst /,\,${*}))
68 -@if exist $(tmp_del_file) del /Q $(tmp_del_file)
69 endef
70
71 # ${1} is a space delimited list of files to be deleted.
72 define SHELL_DELETE_ALL
73 $(eval $(foreach filename,$(wildcard ${1}),$(call DELETE_IF_THERE,${filename})))
74 endef
75
76 # ${1} is the directory to be generated.
77 # ${2} is optional, and allows prerequisites to be specified.
78 define MAKE_PREREQ_DIR
79
80${1} : ${2}
81 $(eval tmp_dir:=$(subst /,\,${1}))
82 -@if not exist "$(tmp_dir)" mkdir "${tmp_dir}"
83
84 endef
85
86 # ${1} is the directory to be removed.
87 define SHELL_REMOVE_DIR
88 $(eval tmp_dir:=$(subst /,\,${1}))
89 -@if exist "$(tmp_dir)" rd /Q /S "$(tmp_dir)"
90 endef
91
92endif
93
Evan Lloydcf6e9d42015-12-03 12:58:52 +000094# Because git is not available from CMD.EXE, we need to avoid
95# the BUILD_STRING generation which uses git.
96# For now we use "development build".
97# This can be overridden from the command line or environment.
98BUILD_STRING ?= development build
99
100# The DOS echo shell command does not strip ' characters from the command
101# parameters before printing. We therefore use an alternative method invoked
102# by defining the MAKE_BUILD_STRINGS macro.
103BUILT_TIME_DATE_STRING = const char build_message[] = "Built : "${BUILD_MESSAGE_TIMESTAMP};
104VERSION_STRING_MESSAGE = const char version_string[] = "${VERSION_STRING}";
105define MAKE_BUILD_STRINGS
106 @echo $$(BUILT_TIME_DATE_STRING) $$(VERSION_STRING_MESSAGE) | \
107 $$(CC) $$(CFLAGS) -x c - -o $1
108endef
109