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/checkconf.mk 22 23.PHONY: all 24all: 25 26.PHONY: mem_usage 27mem_usage: 28 29# log and load eventual tee config file 30# path is absolute or relative to current source root directory. 31ifdef CFG_OPTEE_CONFIG 32$(info Loading OPTEE configuration file $(CFG_OPTEE_CONFIG)) 33include $(CFG_OPTEE_CONFIG) 34endif 35 36# If $(PLATFORM) is defined and contains a hyphen, parse it as 37# $(PLATFORM)-$(PLATFORM_FLAVOR) for convenience 38ifneq (,$(findstring -,$(PLATFORM))) 39ops := $(join PLATFORM PLATFORM_FLAVOR,$(addprefix =,$(subst -, ,$(PLATFORM)))) 40$(foreach op,$(ops),$(eval override $(op))) 41endif 42 43# Make these default for now 44ARCH ?= arm 45PLATFORM ?= vexpress 46# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk 47ifeq ($O,) 48O := out 49out-dir := $(O)/$(ARCH)-plat-$(PLATFORM) 50else 51out-dir := $(O) 52endif 53 54arch_$(ARCH) := y 55 56ifneq ($V,1) 57q := @ 58cmd-echo := true 59cmd-echo-silent := echo 60else 61q := 62cmd-echo := echo 63cmd-echo-silent := true 64endif 65 66ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 67ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) 68cmd-echo-silent := true 69endif 70else # make-3.8x 71ifneq ($(findstring s, $(MAKEFLAGS)),) 72cmd-echo-silent := true 73endif 74endif 75 76SCRIPTS_DIR := scripts 77 78include core/core.mk 79 80# Platform/arch config is supposed to assign the targets 81ta-targets ?= invalid 82$(call force,default-user-ta-target,$(firstword $(ta-targets))) 83 84ifeq ($(CFG_WITH_USER_TA),y) 85include ldelf/ldelf.mk 86define build-ta-target 87ta-target := $(1) 88include ta/ta.mk 89endef 90$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t)))) 91 92# Build user TAs included in this git 93ifeq ($(CFG_BUILD_IN_TREE_TA),y) 94define build-user-ta 95ta-mk-file := $(1) 96include ta/mk/build-user-ta.mk 97endef 98$(foreach t, $(sort $(wildcard ta/*/user_ta.mk)), $(eval $(call build-user-ta,$(t)))) 99endif 100endif 101 102include mk/cleandirs.mk 103 104.PHONY: clean 105clean: 106 @$(cmd-echo-silent) ' CLEAN $(out-dir)' 107 $(call do-rm-f, $(cleanfiles)) 108 ${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi 109 @if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) ' CLEAN $(O)'; fi 110 ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi 111 112.PHONY: cscope 113cscope: 114 @echo ' CSCOPE .' 115 ${q}rm -f cscope.* 116 ${q}find $(PWD) -name "*.[chSs]" | grep -v export-ta_ | \ 117 grep -v -F _init.ld.S | grep -v -F _unpaged.ld.S > cscope.files 118 ${q}cscope -b -q -k 119 120.PHONY: checkpatch checkpatch-staging checkpatch-working 121checkpatch: checkpatch-staging checkpatch-working 122 123checkpatch-working: 124 ${q}./scripts/checkpatch.sh 125 126checkpatch-staging: 127 ${q}./scripts/checkpatch.sh --cached 128