blob: 25d76894eb276ab6b344425e39976cdc61ab3db0 [file] [log] [blame]
Rouven Czerwinskia7ec3d42020-04-14 10:09:14 +02001SHELL = bash
Pascal Brandb0104772014-06-12 15:56:20 +02002
Jerome Forissier80b563f2016-12-02 17:54:52 +01003# 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
Jerome Forissier63633252019-09-19 13:44:47 +020017# 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
Victor Chongc0b2e932018-02-03 13:27:25 +000021include mk/checkconf.mk
22
Pascal Brandb0104772014-06-12 15:56:20 +020023.PHONY: all
24all:
25
Jens Wiklander29f1a452014-08-29 08:26:57 +020026.PHONY: mem_usage
27mem_usage:
28
etienne carrieredde0e232015-02-26 10:29:27 +010029# 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
Jerome Forissier71767a52014-10-29 14:43:11 +010036# 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
Pascal Brandb0104772014-06-12 15:56:20 +020043# Make these default for now
Marouene Boubakri8a926862021-12-27 17:23:13 +010044ARCH ?= arm
Jerome Forissiera75f2e12015-07-07 19:07:50 +020045PLATFORM ?= vexpress
Jerome Forissier9fc53172016-08-23 11:20:21 +020046# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk
Jerome Forissier9ac870c2017-01-06 09:33:29 +010047ifeq ($O,)
48O := out
49out-dir := $(O)/$(ARCH)-plat-$(PLATFORM)
50else
51out-dir := $(O)
52endif
Pascal Brandb0104772014-06-12 15:56:20 +020053
54arch_$(ARCH) := y
55
Pascal Brandb0104772014-06-12 15:56:20 +020056ifneq ($V,1)
57q := @
58cmd-echo := true
Jens Wiklander62428632015-04-29 15:05:19 +020059cmd-echo-silent := echo
Pascal Brandb0104772014-06-12 15:56:20 +020060else
61q :=
62cmd-echo := echo
Jens Wiklander62428632015-04-29 15:05:19 +020063cmd-echo-silent := true
Pascal Brandb0104772014-06-12 15:56:20 +020064endif
65
Jens Wiklander62428632015-04-29 15:05:19 +020066ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
67ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
68cmd-echo-silent := true
69endif
70else # make-3.8x
Pascal Brand3dc79b02015-05-28 14:02:47 +020071ifneq ($(findstring s, $(MAKEFLAGS)),)
Jens Wiklander62428632015-04-29 15:05:19 +020072cmd-echo-silent := true
73endif
74endif
75
Jerome Forissier38f42602019-09-17 10:38:15 +020076SCRIPTS_DIR := scripts
Jens Wiklander62428632015-04-29 15:05:19 +020077
Pascal Brandb0104772014-06-12 15:56:20 +020078include core/core.mk
79
Jerome Forissierdc701d92018-12-14 18:33:35 +010080# Platform/arch config is supposed to assign the targets
81ta-targets ?= invalid
Jens Wiklandercfa34d92018-07-17 15:47:46 +020082default-user-ta-target ?= $(firstword $(ta-targets))
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010083
Jens Wiklander6fbac372015-11-05 14:22:05 +010084ifeq ($(CFG_WITH_USER_TA),y)
Jens Wiklander7509ff72019-05-23 17:42:08 +020085include ldelf/ldelf.mk
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010086define build-ta-target
87ta-target := $(1)
Pascal Brandb0104772014-06-12 15:56:20 +020088include ta/ta.mk
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010089endef
90$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t))))
Jens Wiklandercfa34d92018-07-17 15:47:46 +020091
92# Build user TAs included in this git
Balsam CHIHI2c201682022-03-29 09:42:08 +000093ifeq ($(CFG_BUILD_IN_TREE_TA),y)
Jens Wiklandercfa34d92018-07-17 15:47:46 +020094define build-user-ta
95ta-mk-file := $(1)
96include ta/mk/build-user-ta.mk
97endef
Jerome Forissieref81a822020-10-01 14:25:05 +020098$(foreach t, $(sort $(wildcard ta/*/user_ta.mk)), $(eval $(call build-user-ta,$(t))))
Jens Wiklander6fbac372015-11-05 14:22:05 +010099endif
Balsam CHIHI2c201682022-03-29 09:42:08 +0000100endif
Pascal Brandb0104772014-06-12 15:56:20 +0200101
Jerome Forissier9ac870c2017-01-06 09:33:29 +0100102include mk/cleandirs.mk
103
Pascal Brandb0104772014-06-12 15:56:20 +0200104.PHONY: clean
105clean:
Jerome Forissier9ac870c2017-01-06 09:33:29 +0100106 @$(cmd-echo-silent) ' CLEAN $(out-dir)'
Jerome Forissierbc0d2712017-10-25 11:31:25 +0200107 $(call do-rm-f, $(cleanfiles))
Jerome Forissier30a44332017-02-07 14:30:32 +0100108 ${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
Jerome Forissier9ac870c2017-01-06 09:33:29 +0100109 @if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) ' CLEAN $(O)'; fi
Jerome Forissier30a44332017-02-07 14:30:32 +0100110 ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
Pascal Brandb0104772014-06-12 15:56:20 +0200111
112.PHONY: cscope
113cscope:
Jerome Forissier0047cb62014-09-01 13:41:48 +0200114 @echo ' CSCOPE .'
Pascal Brandb0104772014-06-12 15:56:20 +0200115 ${q}rm -f cscope.*
Jens Wiklander023aecc2022-03-28 17:06:32 +0200116 ${q}find $(PWD) -name "*.[chSs]" | grep -v export-ta_ | \
117 grep -v -F _init.ld.S | grep -v -F _unpaged.ld.S > cscope.files
Pascal Brandb0104772014-06-12 15:56:20 +0200118 ${q}cscope -b -q -k
Markus S. Wamserfcf09d22018-10-25 13:06:25 +0200119
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