xref: /optee_os/Makefile (revision 80b563f50dd641c77f7d809db192016ea8fdfe38)
1b0104773SPascal BrandSHELL = /bin/bash
2b0104773SPascal Brand
3*80b563f5SJerome Forissier# It can happen that a makefile calls us, which contains an 'export' directive
4*80b563f5SJerome Forissier# or the '.EXPORT_ALL_VARIABLES:' special target. In this case, all the make
5*80b563f5SJerome Forissier# variables are added to the environment for each line of the recipes, so that
6*80b563f5SJerome Forissier# any sub-makefile can use them.
7*80b563f5SJerome Forissier# We have observed this can cause issues such as 'Argument list too long'
8*80b563f5SJerome Forissier# errors as the shell runs out of memory.
9*80b563f5SJerome Forissier# Since this Makefile won't call any sub-makefiles, and since the commands do
10*80b563f5SJerome Forissier# not expect to implicitely obtain any make variable from the environment, we
11*80b563f5SJerome Forissier# can safely cancel this export mechanism. Unfortunately, it can't be done
12*80b563f5SJerome Forissier# globally, only by name. Let's unexport MAKEFILE_LIST which is by far the
13*80b563f5SJerome Forissier# biggest one due to our way of tracking dependencies and compile flags
14*80b563f5SJerome Forissier# (we include many *.cmd and *.d files).
15*80b563f5SJerome Forissierunexport MAKEFILE_LIST
16*80b563f5SJerome Forissier
17b0104773SPascal Brand.PHONY: all
18b0104773SPascal Brandall:
19b0104773SPascal Brand
2029f1a45dSJens Wiklander.PHONY: mem_usage
2129f1a45dSJens Wiklandermem_usage:
2229f1a45dSJens Wiklander
23dde0e235Setienne carriere# log and load eventual tee config file
24dde0e235Setienne carriere# path is absolute or relative to current source root directory.
25dde0e235Setienne carriereifdef CFG_OPTEE_CONFIG
26dde0e235Setienne carriere$(info Loading OPTEE configuration file $(CFG_OPTEE_CONFIG))
27dde0e235Setienne carriereinclude $(CFG_OPTEE_CONFIG)
28dde0e235Setienne carriereendif
29dde0e235Setienne carriere
3071767a5cSJerome Forissier# If $(PLATFORM) is defined and contains a hyphen, parse it as
3171767a5cSJerome Forissier# $(PLATFORM)-$(PLATFORM_FLAVOR) for convenience
3271767a5cSJerome Forissierifneq (,$(findstring -,$(PLATFORM)))
3371767a5cSJerome Forissierops := $(join PLATFORM PLATFORM_FLAVOR,$(addprefix =,$(subst -, ,$(PLATFORM))))
3471767a5cSJerome Forissier$(foreach op,$(ops),$(eval override $(op)))
3571767a5cSJerome Forissierendif
3671767a5cSJerome Forissier
37b0104773SPascal Brand# Make these default for now
38abe38974SJens WiklanderARCH            ?= arm
39a75f2e14SJerome ForissierPLATFORM        ?= vexpress
409fc53171SJerome Forissier# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk
41b0104773SPascal BrandO		?= out/$(ARCH)-plat-$(PLATFORM)
42b0104773SPascal Brand
43b0104773SPascal Brandarch_$(ARCH)	:= y
44b0104773SPascal Brand
45b0104773SPascal Brandifneq ($O,)
464334e8d7SJerome Forissierout-dir := $O
47b0104773SPascal Brandendif
48b0104773SPascal Brand
49b0104773SPascal Brandifneq ($V,1)
50b0104773SPascal Brandq := @
51b0104773SPascal Brandcmd-echo := true
5262428631SJens Wiklandercmd-echo-silent := echo
53b0104773SPascal Brandelse
54b0104773SPascal Brandq :=
55b0104773SPascal Brandcmd-echo := echo
5662428631SJens Wiklandercmd-echo-silent := true
57b0104773SPascal Brandendif
58b0104773SPascal Brand
5962428631SJens Wiklanderifneq ($(filter 4.%,$(MAKE_VERSION)),)  # make-4
6062428631SJens Wiklanderifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
6162428631SJens Wiklandercmd-echo-silent := true
6262428631SJens Wiklanderendif
6362428631SJens Wiklanderelse                                    # make-3.8x
643dc79b0dSPascal Brandifneq ($(findstring s, $(MAKEFLAGS)),)
6562428631SJens Wiklandercmd-echo-silent := true
6662428631SJens Wiklanderendif
6762428631SJens Wiklanderendif
6862428631SJens Wiklander
6962428631SJens Wiklander
70b0104773SPascal Brandinclude core/core.mk
71b0104773SPascal Brand
72bc33bbd9SJens Wiklander# Platform config is supposed to assign the targets
73bc33bbd9SJens Wiklanderta-targets ?= user_ta
74bc33bbd9SJens Wiklander
756fbac37eSJens Wiklanderifeq ($(CFG_WITH_USER_TA),y)
76bc33bbd9SJens Wiklanderdefine build-ta-target
77bc33bbd9SJens Wiklanderta-target := $(1)
78b0104773SPascal Brandinclude ta/ta.mk
79bc33bbd9SJens Wiklanderendef
80bc33bbd9SJens Wiklander$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t))))
816fbac37eSJens Wiklanderendif
82b0104773SPascal Brand
83b0104773SPascal Brand.PHONY: clean
84b0104773SPascal Brandclean:
8562428631SJens Wiklander	@$(cmd-echo-silent) '  CLEAN   .'
86b0104773SPascal Brand	${q}rm -f $(cleanfiles)
87b0104773SPascal Brand
88b0104773SPascal Brand.PHONY: cscope
89b0104773SPascal Brandcscope:
900047cb63SJerome Forissier	@echo '  CSCOPE  .'
91b0104773SPascal Brand	${q}rm -f cscope.*
92b0104773SPascal Brand	${q}find $(PWD) -name "*.[chSs]" > cscope.files
93b0104773SPascal Brand	${q}cscope -b -q -k
94