BOOTLOADER_BUILD_DIR=$(BUILD_DIR_BASE)/bootloader
BOOTLOADER_BIN=$(BOOTLOADER_BUILD_DIR)/bootloader.bin
+# Custom recursive make for bootloader sub-project
+BOOTLOADER_MAKE=$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
+ MAKEFLAGS= V=$(V) \
+ BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
+
.PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
$(BOOTLOADER_BIN): $(COMPONENT_PATH)/src/sdkconfig
- $(Q) PROJECT_PATH= \
- BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
- $(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src MAKEFLAGS= V=$(V) TARGET_BIN_LAYOUT="$(BOOTLOADER_TARGET_BIN_LAYOUT)" $(BOOTLOADER_BIN)
+ $(Q) $(BOOTLOADER_MAKE) $@
bootloader-clean:
- $(Q) PROJECT_PATH= \
- BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
- $(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src app-clean MAKEFLAGS= V=$(V)
+ $(Q) $(BOOTLOADER_MAKE) app-clean
clean: bootloader-clean
# bootloader-flash calls flash in the bootloader dummy project
bootloader-flash: $(BOOTLOADER_BIN)
- $(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src flash MAKEFLAGS= V=$(V)
+ $(BOOTLOADER_MAKE) flash
+
else
CFLAGS += -D BOOTLOADER_BUILD=1 -I $(IDF_PATH)/components/esp32/include
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
# please read the esp-idf build system document if you need to do this.
#
--include $(PROJECT_PATH)/build/include/config/auto.conf
+-include $(BUILD_DIR_BASE)/include/config/auto.conf
COMPONENT_SRCDIRS := . hwcrypto
# saves us from having to add the target to a Makefile.projbuild
$(COMPONENT_LIBRARY): esp32_out.ld
+# .. is BUILD_DIR_BASE here, as component makefiles
+# are evaluated with CWD=component build dir
esp32_out.ld: $(COMPONENT_PATH)/ld/esp32.ld ../include/sdkconfig.h
$(CC) -I ../include -C -P -x c -E $< -o $@
#The directory where we put all objects/libraries/binaries. The project Makefile can
#configure this if needed.
BUILD_DIR_BASE ?= $(PROJECT_PATH)/build
+export BUILD_DIR_BASE
#Component directories. These directories are searched for components.
#The project Makefile can override these component dirs, or define extra component directories.
$(call GetVariable,$(comp),COMPONENT_ADD_INCLUDEDIRS))))
#Also add project include path, for sdk includes
-COMPONENT_INCLUDES += $(PROJECT_PATH)/build/include/
+COMPONENT_INCLUDES += $(BUILD_DIR_BASE)/include/
export COMPONENT_INCLUDES
#COMPONENT_LDFLAGS has a list of all flags that are needed to link the components together. It's collected
CC=$(HOSTCC) LD=$(HOSTLD) \
$(MAKE) -C $(KCONFIG_TOOL_DIR)
-menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
- $(summary) MENUCONFIG
- $(Q) KCONFIG_AUTOHEADER=$(PROJECT_PATH)/build/include/sdkconfig.h \
+# use a wrapper environment for where we run Kconfig tools
+KCONFIG_TOOL_ENV=KCONFIG_AUTOHEADER=$(BUILD_DIR_BASE)/include/sdkconfig.h \
KCONFIG_CONFIG=$(PROJECT_PATH)/sdkconfig \
COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" \
- COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
- $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
+ COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)"
+
+menuconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
+ $(summary) MENUCONFIG
+ $(Q) $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig
ifeq ("$(wildcard $(PROJECT_PATH)/sdkconfig)","")
#No sdkconfig found. Need to run menuconfig to make this if we need it.
defconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
$(summary) DEFCONFIG
- $(Q) mkdir -p $(PROJECT_PATH)/build/include/config
- $(Q) KCONFIG_AUTOHEADER=$(PROJECT_PATH)/build/include/sdkconfig.h \
- KCONFIG_CONFIG=$(PROJECT_PATH)/sdkconfig \
- COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" \
- COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
- $(KCONFIG_TOOL_DIR)/conf --olddefconfig $(IDF_PATH)/Kconfig
+ $(Q) mkdir -p $(BUILD_DIR_BASE)/include/config
+ $(Q) $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --olddefconfig $(IDF_PATH)/Kconfig
# Work out of whether we have to build the Kconfig makefile
# (auto.conf), or if we're in a situation where we don't need it
NON_CONFIG_TARGETS := clean %-clean get_variable help menuconfig defconfig
-AUTO_CONF_REGEN_TARGET := $(PROJECT_PATH)/build/include/config/auto.conf
+AUTO_CONF_REGEN_TARGET := $(BUILD_DIR_BASE)/include/config/auto.conf
# disable AUTO_CONF_REGEN_TARGET if all targets are non-config targets
# (and not building default target)
ifeq ($(filter $(NON_CONFIG_TARGETS), $(MAKECMDGOALS)),$(MAKECMDGOALS))
AUTO_CONF_REGEN_TARGET :=
# dummy target
-$(PROJECT_PATH)/build/include/config/auto.conf:
+$(BUILD_DIR_BASE)/include/config/auto.conf:
endif
endif
-$(AUTO_CONF_REGEN_TARGET) $(PROJECT_PATH)/build/include/sdkconfig.h: $(PROJECT_PATH)/sdkconfig $(KCONFIG_TOOL_DIR)/conf $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD)
+$(AUTO_CONF_REGEN_TARGET) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(PROJECT_PATH)/sdkconfig $(KCONFIG_TOOL_DIR)/conf $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD)
$(summary) GENCONFIG
- $(Q) mkdir -p $(PROJECT_PATH)/build/include/config
- $(Q) cd build; KCONFIG_AUTOHEADER="$(PROJECT_PATH)/build/include/sdkconfig.h" \
- KCONFIG_CONFIG=$(PROJECT_PATH)/sdkconfig \
- COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" \
- COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \
- $(KCONFIG_TOOL_DIR)/conf --silentoldconfig $(IDF_PATH)/Kconfig
- $(Q) touch $(AUTO_CONF_REGEN_TARGET) $(PROJECT_PATH)/build/include/sdkconfig.h
+ $(Q) mkdir -p $(BUILD_DIR_BASE)/include/config
+ $(Q) cd $(BUILD_DIR_BASE); $(KCONFIG_TOOL_ENV) $(KCONFIG_TOOL_DIR)/conf --silentoldconfig $(IDF_PATH)/Kconfig
+ $(Q) touch $(AUTO_CONF_REGEN_TARGET) $(BUILD_DIR_BASE)/include/sdkconfig.h
# touch to ensure both output files are newer - as 'conf' can also update sdkconfig (a dependency). Without this,
# sometimes you can get an infinite make loop on Windows where sdkconfig always gets regenerated newer
# than the target(!)
config-clean:
$(summary RM CONFIG)
$(MAKE) -C $(KCONFIG_TOOL_DIR) clean
- $(Q) rm -rf $(PROJECT_PATH)/build/include/config $(PROJECT_PATH)/build/include/sdkconfig.h
+ $(Q) rm -rf $(BUILD_DIR_BASE)/include/config $(BUILD_DIR_BASE)/include/sdkconfig.h