]> granicus.if.org Git - esp-idf/blob - make/common.mk
Merge branch 'feature/nghttp2_v1_22' into 'master'
[esp-idf] / make / common.mk
1 # Functionality common to both top-level project makefile (project.mk)
2 # and component makefiles (component_wrapper.mk)
3 #
4
5 # Include project config makefile, if it exists.
6 #
7 # (Note that we only rebuild this makefile automatically for some
8 # targets, see project_config.mk for details.)
9 SDKCONFIG_MAKEFILE ?= $(abspath $(BUILD_DIR_BASE)/include/config/auto.conf)
10 -include $(SDKCONFIG_MAKEFILE)
11 export SDKCONFIG_MAKEFILE  # sub-makes (like bootloader) will reuse this path
12
13 # BATCH_BUILD flag disables interactive terminal features, defaults to verbose build
14 ifdef BATCH_BUILD
15 V ?= 1
16 endif
17
18 #Handling of V=1/VERBOSE=1 flag
19 #
20 # if V=1, $(summary) does nothing and $(details) will echo extra details
21 # if V is unset or not 1, $(summary) echoes a summary and $(details) does nothing
22 V ?= $(VERBOSE)
23 ifeq ("$(V)","1")
24 summary := @true
25 details := @echo
26 else
27 summary := @echo
28 details := @true
29
30 # disable echoing of commands, directory names
31 MAKEFLAGS += --silent
32 endif
33
34 # General make utilities
35
36 # convenience variable for printing an 80 asterisk wide separator line
37 SEPARATOR:="*******************************************************************************"
38
39 # macro to remove quotes from an argument, ie $(call dequote,$(CONFIG_BLAH))
40 define dequote
41 $(subst ",,$(1))
42 endef
43 # " comment kept here to keep syntax highlighting happy
44
45
46 # macro to keep an absolute path as-is, but resolve a relative path
47 # against a particular parent directory
48 #
49 # $(1) path to resolve
50 # $(2) directory to resolve non-absolute path against
51 #
52 # Path and directory don't have to exist (definition of a "relative
53 # path" is one that doesn't start with /)
54 #
55 # $(2) can contain a trailing forward slash or not, result will not
56 # double any path slashes.
57 #
58 # example $(call resolvepath,$(CONFIG_PATH),$(CONFIG_DIR))
59 define resolvepath
60 $(foreach dir,$(1),$(if $(filter /%,$(dir)),$(dir),$(subst //,/,$(2)/$(dir))))
61 endef
62
63
64 # macro to include a target only if it's on the list of targets that make
65 # was invoked with
66 #
67 # This allows you to have something like an "order-only phony prerequisite",
68 # ie a prerequisite that determines an order phony targets have to run in.
69 #
70 # Because normal order-only prerequisites don't work with phony targets.
71 #
72 # example $(call prereq_if_explicit,erase_flash)
73 define prereq_if_explicit
74 $(filter $(1),$(MAKECMDGOALS))
75 endef
76
77 # macro to kill duplicate items in a list without messing up the sort order of the list.
78 # Will only keep the unique items; if there are non-unique items in the list, it will remove
79 # the later recurring ones so only the first one remains.
80 # Copied from http://stackoverflow.com/questions/16144115/makefile-remove-duplicate-words-without-sorting
81 define uniq
82 $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
83 endef