2016-11-10 02:20:55 +00:00
|
|
|
# Functionality common to both top-level project makefile (project.mk)
|
|
|
|
# and component makefiles (component_wrapper.mk)
|
2016-08-17 15:08:22 +00:00
|
|
|
#
|
|
|
|
|
2019-03-14 08:54:04 +00:00
|
|
|
PYTHON=$(call dequote,$(CONFIG_SDK_PYTHON))
|
2018-12-19 14:16:58 +00:00
|
|
|
|
2016-11-10 02:20:55 +00:00
|
|
|
# Include project config makefile, if it exists.
|
|
|
|
#
|
|
|
|
# (Note that we only rebuild this makefile automatically for some
|
|
|
|
# targets, see project_config.mk for details.)
|
2017-02-06 06:02:07 +00:00
|
|
|
SDKCONFIG_MAKEFILE ?= $(abspath $(BUILD_DIR_BASE)/include/config/auto.conf)
|
2017-04-26 10:26:21 +00:00
|
|
|
-include $(SDKCONFIG_MAKEFILE)
|
2016-11-10 02:20:55 +00:00
|
|
|
export SDKCONFIG_MAKEFILE # sub-makes (like bootloader) will reuse this path
|
|
|
|
|
2017-02-10 06:38:24 +00:00
|
|
|
# BATCH_BUILD flag disables interactive terminal features, defaults to verbose build
|
|
|
|
ifdef BATCH_BUILD
|
|
|
|
V ?= 1
|
|
|
|
endif
|
|
|
|
|
2016-08-17 15:08:22 +00:00
|
|
|
#Handling of V=1/VERBOSE=1 flag
|
2016-08-24 05:02:24 +00:00
|
|
|
#
|
|
|
|
# if V=1, $(summary) does nothing and $(details) will echo extra details
|
|
|
|
# if V is unset or not 1, $(summary) echoes a summary and $(details) does nothing
|
2016-12-03 22:11:22 +00:00
|
|
|
VERBOSE ?=
|
2016-08-17 15:08:22 +00:00
|
|
|
V ?= $(VERBOSE)
|
|
|
|
ifeq ("$(V)","1")
|
2016-08-24 05:02:24 +00:00
|
|
|
summary := @true
|
|
|
|
details := @echo
|
2016-08-17 15:08:22 +00:00
|
|
|
else
|
2016-08-24 05:02:24 +00:00
|
|
|
summary := @echo
|
|
|
|
details := @true
|
2016-11-11 01:29:38 +00:00
|
|
|
|
|
|
|
# disable echoing of commands, directory names
|
2017-09-05 06:10:00 +00:00
|
|
|
MAKEFLAGS += --silent
|
2017-09-08 07:34:02 +00:00
|
|
|
endif # $(V)==1
|
2017-09-05 06:10:00 +00:00
|
|
|
|
2019-03-14 08:54:04 +00:00
|
|
|
ifdef CONFIG_SDK_MAKE_WARN_UNDEFINED_VARIABLES
|
2017-09-05 06:10:00 +00:00
|
|
|
MAKEFLAGS += --warn-undefined-variables
|
2016-08-17 15:08:22 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# General make utilities
|
|
|
|
|
|
|
|
# convenience variable for printing an 80 asterisk wide separator line
|
|
|
|
SEPARATOR:="*******************************************************************************"
|
|
|
|
|
2016-11-03 06:33:30 +00:00
|
|
|
# macro to remove quotes from an argument, ie $(call dequote,$(CONFIG_BLAH))
|
2016-08-17 15:08:22 +00:00
|
|
|
define dequote
|
|
|
|
$(subst ",,$(1))
|
|
|
|
endef
|
|
|
|
# " comment kept here to keep syntax highlighting happy
|
2016-11-03 06:33:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
# macro to keep an absolute path as-is, but resolve a relative path
|
|
|
|
# against a particular parent directory
|
|
|
|
#
|
|
|
|
# $(1) path to resolve
|
|
|
|
# $(2) directory to resolve non-absolute path against
|
|
|
|
#
|
|
|
|
# Path and directory don't have to exist (definition of a "relative
|
|
|
|
# path" is one that doesn't start with /)
|
|
|
|
#
|
|
|
|
# $(2) can contain a trailing forward slash or not, result will not
|
|
|
|
# double any path slashes.
|
|
|
|
#
|
|
|
|
# example $(call resolvepath,$(CONFIG_PATH),$(CONFIG_DIR))
|
|
|
|
define resolvepath
|
2018-04-05 04:57:31 +00:00
|
|
|
$(abspath $(foreach dir,$(1),$(if $(filter /%,$(dir)),$(dir),$(subst //,/,$(2)/$(dir)))))
|
2016-11-03 06:33:30 +00:00
|
|
|
endef
|
2016-12-22 05:32:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
# macro to include a target only if it's on the list of targets that make
|
|
|
|
# was invoked with
|
|
|
|
#
|
|
|
|
# This allows you to have something like an "order-only phony prerequisite",
|
|
|
|
# ie a prerequisite that determines an order phony targets have to run in.
|
|
|
|
#
|
|
|
|
# Because normal order-only prerequisites don't work with phony targets.
|
|
|
|
#
|
|
|
|
# example $(call prereq_if_explicit,erase_flash)
|
|
|
|
define prereq_if_explicit
|
|
|
|
$(filter $(1),$(MAKECMDGOALS))
|
|
|
|
endef
|
2017-05-31 09:20:29 +00:00
|
|
|
|
|
|
|
# macro to kill duplicate items in a list without messing up the sort order of the list.
|
|
|
|
# Will only keep the unique items; if there are non-unique items in the list, it will remove
|
|
|
|
# the later recurring ones so only the first one remains.
|
|
|
|
# Copied from http://stackoverflow.com/questions/16144115/makefile-remove-duplicate-words-without-sorting
|
|
|
|
define uniq
|
|
|
|
$(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
|
|
|
endef
|
2018-04-05 04:57:31 +00:00
|
|
|
|
|
|
|
# macro to strip leading ../s from a path
|
|
|
|
# Given $(1) which is a directory, remove any leading ../s from it
|
|
|
|
# (recursively keeps removing ../ until not found)
|
|
|
|
# if the path contains nothing but ../.., a single . is returned (cwd)
|
|
|
|
define stripLeadingParentDirs
|
|
|
|
$(foreach path,$(1),$(if $(subst ..,,$(path)),$(if $(filter ../%,$(path)),$(call stripLeadingParentDirs,$(patsubst ../%,%,$(path))),$(path)),.))
|
|
|
|
endef
|