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