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