common.mk 2.3 KB

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