common.mk 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Functionality common to both top-level project makefile
  2. # and component makefiles
  3. #
  4. # Include project config file, if it exists.
  5. #
  6. # (Note that we only rebuild auto.conf automatically for some targets,
  7. # see project_config.mk for details.)
  8. -include $(BUILD_DIR_BASE)/include/config/auto.conf
  9. #Handling of V=1/VERBOSE=1 flag
  10. #
  11. # if V=1, $(summary) does nothing and $(details) will echo extra details
  12. # if V is unset or not 1, $(summary) echoes a summary and $(details) does nothing
  13. V ?= $(VERBOSE)
  14. ifeq ("$(V)","1")
  15. Q :=
  16. summary := @true
  17. details := @echo
  18. else
  19. Q := @
  20. summary := @echo
  21. details := @true
  22. endif
  23. # Pseudo-target to check a git submodule has been properly initialised
  24. #
  25. # $(eval $(call SubmoduleCheck,FILENAMES,SUBMODULE_PATH)) to create a target that
  26. # automatically runs 'git submodule update --init SUBMODULE_PATH' if any of
  27. # the files in FILENAMES are missing, and fails if this is not possible.
  28. #
  29. # Will also print a WARNING if the submodule at SUBMODULE_PATH appears
  30. # to require an update.
  31. define SubmoduleCheck
  32. $(1):
  33. @echo "WARNING: Missing submodule $(2) for $$@..."
  34. $(Q) [ -d ${IDF_PATH}/.git ] || ( echo "ERROR: esp-idf must be cloned from git to work."; exit 1)
  35. $(Q) [ -x $(which git) ] || ( echo "ERROR: Need to run 'git submodule --init' in esp-idf root directory."; exit 1)
  36. @echo "Attempting 'git submodule update --init' in esp-idf root directory..."
  37. cd ${IDF_PATH} && git submodule update --init $(2)
  38. # Parse 'git submodule status' output for out-of-date submodule.
  39. # Status output prefixes status line with '+' if the submodule commit doesn't match
  40. ifneq ("$(shell cd ${IDF_PATH} && git submodule status $(2) | grep '^+')","")
  41. $$(info WARNING: git submodule $2 may be out of date. Run 'git submodule update' to update.)
  42. endif
  43. endef
  44. # General make utilities
  45. # convenience variable for printing an 80 asterisk wide separator line
  46. SEPARATOR:="*******************************************************************************"
  47. # macro to remove quotes from an argument, ie $(call dequote (CONFIG_BLAH))
  48. define dequote
  49. $(subst ",,$(1))
  50. endef
  51. # " comment kept here to keep syntax highlighting happy