]> granicus.if.org Git - esp-idf/blob - make/common.mk
Merge branch 'master' into feature/btdm_gatt_api
[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 #Handling of V=1/VERBOSE=1 flag
14 #
15 # if V=1, $(summary) does nothing and $(details) will echo extra details
16 # if V is unset or not 1, $(summary) echoes a summary and $(details) does nothing
17 V ?= $(VERBOSE)
18 ifeq ("$(V)","1")
19 summary := @true
20 details := @echo
21 else
22 summary := @echo
23 details := @true
24
25 # disable echoing of commands, directory names
26 MAKEFLAGS += --silent
27 endif
28
29 # General make utilities
30
31 # convenience variable for printing an 80 asterisk wide separator line
32 SEPARATOR:="*******************************************************************************"
33
34 # macro to remove quotes from an argument, ie $(call dequote,$(CONFIG_BLAH))
35 define dequote
36 $(subst ",,$(1))
37 endef
38 # " comment kept here to keep syntax highlighting happy
39
40
41 # macro to keep an absolute path as-is, but resolve a relative path
42 # against a particular parent directory
43 #
44 # $(1) path to resolve
45 # $(2) directory to resolve non-absolute path against
46 #
47 # Path and directory don't have to exist (definition of a "relative
48 # path" is one that doesn't start with /)
49 #
50 # $(2) can contain a trailing forward slash or not, result will not
51 # double any path slashes.
52 #
53 # example $(call resolvepath,$(CONFIG_PATH),$(CONFIG_DIR))
54 define resolvepath
55 $(foreach dir,$(1),$(if $(filter /%,$(dir)),$(dir),$(subst //,/,$(2)/$(dir))))
56 endef
57
58
59 # macro to include a target only if it's on the list of targets that make
60 # was invoked with
61 #
62 # This allows you to have something like an "order-only phony prerequisite",
63 # ie a prerequisite that determines an order phony targets have to run in.
64 #
65 # Because normal order-only prerequisites don't work with phony targets.
66 #
67 # example $(call prereq_if_explicit,erase_flash)
68 define prereq_if_explicit
69 $(filter $(1),$(MAKECMDGOALS))
70 endef