blob: a545cd09558d2296e0ffd1e794448321d2e6e694 [file] [log] [blame]
Evan Lloyda71d2592015-12-02 18:56:06 +00001#
Chris Kayc8a47ba2023-10-20 09:17:33 +00002# Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
Evan Lloyda71d2592015-12-02 18:56:06 +00003#
dp-armfa3cf0b2017-05-03 09:38:09 +01004# SPDX-License-Identifier: BSD-3-Clause
Evan Lloyda71d2592015-12-02 18:56:06 +00005#
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 MD := $$(error "Replace MD with call to MAKE_PREREQ_DIR.")
19 MKDIR := $$(error "Replace MKDIR with call to MAKE_PREREQ_DIR.")
20 RD := $$(error "Replace RD with call to SHELL_REMOVE_DIR.")
21 RM := $$(error "Replace RM with call to SHELL_DELETE.")
22 RMDIR := $$(error "Replace RMDIR with call to SHELL_REMOVE_DIR.")
23
24 ENV_FILE_TO_INCLUDE := unix.mk
25 ifdef OSTYPE
26 ifneq ($(findstring ${OSTYPE}, cygwin),)
27 ENV_FILE_TO_INCLUDE := cygwin.mk
28 else
29 ifneq ($(findstring ${OSTYPE}, MINGW32 mingw msys),)
30 ENV_FILE_TO_INCLUDE := msys.mk
31 endif
32 endif
33 else
34 ifdef MSYSTEM
35 # Although the MINGW MSYS shell sets OSTYPE as msys in its environment,
36 # it does not appear in the GNU make view of environment variables.
37 # We use MSYSTEM as an alternative, as that is seen by make
38 ifneq ($(findstring ${MSYSTEM}, MINGW32 mingw msys),)
39 OSTYPE ?= msys
40 ENV_FILE_TO_INCLUDE := msys.mk
41 endif
42 else
43 ifdef OS
44 ifneq ($(findstring ${OS}, Windows_NT),)
45 ENV_FILE_TO_INCLUDE := windows.mk
46 endif
47 endif
48 endif
49 endif
Chris Kayc8a47ba2023-10-20 09:17:33 +000050 include $(dir $(lastword $(MAKEFILE_LIST)))${ENV_FILE_TO_INCLUDE}
Evan Lloyda71d2592015-12-02 18:56:06 +000051 ENV_FILE_TO_INCLUDE :=
52
53 ifndef SHELL_COPY
54 $(error "SHELL_COPY not defined for build environment.")
55 endif
56 ifndef SHELL_COPY_TREE
57 $(error "SHELL_COPY_TREE not defined for build environment.")
58 endif
59 ifndef SHELL_DELETE_ALL
60 $(error "SHELL_DELETE_ALL not defined for build environment.")
61 endif
62 ifndef SHELL_DELETE
63 $(error "SHELL_DELETE not defined for build environment.")
64 endif
65 ifndef MAKE_PREREQ_DIR
66 $(error "MAKE_PREREQ_DIR not defined for build environment.")
67 endif
68 ifndef SHELL_REMOVE_DIR
69 $(error "SHELL_REMOVE_DIR not defined for build environment.")
70 endif
71
72endif