common.mk 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Functionality common to both top-level project makefile (project.mk)
  2. # and component makefiles (component_wrapper.mk)
  3. #
  4. # Include project config makefile, if it exists.
  5. #
  6. # (Note that we only rebuild this makefile automatically for some
  7. # targets, see project_config.mk for details.)
  8. SDKCONFIG_MAKEFILE ?= $(abspath $(BUILD_DIR_BASE)/include/config/auto.conf)
  9. -include $(SDKCONFIG_MAKEFILE)
  10. export SDKCONFIG_MAKEFILE # sub-makes (like bootloader) will reuse this path
  11. #Handling of V=1/VERBOSE=1 flag
  12. #
  13. # if V=1, $(summary) does nothing and $(details) will echo extra details
  14. # if V is unset or not 1, $(summary) echoes a summary and $(details) does nothing
  15. V ?= $(VERBOSE)
  16. ifeq ("$(V)","1")
  17. summary := @true
  18. details := @echo
  19. else
  20. summary := @echo
  21. details := @true
  22. # disable echoing of commands, directory names
  23. MAKEFLAGS += --silent
  24. endif
  25. # General make utilities
  26. # convenience variable for printing an 80 asterisk wide separator line
  27. SEPARATOR:="*******************************************************************************"
  28. # macro to remove quotes from an argument, ie $(call dequote,$(CONFIG_BLAH))
  29. define dequote
  30. $(subst ",,$(1))
  31. endef
  32. # " comment kept here to keep syntax highlighting happy
  33. # macro to keep an absolute path as-is, but resolve a relative path
  34. # against a particular parent directory
  35. #
  36. # $(1) path to resolve
  37. # $(2) directory to resolve non-absolute path against
  38. #
  39. # Path and directory don't have to exist (definition of a "relative
  40. # path" is one that doesn't start with /)
  41. #
  42. # $(2) can contain a trailing forward slash or not, result will not
  43. # double any path slashes.
  44. #
  45. # example $(call resolvepath,$(CONFIG_PATH),$(CONFIG_DIR))
  46. define resolvepath
  47. $(foreach dir,$(1),$(if $(filter /%,$(dir)),$(dir),$(subst //,/,$(2)/$(dir))))
  48. endef
  49. # macro to include a target only if it's on the list of targets that make
  50. # was invoked with
  51. #
  52. # This allows you to have something like an "order-only phony prerequisite",
  53. # ie a prerequisite that determines an order phony targets have to run in.
  54. #
  55. # Because normal order-only prerequisites don't work with phony targets.
  56. #
  57. # example $(call prereq_if_explicit,erase_flash)
  58. define prereq_if_explicit
  59. $(filter $(1),$(MAKECMDGOALS))
  60. endef