Augment /components/bootloader/subproject/Makefile with notice (apache-2.0)
[apeos.git] / make / project.mk
blob4f7fb0731a6a1530fba1f342cc8d39fecad1c4c3
1 # Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
3 # Main Project Makefile
4 # This Makefile is included directly from the user project Makefile in order to call the component.mk
5 # makefiles of all components (in a separate make process) to build all the libraries, then links them
6 # together into the final file. If so, PWD is the project dir (we assume).
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
21 # This makefile requires the environment variable IDF_PATH to be set to the top-level esp-idf directory
22 # where this file is located.
25 .PHONY: build-components menuconfig defconfig all build clean all_binaries check-submodules size size-components size-files list-components
27 MAKECMDGOALS ?= all
28 all: all_binaries
29 # see below for recipe of 'all' target
31 # # other components will add dependencies to 'all_binaries'. The
32 # reason all_binaries is used instead of 'all' is so that the flash
33 # target can build everything without triggering the per-component "to
34 # flash..." output targets.)
36 help:
37 @echo "Welcome to Espressif IDF build system. Some useful make targets:"
38 @echo ""
39 @echo "make menuconfig - Configure IDF project"
40 @echo "make defconfig - Set defaults for all new configuration options"
41 @echo ""
42 @echo "make all - Build app, bootloader, partition table"
43 @echo "make flash - Flash app, bootloader, partition table to a chip"
44 @echo "make clean - Remove all build output"
45 @echo "make size - Display the static memory footprint of the app"
46 @echo "make size-components, size-files - Finer-grained memory footprints"
47 @echo "make erase_flash - Erase entire flash contents"
48 @echo "make monitor - Run idf_monitor tool to monitor serial output from app"
49 @echo "make simple_monitor - Monitor serial output on terminal console"
50 @echo "make list-components - List all components in the project"
51 @echo ""
52 @echo "make app - Build just the app"
53 @echo "make app-flash - Flash just the app"
54 @echo "make app-clean - Clean just the app"
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 $(error IDF_PATH variable is not set to a valid directory.)
98 endif
100 ifneq ("$(IDF_PATH)","$(SANITISED_IDF_PATH)")
101 # implies IDF_PATH was overriden on make command line.
102 # Due to the way make manages variables, this is hard to account for
104 # if you see this error, do the shell expansion in the shell ie
105 # make IDF_PATH=~/blah not make IDF_PATH="~/blah"
106 $(error If IDF_PATH is overriden on command line, it must be an absolute path with no embedded shell special characters)
107 endif
109 ifneq ("$(IDF_PATH)","$(subst :,,$(IDF_PATH))")
110 $(error IDF_PATH cannot contain colons. If overriding IDF_PATH on Windows, use MSYS Unix-style /c/dir instead of C:/dir)
111 endif
113 # disable built-in make rules, makes debugging saner
114 MAKEFLAGS_OLD := $(MAKEFLAGS)
115 MAKEFLAGS +=-rR
117 # Default path to the project: we assume the Makefile including this file
118 # is in the project directory
119 ifndef PROJECT_PATH
120 PROJECT_PATH := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
121 export PROJECT_PATH
122 endif
124 # A list of the "common" makefiles, to use as a target dependency
125 COMMON_MAKEFILES := $(abspath $(IDF_PATH)/make/project.mk $(IDF_PATH)/make/common.mk $(IDF_PATH)/make/component_wrapper.mk $(firstword $(MAKEFILE_LIST)))
126 export COMMON_MAKEFILES
128 # The directory where we put all objects/libraries/binaries. The project Makefile can
129 # configure this if needed.
130 ifndef BUILD_DIR_BASE
131 BUILD_DIR_BASE := $(PROJECT_PATH)/build
132 endif
133 export BUILD_DIR_BASE
135 # Component directories. These directories are searched for components (either the directory is a component,
136 # or the directory contains subdirectories which are components.)
137 # The project Makefile can override these component dirs, or add extras via EXTRA_COMPONENT_DIRS
138 ifndef COMPONENT_DIRS
139 EXTRA_COMPONENT_DIRS ?=
140 COMPONENT_DIRS := $(PROJECT_PATH)/components $(EXTRA_COMPONENT_DIRS) $(IDF_PATH)/components $(PROJECT_PATH)/main
141 endif
142 export COMPONENT_DIRS
144 ifdef SRCDIRS
145 $(warning SRCDIRS variable is deprecated. These paths can be added to EXTRA_COMPONENT_DIRS or COMPONENT_DIRS instead.)
146 COMPONENT_DIRS += $(abspath $(SRCDIRS))
147 endif
149 # The project Makefile can define a list of components, but if it does not do this we just take all available components
150 # in the component dirs. A component is COMPONENT_DIRS directory, or immediate subdirectory,
151 # which contains a component.mk file.
153 # Use the "make list-components" target to debug this step.
154 ifndef COMPONENTS
155 # Find all component names. The component names are the same as the
156 # directories they're in, so /bla/components/mycomponent/component.mk -> mycomponent.
157 COMPONENTS := $(dir $(foreach cd,$(COMPONENT_DIRS), \
158 $(wildcard $(cd)/*/component.mk) $(wildcard $(cd)/component.mk) \
160 COMPONENTS := $(sort $(foreach comp,$(COMPONENTS),$(lastword $(subst /, ,$(comp)))))
161 endif
162 export COMPONENTS
164 # Resolve all of COMPONENTS into absolute paths in COMPONENT_PATHS.
166 # If a component name exists in multiple COMPONENT_DIRS, we take the first match.
168 # NOTE: These paths must be generated WITHOUT a trailing / so we
169 # can use $(notdir x) to get the component name.
170 COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach cd,$(COMPONENT_DIRS),$(wildcard $(dir $(cd))$(comp) $(cd)/$(comp)))))
171 export COMPONENT_PATHS
173 TEST_COMPONENTS ?=
174 TESTS_ALL ?=
176 # If TESTS_ALL set to 1, set TEST_COMPONENTS_LIST to all components.
177 # Otherwise, use the list supplied in TEST_COMPONENTS.
178 ifeq ($(TESTS_ALL),1)
179 TEST_COMPONENTS_LIST := $(COMPONENTS)
180 else
181 TEST_COMPONENTS_LIST := $(TEST_COMPONENTS)
182 endif
184 TEST_COMPONENT_PATHS := $(foreach comp,$(TEST_COMPONENTS_LIST),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)/test))))
185 TEST_COMPONENT_NAMES := $(foreach comp,$(TEST_COMPONENT_PATHS),$(lastword $(subst /, ,$(dir $(comp))))_test)
187 # Initialise project-wide variables which can be added to by
188 # each component.
190 # These variables are built up via the component_project_vars.mk
191 # generated makefiles (one per component).
193 # See docs/build-system.rst for more details.
194 COMPONENT_INCLUDES :=
195 COMPONENT_LDFLAGS :=
196 COMPONENT_SUBMODULES :=
197 COMPONENT_LIBRARIES :=
199 # COMPONENT_PROJECT_VARS is the list of component_project_vars.mk generated makefiles
200 # for each component.
202 # Including $(COMPONENT_PROJECT_VARS) builds the COMPONENT_INCLUDES,
203 # COMPONENT_LDFLAGS variables and also targets for any inter-component
204 # dependencies.
206 # See the component_project_vars.mk target in component_wrapper.mk
207 COMPONENT_PROJECT_VARS := $(addsuffix /component_project_vars.mk,$(notdir $(COMPONENT_PATHS) ) $(TEST_COMPONENT_NAMES))
208 COMPONENT_PROJECT_VARS := $(addprefix $(BUILD_DIR_BASE)/,$(COMPONENT_PROJECT_VARS))
209 # this line is -include instead of include to prevent a spurious error message on make 3.81
210 -include $(COMPONENT_PROJECT_VARS)
212 # Also add top-level project include path, for top-level includes
213 COMPONENT_INCLUDES += $(abspath $(BUILD_DIR_BASE)/include/)
215 export COMPONENT_INCLUDES
217 # Set variables common to both project & component
218 include $(IDF_PATH)/make/common.mk
220 all:
221 ifdef CONFIG_SECURE_BOOT_ENABLED
222 @echo "(Secure boot enabled, so bootloader not flashed automatically. See 'make bootloader' output)"
223 ifndef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
224 @echo "App built but not signed. Sign app & partition data before flashing, via espsecure.py:"
225 @echo "espsecure.py sign_data --keyfile KEYFILE $(APP_BIN)"
226 @echo "espsecure.py sign_data --keyfile KEYFILE $(PARTITION_TABLE_BIN)"
227 endif
228 @echo "To flash app & partition table, run 'make flash' or:"
229 else
230 @echo "To flash all build output, run 'make flash' or:"
231 endif
232 @echo $(ESPTOOLPY_WRITE_FLASH) $(ESPTOOL_ALL_FLASH_ARGS)
235 IDF_VER := $(shell cd ${IDF_PATH} && git describe --always --tags --dirty)
237 # Set default LDFLAGS
238 EXTRA_LDFLAGS ?=
239 LDFLAGS ?= -nostdlib \
240 -u call_user_start_cpu0 \
241 $(EXTRA_LDFLAGS) \
242 -Wl,--gc-sections \
243 -Wl,-static \
244 -Wl,--start-group \
245 $(COMPONENT_LDFLAGS) \
246 -lgcc \
247 -lstdc++ \
248 -lgcov \
249 -Wl,--end-group \
250 -Wl,-EL
252 # Set default CPPFLAGS, CFLAGS, CXXFLAGS
253 # These are exported so that components can use them when compiling.
254 # If you need your component to add CFLAGS/etc for it's own source compilation only, set CFLAGS += in your component's Makefile.
255 # If you need your component to add CFLAGS/etc globally for all source
256 # files, set CFLAGS += in your component's Makefile.projbuild
257 # If you need to set CFLAGS/CPPFLAGS/CXXFLAGS at project level, set them in application Makefile
258 # before including project.mk. Default flags will be added before the ones provided in application Makefile.
260 # CPPFLAGS used by C preprocessor
261 # If any flags are defined in application Makefile, add them at the end.
262 CPPFLAGS ?=
263 EXTRA_CPPFLAGS ?=
264 CPPFLAGS := -DESP_PLATFORM -D IDF_VER=\"$(IDF_VER)\" -MMD -MP $(CPPFLAGS) $(EXTRA_CPPFLAGS)
266 # Warnings-related flags relevant both for C and C++
267 COMMON_WARNING_FLAGS = -Wall -Werror=all \
268 -Wno-error=unused-function \
269 -Wno-error=unused-but-set-variable \
270 -Wno-error=unused-variable \
271 -Wno-error=deprecated-declarations \
272 -Wextra \
273 -Wno-unused-parameter -Wno-sign-compare
275 # Flags which control code generation and dependency generation, both for C and C++
276 COMMON_FLAGS = \
277 -ffunction-sections -fdata-sections \
278 -fstrict-volatile-bitfields \
279 -mlongcalls \
280 -nostdlib
282 ifndef IS_BOOTLOADER_BUILD
283 # stack protection (only one option can be selected in menuconfig)
284 ifdef CONFIG_STACK_CHECK_NORM
285 COMMON_FLAGS += -fstack-protector
286 endif
287 ifdef CONFIG_STACK_CHECK_STRONG
288 COMMON_FLAGS += -fstack-protector-strong
289 endif
290 ifdef CONFIG_STACK_CHECK_ALL
291 COMMON_FLAGS += -fstack-protector-all
292 endif
293 endif
295 # Optimization flags are set based on menuconfig choice
296 ifdef CONFIG_OPTIMIZATION_LEVEL_RELEASE
297 OPTIMIZATION_FLAGS = -Os
298 else
299 OPTIMIZATION_FLAGS = -Og
300 endif
302 ifdef CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED
303 CPPFLAGS += -DNDEBUG
304 endif
306 # Enable generation of debugging symbols
307 # (we generate even in Release mode, as this has no impact on final binary size.)
308 DEBUG_FLAGS ?= -ggdb
310 # List of flags to pass to C compiler
311 # If any flags are defined in application Makefile, add them at the end.
312 CFLAGS ?=
313 EXTRA_CFLAGS ?=
314 CFLAGS := $(strip \
315 -std=gnu99 \
316 $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) \
317 $(COMMON_FLAGS) \
318 $(COMMON_WARNING_FLAGS) -Wno-old-style-declaration \
319 $(CFLAGS) \
320 $(EXTRA_CFLAGS))
322 # List of flags to pass to C++ compiler
323 # If any flags are defined in application Makefile, add them at the end.
324 CXXFLAGS ?=
325 EXTRA_CXXFLAGS ?=
326 CXXFLAGS := $(strip \
327 -std=gnu++11 \
328 -fno-rtti \
329 $(OPTIMIZATION_FLAGS) $(DEBUG_FLAGS) \
330 $(COMMON_FLAGS) \
331 $(COMMON_WARNING_FLAGS) \
332 $(CXXFLAGS) \
333 $(EXTRA_CXXFLAGS))
335 ifdef CONFIG_CXX_EXCEPTIONS
336 CXXFLAGS += -fexceptions
337 else
338 CXXFLAGS += -fno-exceptions
339 endif
341 export CFLAGS CPPFLAGS CXXFLAGS
343 # Set default values that were not previously defined
344 CC ?= gcc
345 LD ?= ld
346 AR ?= ar
347 OBJCOPY ?= objcopy
348 SIZE ?= size
350 # Set host compiler and binutils
351 HOSTCC := $(CC)
352 HOSTLD := $(LD)
353 HOSTAR := $(AR)
354 HOSTOBJCOPY := $(OBJCOPY)
355 HOSTSIZE := $(SIZE)
356 export HOSTCC HOSTLD HOSTAR HOSTOBJCOPY SIZE
358 # Set target compiler. Defaults to whatever the user has
359 # configured as prefix + ye olde gcc commands
360 CC := $(call dequote,$(CONFIG_TOOLPREFIX))gcc
361 CXX := $(call dequote,$(CONFIG_TOOLPREFIX))c++
362 LD := $(call dequote,$(CONFIG_TOOLPREFIX))ld
363 AR := $(call dequote,$(CONFIG_TOOLPREFIX))ar
364 OBJCOPY := $(call dequote,$(CONFIG_TOOLPREFIX))objcopy
365 SIZE := $(call dequote,$(CONFIG_TOOLPREFIX))size
366 export CC CXX LD AR OBJCOPY SIZE
368 PYTHON=$(call dequote,$(CONFIG_PYTHON))
370 # the app is the main executable built by the project
371 APP_ELF:=$(BUILD_DIR_BASE)/$(PROJECT_NAME).elf
372 APP_MAP:=$(APP_ELF:.elf=.map)
373 APP_BIN:=$(APP_ELF:.elf=.bin)
375 # Include any Makefile.projbuild file letting components add
376 # configuration at the project level
377 define includeProjBuildMakefile
378 $(if $(V),$(info including $(1)/Makefile.projbuild...))
379 COMPONENT_PATH := $(1)
380 include $(1)/Makefile.projbuild
381 endef
382 $(foreach componentpath,$(COMPONENT_PATHS), \
383 $(if $(wildcard $(componentpath)/Makefile.projbuild), \
384 $(eval $(call includeProjBuildMakefile,$(componentpath)))))
386 # once we know component paths, we can include the config generation targets
388 # (bootloader build doesn't need this, config is exported from top-level)
389 ifndef IS_BOOTLOADER_BUILD
390 include $(IDF_PATH)/make/project_config.mk
391 endif
393 # ELF depends on the library archive files for COMPONENT_LIBRARIES
394 # the rules to build these are emitted as part of GenerateComponentTarget below
396 # also depends on additional dependencies (linker scripts & binary libraries)
397 # stored in COMPONENT_LINKER_DEPS, built via component.mk files' COMPONENT_ADD_LINKER_DEPS variable
398 COMPONENT_LINKER_DEPS ?=
399 $(APP_ELF): $(foreach libcomp,$(COMPONENT_LIBRARIES),$(BUILD_DIR_BASE)/$(libcomp)/lib$(libcomp).a) $(COMPONENT_LINKER_DEPS) $(COMPONENT_PROJECT_VARS)
400 $(summary) LD $(patsubst $(PWD)/%,%,$@)
401 $(CC) $(LDFLAGS) -o $@ -Wl,-Map=$(APP_MAP)
403 app: $(APP_BIN)
404 ifeq ("$(CONFIG_SECURE_BOOT_ENABLED)$(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)","y") # secure boot enabled, but remote sign app image
405 @echo "App built but not signed. Signing step via espsecure.py:"
406 @echo "espsecure.py sign_data --keyfile KEYFILE $(APP_BIN)"
407 @echo "Then flash app command is:"
408 @echo $(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN)
409 else
410 @echo "App built. Default flash app command is:"
411 @echo $(ESPTOOLPY_WRITE_FLASH) $(CONFIG_APP_OFFSET) $(APP_BIN)
412 endif
414 all_binaries: $(APP_BIN)
416 $(BUILD_DIR_BASE):
417 mkdir -p $(BUILD_DIR_BASE)
419 # Macro for the recursive sub-make for each component
420 # $(1) - component directory
421 # $(2) - component name only
423 # Is recursively expanded by the GenerateComponentTargets macro
424 define ComponentMake
425 +$(MAKE) -C $(BUILD_DIR_BASE)/$(2) -f $(IDF_PATH)/make/component_wrapper.mk COMPONENT_MAKEFILE=$(1)/component.mk COMPONENT_NAME=$(2)
426 endef
428 # Generate top-level component-specific targets for each component
429 # $(1) - path to component dir
430 # $(2) - name of component
432 define GenerateComponentTargets
433 .PHONY: component-$(2)-build component-$(2)-clean
435 component-$(2)-build: check-submodules $(call prereq_if_explicit, component-$(2)-clean) | $(BUILD_DIR_BASE)/$(2)
436 $(call ComponentMake,$(1),$(2)) build
438 component-$(2)-clean: | $(BUILD_DIR_BASE)/$(2) $(BUILD_DIR_BASE)/$(2)/component_project_vars.mk
439 $(call ComponentMake,$(1),$(2)) clean
441 $(BUILD_DIR_BASE)/$(2):
442 @mkdir -p $(BUILD_DIR_BASE)/$(2)
444 # tell make it can build any component's library by invoking the -build target
445 # (this target exists for all components even ones which don't build libraries, but it's
446 # only invoked for the targets whose libraries appear in COMPONENT_LIBRARIES and hence the
447 # APP_ELF dependencies.)
448 $(BUILD_DIR_BASE)/$(2)/lib$(2).a: component-$(2)-build
449 $(details) "Target '$$^' responsible for '$$@'" # echo which build target built this file
451 # add a target to generate the component_project_vars.mk files that
452 # are used to inject variables into project make pass (see matching
453 # component_project_vars.mk target in component_wrapper.mk).
455 # If any component_project_vars.mk file is out of date, the make
456 # process will call this target to rebuild it and then restart.
458 $(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(SDKCONFIG_MAKEFILE) | $(BUILD_DIR_BASE)/$(2)
459 $(call ComponentMake,$(1),$(2)) component_project_vars.mk
460 endef
462 $(foreach component,$(COMPONENT_PATHS),$(eval $(call GenerateComponentTargets,$(component),$(notdir $(component)))))
463 $(foreach component,$(TEST_COMPONENT_PATHS),$(eval $(call GenerateComponentTargets,$(component),$(lastword $(subst /, ,$(dir $(component))))_test)))
465 app-clean: $(addprefix component-,$(addsuffix -clean,$(notdir $(COMPONENT_PATHS))))
466 $(summary) RM $(APP_ELF)
467 rm -f $(APP_ELF) $(APP_BIN) $(APP_MAP)
469 size: $(APP_ELF)
470 $(PYTHON) $(IDF_PATH)/tools/idf_size.py $(APP_MAP)
472 size-files: $(APP_ELF)
473 $(PYTHON) $(IDF_PATH)/tools/idf_size.py --files $(APP_MAP)
475 size-components: $(APP_ELF)
476 $(PYTHON) $(IDF_PATH)/tools/idf_size.py --archives $(APP_MAP)
478 # NB: this ordering is deliberate (app-clean & bootloader-clean before
479 # _config-clean), so config remains valid during all component clean
480 # targets
481 config-clean: app-clean bootloader-clean
482 clean: app-clean bootloader-clean config-clean
484 # phony target to check if any git submodule listed in COMPONENT_SUBMODULES are missing
485 # or out of date, and exit if so. Components can add paths to this variable.
487 # This only works for components inside IDF_PATH
488 check-submodules:
490 # Dump the git status for the whole working copy once, then grep it for each submodule. This saves a lot of time on Windows.
491 GIT_STATUS := $(shell cd ${IDF_PATH} && git status --porcelain --ignore-submodules=dirty)
493 # Generate a target to check this submodule
494 # $(1) - submodule directory, relative to IDF_PATH
495 define GenerateSubmoduleCheckTarget
496 check-submodules: $(IDF_PATH)/$(1)/.git
497 $(IDF_PATH)/$(1)/.git:
498 @echo "WARNING: Missing submodule $(1)..."
499 [ -e ${IDF_PATH}/.git ] || ( echo "ERROR: esp-idf must be cloned from git to work."; exit 1)
500 [ -x $$(which git) ] || ( echo "ERROR: Need to run 'git submodule init $(1)' in esp-idf root directory."; exit 1)
501 @echo "Attempting 'git submodule update --init $(1)' in esp-idf root directory..."
502 cd ${IDF_PATH} && git submodule update --init $(1)
504 # Parse 'git status' output to check if the submodule commit is different to expected
505 ifneq ("$(filter $(1),$(GIT_STATUS))","")
506 $$(info WARNING: esp-idf git submodule $(1) may be out of date. Run 'git submodule update' in IDF_PATH dir to update.)
507 endif
508 endef
510 # filter/subst in expression ensures all submodule paths begin with $(IDF_PATH), and then strips that prefix
511 # so the argument is suitable for use with 'git submodule' commands
512 $(foreach submodule,$(subst $(IDF_PATH)/,,$(filter $(IDF_PATH)/%,$(COMPONENT_SUBMODULES))),$(eval $(call GenerateSubmoduleCheckTarget,$(submodule))))
515 # PHONY target to list components in the build and their paths
516 list-components:
517 $(info $(call dequote,$(SEPARATOR)))
518 $(info COMPONENT_DIRS (components searched for here))
519 $(foreach cd,$(COMPONENT_DIRS),$(info $(cd)))
520 $(info $(call dequote,$(SEPARATOR)))
521 $(info COMPONENTS (list of component names))
522 $(info $(COMPONENTS))
523 $(info $(call dequote,$(SEPARATOR)))
524 $(info COMPONENT_PATHS (paths to all components):)
525 $(foreach cp,$(COMPONENT_PATHS),$(info $(cp)))
527 # print flash command, so users can dump this to config files and download somewhere without idf
528 print_flash_cmd:
529 echo $(ESPTOOL_WRITE_FLASH_OPTIONS) $(ESPTOOL_ALL_FLASH_ARGS) | sed -e 's:'$(PWD)/build/'::g'
531 # Check toolchain version using the output of xtensa-esp32-elf-gcc --version command.
532 # The output normally looks as follows
533 # xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-59-ga194053) 4.8.5
534 # The part in brackets is extracted into TOOLCHAIN_COMMIT_DESC variable,
535 # the part after the brackets is extracted into TOOLCHAIN_GCC_VER.
536 ifdef CONFIG_TOOLPREFIX
537 ifndef MAKE_RESTARTS
538 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')
539 TOOLCHAIN_GCC_VER := $(shell $(CC) --version | sed -E -n 's|xtensa-esp32-elf-gcc.*\ \(.*\)\ (.*)|\1|gp')
541 # Officially supported version(s)
542 SUPPORTED_TOOLCHAIN_COMMIT_DESC := 1.22.0-80-g6c4433a
543 SUPPORTED_TOOLCHAIN_GCC_VERSIONS := 5.2.0
545 ifdef TOOLCHAIN_COMMIT_DESC
546 ifneq ($(TOOLCHAIN_COMMIT_DESC), $(SUPPORTED_TOOLCHAIN_COMMIT_DESC))
547 $(info WARNING: Toolchain version is not supported: $(TOOLCHAIN_COMMIT_DESC))
548 $(info Expected to see version: $(SUPPORTED_TOOLCHAIN_COMMIT_DESC))
549 $(info Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.)
550 endif
551 ifeq (,$(findstring $(TOOLCHAIN_GCC_VER), $(SUPPORTED_TOOLCHAIN_GCC_VERSIONS)))
552 $(info WARNING: Compiler version is not supported: $(TOOLCHAIN_GCC_VER))
553 $(info Expected to see version(s): $(SUPPORTED_TOOLCHAIN_GCC_VERSIONS))
554 $(info Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.)
555 endif
556 else
557 $(info WARNING: Failed to find Xtensa toolchain, may need to alter PATH or set one in the configuration menu)
558 endif # TOOLCHAIN_COMMIT_DESC
560 endif #MAKE_RESTARTS
561 endif #CONFIG_TOOLPREFIX