blob: acc0edfc81adb351dfa0a17087da0ace796d6b8e [file] [log] [blame]
Pascal Brandb0104772014-06-12 15:56:20 +02001SHELL = /bin/bash
2
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
Victor Chongc0b2e932018-02-03 13:27:25 +000017include mk/checkconf.mk
18
Pascal Brandb0104772014-06-12 15:56:20 +020019.PHONY: all
20all:
21
Jens Wiklander29f1a452014-08-29 08:26:57 +020022.PHONY: mem_usage
23mem_usage:
24
etienne carrieredde0e232015-02-26 10:29:27 +010025# log and load eventual tee config file
26# path is absolute or relative to current source root directory.
27ifdef CFG_OPTEE_CONFIG
28$(info Loading OPTEE configuration file $(CFG_OPTEE_CONFIG))
29include $(CFG_OPTEE_CONFIG)
30endif
31
Jerome Forissier71767a52014-10-29 14:43:11 +010032# If $(PLATFORM) is defined and contains a hyphen, parse it as
33# $(PLATFORM)-$(PLATFORM_FLAVOR) for convenience
34ifneq (,$(findstring -,$(PLATFORM)))
35ops := $(join PLATFORM PLATFORM_FLAVOR,$(addprefix =,$(subst -, ,$(PLATFORM))))
36$(foreach op,$(ops),$(eval override $(op)))
37endif
38
Pascal Brandb0104772014-06-12 15:56:20 +020039# Make these default for now
Victor Chongc0b2e932018-02-03 13:27:25 +000040$(call force,ARCH,arm)
Jerome Forissiera75f2e12015-07-07 19:07:50 +020041PLATFORM ?= vexpress
Jerome Forissier9fc53172016-08-23 11:20:21 +020042# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk
Jerome Forissier9ac870c2017-01-06 09:33:29 +010043ifeq ($O,)
44O := out
45out-dir := $(O)/$(ARCH)-plat-$(PLATFORM)
46else
47out-dir := $(O)
48endif
Pascal Brandb0104772014-06-12 15:56:20 +020049
50arch_$(ARCH) := y
51
Pascal Brandb0104772014-06-12 15:56:20 +020052ifneq ($V,1)
53q := @
54cmd-echo := true
Jens Wiklander62428632015-04-29 15:05:19 +020055cmd-echo-silent := echo
Pascal Brandb0104772014-06-12 15:56:20 +020056else
57q :=
58cmd-echo := echo
Jens Wiklander62428632015-04-29 15:05:19 +020059cmd-echo-silent := true
Pascal Brandb0104772014-06-12 15:56:20 +020060endif
61
Jens Wiklander62428632015-04-29 15:05:19 +020062ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
63ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
64cmd-echo-silent := true
65endif
66else # make-3.8x
Pascal Brand3dc79b02015-05-28 14:02:47 +020067ifneq ($(findstring s, $(MAKEFLAGS)),)
Jens Wiklander62428632015-04-29 15:05:19 +020068cmd-echo-silent := true
69endif
70endif
71
72
Pascal Brandb0104772014-06-12 15:56:20 +020073include core/core.mk
74
Jerome Forissierdc701d92018-12-14 18:33:35 +010075# Platform/arch config is supposed to assign the targets
76ta-targets ?= invalid
Jens Wiklandercfa34d92018-07-17 15:47:46 +020077default-user-ta-target ?= $(firstword $(ta-targets))
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010078
Jens Wiklander6fbac372015-11-05 14:22:05 +010079ifeq ($(CFG_WITH_USER_TA),y)
Jens Wiklander7509ff72019-05-23 17:42:08 +020080include ldelf/ldelf.mk
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010081define build-ta-target
82ta-target := $(1)
Pascal Brandb0104772014-06-12 15:56:20 +020083include ta/ta.mk
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010084endef
85$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t))))
Jens Wiklandercfa34d92018-07-17 15:47:46 +020086
87# Build user TAs included in this git
88define build-user-ta
89ta-mk-file := $(1)
90include ta/mk/build-user-ta.mk
91endef
92$(foreach t, $(wildcard ta/*/user_ta.mk), $(eval $(call build-user-ta,$(t))))
Jens Wiklander6fbac372015-11-05 14:22:05 +010093endif
Pascal Brandb0104772014-06-12 15:56:20 +020094
Jerome Forissier9ac870c2017-01-06 09:33:29 +010095include mk/cleandirs.mk
96
Pascal Brandb0104772014-06-12 15:56:20 +020097.PHONY: clean
98clean:
Jerome Forissier9ac870c2017-01-06 09:33:29 +010099 @$(cmd-echo-silent) ' CLEAN $(out-dir)'
Jerome Forissierbc0d2712017-10-25 11:31:25 +0200100 $(call do-rm-f, $(cleanfiles))
Jerome Forissier30a44332017-02-07 14:30:32 +0100101 ${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
Jerome Forissier9ac870c2017-01-06 09:33:29 +0100102 @if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) ' CLEAN $(O)'; fi
Jerome Forissier30a44332017-02-07 14:30:32 +0100103 ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
Pascal Brandb0104772014-06-12 15:56:20 +0200104
105.PHONY: cscope
106cscope:
Jerome Forissier0047cb62014-09-01 13:41:48 +0200107 @echo ' CSCOPE .'
Pascal Brandb0104772014-06-12 15:56:20 +0200108 ${q}rm -f cscope.*
Jerome Forissierc9727be2019-01-08 16:08:05 +0100109 ${q}find $(PWD) -name "*.[chSs]" | grep -v export-ta_ > cscope.files
Pascal Brandb0104772014-06-12 15:56:20 +0200110 ${q}cscope -b -q -k
Markus S. Wamserfcf09d22018-10-25 13:06:25 +0200111
112.PHONY: checkpatch checkpatch-staging checkpatch-working
113checkpatch: checkpatch-staging checkpatch-working
114
115checkpatch-working:
116 ${q}./scripts/checkpatch.sh
117
118checkpatch-staging:
119 ${q}./scripts/checkpatch.sh --cached