build_env.mk 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #
  2. # Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
  3. #
  4. # SPDX-License-Identifier: BSD-3-Clause
  5. #
  6. # This file contains the logic to identify and include any relevant
  7. # build environment specific make include files.
  8. ifndef BUILD_ENV_MK
  9. BUILD_ENV_MK := $(lastword $(MAKEFILE_LIST))
  10. # Block possible built-in command definitions that are not fully portable.
  11. # This traps occurences that need replacing with our OS portable macros
  12. COPY := $$(error "Replace COPY with call to SHELL_COPY or SHELL_COPY_TREE.")
  13. CP := $$(error "Replace CP with call to SHELL_COPY or SHELL_COPY_TREE.")
  14. DEL := $$(error "Replace DEL with call to SHELL_DELETE.")
  15. RD := $$(error "Replace RD with call to SHELL_REMOVE_DIR.")
  16. RM := $$(error "Replace RM with call to SHELL_DELETE.")
  17. RMDIR := $$(error "Replace RMDIR with call to SHELL_REMOVE_DIR.")
  18. ENV_FILE_TO_INCLUDE := unix.mk
  19. ifdef OSTYPE
  20. ifneq ($(findstring ${OSTYPE}, cygwin),)
  21. ENV_FILE_TO_INCLUDE := cygwin.mk
  22. else
  23. ifneq ($(findstring ${OSTYPE}, MINGW32 mingw msys),)
  24. ENV_FILE_TO_INCLUDE := msys.mk
  25. endif
  26. endif
  27. else
  28. ifdef MSYSTEM
  29. # Although the MINGW MSYS shell sets OSTYPE as msys in its environment,
  30. # it does not appear in the GNU make view of environment variables.
  31. # We use MSYSTEM as an alternative, as that is seen by make
  32. ifneq ($(findstring ${MSYSTEM}, MINGW32 mingw msys),)
  33. OSTYPE ?= msys
  34. ENV_FILE_TO_INCLUDE := msys.mk
  35. endif
  36. else
  37. ifdef OS
  38. ifneq ($(findstring ${OS}, Windows_NT),)
  39. ENV_FILE_TO_INCLUDE := windows.mk
  40. endif
  41. endif
  42. endif
  43. endif
  44. include $(dir $(lastword $(MAKEFILE_LIST)))${ENV_FILE_TO_INCLUDE}
  45. ENV_FILE_TO_INCLUDE :=
  46. ifndef SHELL_COPY
  47. $(error "SHELL_COPY not defined for build environment.")
  48. endif
  49. ifndef SHELL_COPY_TREE
  50. $(error "SHELL_COPY_TREE not defined for build environment.")
  51. endif
  52. ifndef SHELL_DELETE_ALL
  53. $(error "SHELL_DELETE_ALL not defined for build environment.")
  54. endif
  55. ifndef SHELL_DELETE
  56. $(error "SHELL_DELETE not defined for build environment.")
  57. endif
  58. ifndef SHELL_REMOVE_DIR
  59. $(error "SHELL_REMOVE_DIR not defined for build environment.")
  60. endif
  61. endif