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