Handle missing IDF_PATH variable in more informative way
[apeos.git] / make / project.mk
blobffce4847d5237182ce801d3c8c130a93fbe99c03
1 # Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
2 # Copyright 2018 apeos contributors
4 # Main Project Makefile (based on esp-idf file with similar purpose)
5 # This Makefile is included directly from the user project Makefile in
6 # order to call the component.mk makefiles of all components (in a
7 # separate make process) to build all the libraries, then links them
8 # together into the final file. If so, PWD is the project dir (we
9 # assume).
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
15 # http://www.apache.org/licenses/LICENSE-2.0
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
24 # This makefile requires the environment variable IDF_PATH to be set
25 # to the top-level esp-idf directory where this file is located.
28 .PHONY: build-components menuconfig defconfig all build clean all_binaries check-submodules size size-components size-files list-components
30 MAKECMDGOALS ?= all
31 all: all_binaries
32 # see below for recipe of 'all' target
34 # # other components will add dependencies to 'all_binaries'. The
35 # reason all_binaries is used instead of 'all' is so that the flash
36 # target can build everything without triggering the per-component "to
37 # flash..." output targets.)
39 help:
40 @echo "Welcome to apeos build system. Some useful make targets:"
41 @echo ""
42 @echo "make menuconfig - Configure IDF project"
43 @echo "make defconfig - Set defaults for all new configuration options"
44 @echo ""
45 @echo "make all - Build app, bootloader, partition table"
46 @echo "make flash - Flash app, bootloader, partition table to a chip"
47 @echo "make clean - Remove all build output"
48 @echo "make size - Display the static memory footprint of the app"
49 @echo "make size-components, size-files - Finer-grained memory footprints"
50 @echo "make erase_flash - Erase entire flash contents"
51 @echo "make monitor - Run idf_monitor tool to monitor serial output from app"
52 @echo "make simple_monitor - Monitor serial output on terminal console"
53 @echo "make list-components - List all components in the project"
54 @echo ""
55 @echo "make print_flash_cmd - Print the arguments for esptool when flash"
56 @echo ""
57 @echo "See also 'make bootloader', 'make bootloader-flash', 'make bootloader-clean', "
58 @echo "'make partition_table', etc, etc."
60 # dependency checks
61 ifndef MAKE_RESTARTS
62 ifeq ("$(filter 4.% 3.81 3.82,$(MAKE_VERSION))","")
63 $(warning esp-idf build system only supports GNU Make versions 3.81 or newer. You may see unexpected results with other Makes.)
64 endif
66 ifdef MSYSTEM
67 ifneq ("$(MSYSTEM)","MINGW32")
68 $(warning esp-idf build system only supports MSYS2 in "MINGW32" mode. Consult the ESP-IDF documentation for details.)
69 endif
70 endif # MSYSTEM
72 endif # MAKE_RESTARTS
74 # can't run 'clean' along with any non-clean targets
75 ifneq ("$(filter clean% %clean,$(MAKECMDGOALS))" ,"")
76 ifneq ("$(filter-out clean% %clean,$(MAKECMDGOALS))", "")
77 $(error esp-idf build system doesn't support running 'clean' targets along with any others. Run 'make clean' and then run other targets separately.)
78 endif
79 endif
81 OS ?=
83 # make IDF_PATH a "real" absolute path
84 # * works around the case where a shell character is embedded in the environment variable value.
85 # * changes Windows-style C:/blah/ paths to MSYS style /c/blah
86 ifeq ("$(OS)","Windows_NT")
87 # On Windows MSYS2, make wildcard function returns empty string for paths of form /xyz
88 # where /xyz is a directory inside the MSYS root - so we don't use it.
89 SANITISED_IDF_PATH:=$(realpath $(IDF_PATH))
90 else
91 SANITISED_IDF_PATH:=$(realpath $(wildcard $(IDF_PATH)))
92 endif
94 export IDF_PATH := $(SANITISED_IDF_PATH)
96 ifndef IDF_PATH
97 $(info IDF_PATH variable is not set to a valid directory.)
98 $(info IDF_PATH variable is part of ESP-IDF setup, which is the official)
99 $(info development framework for ESP32 chip by Espressif.)
100 $(info For more info about ESP32 chip, see)
101 $(info https://espressif.com/en/products/hardware/esp32/overview)
102 $(error ape smiles should ever be)
103 endif
105 ifneq ("$(IDF_PATH)","$(SANITISED_IDF_PATH)")
106 # implies IDF_PATH was overriden on make command line.
107 # Due to the way make manages variables, this is hard to account for
109 # if you see this error, do the shell expansion in the shell ie
110 # make IDF_PATH=~/blah not make IDF_PATH="~/blah"
111 $(error If IDF_PATH is overriden on command line, it must be an absolute path with no embedded shell special characters)
112 endif
114 ifneq ("$(IDF_PATH)","$(subst :,,$(IDF_PATH))")
115 $(error IDF_PATH cannot contain colons. If overriding IDF_PATH on Windows, use MSYS Unix-style /c/dir instead of C:/dir)
116 endif
118 # disable built-in make rules, makes debugging saner
119 MAKEFLAGS_OLD := $(MAKEFLAGS)
120 MAKEFLAGS +=-rR
122 # Default path to the project: we assume the Makefile including this file
123 # is in the project directory
124 ifndef PROJECT_PATH
125 PROJECT_PATH := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
126 export PROJECT_PATH
127 endif
129 # TOP_DIR is useful to distinguish apeos esp-idf build system variant
130 # from upstream esp-idf variant in IDF_PATH
131 TOP_DIR=$(PROJECT_PATH)
132 export TOP_DIR
134 # A list of the "common" makefiles, to use as a target dependency
135 COMMON_MAKEFILES := $(abspath $(TOP_DIR)/make/project.mk $(TOP_DIR)/make/common.mk $(TOP_DIR)/make/component_wrapper.mk $(firstword $(MAKEFILE_LIST)))
136 export COMMON_MAKEFILES
138 # The directory where we put all objects/libraries/binaries. The project Makefile can
139 # configure this if needed.
140 ifndef BUILD_DIR_BASE
141 BUILD_DIR_BASE := $(PROJECT_PATH)/build
142 endif
143 export BUILD_DIR_BASE
145 # Component directories. These directories are searched for components (either the directory is a component,
146 # or the directory contains subdirectories which are components.)
147 # The project Makefile can override these component dirs, or add extras via EXTRA_COMPONENT_DIRS
148 ifndef COMPONENT_DIRS
149 EXTRA_COMPONENT_DIRS ?=
150 COMPONENT_DIRS := $(PROJECT_PATH)/components $(EXTRA_COMPONENT_DIRS) $(IDF_PATH)/components $(PROJECT_PATH)/main
151 endif
152 export COMPONENT_DIRS
154 ifdef SRCDIRS
155 $(warning SRCDIRS variable is deprecated. These paths can be added to EXTRA_COMPONENT_DIRS or COMPONENT_DIRS instead.)
156 COMPONENT_DIRS += $(abspath $(SRCDIRS))
157 endif
159 # The project Makefile can define a list of components, but if it does not do this we just take all available components
160 # in the component dirs. A component is COMPONENT_DIRS directory, or immediate subdirectory,
161 # which contains a component.mk file.
163 # Use the "make list-components" target to debug this step.
164 ifndef COMPONENTS
165 # Find all component names. The component names are the same as the
166 # directories they're in, so /bla/components/mycomponent/component.mk -> mycomponent.
167 COMPONENTS := $(dir $(foreach cd,$(COMPONENT_DIRS), \
168 $(wildcard $(cd)/*/component.mk) $(wildcard $(cd)/component.mk) \
170 COMPONENTS := $(sort $(foreach comp,$(COMPONENTS),$(lastword $(subst /, ,$(comp)))))
171 endif
172 export COMPONENTS
174 # Resolve all of COMPONENTS into absolute paths in COMPONENT_PATHS.
176 # If a component name exists in multiple COMPONENT_DIRS, we take the first match.
178 # NOTE: These paths must be generated WITHOUT a trailing / so we
179 # can use $(notdir x) to get the component name.
180 COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach cd,$(COMPONENT_DIRS),$(wildcard $(dir $(cd))$(comp) $(cd)/$(comp)))))
181 export COMPONENT_PATHS
183 TEST_COMPONENTS ?=
184 TESTS_ALL ?=
186 # If TESTS_ALL set to 1, set TEST_COMPONENTS_LIST to all components.
187 # Otherwise, use the list supplied in TEST_COMPONENTS.
188 ifeq ($(TESTS_ALL),1)
189 TEST_COMPONENTS_LIST := $(COMPONENTS)
190 else
191 TEST_COMPONENTS_LIST := $(TEST_COMPONENTS)
192 endif
194 TEST_COMPONENT_PATHS := $(foreach comp,$(TEST_COMPONENTS_LIST),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)/test))))
195 TEST_COMPONENT_NAMES := $(foreach comp,$(TEST_COMPONENT_PATHS),$(lastword $(subst /, ,$(dir $(comp))))_test)
197 # Initialise project-wide variables which can be added to by
198 # each component.
200 # These variables are built up via the component_project_vars.mk
201 # generated makefiles (one per component).
203 # See docs/build-system.rst for more details.
204 COMPONENT_INCLUDES :=
205 COMPONENT_LDFLAGS :=
206 COMPONENT_SUBMODULES :=
207 COMPONENT_LIBRARIES :=
209 # COMPONENT_PROJECT_VARS is the list of component_project_vars.mk generated makefiles
210 # for each component.
212 # Including $(COMPONENT_PROJECT_VARS) builds the COMPONENT_INCLUDES,
213 # COMPONENT_LDFLAGS variables and also targets for any inter-component
214 # dependencies.
216 # See the component_project_vars.mk target in component_wrapper.mk
217 COMPONENT_PROJECT_VARS := $(addsuffix /component_project_vars.mk,$(notdir $(COMPONENT_PATHS) ) $(TEST_COMPONENT_NAMES))
218 COMPONENT_PROJECT_VARS := $(addprefix $(BUILD_DIR_BASE)/,$(COMPONENT_PROJECT_VARS))
219 # this line is -include instead of include to prevent a spurious error message on make 3.81
220 -include $(COMPONENT_PROJECT_VARS)
222 # Also add top-level project include path, for top-level includes
223 COMPONENT_INCLUDES += $(abspath $(BUILD_DIR_BASE)/include/)
225 export COMPONENT_INCLUDES
227 # Set variables common to both project & component
228 $(if $(V),$(info including $(TOP_DIR)/make/common.mk...))
229 include $(TOP_DIR)/make/common.mk
231 all:
232 ifdef CONFIG_SECURE_BOOT_ENABLED
233 @echo "(Secure boot enabled, so bootloader not flashed automatically. See 'make bootloader' output)"
234 ifndef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
235 @echo "App built but not signed. Sign app & partition data before flashing, via espsecure.py:"
236 @echo "espsecure.py sign_data --keyfile KEYFILE $(APP_BIN)"
237 @echo "espsecure.py sign_data --keyfile KEYFILE $(PARTITION_TABLE_BIN)"
238 endif
239 @echo "To flash app & partition table, run 'make flash' or:"
240 else
241 @echo "To flash all build output, run:"
242 endif
243 @echo $(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS)
246 IDF_VER := $(shell cd ${IDF_PATH} && git describe --always --tags --dirty)
248 # Set default LDFLAGS
249 EXTRA_LDFLAGS ?=
250 LDFLAGS ?= -nostdlib \
251 -u call_user_start_cpu0 \
252 $(EXTRA_LDFLAGS) \
253 -Wl,--gc-sections \
254 -Wl,-static \
255 -Wl,--start-group \
256 $(COMPONENT_LDFLAGS) \
257 -lgcc \
258 -lstdc++ \
259 -lgcov \
260 -Wl,--end-group \
261 -Wl,-EL
263 # Set default CPPFLAGS, CFLAGS, CXXFLAGS
264 # These are exported so that components can use them when compiling.
265 # If you need your component to add CFLAGS/etc for it's own source compilation only, set CFLAGS += in your component's Makefile.
266 # If you need your component to add CFLAGS/etc globally for all source
267 # files, set CFLAGS += in your component's Makefile.projbuild
268 # If you need to set CFLAGS/CPPFLAGS/CXXFLAGS at project level, set them in application Makefile
269 # before including project.mk. Default flags will be added before the ones provided in application Makefile.
271 # CPPFLAGS used by C preprocessor
272 # If any flags are defined in application Makefile, add them at the end.
273 CPPFLAGS ?=
274 EXTRA_CPPFLAGS ?=
275 CPPFLAGS := -DESP_PLATFORM -D IDF_VER=\"$(IDF_VER)\" -MMD -MP $(CPPFLAGS) $(EXTRA_CPPFLAGS)
277 # Warnings-related flags relevant both for C and C++
278 COMMON_WARNING_FLAGS = -Wall -Werror=all \
279 -Wno-error=unused-function \
280 -Wno-error=unused-but-set-variable \
281 -Wno-error=unused-variable \
282 -Wno-error=deprecated-declarations \
283 -Wextra \
284 -Wno-unused-parameter -Wno-sign-compare
286 # Flags which control code generation and dependency generation, both for C and C++
287 COMMON_FLAGS = \
288 -ffunction-sections -fdata-sections \
289 -fstrict-volatile-bitfields \
290 -mlongcalls \
291 -nostdlib
293 ifndef IS_BOOTLOADER_BUILD
294 # stack protection (only one option can be selected in menuconfig)
295 ifdef CONFIG_STACK_CHECK_NORM
296 COMMON_FLAGS += -fstack-protector
297 endif
298 ifdef CONFIG_STACK_CHECK_STRONG
299 COMMON_FLAGS += -fstack-protector-strong
300 endif
301 ifdef CONFIG_STACK_CHECK_ALL
302 COMMON_FLAGS += -fstack-protector-all
303 endif
304 endif
306 # Optimization flags are set based on menuconfig choice
307 ifdef CONFIG_OPTIMIZATION_LEVEL_RELEASE
308 OPTIMIZATION_FLAGS = -Os
309 else
310 OPTIMIZATION_FLAGS = -Og
311 endif
313 ifdef CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED
314 CPPFLAGS += -DNDEBUG
315 endif
317 # Enable generation of debugging symbols
318 # (we generate even in Release mode, as this has no impact on final binary size.)
319 DEBUG_FLAGS ?= -ggdb
321 # List of flags to pass to C compiler
322 # If any flags are defined in application Makefile, add them at the end.
323 CFLAGS ?=
324 EXTRA_CFLAGS ?=
325 CFLAGS := $(strip \
326 -std=gnu99 \
327 $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) \
328 $(COMMON_FLAGS) \
329 $(COMMON_WARNING_FLAGS) -Wno-old-style-declaration \
330 $(CFLAGS) \
331 $(EXTRA_CFLAGS))
333 # List of flags to pass to C++ compiler
334 # If any flags are defined in application Makefile, add them at the end.
335 CXXFLAGS ?=
336 EXTRA_CXXFLAGS ?=
337 CXXFLAGS := $(strip \
338 -std=gnu++11 \
339 -fno-rtti \
340 $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) \
341 $(COMMON_FLAGS) \
342 $(COMMON_WARNING_FLAGS) \
343 $(CXXFLAGS) \
344 $(EXTRA_CXXFLAGS))
346 ifdef CONFIG_CXX_EXCEPTIONS
347 CXXFLAGS += -fexceptions
348 else
349 CXXFLAGS += -fno-exceptions
350 endif
352 export CFLAGS CPPFLAGS CXXFLAGS
354 # Set default values that were not previously defined
355 CC ?= gcc
356 LD ?= ld
357 AR ?= ar
358 OBJCOPY ?= objcopy
359 SIZE ?= size
361 # Set host compiler and binutils
362 HOSTCC := $(CC)
363 HOSTLD := $(LD)
364 HOSTAR := $(AR)
365 HOSTOBJCOPY := $(OBJCOPY)
366 HOSTSIZE := $(SIZE)
367 export HOSTCC HOSTLD HOSTAR HOSTOBJCOPY SIZE
369 # Set target compiler. Defaults to whatever the user has
370 # configured as prefix + ye olde gcc commands
371 CC := $(call dequote,$(CONFIG_TOOLPREFIX))gcc
372 CXX := $(call dequote,$(CONFIG_TOOLPREFIX))c++
373 LD := $(call dequote,$(CONFIG_TOOLPREFIX))ld
374 AR := $(call dequote,$(CONFIG_TOOLPREFIX))ar
375 OBJCOPY := $(call dequote,$(CONFIG_TOOLPREFIX))objcopy
376 SIZE := $(call dequote,$(CONFIG_TOOLPREFIX))size
377 export CC CXX LD AR OBJCOPY SIZE
379 PYTHON=$(call dequote,$(CONFIG_PYTHON))
381 # the app is the main executable built by the project
382 # bootloader subproject is considered app
383 APP_ELF:=$(BUILD_DIR_BASE)/$(PROJECT_NAME).elf
384 APP_MAP:=$(APP_ELF:.elf=.map)
385 APP_BIN:=$(APP_ELF:.elf=.bin)
387 # Include any Makefile.projbuild file letting components add
388 # configuration at the project level
389 define includeProjBuildMakefile
390 $(if $(V),$(info including $(1)/Makefile.projbuild...))
391 COMPONENT_PATH := $(1)
392 include $(1)/Makefile.projbuild
393 endef
394 $(foreach componentpath,$(COMPONENT_PATHS), \
395 $(if $(wildcard $(componentpath)/Makefile.projbuild), \
396 $(eval $(call includeProjBuildMakefile,$(componentpath)))))
398 # once we know component paths, we can include the config generation targets
400 # (bootloader build doesn't need this, config is exported from top-level)
401 ifndef IS_BOOTLOADER_BUILD
402 $(if $(V),$(info including $(TOP_DIR)/make/project_config.mk...))
403 include $(TOP_DIR)/make/project_config.mk
404 endif
406 ifdef IS_BOOTLOADER_BUILD
407 # ELF depends on the library archive files for COMPONENT_LIBRARIES
408 # the rules to build these are emitted as part of GenerateComponentTarget below
410 # also depends on additional dependencies (linker scripts & binary libraries)
411 # stored in COMPONENT_LINKER_DEPS, built via component.mk files' COMPONENT_ADD_LINKER_DEPS variable
412 COMPONENT_LINKER_DEPS ?=
413 $(APP_ELF): $(foreach libcomp,$(COMPONENT_LIBRARIES),$(BUILD_DIR_BASE)/$(libcomp)/lib$(libcomp).a) $(COMPONENT_LINKER_DEPS) $(COMPONENT_PROJECT_VARS)
414 $(summary) LD $(patsubst $(PWD)/%,%,$@)
415 $(CC) $(LDFLAGS) -o $@ -Wl,-Map=$(APP_MAP)
417 all_binaries: $(APP_BIN)
418 endif
420 $(BUILD_DIR_BASE):
421 mkdir -p $(BUILD_DIR_BASE)
423 # Macro for the recursive sub-make for each component
424 # $(1) - component directory
425 # $(2) - component name only
427 # Is recursively expanded by the GenerateComponentTargets macro
428 define ComponentMake
429 +$(MAKE) -C $(BUILD_DIR_BASE)/$(2) -f $(TOP_DIR)/make/component_wrapper.mk COMPONENT_MAKEFILE=$(1)/component.mk COMPONENT_NAME=$(2)
430 endef
432 # Generate top-level component-specific targets for each component
433 # $(1) - path to component dir
434 # $(2) - name of component
436 define GenerateComponentTargets
437 .PHONY: component-$(2)-build component-$(2)-clean
439 component-$(2)-build: check-submodules $(call prereq_if_explicit, component-$(2)-clean) | $(BUILD_DIR_BASE)/$(2)
440 $(call ComponentMake,$(1),$(2)) build
442 component-$(2)-clean: | $(BUILD_DIR_BASE)/$(2) $(BUILD_DIR_BASE)/$(2)/component_project_vars.mk
443 $(call ComponentMake,$(1),$(2)) clean
445 $(BUILD_DIR_BASE)/$(2):
446 @mkdir -p $(BUILD_DIR_BASE)/$(2)
448 # tell make it can build any component's library by invoking the -build target
449 # (this target exists for all components even ones which don't build libraries, but it's
450 # only invoked for the targets whose libraries appear in COMPONENT_LIBRARIES and hence the
451 # APP_ELF dependencies.)
452 $(BUILD_DIR_BASE)/$(2)/lib$(2).a: component-$(2)-build
453 $(details) "Target '$$^' responsible for '$$@'" # echo which build target built this file
455 # add a target to generate the component_project_vars.mk files that
456 # are used to inject variables into project make pass (see matching
457 # component_project_vars.mk target in component_wrapper.mk).
459 # If any component_project_vars.mk file is out of date, the make
460 # process will call this target to rebuild it and then restart.
462 $(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(SDKCONFIG_MAKEFILE) | $(BUILD_DIR_BASE)/$(2)
463 $(call ComponentMake,$(1),$(2)) component_project_vars.mk
464 endef
466 $(foreach component,$(COMPONENT_PATHS),$(eval $(call GenerateComponentTargets,$(component),$(notdir $(component)))))
467 $(foreach component,$(TEST_COMPONENT_PATHS),$(eval $(call GenerateComponentTargets,$(component),$(lastword $(subst /, ,$(dir $(component))))_test)))
469 # NB: this ordering is deliberate (app-clean & bootloader-clean before
470 # _config-clean), so config remains valid during all component clean
471 # targets
472 config-clean: bootloader-clean
473 clean: bootloader-clean config-clean
475 # phony target to check if any git submodule listed in COMPONENT_SUBMODULES are missing
476 # or out of date, and exit if so. Components can add paths to this variable.
478 # This only works for components inside IDF_PATH
479 check-submodules:
481 # Dump the git status for the whole working copy once, then grep it for each submodule. This saves a lot of time on Windows.
482 GIT_STATUS := $(shell cd ${IDF_PATH} && git status --porcelain --ignore-submodules=dirty)
484 # Generate a target to check this submodule
485 # $(1) - submodule directory, relative to IDF_PATH
486 define GenerateSubmoduleCheckTarget
487 check-submodules: $(IDF_PATH)/$(1)/.git
488 $(IDF_PATH)/$(1)/.git:
489 @echo "WARNING: Missing submodule $(1)..."
490 [ -e ${IDF_PATH}/.git ] || ( echo "ERROR: esp-idf must be cloned from git to work."; exit 1)
491 [ -x $$(which git) ] || ( echo "ERROR: Need to run 'git submodule init $(1)' in esp-idf root directory."; exit 1)
492 @echo "Attempting 'git submodule update --init $(1)' in esp-idf root directory..."
493 cd ${IDF_PATH} && git submodule update --init $(1)
495 # Parse 'git status' output to check if the submodule commit is different to expected
496 ifneq ("$(filter $(1),$(GIT_STATUS))","")
497 $$(info WARNING: esp-idf git submodule $(1) may be out of date. Run 'git submodule update' in IDF_PATH dir to update.)
498 endif
499 endef
501 # filter/subst in expression ensures all submodule paths begin with $(IDF_PATH), and then strips that prefix
502 # so the argument is suitable for use with 'git submodule' commands
503 $(foreach submodule,$(subst $(IDF_PATH)/,,$(filter $(IDF_PATH)/%,$(COMPONENT_SUBMODULES))),$(eval $(call GenerateSubmoduleCheckTarget,$(submodule))))
506 # PHONY target to list components in the build and their paths
507 list-components:
508 $(info $(call dequote,$(SEPARATOR)))
509 $(info COMPONENT_DIRS (components searched for here))
510 $(foreach cd,$(COMPONENT_DIRS),$(info $(cd)))
511 $(info $(call dequote,$(SEPARATOR)))
512 $(info COMPONENTS (list of component names))
513 $(info $(COMPONENTS))
514 $(info $(call dequote,$(SEPARATOR)))
515 $(info COMPONENT_PATHS (paths to all components):)
516 $(foreach cp,$(COMPONENT_PATHS),$(info $(cp)))
518 # print flash command, so users can dump this to config files and download somewhere without idf
519 print_flash_cmd:
520 echo $(ESPTOOL_WRITE_FLASH_OPTIONS) $(ESPTOOL_ALL_FLASH_ARGS) | sed -e 's:'$(PWD)/build/'::g'
522 # Check toolchain version using the output of xtensa-esp32-elf-gcc --version command.
523 # The output normally looks as follows
524 # xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-59-ga194053) 4.8.5
525 # The part in brackets is extracted into TOOLCHAIN_COMMIT_DESC variable,
526 # the part after the brackets is extracted into TOOLCHAIN_GCC_VER.
527 ifdef CONFIG_TOOLPREFIX
528 ifndef MAKE_RESTARTS
529 TOOLCHAIN_COMMIT_DESC := $(shell $(CC) --version | sed -E -n 's|.*crosstool-ng-([0-9]+).([0-9]+).([0-9]+)-([0-9]+)-g([0-9a-f]{7}).*|\1.\2.\3-\4-g\5|gp')
530 TOOLCHAIN_GCC_VER := $(shell $(CC) --version | sed -E -n 's|xtensa-esp32-elf-gcc.*\ \(.*\)\ (.*)|\1|gp')
532 # Officially supported version(s)
533 SUPPORTED_TOOLCHAIN_COMMIT_DESC := 1.22.0-80-g6c4433a
534 SUPPORTED_TOOLCHAIN_GCC_VERSIONS := 5.2.0
536 ifdef TOOLCHAIN_COMMIT_DESC
537 ifneq ($(TOOLCHAIN_COMMIT_DESC), $(SUPPORTED_TOOLCHAIN_COMMIT_DESC))
538 $(info WARNING: Toolchain version is not supported: $(TOOLCHAIN_COMMIT_DESC))
539 $(info Expected to see version: $(SUPPORTED_TOOLCHAIN_COMMIT_DESC))
540 $(info Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.)
541 endif
542 ifeq (,$(findstring $(TOOLCHAIN_GCC_VER), $(SUPPORTED_TOOLCHAIN_GCC_VERSIONS)))
543 $(info WARNING: Compiler version is not supported: $(TOOLCHAIN_GCC_VER))
544 $(info Expected to see version(s): $(SUPPORTED_TOOLCHAIN_GCC_VERSIONS))
545 $(info Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.)
546 endif
547 else
548 $(info WARNING: Failed to find Xtensa toolchain, may need to alter PATH or set one in the configuration menu)
549 endif # TOOLCHAIN_COMMIT_DESC
551 endif #MAKE_RESTARTS
552 endif #CONFIG_TOOLPREFIX