This works because all CONFIG variables are exported into child make processes.
BOOTLOADER_COMPONENT_PATH := $(COMPONENT_PATH)
BOOTLOADER_BUILD_DIR=$(abspath $(BUILD_DIR_BASE)/bootloader)
BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
-BOOTLOADER_SDKCONFIG=$(BOOTLOADER_BUILD_DIR)/sdkconfig
# Custom recursive make for bootloader sub-project
BOOTLOADER_MAKE=+$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
- V=$(V) SDKCONFIG=$(BOOTLOADER_SDKCONFIG) \
- BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
+ V=$(V) BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
.PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
-$(BOOTLOADER_BIN): | $(BOOTLOADER_BUILD_DIR)/sdkconfig
+$(BOOTLOADER_BIN):
$(Q) $(BOOTLOADER_MAKE) $@
bootloader-clean:
- $(Q) $(BOOTLOADER_MAKE) app-clean config-clean
- $(Q) rm -f $(BOOTLOADER_SDKCONFIG) $(BOOTLOADER_SDKCONFIG).old
+ $(Q) $(BOOTLOADER_MAKE) app-clean
clean: bootloader-clean
bootloader-flash: $(BOOTLOADER_BIN)
$(ESPTOOLPY_WRITE_FLASH) 0x1000 $^
-# synchronise the project level config to the bootloader's
-# config
-$(BOOTLOADER_SDKCONFIG): $(PROJECT_PATH)/sdkconfig | $(BOOTLOADER_BUILD_DIR)
- $(Q) cp $< $@
-
$(BOOTLOADER_BUILD_DIR):
$(Q) mkdir -p $@
else
-CFLAGS += -D BOOTLOADER_BUILD=1 -I $(IDF_PATH)/components/esp32/include
+CFLAGS += -D BOOTLOADER_BUILD=1 -I $(IDF_PATH)/components/esp32/include
endif
#
PROJECT_NAME := bootloader
+
+#We cannot include the esp32 component directly but we need its includes.
+#This is fixed by adding CFLAGS from Makefile.projbuild
COMPONENTS := esptool_py bootloader log spi_flash
# The bootloader pseudo-component is also included in this build, for its Kconfig.projbuild to be included.
IS_BOOTLOADER_BUILD := 1
export IS_BOOTLOADER_BUILD
-#We cannot include the esp32 component directly but we need its includes.
-#This is fixed by adding CFLAGS from Makefile.projbuild
+# include the top-level "project" include directory, for sdkconfig.h
+CFLAGS += -I$(BUILD_DIR_BASE)/../include
include $(IDF_PATH)/make/project.mk
# project.mk evaluates dependencies before calling down to here. See
# GenerateProjectVarsTarget in project.mk.
component_project_vars.mk::
- $(details) "Rebuilding component project variables list $(abspath $@)"
+ $(details) "Building component project variables list $(abspath $@)"
@echo "# Automatically generated build file. Do not edit." > $@
@echo "COMPONENT_INCLUDES += $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS))" >> $@
@echo "COMPONENT_LDFLAGS += $(COMPONENT_ADD_LDFLAGS)" >> $@
BUILD_DIR_BASE ?= $(PROJECT_PATH)/build
export BUILD_DIR_BASE
+ifndef IS_BOOTLOADER_BUILD
# Include project config file, if it exists.
+# (bootloader build doesn't need this, config is exported from top-level)
#
# (Note that we only rebuild auto.conf automatically for some targets,
# see project_config.mk for details.)
+#
SDKCONFIG_MAKEFILE := $(BUILD_DIR_BASE)/include/config/auto.conf
-include $(SDKCONFIG_MAKEFILE)
export $(filter CONFIG_%,$(.VARIABLES))
+endif
#Component directories. These directories are searched for components.
#The project Makefile can override these component dirs, or define extra component directories.
#
# Rebuilds if component.mk, makefiles or sdkconfig changes.
define GenerateProjectVarsTarget
-$(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(if $(MAKE_RESTARTS),,$(SDKCONFIG_MAKEFILE)) $(BUILD_DIR_BASE)/$(2)
+$(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(SDKCONFIG) | $(BUILD_DIR_BASE)/$(2)
$(Q) +$(MAKE) -C $(BUILD_DIR_BASE)/$(2) -f $(1)/component.mk component_project_vars.mk COMPONENT_PATH=$(1)
endef
$(foreach comp,$(COMPONENT_PATHS_BUILDABLE), $(eval $(call GenerateProjectVarsTarget,$(comp),$(notdir $(comp)))))
endef
$(foreach componentpath,$(COMPONENT_PATHS),$(eval $(call includeProjBuildMakefile,$(componentpath))))
+ifndef IS_BOOTLOADER_BUILD
# once we know component paths, we can include the config generation targets
+#
+# (bootloader build doesn't need this, config is exported from top-level)
include $(IDF_PATH)/make/project_config.mk
+endif
# A "component" library is any library in the LDFLAGS where
# the name of the library is also a name of the component