blob: 8908849d50fbcdebc24ae314b05fd052e9324ebe [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
Jens Wiklander5831e422023-05-31 10:49:16 +020021include mk/macros.mk
Victor Chongc0b2e932018-02-03 13:27:25 +000022include mk/checkconf.mk
23
Pascal Brandb0104772014-06-12 15:56:20 +020024.PHONY: all
25all:
26
Jens Wiklander29f1a452014-08-29 08:26:57 +020027.PHONY: mem_usage
28mem_usage:
29
etienne carrieredde0e232015-02-26 10:29:27 +010030# 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
Jerome Forissier71767a52014-10-29 14:43:11 +010037# 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
Pascal Brandb0104772014-06-12 15:56:20 +020044# Make these default for now
Marouene Boubakri8a926862021-12-27 17:23:13 +010045ARCH ?= arm
Jerome Forissiera75f2e12015-07-07 19:07:50 +020046PLATFORM ?= vexpress
Jerome Forissier9fc53172016-08-23 11:20:21 +020047# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk
Jerome Forissier9ac870c2017-01-06 09:33:29 +010048ifeq ($O,)
49O := out
50out-dir := $(O)/$(ARCH)-plat-$(PLATFORM)
51else
52out-dir := $(O)
53endif
Pascal Brandb0104772014-06-12 15:56:20 +020054
55arch_$(ARCH) := y
56
Pascal Brandb0104772014-06-12 15:56:20 +020057ifneq ($V,1)
58q := @
59cmd-echo := true
Jens Wiklander62428632015-04-29 15:05:19 +020060cmd-echo-silent := echo
Pascal Brandb0104772014-06-12 15:56:20 +020061else
62q :=
63cmd-echo := echo
Jens Wiklander62428632015-04-29 15:05:19 +020064cmd-echo-silent := true
Pascal Brandb0104772014-06-12 15:56:20 +020065endif
66
Jens Wiklander62428632015-04-29 15:05:19 +020067ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
68ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
69cmd-echo-silent := true
70endif
71else # make-3.8x
Pascal Brand3dc79b02015-05-28 14:02:47 +020072ifneq ($(findstring s, $(MAKEFLAGS)),)
Jens Wiklander62428632015-04-29 15:05:19 +020073cmd-echo-silent := true
74endif
75endif
76
Jerome Forissier38f42602019-09-17 10:38:15 +020077SCRIPTS_DIR := scripts
Jens Wiklander62428632015-04-29 15:05:19 +020078
Pascal Brandb0104772014-06-12 15:56:20 +020079include core/core.mk
80
Jerome Forissierdc701d92018-12-14 18:33:35 +010081# Platform/arch config is supposed to assign the targets
82ta-targets ?= invalid
Jerome Forissier92166432023-06-27 15:29:29 +020083$(call force,default-user-ta-target,$(firstword $(ta-targets)))
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010084
Jens Wiklander6fbac372015-11-05 14:22:05 +010085ifeq ($(CFG_WITH_USER_TA),y)
Jens Wiklander7509ff72019-05-23 17:42:08 +020086include ldelf/ldelf.mk
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010087define build-ta-target
88ta-target := $(1)
Pascal Brandb0104772014-06-12 15:56:20 +020089include ta/ta.mk
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010090endef
91$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t))))
Jens Wiklandercfa34d92018-07-17 15:47:46 +020092
93# Build user TAs included in this git
Balsam CHIHI2c201682022-03-29 09:42:08 +000094ifeq ($(CFG_BUILD_IN_TREE_TA),y)
Jens Wiklandercfa34d92018-07-17 15:47:46 +020095define build-user-ta
96ta-mk-file := $(1)
97include ta/mk/build-user-ta.mk
98endef
Jerome Forissieref81a822020-10-01 14:25:05 +020099$(foreach t, $(sort $(wildcard ta/*/user_ta.mk)), $(eval $(call build-user-ta,$(t))))
Jens Wiklander6fbac372015-11-05 14:22:05 +0100100endif
Balsam CHIHI2c201682022-03-29 09:42:08 +0000101endif
Pascal Brandb0104772014-06-12 15:56:20 +0200102
Jerome Forissier9ac870c2017-01-06 09:33:29 +0100103include mk/cleandirs.mk
104
Pascal Brandb0104772014-06-12 15:56:20 +0200105.PHONY: clean
106clean:
Jerome Forissier9ac870c2017-01-06 09:33:29 +0100107 @$(cmd-echo-silent) ' CLEAN $(out-dir)'
Jerome Forissierbc0d2712017-10-25 11:31:25 +0200108 $(call do-rm-f, $(cleanfiles))
Jerome Forissier30a44332017-02-07 14:30:32 +0100109 ${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
Jerome Forissier9ac870c2017-01-06 09:33:29 +0100110 @if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) ' CLEAN $(O)'; fi
Jerome Forissier30a44332017-02-07 14:30:32 +0100111 ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
Joakim Bech8d541ae2023-10-19 10:37:58 +0200112 ${q}rm -f compile_commands.json
Pascal Brandb0104772014-06-12 15:56:20 +0200113
114.PHONY: cscope
115cscope:
Jerome Forissier0047cb62014-09-01 13:41:48 +0200116 @echo ' CSCOPE .'
Pascal Brandb0104772014-06-12 15:56:20 +0200117 ${q}rm -f cscope.*
Jens Wiklander023aecc2022-03-28 17:06:32 +0200118 ${q}find $(PWD) -name "*.[chSs]" | grep -v export-ta_ | \
119 grep -v -F _init.ld.S | grep -v -F _unpaged.ld.S > cscope.files
Pascal Brandb0104772014-06-12 15:56:20 +0200120 ${q}cscope -b -q -k
Markus S. Wamserfcf09d22018-10-25 13:06:25 +0200121
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