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