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