]> granicus.if.org Git - esp-idf/commitdiff
build system: Fix out-of-tree building via BUILD_DIR_BASE
authorAngus Gratton <angus@espressif.com>
Tue, 4 Oct 2016 04:03:48 +0000 (15:03 +1100)
committerAngus Gratton <angus@espressif.com>
Tue, 4 Oct 2016 04:04:56 +0000 (15:04 +1100)
Closes #38

components/bootloader/Makefile.projbuild
components/esp32/component.mk
make/common.mk
make/project.mk
make/project_config.mk

index d45cf144e7270a56f78d514216d0761e0f6928cf..7c5cde3b8cdae039cfa114987314b000aef5420c 100644 (file)
@@ -14,17 +14,18 @@ BOOTLOADER_COMPONENT_PATH := $(COMPONENT_PATH)
 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
 
@@ -43,7 +44,8 @@ $(COMPONENT_PATH)/src/sdkconfig: $(PROJECT_PATH)/sdkconfig
 
 # 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 
index 6eac77afd307582cba66cf532821ec2ab4bb1403..85040d77a0ea8e10d1277b732f6d30cde8c61b82 100644 (file)
@@ -6,7 +6,7 @@
 # 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
 
@@ -44,6 +44,8 @@ $(COMPONENT_LIBRARY): $(ALL_LIB_FILES)
 # 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 $@
 
index a515584a9b72c7f93b96055d420376a7841b471e..b2917d5c96c62d08507fb2b48a1ac0cad6004db9 100644 (file)
@@ -6,7 +6,7 @@
 #
 # (Note that we only rebuild auto.conf automatically for some targets,
 # see project_config.mk for details.)
--include $(PROJECT_PATH)/build/include/config/auto.conf
+-include $(BUILD_DIR_BASE)/include/config/auto.conf
 
 #Handling of V=1/VERBOSE=1 flag
 #
index 35dccaf24833862b249814754e5c5d84d4f21eee..74943334a677557dcdd3b1227875c99dea4b122a 100644 (file)
@@ -50,6 +50,7 @@ endif
 #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.
@@ -105,7 +106,7 @@ COMPONENT_INCLUDES := $(abspath $(foreach comp,$(COMPONENT_PATHS_BUILDABLE),$(ad
        $(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
index d2909bb308ebd8c0be9a5aa6308f5f2b559654dd..92937e8bfea88f0fcec4bb0c1dfba676554159ea 100644 (file)
@@ -13,13 +13,15 @@ $(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf:
        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.
@@ -28,17 +30,13 @@ endif
 
 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)
@@ -46,19 +44,15 @@ ifneq ("$(MAKECMDGOALS)","")
 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(!)
@@ -68,4 +62,4 @@ clean: config-clean
 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