Rouven Czerwinski | a7ec3d4 | 2020-04-14 10:09:14 +0200 | [diff] [blame] | 1 | SHELL = bash |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 2 | |
Jerome Forissier | 80b563f | 2016-12-02 17:54:52 +0100 | [diff] [blame] | 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). |
| 15 | unexport MAKEFILE_LIST |
| 16 | |
Jerome Forissier | 6363325 | 2019-09-19 13:44:47 +0200 | [diff] [blame] | 17 | # Automatically delete corrupt targets (file updated but recipe exits with a |
| 18 | # nonzero status). Useful since a few recipes use shell redirection. |
| 19 | .DELETE_ON_ERROR: |
| 20 | |
Victor Chong | c0b2e93 | 2018-02-03 13:27:25 +0000 | [diff] [blame] | 21 | include mk/checkconf.mk |
| 22 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 23 | .PHONY: all |
| 24 | all: |
| 25 | |
Jens Wiklander | 29f1a45 | 2014-08-29 08:26:57 +0200 | [diff] [blame] | 26 | .PHONY: mem_usage |
| 27 | mem_usage: |
| 28 | |
etienne carriere | dde0e23 | 2015-02-26 10:29:27 +0100 | [diff] [blame] | 29 | # log and load eventual tee config file |
| 30 | # path is absolute or relative to current source root directory. |
| 31 | ifdef CFG_OPTEE_CONFIG |
| 32 | $(info Loading OPTEE configuration file $(CFG_OPTEE_CONFIG)) |
| 33 | include $(CFG_OPTEE_CONFIG) |
| 34 | endif |
| 35 | |
Jerome Forissier | 71767a5 | 2014-10-29 14:43:11 +0100 | [diff] [blame] | 36 | # If $(PLATFORM) is defined and contains a hyphen, parse it as |
| 37 | # $(PLATFORM)-$(PLATFORM_FLAVOR) for convenience |
| 38 | ifneq (,$(findstring -,$(PLATFORM))) |
| 39 | ops := $(join PLATFORM PLATFORM_FLAVOR,$(addprefix =,$(subst -, ,$(PLATFORM)))) |
| 40 | $(foreach op,$(ops),$(eval override $(op))) |
| 41 | endif |
| 42 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 43 | # Make these default for now |
Victor Chong | c0b2e93 | 2018-02-03 13:27:25 +0000 | [diff] [blame] | 44 | $(call force,ARCH,arm) |
Jerome Forissier | a75f2e1 | 2015-07-07 19:07:50 +0200 | [diff] [blame] | 45 | PLATFORM ?= vexpress |
Jerome Forissier | 9fc5317 | 2016-08-23 11:20:21 +0200 | [diff] [blame] | 46 | # Default value for PLATFORM_FLAVOR is set in plat-$(PLATFORM)/conf.mk |
Jerome Forissier | 9ac870c | 2017-01-06 09:33:29 +0100 | [diff] [blame] | 47 | ifeq ($O,) |
| 48 | O := out |
| 49 | out-dir := $(O)/$(ARCH)-plat-$(PLATFORM) |
| 50 | else |
| 51 | out-dir := $(O) |
| 52 | endif |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 53 | |
| 54 | arch_$(ARCH) := y |
| 55 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 56 | ifneq ($V,1) |
| 57 | q := @ |
| 58 | cmd-echo := true |
Jens Wiklander | 6242863 | 2015-04-29 15:05:19 +0200 | [diff] [blame] | 59 | cmd-echo-silent := echo |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 60 | else |
| 61 | q := |
| 62 | cmd-echo := echo |
Jens Wiklander | 6242863 | 2015-04-29 15:05:19 +0200 | [diff] [blame] | 63 | cmd-echo-silent := true |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 64 | endif |
| 65 | |
Jens Wiklander | 6242863 | 2015-04-29 15:05:19 +0200 | [diff] [blame] | 66 | ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 |
| 67 | ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) |
| 68 | cmd-echo-silent := true |
| 69 | endif |
| 70 | else # make-3.8x |
Pascal Brand | 3dc79b0 | 2015-05-28 14:02:47 +0200 | [diff] [blame] | 71 | ifneq ($(findstring s, $(MAKEFLAGS)),) |
Jens Wiklander | 6242863 | 2015-04-29 15:05:19 +0200 | [diff] [blame] | 72 | cmd-echo-silent := true |
| 73 | endif |
| 74 | endif |
| 75 | |
Jerome Forissier | 38f4260 | 2019-09-17 10:38:15 +0200 | [diff] [blame] | 76 | SCRIPTS_DIR := scripts |
Jens Wiklander | 6242863 | 2015-04-29 15:05:19 +0200 | [diff] [blame] | 77 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 78 | include core/core.mk |
| 79 | |
Jerome Forissier | dc701d9 | 2018-12-14 18:33:35 +0100 | [diff] [blame] | 80 | # Platform/arch config is supposed to assign the targets |
| 81 | ta-targets ?= invalid |
Jens Wiklander | cfa34d9 | 2018-07-17 15:47:46 +0200 | [diff] [blame] | 82 | default-user-ta-target ?= $(firstword $(ta-targets)) |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 83 | |
Jens Wiklander | 6fbac37 | 2015-11-05 14:22:05 +0100 | [diff] [blame] | 84 | ifeq ($(CFG_WITH_USER_TA),y) |
Jens Wiklander | 7509ff7 | 2019-05-23 17:42:08 +0200 | [diff] [blame] | 85 | include ldelf/ldelf.mk |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 86 | define build-ta-target |
| 87 | ta-target := $(1) |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 88 | include ta/ta.mk |
Jens Wiklander | bc33bbd | 2015-11-11 14:08:26 +0100 | [diff] [blame] | 89 | endef |
| 90 | $(foreach t, $(ta-targets), $(eval $(call build-ta-target, $(t)))) |
Jens Wiklander | cfa34d9 | 2018-07-17 15:47:46 +0200 | [diff] [blame] | 91 | |
| 92 | # Build user TAs included in this git |
| 93 | define build-user-ta |
| 94 | ta-mk-file := $(1) |
| 95 | include ta/mk/build-user-ta.mk |
| 96 | endef |
Jerome Forissier | ef81a82 | 2020-10-01 14:25:05 +0200 | [diff] [blame] | 97 | $(foreach t, $(sort $(wildcard ta/*/user_ta.mk)), $(eval $(call build-user-ta,$(t)))) |
Jens Wiklander | 6fbac37 | 2015-11-05 14:22:05 +0100 | [diff] [blame] | 98 | endif |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 99 | |
Jerome Forissier | 9ac870c | 2017-01-06 09:33:29 +0100 | [diff] [blame] | 100 | include mk/cleandirs.mk |
| 101 | |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 102 | .PHONY: clean |
| 103 | clean: |
Jerome Forissier | 9ac870c | 2017-01-06 09:33:29 +0100 | [diff] [blame] | 104 | @$(cmd-echo-silent) ' CLEAN $(out-dir)' |
Jerome Forissier | bc0d271 | 2017-10-25 11:31:25 +0200 | [diff] [blame] | 105 | $(call do-rm-f, $(cleanfiles)) |
Jerome Forissier | 30a4433 | 2017-02-07 14:30:32 +0100 | [diff] [blame] | 106 | ${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi |
Jerome Forissier | 9ac870c | 2017-01-06 09:33:29 +0100 | [diff] [blame] | 107 | @if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) ' CLEAN $(O)'; fi |
Jerome Forissier | 30a4433 | 2017-02-07 14:30:32 +0100 | [diff] [blame] | 108 | ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 109 | |
| 110 | .PHONY: cscope |
| 111 | cscope: |
Jerome Forissier | 0047cb6 | 2014-09-01 13:41:48 +0200 | [diff] [blame] | 112 | @echo ' CSCOPE .' |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 113 | ${q}rm -f cscope.* |
Jerome Forissier | c9727be | 2019-01-08 16:08:05 +0100 | [diff] [blame] | 114 | ${q}find $(PWD) -name "*.[chSs]" | grep -v export-ta_ > cscope.files |
Pascal Brand | b010477 | 2014-06-12 15:56:20 +0200 | [diff] [blame] | 115 | ${q}cscope -b -q -k |
Markus S. Wamser | fcf09d2 | 2018-10-25 13:06:25 +0200 | [diff] [blame] | 116 | |
| 117 | .PHONY: checkpatch checkpatch-staging checkpatch-working |
| 118 | checkpatch: checkpatch-staging checkpatch-working |
| 119 | |
| 120 | checkpatch-working: |
| 121 | ${q}./scripts/checkpatch.sh |
| 122 | |
| 123 | checkpatch-staging: |
| 124 | ${q}./scripts/checkpatch.sh --cached |