xref: /optee_os/Makefile (revision 9216643181c1f3dd9be3e1d1665fb761d3235f8a)
1a7ec3d4cSRouven CzerwinskiSHELL = bash
2b0104773SPascal Brand
380b563f5SJerome Forissier# It can happen that a makefile calls us, which contains an 'export' directive
480b563f5SJerome Forissier# or the '.EXPORT_ALL_VARIABLES:' special target. In this case, all the make
580b563f5SJerome Forissier# variables are added to the environment for each line of the recipes, so that
680b563f5SJerome Forissier# any sub-makefile can use them.
780b563f5SJerome Forissier# We have observed this can cause issues such as 'Argument list too long'
880b563f5SJerome Forissier# errors as the shell runs out of memory.
980b563f5SJerome Forissier# Since this Makefile won't call any sub-makefiles, and since the commands do
1080b563f5SJerome Forissier# not expect to implicitely obtain any make variable from the environment, we
1180b563f5SJerome Forissier# can safely cancel this export mechanism. Unfortunately, it can't be done
1280b563f5SJerome Forissier# globally, only by name. Let's unexport MAKEFILE_LIST which is by far the
1380b563f5SJerome Forissier# biggest one due to our way of tracking dependencies and compile flags
1480b563f5SJerome Forissier# (we include many *.cmd and *.d files).
1580b563f5SJerome Forissierunexport MAKEFILE_LIST
1680b563f5SJerome Forissier
176363325cSJerome Forissier# Automatically delete corrupt targets (file updated but recipe exits with a
186363325cSJerome Forissier# nonzero status). Useful since a few recipes use shell redirection.
196363325cSJerome Forissier.DELETE_ON_ERROR:
206363325cSJerome Forissier
21c0b2e931SVictor Chonginclude mk/checkconf.mk
22c0b2e931SVictor Chong
23b0104773SPascal Brand.PHONY: all
24b0104773SPascal Brandall:
25b0104773SPascal Brand
2629f1a45dSJens Wiklander.PHONY: mem_usage
2729f1a45dSJens Wiklandermem_usage:
2829f1a45dSJens Wiklander
29dde0e235Setienne carriere# log and load eventual tee config file
30dde0e235Setienne carriere# path is absolute or relative to current source root directory.
31dde0e235Setienne carriereifdef CFG_OPTEE_CONFIG
32dde0e235Setienne carriere$(info Loading OPTEE configuration file $(CFG_OPTEE_CONFIG))
33dde0e235Setienne carriereinclude $(CFG_OPTEE_CONFIG)
34dde0e235Setienne carriereendif
35dde0e235Setienne carriere
3671767a5cSJerome Forissier# If $(PLATFORM) is defined and contains a hyphen, parse it as
3771767a5cSJerome Forissier# $(PLATFORM)-$(PLATFORM_FLAVOR) for convenience
3871767a5cSJerome Forissierifneq (,$(findstring -,$(PLATFORM)))
3971767a5cSJerome Forissierops := $(join PLATFORM PLATFORM_FLAVOR,$(addprefix =,$(subst -, ,$(PLATFORM))))
4071767a5cSJerome Forissier$(foreach op,$(ops),$(eval override $(op)))
4171767a5cSJerome Forissierendif
4271767a5cSJerome Forissier
43b0104773SPascal Brand# Make these default for now
448a926867SMarouene BoubakriARCH            ?= arm
45a75f2e14SJerome ForissierPLATFORM        ?= vexpress
469fc53171SJerome Forissier# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk
479ac870c9SJerome Forissierifeq ($O,)
489ac870c9SJerome ForissierO               := out
499ac870c9SJerome Forissierout-dir         := $(O)/$(ARCH)-plat-$(PLATFORM)
509ac870c9SJerome Forissierelse
519ac870c9SJerome Forissierout-dir         := $(O)
529ac870c9SJerome Forissierendif
53b0104773SPascal Brand
54b0104773SPascal Brandarch_$(ARCH)	:= y
55b0104773SPascal Brand
56b0104773SPascal Brandifneq ($V,1)
57b0104773SPascal Brandq := @
58b0104773SPascal Brandcmd-echo := true
5962428631SJens Wiklandercmd-echo-silent := echo
60b0104773SPascal Brandelse
61b0104773SPascal Brandq :=
62b0104773SPascal Brandcmd-echo := echo
6362428631SJens Wiklandercmd-echo-silent := true
64b0104773SPascal Brandendif
65b0104773SPascal Brand
6662428631SJens Wiklanderifneq ($(filter 4.%,$(MAKE_VERSION)),)  # make-4
6762428631SJens Wiklanderifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
6862428631SJens Wiklandercmd-echo-silent := true
6962428631SJens Wiklanderendif
7062428631SJens Wiklanderelse                                    # make-3.8x
713dc79b0dSPascal Brandifneq ($(findstring s, $(MAKEFLAGS)),)
7262428631SJens Wiklandercmd-echo-silent := true
7362428631SJens Wiklanderendif
7462428631SJens Wiklanderendif
7562428631SJens Wiklander
7638f4260cSJerome ForissierSCRIPTS_DIR := scripts
7762428631SJens Wiklander
78b0104773SPascal Brandinclude core/core.mk
79b0104773SPascal Brand
80dc701d99SJerome Forissier# Platform/arch config is supposed to assign the targets
81dc701d99SJerome Forissierta-targets ?= invalid
82*92166431SJerome Forissier$(call force,default-user-ta-target,$(firstword $(ta-targets)))
83bc33bbd9SJens Wiklander
846fbac37eSJens Wiklanderifeq ($(CFG_WITH_USER_TA),y)
857509ff7cSJens Wiklanderinclude ldelf/ldelf.mk
86bc33bbd9SJens Wiklanderdefine build-ta-target
87bc33bbd9SJens Wiklanderta-target := $(1)
88b0104773SPascal Brandinclude ta/ta.mk
89bc33bbd9SJens Wiklanderendef
90bc33bbd9SJens Wiklander$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t))))
91cfa34d9aSJens Wiklander
92cfa34d9aSJens Wiklander# Build user TAs included in this git
932c20168bSBalsam CHIHIifeq ($(CFG_BUILD_IN_TREE_TA),y)
94cfa34d9aSJens Wiklanderdefine build-user-ta
95cfa34d9aSJens Wiklanderta-mk-file := $(1)
96cfa34d9aSJens Wiklanderinclude ta/mk/build-user-ta.mk
97cfa34d9aSJens Wiklanderendef
98ef81a821SJerome Forissier$(foreach t, $(sort $(wildcard ta/*/user_ta.mk)), $(eval $(call build-user-ta,$(t))))
996fbac37eSJens Wiklanderendif
1002c20168bSBalsam CHIHIendif
101b0104773SPascal Brand
1029ac870c9SJerome Forissierinclude mk/cleandirs.mk
1039ac870c9SJerome Forissier
104b0104773SPascal Brand.PHONY: clean
105b0104773SPascal Brandclean:
1069ac870c9SJerome Forissier	@$(cmd-echo-silent) '  CLEAN   $(out-dir)'
107bc0d2712SJerome Forissier	$(call do-rm-f, $(cleanfiles))
10830a44336SJerome Forissier	${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
1099ac870c9SJerome Forissier	@if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) '  CLEAN   $(O)'; fi
11030a44336SJerome Forissier	${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
111b0104773SPascal Brand
112b0104773SPascal Brand.PHONY: cscope
113b0104773SPascal Brandcscope:
1140047cb63SJerome Forissier	@echo '  CSCOPE  .'
115b0104773SPascal Brand	${q}rm -f cscope.*
116023aecc6SJens Wiklander	${q}find $(PWD) -name "*.[chSs]" | grep -v export-ta_ | \
117023aecc6SJens Wiklander		grep -v -F _init.ld.S | grep -v -F _unpaged.ld.S > cscope.files
118b0104773SPascal Brand	${q}cscope -b -q -k
119fcf09d24SMarkus S. Wamser
120fcf09d24SMarkus S. Wamser.PHONY: checkpatch checkpatch-staging checkpatch-working
121fcf09d24SMarkus S. Wamsercheckpatch: checkpatch-staging checkpatch-working
122fcf09d24SMarkus S. Wamser
123fcf09d24SMarkus S. Wamsercheckpatch-working:
124fcf09d24SMarkus S. Wamser	${q}./scripts/checkpatch.sh
125fcf09d24SMarkus S. Wamser
126fcf09d24SMarkus S. Wamsercheckpatch-staging:
127fcf09d24SMarkus S. Wamser	${q}./scripts/checkpatch.sh --cached
128