project.mk 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. #
  2. # Main Project Makefile
  3. # This Makefile is included directly from the user project Makefile in order to call the component.mk
  4. # makefiles of all components (in a separate make process) to build all the libraries, then links them
  5. # together into the final file. If so, PWD is the project dir (we assume).
  6. #
  7. #
  8. # This makefile requires the environment variable IDF_PATH to be set to the top-level esp-idf directory
  9. # where this file is located.
  10. #
  11. .PHONY: build-components menuconfig defconfig all build clean all_binaries check-submodules size
  12. all: all_binaries
  13. # see below for recipe of 'all' target
  14. #
  15. # # other components will add dependencies to 'all_binaries'. The
  16. # reason all_binaries is used instead of 'all' is so that the flash
  17. # target can build everything without triggering the per-component "to
  18. # flash..." output targets.)
  19. help:
  20. @echo "Welcome to Espressif IDF build system. Some useful make targets:"
  21. @echo ""
  22. @echo "make menuconfig - Configure IDF project"
  23. @echo "make defconfig - Set defaults for all new configuration options"
  24. @echo ""
  25. @echo "make all - Build app, bootloader, partition table"
  26. @echo "make flash - Flash app, bootloader, partition table to a chip"
  27. @echo "make clean - Remove all build output"
  28. @echo "make size - Display the memory footprint of the app"
  29. @echo "make erase_flash - Erase entire flash contents"
  30. @echo "make monitor - Run idf_monitor tool to monitor serial output from app"
  31. @echo "make simple_monitor - Monitor serial output on terminal console"
  32. @echo ""
  33. @echo "make app - Build just the app"
  34. @echo "make app-flash - Flash just the app"
  35. @echo "make app-clean - Clean just the app"
  36. @echo ""
  37. @echo "See also 'make bootloader', 'make bootloader-flash', 'make bootloader-clean', "
  38. @echo "'make partition_table', etc, etc."
  39. # dependency checks
  40. ifndef MAKE_RESTARTS
  41. ifeq ("$(filter 4.% 3.81 3.82,$(MAKE_VERSION))","")
  42. $(warning "esp-idf build system only supports GNU Make versions 3.81 or newer. You may see unexpected results with other Makes.")
  43. endif
  44. endif
  45. # make IDF_PATH a "real" absolute path
  46. # * works around the case where a shell character is embedded in the environment variable value.
  47. # * changes Windows-style C:/blah/ paths to MSYS/Cygwin style /c/blah
  48. ifeq ("$(OS)","Windows_NT")
  49. # On Windows MSYS2, make wildcard function returns empty string for paths of form /xyz
  50. # where /xyz is a directory inside the MSYS root - so we don't use it.
  51. SANITISED_IDF_PATH:=$(realpath $(IDF_PATH))
  52. else
  53. SANITISED_IDF_PATH:=$(realpath $(wildcard $(IDF_PATH)))
  54. endif
  55. export IDF_PATH := $(SANITISED_IDF_PATH)
  56. ifndef IDF_PATH
  57. $(error IDF_PATH variable is not set to a valid directory.)
  58. endif
  59. ifneq ("$(IDF_PATH)","$(SANITISED_IDF_PATH)")
  60. # implies IDF_PATH was overriden on make command line.
  61. # Due to the way make manages variables, this is hard to account for
  62. #
  63. # if you see this error, do the shell expansion in the shell ie
  64. # make IDF_PATH=~/blah not make IDF_PATH="~/blah"
  65. $(error If IDF_PATH is overriden on command line, it must be an absolute path with no embedded shell special characters)
  66. endif
  67. ifneq ("$(IDF_PATH)","$(subst :,,$(IDF_PATH))")
  68. $(error IDF_PATH cannot contain colons. If overriding IDF_PATH on Windows, use Cygwin-style /c/dir instead of C:/dir)
  69. endif
  70. # disable built-in make rules, makes debugging saner
  71. MAKEFLAGS_OLD := $(MAKEFLAGS)
  72. MAKEFLAGS +=-rR
  73. # Default path to the project: we assume the Makefile including this file
  74. # is in the project directory
  75. ifndef PROJECT_PATH
  76. PROJECT_PATH := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
  77. export PROJECT_PATH
  78. endif
  79. # A list of the "common" makefiles, to use as a target dependency
  80. COMMON_MAKEFILES := $(abspath $(IDF_PATH)/make/project.mk $(IDF_PATH)/make/common.mk $(IDF_PATH)/make/component_wrapper.mk)
  81. export COMMON_MAKEFILES
  82. # The directory where we put all objects/libraries/binaries. The project Makefile can
  83. # configure this if needed.
  84. BUILD_DIR_BASE ?= $(PROJECT_PATH)/build
  85. export BUILD_DIR_BASE
  86. # Component directories. These directories are searched for components.
  87. # The project Makefile can override these component dirs, or define extra component directories.
  88. COMPONENT_DIRS ?= $(PROJECT_PATH)/components $(EXTRA_COMPONENT_DIRS) $(IDF_PATH)/components
  89. export COMPONENT_DIRS
  90. # Source directories of the project itself (a special, project-specific component.) Defaults to only "main".
  91. SRCDIRS ?= main
  92. # The project Makefile can define a list of components, but if it does not do this we just take
  93. # all available components in the component dirs.
  94. ifndef COMPONENTS
  95. # Find all component names. The component names are the same as the
  96. # directories they're in, so /bla/components/mycomponent/ -> mycomponent. We then use
  97. # COMPONENT_DIRS to build COMPONENT_PATHS with the full path to each component.
  98. COMPONENTS := $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/*))
  99. COMPONENTS := $(sort $(foreach comp,$(COMPONENTS),$(lastword $(subst /, ,$(comp)))))
  100. endif
  101. export COMPONENTS
  102. # Resolve all of COMPONENTS into absolute paths in COMPONENT_PATHS.
  103. #
  104. # If a component name exists in multiple COMPONENT_DIRS, we take the first match.
  105. #
  106. # NOTE: These paths must be generated WITHOUT a trailing / so we
  107. # can use $(notdir x) to get the component name.
  108. COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)))))
  109. COMPONENT_PATHS += $(abspath $(SRCDIRS))
  110. # A component is buildable if it has a component.mk makefile in it
  111. COMPONENT_PATHS_BUILDABLE := $(foreach cp,$(COMPONENT_PATHS),$(if $(wildcard $(cp)/component.mk),$(cp)))
  112. # If TESTS_ALL set to 1, set TEST_COMPONENTS_LIST to all components
  113. ifeq ($(TESTS_ALL),1)
  114. TEST_COMPONENTS_LIST := $(COMPONENTS)
  115. else
  116. # otherwise, use TEST_COMPONENTS
  117. TEST_COMPONENTS_LIST := $(TEST_COMPONENTS)
  118. endif
  119. TEST_COMPONENT_PATHS := $(foreach comp,$(TEST_COMPONENTS_LIST),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)/test))))
  120. TEST_COMPONENT_NAMES := $(foreach comp,$(TEST_COMPONENT_PATHS),$(lastword $(subst /, ,$(dir $(comp))))_test)
  121. # Initialise project-wide variables which can be added to by
  122. # each component.
  123. #
  124. # These variables are built up via the component_project_vars.mk
  125. # generated makefiles (one per component).
  126. #
  127. # See docs/build-system.rst for more details.
  128. COMPONENT_INCLUDES :=
  129. COMPONENT_LDFLAGS :=
  130. COMPONENT_SUBMODULES :=
  131. # COMPONENT_PROJECT_VARS is the list of component_project_vars.mk generated makefiles
  132. # for each component.
  133. #
  134. # Including $(COMPONENT_PROJECT_VARS) builds the COMPONENT_INCLUDES,
  135. # COMPONENT_LDFLAGS variables and also targets for any inter-component
  136. # dependencies.
  137. #
  138. # See the component_project_vars.mk target in component_wrapper.mk
  139. COMPONENT_PROJECT_VARS := $(addsuffix /component_project_vars.mk,$(notdir $(COMPONENT_PATHS_BUILDABLE) ) $(TEST_COMPONENT_NAMES))
  140. COMPONENT_PROJECT_VARS := $(addprefix $(BUILD_DIR_BASE)/,$(COMPONENT_PROJECT_VARS))
  141. # this line is -include instead of include to prevent a spurious error message on make 3.81
  142. -include $(COMPONENT_PROJECT_VARS)
  143. # Also add top-level project include path, for top-level includes
  144. COMPONENT_INCLUDES += $(abspath $(BUILD_DIR_BASE)/include/)
  145. export COMPONENT_INCLUDES
  146. # Set variables common to both project & component
  147. include $(IDF_PATH)/make/common.mk
  148. all:
  149. ifdef CONFIG_SECURE_BOOT_ENABLED
  150. @echo "(Secure boot enabled, so bootloader not flashed automatically. See 'make bootloader' output)"
  151. ifndef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
  152. @echo "App built but not signed. Sign app & partition data before flashing, via espsecure.py:"
  153. @echo "espsecure.py sign_data --keyfile KEYFILE $(APP_BIN)"
  154. @echo "espsecure.py sign_data --keyfile KEYFILE $(PARTITION_TABLE_BIN)"
  155. endif
  156. @echo "To flash app & partition table, run 'make flash' or:"
  157. else
  158. @echo "To flash all build output, run 'make flash' or:"
  159. endif
  160. @echo $(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS)
  161. IDF_VER := $(shell cd ${IDF_PATH} && git describe --always --tags --dirty)
  162. # Set default LDFLAGS
  163. SRCDIRS_COMPONENT_NAMES := $(sort $(foreach comp,$(SRCDIRS),$(lastword $(subst /, ,$(comp)))))
  164. LDFLAGS ?= -nostdlib \
  165. $(addprefix -L$(BUILD_DIR_BASE)/,$(COMPONENTS) $(TEST_COMPONENT_NAMES) $(SRCDIRS_COMPONENT_NAMES) ) \
  166. -u call_user_start_cpu0 \
  167. $(EXTRA_LDFLAGS) \
  168. -Wl,--gc-sections \
  169. -Wl,-static \
  170. -Wl,--start-group \
  171. $(COMPONENT_LDFLAGS) \
  172. -lgcc \
  173. -lstdc++ \
  174. -Wl,--end-group \
  175. -Wl,-EL
  176. # Set default CPPFLAGS, CFLAGS, CXXFLAGS
  177. # These are exported so that components can use them when compiling.
  178. # If you need your component to add CFLAGS/etc for it's own source compilation only, set CFLAGS += in your component's Makefile.
  179. # If you need your component to add CFLAGS/etc globally for all source
  180. # files, set CFLAGS += in your component's Makefile.projbuild
  181. # If you need to set CFLAGS/CPPFLAGS/CXXFLAGS at project level, set them in application Makefile
  182. # before including project.mk. Default flags will be added before the ones provided in application Makefile.
  183. # CPPFLAGS used by C preprocessor
  184. # If any flags are defined in application Makefile, add them at the end.
  185. CPPFLAGS := -DESP_PLATFORM -D IDF_VER=\"$(IDF_VER)\" -MMD -MP $(CPPFLAGS) $(EXTRA_CPPFLAGS)
  186. # Warnings-related flags relevant both for C and C++
  187. COMMON_WARNING_FLAGS = -Wall -Werror=all \
  188. -Wno-error=unused-function \
  189. -Wno-error=unused-but-set-variable \
  190. -Wno-error=unused-variable \
  191. -Wno-error=deprecated-declarations \
  192. -Wextra \
  193. -Wno-unused-parameter -Wno-sign-compare
  194. # Flags which control code generation and dependency generation, both for C and C++
  195. COMMON_FLAGS = \
  196. -ffunction-sections -fdata-sections \
  197. -fstrict-volatile-bitfields \
  198. -mlongcalls \
  199. -nostdlib
  200. # Optimization flags are set based on menuconfig choice
  201. ifneq ("$(CONFIG_OPTIMIZATION_LEVEL_RELEASE)","")
  202. OPTIMIZATION_FLAGS = -Os
  203. CPPFLAGS += -DNDEBUG
  204. else
  205. OPTIMIZATION_FLAGS = -Og
  206. endif
  207. # Enable generation of debugging symbols
  208. # (we generate even in Release mode, as this has no impact on final binary size.)
  209. DEBUG_FLAGS ?= -ggdb
  210. # List of flags to pass to C compiler
  211. # If any flags are defined in application Makefile, add them at the end.
  212. CFLAGS := $(strip \
  213. -std=gnu99 \
  214. $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) \
  215. $(COMMON_FLAGS) \
  216. $(COMMON_WARNING_FLAGS) -Wno-old-style-declaration \
  217. $(CFLAGS) \
  218. $(EXTRA_CFLAGS))
  219. # List of flags to pass to C++ compiler
  220. # If any flags are defined in application Makefile, add them at the end.
  221. CXXFLAGS := $(strip \
  222. -std=gnu++11 \
  223. -fno-exceptions \
  224. -fno-rtti \
  225. $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) \
  226. $(COMMON_FLAGS) \
  227. $(COMMON_WARNING_FLAGS) \
  228. $(CXXFLAGS) \
  229. $(EXTRA_CXXFLAGS))
  230. export CFLAGS CPPFLAGS CXXFLAGS
  231. # Set host compiler and binutils
  232. HOSTCC := $(CC)
  233. HOSTLD := $(LD)
  234. HOSTAR := $(AR)
  235. HOSTOBJCOPY := $(OBJCOPY)
  236. HOSTSIZE := $(SIZE)
  237. export HOSTCC HOSTLD HOSTAR HOSTOBJCOPY SIZE
  238. # Set target compiler. Defaults to whatever the user has
  239. # configured as prefix + ye olde gcc commands
  240. CC := $(call dequote,$(CONFIG_TOOLPREFIX))gcc
  241. CXX := $(call dequote,$(CONFIG_TOOLPREFIX))c++
  242. LD := $(call dequote,$(CONFIG_TOOLPREFIX))ld
  243. AR := $(call dequote,$(CONFIG_TOOLPREFIX))ar
  244. OBJCOPY := $(call dequote,$(CONFIG_TOOLPREFIX))objcopy
  245. SIZE := $(call dequote,$(CONFIG_TOOLPREFIX))size
  246. export CC CXX LD AR OBJCOPY SIZE
  247. PYTHON=$(call dequote,$(CONFIG_PYTHON))
  248. # the app is the main executable built by the project
  249. APP_ELF:=$(BUILD_DIR_BASE)/$(PROJECT_NAME).elf
  250. APP_MAP:=$(APP_ELF:.elf=.map)
  251. APP_BIN:=$(APP_ELF:.elf=.bin)
  252. # Include any Makefile.projbuild file letting components add
  253. # configuration at the project level
  254. define includeProjBuildMakefile
  255. $(if $(V),$(if $(wildcard $(1)/Makefile.projbuild),$(info including $(1)/Makefile.projbuild...)))
  256. COMPONENT_PATH := $(1)
  257. -include $(1)/Makefile.projbuild
  258. endef
  259. $(foreach componentpath,$(COMPONENT_PATHS),$(eval $(call includeProjBuildMakefile,$(componentpath))))
  260. # once we know component paths, we can include the config generation targets
  261. #
  262. # (bootloader build doesn't need this, config is exported from top-level)
  263. ifndef IS_BOOTLOADER_BUILD
  264. include $(IDF_PATH)/make/project_config.mk
  265. endif
  266. # A "component" library is any library in the LDFLAGS where
  267. # the name of the library is also a name of the component
  268. APP_LIBRARIES = $(patsubst -l%,%,$(filter -l%,$(LDFLAGS)))
  269. COMPONENT_LIBRARIES = $(filter $(notdir $(COMPONENT_PATHS_BUILDABLE)) $(TEST_COMPONENT_NAMES),$(APP_LIBRARIES))
  270. # ELF depends on the library archive files for COMPONENT_LIBRARIES
  271. # the rules to build these are emitted as part of GenerateComponentTarget below
  272. #
  273. # also depends on additional dependencies (linker scripts & binary libraries)
  274. # stored in COMPONENT_LINKER_DEPS, built via component.mk files' COMPONENT_ADD_LINKER_DEPS variable
  275. $(APP_ELF): $(foreach libcomp,$(COMPONENT_LIBRARIES),$(BUILD_DIR_BASE)/$(libcomp)/lib$(libcomp).a) $(COMPONENT_LINKER_DEPS)
  276. $(summary) LD $(notdir $@)
  277. $(CC) $(LDFLAGS) -o $@ -Wl,-Map=$(APP_MAP)
  278. # Generation of $(APP_BIN) from $(APP_ELF) is added by the esptool
  279. # component's Makefile.projbuild
  280. app: $(APP_BIN)
  281. ifeq ("$(CONFIG_SECURE_BOOT_ENABLED)$(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)","y") # secure boot enabled, but remote sign app image
  282. @echo "App built but not signed. Signing step via espsecure.py:"
  283. @echo "espsecure.py sign_data --keyfile KEYFILE $(APP_BIN)"
  284. @echo "Then flash app command is:"
  285. @echo $(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN)
  286. else
  287. @echo "App built. Default flash app command is:"
  288. @echo $(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN)
  289. endif
  290. all_binaries: $(APP_BIN)
  291. $(BUILD_DIR_BASE):
  292. mkdir -p $(BUILD_DIR_BASE)
  293. # Macro for the recursive sub-make for each component
  294. # $(1) - component directory
  295. # $(2) - component name only
  296. #
  297. # Is recursively expanded by the GenerateComponentTargets macro
  298. define ComponentMake
  299. +$(MAKE) -C $(BUILD_DIR_BASE)/$(2) -f $(IDF_PATH)/make/component_wrapper.mk COMPONENT_MAKEFILE=$(1)/component.mk COMPONENT_NAME=$(2)
  300. endef
  301. # Generate top-level component-specific targets for each component
  302. # $(1) - path to component dir
  303. # $(2) - name of component
  304. #
  305. define GenerateComponentTargets
  306. .PHONY: $(2)-build $(2)-clean
  307. $(2)-build: check-submodules
  308. $(call ComponentMake,$(1),$(2)) build
  309. $(2)-clean:
  310. $(call ComponentMake,$(1),$(2)) clean
  311. $(BUILD_DIR_BASE)/$(2):
  312. @mkdir -p $(BUILD_DIR_BASE)/$(2)
  313. # tell make it can build any component's library by invoking the -build target
  314. # (this target exists for all components even ones which don't build libraries, but it's
  315. # only invoked for the targets whose libraries appear in COMPONENT_LIBRARIES and hence the
  316. # APP_ELF dependencies.)
  317. $(BUILD_DIR_BASE)/$(2)/lib$(2).a: $(2)-build
  318. $(details) "Target '$$^' responsible for '$$@'" # echo which build target built this file
  319. # add a target to generate the component_project_vars.mk files that
  320. # are used to inject variables into project make pass (see matching
  321. # component_project_vars.mk target in component_wrapper.mk).
  322. #
  323. # If any component_project_vars.mk file is out of date, the make
  324. # process will call this target to rebuild it and then restart.
  325. #
  326. $(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(SDKCONFIG_MAKEFILE) | $(BUILD_DIR_BASE)/$(2)
  327. $(call ComponentMake,$(1),$(2)) component_project_vars.mk
  328. endef
  329. $(foreach component,$(COMPONENT_PATHS_BUILDABLE),$(eval $(call GenerateComponentTargets,$(component),$(notdir $(component)))))
  330. $(foreach component,$(TEST_COMPONENT_PATHS),$(eval $(call GenerateComponentTargets,$(component),$(lastword $(subst /, ,$(dir $(component))))_test)))
  331. app-clean: $(addsuffix -clean,$(notdir $(COMPONENT_PATHS_BUILDABLE)))
  332. $(summary) RM $(APP_ELF)
  333. rm -f $(APP_ELF) $(APP_BIN) $(APP_MAP)
  334. size: $(APP_ELF)
  335. $(SIZE) $(APP_ELF)
  336. # NB: this ordering is deliberate (app-clean before config-clean),
  337. # so config remains valid during all component clean targets
  338. config-clean: app-clean
  339. clean: config-clean
  340. # phony target to check if any git submodule listed in COMPONENT_SUBMODULES are missing
  341. # or out of date, and exit if so. Components can add paths to this variable.
  342. #
  343. # This only works for components inside IDF_PATH
  344. check-submodules:
  345. # Dump the git status for the whole working copy once, then grep it for each submodule. This saves a lot of time on Windows.
  346. GIT_STATUS := $(shell cd ${IDF_PATH} && git status --porcelain --ignore-submodules=dirty)
  347. # Generate a target to check this submodule
  348. # $(1) - submodule directory, relative to IDF_PATH
  349. define GenerateSubmoduleCheckTarget
  350. check-submodules: $(IDF_PATH)/$(1)/.git
  351. $(IDF_PATH)/$(1)/.git:
  352. @echo "WARNING: Missing submodule $(1)..."
  353. [ -e ${IDF_PATH}/.git ] || ( echo "ERROR: esp-idf must be cloned from git to work."; exit 1)
  354. [ -x $(which git) ] || ( echo "ERROR: Need to run 'git submodule init $(1)' in esp-idf root directory."; exit 1)
  355. @echo "Attempting 'git submodule update --init $(1)' in esp-idf root directory..."
  356. cd ${IDF_PATH} && git submodule update --init $(1)
  357. # Parse 'git status' output to check if the submodule commit is different to expected
  358. ifneq ("$(filter $(1),$(GIT_STATUS))","")
  359. $$(info WARNING: esp-idf git submodule $(1) may be out of date. Run 'git submodule update' in IDF_PATH dir to update.)
  360. endif
  361. endef
  362. # filter/subst in expression ensures all submodule paths begin with $(IDF_PATH), and then strips that prefix
  363. # so the argument is suitable for use with 'git submodule' commands
  364. $(foreach submodule,$(subst $(IDF_PATH)/,,$(filter $(IDF_PATH)/%,$(COMPONENT_SUBMODULES))),$(eval $(call GenerateSubmoduleCheckTarget,$(submodule))))
  365. # Check toolchain version using the output of xtensa-esp32-elf-gcc --version command.
  366. # The output normally looks as follows
  367. # xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-59-ga194053) 4.8.5
  368. # The part in brackets is extracted into TOOLCHAIN_COMMIT_DESC variable,
  369. # the part after the brackets is extracted into TOOLCHAIN_GCC_VER.
  370. ifdef CONFIG_TOOLPREFIX
  371. ifndef MAKE_RESTARTS
  372. TOOLCHAIN_COMMIT_DESC := $(shell $(CC) --version | sed -E -n 's|xtensa-esp32-elf-gcc.*\ \(([^)]*).*|\1|gp')
  373. TOOLCHAIN_GCC_VER := $(shell $(CC) --version | sed -E -n 's|xtensa-esp32-elf-gcc.*\ \(.*\)\ (.*)|\1|gp')
  374. # Officially supported version(s)
  375. SUPPORTED_TOOLCHAIN_COMMIT_DESC := crosstool-NG crosstool-ng-1.22.0-61-gab8375a
  376. SUPPORTED_TOOLCHAIN_GCC_VERSIONS := 5.2.0
  377. ifdef TOOLCHAIN_COMMIT_DESC
  378. ifneq ($(TOOLCHAIN_COMMIT_DESC), $(SUPPORTED_TOOLCHAIN_COMMIT_DESC))
  379. $(info WARNING: Toolchain version is not supported: $(TOOLCHAIN_COMMIT_DESC))
  380. $(info Expected to see version: $(SUPPORTED_TOOLCHAIN_COMMIT_DESC))
  381. $(info Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.)
  382. endif
  383. ifeq (,$(findstring $(TOOLCHAIN_GCC_VER), $(SUPPORTED_TOOLCHAIN_GCC_VERSIONS)))
  384. $(info WARNING: Compiler version is not supported: $(TOOLCHAIN_GCC_VER))
  385. $(info Expected to see version(s): $(SUPPORTED_TOOLCHAIN_GCC_VERSIONS))
  386. $(info Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.)
  387. endif
  388. else
  389. $(info WARNING: Failed to find Xtensa toolchain, may need to alter PATH or set one in the configuration menu)
  390. endif # TOOLCHAIN_COMMIT_DESC
  391. endif #MAKE_RESTARTS
  392. endif #CONFIG_TOOLPREFIX