1SHELL = bash 2 3# It can happen that a makefile calls us, which contains an 'export' directive 4# or the '.EXPORT_ALL_VARIABLES:' special target. In this case, all the make 5# variables are added to the environment for each line of the recipes, so that 6# any sub-makefile can use them. 7# We have observed this can cause issues such as 'Argument list too long' 8# errors as the shell runs out of memory. 9# Since this Makefile won't call any sub-makefiles, and since the commands do 10# not expect to implicitely obtain any make variable from the environment, we 11# can safely cancel this export mechanism. Unfortunately, it can't be done 12# globally, only by name. Let's unexport MAKEFILE_LIST which is by far the 13# biggest one due to our way of tracking dependencies and compile flags 14# (we include many *.cmd and *.d files). 15unexport MAKEFILE_LIST 16 17# Automatically delete corrupt targets (file updated but recipe exits with a 18# nonzero status). Useful since a few recipes use shell redirection. 19.DELETE_ON_ERROR: 20 21include mk/macros.mk 22include mk/checkconf.mk 23 24.PHONY: all 25all: 26 27.PHONY: mem_usage 28mem_usage: 29 30# log and load eventual tee config file 31# path is absolute or relative to current source root directory. 32ifdef CFG_OPTEE_CONFIG 33$(info Loading OPTEE configuration file $(CFG_OPTEE_CONFIG)) 34include $(CFG_OPTEE_CONFIG) 35endif 36 37# If $(PLATFORM) is defined and contains a hyphen, parse it as 38# $(PLATFORM)-$(PLATFORM_FLAVOR) for convenience 39ifneq (,$(findstring -,$(PLATFORM))) 40ops := $(join PLATFORM PLATFORM_FLAVOR,$(addprefix =,$(subst -, ,$(PLATFORM)))) 41$(foreach op,$(ops),$(eval override $(op))) 42endif 43 44# Make these default for now 45ARCH ?= arm 46PLATFORM ?= vexpress 47# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk 48ifeq ($O,) 49O := out 50out-dir := $(O)/$(ARCH)-plat-$(PLATFORM) 51else 52out-dir := $(O) 53endif 54 55arch_$(ARCH) := y 56 57ifneq ($V,1) 58q := @ 59cmd-echo := true 60cmd-echo-silent := echo 61else 62q := 63cmd-echo := echo 64cmd-echo-silent := true 65endif 66 67ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 68ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) 69cmd-echo-silent := true 70endif 71else # make-3.8x 72ifneq ($(findstring s, $(MAKEFLAGS)),) 73cmd-echo-silent := true 74endif 75endif 76 77SCRIPTS_DIR := scripts 78 79include core/core.mk 80 81# Platform/arch config is supposed to assign the targets 82ta-targets ?= invalid 83$(call force,default-user-ta-target,$(firstword $(ta-targets))) 84 85ifeq ($(CFG_WITH_USER_TA),y) 86include ldelf/ldelf.mk 87define build-ta-target 88ta-target := $(1) 89include ta/ta.mk 90endef 91$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t)))) 92 93# Build user TAs included in this git 94ifeq ($(CFG_BUILD_IN_TREE_TA),y) 95define build-user-ta 96ta-mk-file := $(1) 97include ta/mk/build-user-ta.mk 98endef 99$(foreach t, $(sort $(wildcard ta/*/user_ta.mk)), $(eval $(call build-user-ta,$(t)))) 100endif 101endif 102 103include mk/cleandirs.mk 104 105.PHONY: clean 106clean: 107 @$(cmd-echo-silent) ' CLEAN $(out-dir)' 108 $(call do-rm-f, $(cleanfiles)) 109 ${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi 110 @if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) ' CLEAN $(O)'; fi 111 ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi 112 ${q}rm -f compile_commands.json 113 114.PHONY: cscope 115cscope: 116 @echo ' CSCOPE .' 117 ${q}rm -f cscope.* 118 ${q}find $(PWD) -name "*.[chSs]" | grep -v export-ta_ | \ 119 grep -v -F _init.ld.S | grep -v -F _unpaged.ld.S > cscope.files 120 ${q}cscope -b -q -k 121 122.PHONY: checkpatch checkpatch-staging checkpatch-working 123checkpatch: checkpatch-staging checkpatch-working 124 125checkpatch-working: 126 ${q}./scripts/checkpatch.sh 127 128checkpatch-staging: 129 ${q}./scripts/checkpatch.sh --cached 130