build_env.mk 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #
  2. # Copyright (c) 2016, 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. MD := $$(error "Replace MD with call to MAKE_PREREQ_DIR.")
  16. MKDIR := $$(error "Replace MKDIR with call to MAKE_PREREQ_DIR.")
  17. RD := $$(error "Replace RD with call to SHELL_REMOVE_DIR.")
  18. RM := $$(error "Replace RM with call to SHELL_DELETE.")
  19. RMDIR := $$(error "Replace RMDIR with call to SHELL_REMOVE_DIR.")
  20. ENV_FILE_TO_INCLUDE := unix.mk
  21. ifdef OSTYPE
  22. ifneq ($(findstring ${OSTYPE}, cygwin),)
  23. ENV_FILE_TO_INCLUDE := cygwin.mk
  24. else
  25. ifneq ($(findstring ${OSTYPE}, MINGW32 mingw msys),)
  26. ENV_FILE_TO_INCLUDE := msys.mk
  27. endif
  28. endif
  29. else
  30. ifdef MSYSTEM
  31. # Although the MINGW MSYS shell sets OSTYPE as msys in its environment,
  32. # it does not appear in the GNU make view of environment variables.
  33. # We use MSYSTEM as an alternative, as that is seen by make
  34. ifneq ($(findstring ${MSYSTEM}, MINGW32 mingw msys),)
  35. OSTYPE ?= msys
  36. ENV_FILE_TO_INCLUDE := msys.mk
  37. endif
  38. else
  39. ifdef OS
  40. ifneq ($(findstring ${OS}, Windows_NT),)
  41. ENV_FILE_TO_INCLUDE := windows.mk
  42. endif
  43. endif
  44. endif
  45. endif
  46. include ${MAKE_HELPERS_DIRECTORY}${ENV_FILE_TO_INCLUDE}
  47. ENV_FILE_TO_INCLUDE :=
  48. ifndef SHELL_COPY
  49. $(error "SHELL_COPY not defined for build environment.")
  50. endif
  51. ifndef SHELL_COPY_TREE
  52. $(error "SHELL_COPY_TREE not defined for build environment.")
  53. endif
  54. ifndef SHELL_DELETE_ALL
  55. $(error "SHELL_DELETE_ALL not defined for build environment.")
  56. endif
  57. ifndef SHELL_DELETE
  58. $(error "SHELL_DELETE not defined for build environment.")
  59. endif
  60. ifndef MAKE_PREREQ_DIR
  61. $(error "MAKE_PREREQ_DIR not defined for build environment.")
  62. endif
  63. ifndef SHELL_REMOVE_DIR
  64. $(error "SHELL_REMOVE_DIR not defined for build environment.")
  65. endif
  66. endif