blob: 069519a4a215922545d79019c8ee8c4a9c9181dd [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
Pascal Brandb0104772014-06-12 15:56:20 +020017.PHONY: all
18all:
19
Jens Wiklander29f1a452014-08-29 08:26:57 +020020.PHONY: mem_usage
21mem_usage:
22
etienne carrieredde0e232015-02-26 10:29:27 +010023# log and load eventual tee config file
24# path is absolute or relative to current source root directory.
25ifdef CFG_OPTEE_CONFIG
26$(info Loading OPTEE configuration file $(CFG_OPTEE_CONFIG))
27include $(CFG_OPTEE_CONFIG)
28endif
29
Jerome Forissier71767a52014-10-29 14:43:11 +010030# If $(PLATFORM) is defined and contains a hyphen, parse it as
31# $(PLATFORM)-$(PLATFORM_FLAVOR) for convenience
32ifneq (,$(findstring -,$(PLATFORM)))
33ops := $(join PLATFORM PLATFORM_FLAVOR,$(addprefix =,$(subst -, ,$(PLATFORM))))
34$(foreach op,$(ops),$(eval override $(op)))
35endif
36
Pascal Brandb0104772014-06-12 15:56:20 +020037# Make these default for now
Jens Wiklanderabe38972015-03-09 08:46:51 +010038ARCH ?= arm
Jerome Forissiera75f2e12015-07-07 19:07:50 +020039PLATFORM ?= vexpress
Jerome Forissier9fc53172016-08-23 11:20:21 +020040# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk
Jerome Forissier9ac870c2017-01-06 09:33:29 +010041ifeq ($O,)
42O := out
43out-dir := $(O)/$(ARCH)-plat-$(PLATFORM)
44else
45out-dir := $(O)
46endif
Pascal Brandb0104772014-06-12 15:56:20 +020047
48arch_$(ARCH) := y
49
Pascal Brandb0104772014-06-12 15:56:20 +020050ifneq ($V,1)
51q := @
52cmd-echo := true
Jens Wiklander62428632015-04-29 15:05:19 +020053cmd-echo-silent := echo
Pascal Brandb0104772014-06-12 15:56:20 +020054else
55q :=
56cmd-echo := echo
Jens Wiklander62428632015-04-29 15:05:19 +020057cmd-echo-silent := true
Pascal Brandb0104772014-06-12 15:56:20 +020058endif
59
Jens Wiklander62428632015-04-29 15:05:19 +020060ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4
61ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
62cmd-echo-silent := true
63endif
64else # make-3.8x
Pascal Brand3dc79b02015-05-28 14:02:47 +020065ifneq ($(findstring s, $(MAKEFLAGS)),)
Jens Wiklander62428632015-04-29 15:05:19 +020066cmd-echo-silent := true
67endif
68endif
69
70
Pascal Brandb0104772014-06-12 15:56:20 +020071include core/core.mk
72
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010073# Platform config is supposed to assign the targets
74ta-targets ?= user_ta
75
Jens Wiklander6fbac372015-11-05 14:22:05 +010076ifeq ($(CFG_WITH_USER_TA),y)
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010077define build-ta-target
78ta-target := $(1)
Pascal Brandb0104772014-06-12 15:56:20 +020079include ta/ta.mk
Jens Wiklanderbc33bbd2015-11-11 14:08:26 +010080endef
81$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t))))
Jens Wiklander6fbac372015-11-05 14:22:05 +010082endif
Pascal Brandb0104772014-06-12 15:56:20 +020083
Jerome Forissier9ac870c2017-01-06 09:33:29 +010084include mk/cleandirs.mk
85
Pascal Brandb0104772014-06-12 15:56:20 +020086.PHONY: clean
87clean:
Jerome Forissier9ac870c2017-01-06 09:33:29 +010088 @$(cmd-echo-silent) ' CLEAN $(out-dir)'
Jerome Forissierbc0d2712017-10-25 11:31:25 +020089 $(call do-rm-f, $(cleanfiles))
Jerome Forissier30a44332017-02-07 14:30:32 +010090 ${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
Jerome Forissier9ac870c2017-01-06 09:33:29 +010091 @if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) ' CLEAN $(O)'; fi
Jerome Forissier30a44332017-02-07 14:30:32 +010092 ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
Pascal Brandb0104772014-06-12 15:56:20 +020093
94.PHONY: cscope
95cscope:
Jerome Forissier0047cb62014-09-01 13:41:48 +020096 @echo ' CSCOPE .'
Pascal Brandb0104772014-06-12 15:56:20 +020097 ${q}rm -f cscope.*
98 ${q}find $(PWD) -name "*.[chSs]" > cscope.files
99 ${q}cscope -b -q -k