common.mk 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 $(PROJECT_PATH)/build/include/config/auto.conf
  9. ifeq ("$(LDFLAGS)","")
  10. LDFLAGS = -nostdlib \
  11. -L$(IDF_PATH)/lib \
  12. -L$(IDF_PATH)/ld \
  13. $(addprefix -L$(BUILD_DIR_BASE)/,$(COMPONENTS) $(SRCDIRS)) \
  14. -u call_user_start_cpu0 \
  15. -Wl,--gc-sections \
  16. -Wl,-static \
  17. -Wl,--start-group \
  18. $(COMPONENT_LDFLAGS) \
  19. -lgcc \
  20. -Wl,--end-group
  21. endif
  22. ifeq ("$(CFLAGS)","")
  23. CFLAGS = -DESP_PLATFORM -Og -std=gnu99 -g3 \
  24. -Wpointer-arith -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable \
  25. -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -Wall -ffunction-sections -fdata-sections $(EXTRA_CFLAGS)
  26. endif
  27. ifeq ("$(CXXFLAGS)","")
  28. CXXFLAGS = -DESP_PLATFORM -Og -std=gnu++11 -g3 \
  29. -Wpointer-arith -Werror -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable \
  30. -Wl,-EL -nostdlib -mlongcalls -Wall -ffunction-sections -fdata-sections $(EXTRA_CFLAGS) -fno-exceptions
  31. endif
  32. #Handling of V=1/VERBOSE=1 flag
  33. #
  34. # if V=1, $(summary) does nothing and $(details) will echo extra details
  35. # if V is unset or not 1, $(summary) echoes a summary and $(details) does nothing
  36. V ?= $(VERBOSE)
  37. ifeq ("$(V)","1")
  38. Q :=
  39. summary := @true
  40. details := @echo
  41. else
  42. Q := @
  43. summary := @echo
  44. details := @true
  45. endif
  46. # Pseudo-target to handle the case where submodules need to be
  47. # re-initialised.
  48. #
  49. # $(eval $(call SubmoduleRequiredForFiles,FILENAMES)) to create a target that
  50. # automatically runs 'git submodule update --init' if those files
  51. # are missing, and fails if this is not possible.
  52. define SubmoduleRequiredForFiles
  53. $(1):
  54. @echo "WARNING: Missing submodule for $$@..."
  55. $(Q) [ -d ${IDF_PATH}/.git ] || ( echo "ERROR: esp-idf must be cloned from git to work."; exit 1)
  56. $(Q) [ -x $(which git) ] || ( echo "ERROR: Need to run 'git submodule --init' in esp-idf root directory."; exit 1)
  57. @echo "Attempting 'git submodule update --init' in esp-idf root directory..."
  58. cd ${IDF_PATH} && git submodule update --init
  59. endef
  60. # General make utilities
  61. # convenience variable for printing an 80 asterisk wide separator line
  62. SEPARATOR:="*******************************************************************************"
  63. # macro to remove quotes from an argument, ie $(call dequote (CONFIG_BLAH))
  64. define dequote
  65. $(subst ",,$(1))
  66. endef
  67. # " comment kept here to keep syntax highlighting happy