windows.mk 3.0 KB

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