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