xref: /optee_os/Makefile (revision c0b2e931b395f098aa53912afa8b4f37cb339e1b)
1b0104773SPascal BrandSHELL = /bin/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
17*c0b2e931SVictor Chonginclude mk/checkconf.mk
18*c0b2e931SVictor Chong
19b0104773SPascal Brand.PHONY: all
20b0104773SPascal Brandall:
21b0104773SPascal Brand
2229f1a45dSJens Wiklander.PHONY: mem_usage
2329f1a45dSJens Wiklandermem_usage:
2429f1a45dSJens Wiklander
25dde0e235Setienne carriere# log and load eventual tee config file
26dde0e235Setienne carriere# path is absolute or relative to current source root directory.
27dde0e235Setienne carriereifdef CFG_OPTEE_CONFIG
28dde0e235Setienne carriere$(info Loading OPTEE configuration file $(CFG_OPTEE_CONFIG))
29dde0e235Setienne carriereinclude $(CFG_OPTEE_CONFIG)
30dde0e235Setienne carriereendif
31dde0e235Setienne carriere
3271767a5cSJerome Forissier# If $(PLATFORM) is defined and contains a hyphen, parse it as
3371767a5cSJerome Forissier# $(PLATFORM)-$(PLATFORM_FLAVOR) for convenience
3471767a5cSJerome Forissierifneq (,$(findstring -,$(PLATFORM)))
3571767a5cSJerome Forissierops := $(join PLATFORM PLATFORM_FLAVOR,$(addprefix =,$(subst -, ,$(PLATFORM))))
3671767a5cSJerome Forissier$(foreach op,$(ops),$(eval override $(op)))
3771767a5cSJerome Forissierendif
3871767a5cSJerome Forissier
39b0104773SPascal Brand# Make these default for now
40*c0b2e931SVictor Chong$(call force,ARCH,arm)
41a75f2e14SJerome ForissierPLATFORM        ?= vexpress
429fc53171SJerome Forissier# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk
439ac870c9SJerome Forissierifeq ($O,)
449ac870c9SJerome ForissierO               := out
459ac870c9SJerome Forissierout-dir         := $(O)/$(ARCH)-plat-$(PLATFORM)
469ac870c9SJerome Forissierelse
479ac870c9SJerome Forissierout-dir         := $(O)
489ac870c9SJerome Forissierendif
49b0104773SPascal Brand
50b0104773SPascal Brandarch_$(ARCH)	:= y
51b0104773SPascal Brand
52b0104773SPascal Brandifneq ($V,1)
53b0104773SPascal Brandq := @
54b0104773SPascal Brandcmd-echo := true
5562428631SJens Wiklandercmd-echo-silent := echo
56b0104773SPascal Brandelse
57b0104773SPascal Brandq :=
58b0104773SPascal Brandcmd-echo := echo
5962428631SJens Wiklandercmd-echo-silent := true
60b0104773SPascal Brandendif
61b0104773SPascal Brand
6262428631SJens Wiklanderifneq ($(filter 4.%,$(MAKE_VERSION)),)  # make-4
6362428631SJens Wiklanderifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
6462428631SJens Wiklandercmd-echo-silent := true
6562428631SJens Wiklanderendif
6662428631SJens Wiklanderelse                                    # make-3.8x
673dc79b0dSPascal Brandifneq ($(findstring s, $(MAKEFLAGS)),)
6862428631SJens Wiklandercmd-echo-silent := true
6962428631SJens Wiklanderendif
7062428631SJens Wiklanderendif
7162428631SJens Wiklander
7262428631SJens Wiklander
73b0104773SPascal Brandinclude core/core.mk
74b0104773SPascal Brand
75bc33bbd9SJens Wiklander# Platform config is supposed to assign the targets
76bc33bbd9SJens Wiklanderta-targets ?= user_ta
77bc33bbd9SJens Wiklander
786fbac37eSJens Wiklanderifeq ($(CFG_WITH_USER_TA),y)
79bc33bbd9SJens Wiklanderdefine build-ta-target
80bc33bbd9SJens Wiklanderta-target := $(1)
81b0104773SPascal Brandinclude ta/ta.mk
82bc33bbd9SJens Wiklanderendef
83bc33bbd9SJens Wiklander$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t))))
846fbac37eSJens Wiklanderendif
85b0104773SPascal Brand
869ac870c9SJerome Forissierinclude mk/cleandirs.mk
879ac870c9SJerome Forissier
88b0104773SPascal Brand.PHONY: clean
89b0104773SPascal Brandclean:
909ac870c9SJerome Forissier	@$(cmd-echo-silent) '  CLEAN   $(out-dir)'
91bc0d2712SJerome Forissier	$(call do-rm-f, $(cleanfiles))
9230a44336SJerome Forissier	${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
939ac870c9SJerome Forissier	@if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) '  CLEAN   $(O)'; fi
9430a44336SJerome Forissier	${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
95b0104773SPascal Brand
96b0104773SPascal Brand.PHONY: cscope
97b0104773SPascal Brandcscope:
980047cb63SJerome Forissier	@echo '  CSCOPE  .'
99b0104773SPascal Brand	${q}rm -f cscope.*
1008a0dd845SJens Wiklander	${q}find $(PWD) -name "*.[chSs]" | grep -v "$(PWD)/out" > cscope.files
101b0104773SPascal Brand	${q}cscope -b -q -k
102