xref: /optee_os/Makefile (revision 38f4260ce7c22085f4386b51aaad6837b539b6fc)
1SHELL = /bin/bash
2
3# 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
17include mk/checkconf.mk
18
19.PHONY: all
20all:
21
22.PHONY: mem_usage
23mem_usage:
24
25# 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
32# 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
39# Make these default for now
40$(call force,ARCH,arm)
41PLATFORM        ?= vexpress
42# Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk
43ifeq ($O,)
44O               := out
45out-dir         := $(O)/$(ARCH)-plat-$(PLATFORM)
46else
47out-dir         := $(O)
48endif
49
50arch_$(ARCH)	:= y
51
52ifneq ($V,1)
53q := @
54cmd-echo := true
55cmd-echo-silent := echo
56else
57q :=
58cmd-echo := echo
59cmd-echo-silent := true
60endif
61
62ifneq ($(filter 4.%,$(MAKE_VERSION)),)  # make-4
63ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
64cmd-echo-silent := true
65endif
66else                                    # make-3.8x
67ifneq ($(findstring s, $(MAKEFLAGS)),)
68cmd-echo-silent := true
69endif
70endif
71
72SCRIPTS_DIR := scripts
73
74include core/core.mk
75
76# Platform/arch config is supposed to assign the targets
77ta-targets ?= invalid
78default-user-ta-target ?= $(firstword $(ta-targets))
79
80ifeq ($(CFG_WITH_USER_TA),y)
81include ldelf/ldelf.mk
82define build-ta-target
83ta-target := $(1)
84include ta/ta.mk
85endef
86$(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t))))
87
88# Build user TAs included in this git
89define build-user-ta
90ta-mk-file := $(1)
91include ta/mk/build-user-ta.mk
92endef
93$(foreach t, $(wildcard ta/*/user_ta.mk), $(eval $(call build-user-ta,$(t))))
94endif
95
96include mk/cleandirs.mk
97
98.PHONY: clean
99clean:
100	@$(cmd-echo-silent) '  CLEAN   $(out-dir)'
101	$(call do-rm-f, $(cleanfiles))
102	${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
103	@if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) '  CLEAN   $(O)'; fi
104	${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
105
106.PHONY: cscope
107cscope:
108	@echo '  CSCOPE  .'
109	${q}rm -f cscope.*
110	${q}find $(PWD) -name "*.[chSs]" | grep -v export-ta_ > cscope.files
111	${q}cscope -b -q -k
112
113.PHONY: checkpatch checkpatch-staging checkpatch-working
114checkpatch: checkpatch-staging checkpatch-working
115
116checkpatch-working:
117	${q}./scripts/checkpatch.sh
118
119checkpatch-staging:
120	${q}./scripts/checkpatch.sh --cached
121