build system: Refactor component.mk to not need component_common.mk
New makefile component_wrapper.mk allows some variables to be set before component.mk is evaluated. This properly fixes problems with sdkconfig being hard to access in all phases of the build. Including component_common.mk is no longer necessary and will print a deprecation warning for components which use it.
This commit is contained in:
parent
f1938a909a
commit
208e83def7
31 changed files with 261 additions and 285 deletions
|
@ -20,7 +20,7 @@ BOOTLOADER_MAKE=+$(MAKE) -C $(BOOTLOADER_COMPONENT_PATH)/src \
|
||||||
|
|
||||||
.PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
|
.PHONY: bootloader-clean bootloader-flash bootloader $(BOOTLOADER_BIN)
|
||||||
|
|
||||||
$(BOOTLOADER_BIN):
|
$(BOOTLOADER_BIN): $(SDKCONFIG_MAKEFILE)
|
||||||
$(Q) $(BOOTLOADER_MAKE) $@
|
$(Q) $(BOOTLOADER_MAKE) $@
|
||||||
|
|
||||||
bootloader-clean:
|
bootloader-clean:
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
#
|
#
|
||||||
# Main Makefile. This is basically the same as a component makefile.
|
# Main bootloader Makefile.
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(IDF_PATH)/make/component_common.mk. By default,
|
# This is basically the same as a component makefile, but in the case of the bootloader
|
||||||
# this will take the sources in the src/ directory, compile them and link them into
|
# we pull in bootloader-specific linker arguments.
|
||||||
# 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.
|
|
||||||
#
|
#
|
||||||
|
|
||||||
COMPONENT_ADD_LDFLAGS := -L $(COMPONENT_PATH) -lmain -T esp32.bootloader.ld -T $(IDF_PATH)/components/esp32/ld/esp32.rom.ld
|
COMPONENT_ADD_LDFLAGS := -L $(COMPONENT_PATH) -lmain -T esp32.bootloader.ld -T $(IDF_PATH)/components/esp32/ld/esp32.rom.ld
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -12,8 +12,6 @@ COMPONENT_ADD_LDFLAGS := -lbt -L $(COMPONENT_PATH)/lib \
|
||||||
$(addprefix -l,$(LIBS)) \
|
$(addprefix -l,$(LIBS)) \
|
||||||
$(LINKER_SCRIPTS)
|
$(LINKER_SCRIPTS)
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
||||||
ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
|
ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
|
||||||
$(COMPONENT_LIBRARY): $(ALL_LIB_FILES)
|
$(COMPONENT_LIBRARY): $(ALL_LIB_FILES)
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
#
|
#
|
||||||
# Component Makefile
|
# Component Makefile
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/make/component.mk. By default,
|
|
||||||
# this will take the sources in this directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the SDK documents if you need to do this.
|
|
||||||
#
|
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := include
|
COMPONENT_ADD_INCLUDEDIRS := include
|
||||||
|
|
||||||
COMPONENT_PRIV_INCLUDEDIRS := include/driver
|
COMPONENT_PRIV_INCLUDEDIRS := include/driver
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
#
|
#
|
||||||
# Component Makefile
|
# Component Makefile
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(IDF_PATH)/make/component_common.mk. By default,
|
|
||||||
# this will take the sources in this directory, compile them and link them into
|
|
||||||
# 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 include/config/auto.conf
|
|
||||||
|
|
||||||
COMPONENT_SRCDIRS := . hwcrypto
|
COMPONENT_SRCDIRS := . hwcrypto
|
||||||
|
|
||||||
|
@ -21,8 +15,6 @@ COMPONENT_ADD_LDFLAGS := -lesp32 \
|
||||||
-L $(COMPONENT_PATH)/ld \
|
-L $(COMPONENT_PATH)/ld \
|
||||||
$(LINKER_SCRIPTS)
|
$(LINKER_SCRIPTS)
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
||||||
ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
|
ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS))
|
||||||
|
|
||||||
# automatically trigger a git submodule update
|
# automatically trigger a git submodule update
|
||||||
|
@ -44,8 +36,6 @@ $(COMPONENT_LIBRARY): $(ALL_LIB_FILES)
|
||||||
# saves us from having to add the target to a Makefile.projbuild
|
# saves us from having to add the target to a Makefile.projbuild
|
||||||
$(COMPONENT_LIBRARY): esp32_out.ld
|
$(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
|
esp32_out.ld: $(COMPONENT_PATH)/ld/esp32.ld ../include/sdkconfig.h
|
||||||
$(CC) -I ../include -C -P -x c -E $< -o $@
|
$(CC) -I ../include -C -P -x c -E $< -o $@
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
#
|
#
|
||||||
# Component Makefile
|
# Component Makefile
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/Makefile. By default,
|
|
||||||
# this will take the sources in this directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the SDK documents if you need to do this.
|
|
||||||
#
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := port/include include/expat
|
COMPONENT_ADD_INCLUDEDIRS := port/include include/expat
|
||||||
|
|
||||||
COMPONENT_SRCDIRS := library port
|
COMPONENT_SRCDIRS := library port
|
||||||
|
|
||||||
CFLAGS += -Wno-unused-function -DHAVE_EXPAT_CONFIG_H
|
CFLAGS += -Wno-unused-function -DHAVE_EXPAT_CONFIG_H
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -6,4 +6,3 @@ COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME) -Wl,--undefined=uxTopUsedPriority
|
||||||
COMPONENT_ADD_INCLUDEDIRS := include
|
COMPONENT_ADD_INCLUDEDIRS := include
|
||||||
COMPONENT_PRIV_INCLUDEDIRS := include/freertos
|
COMPONENT_PRIV_INCLUDEDIRS := include/freertos
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
#
|
#
|
||||||
# Component Makefile
|
# Component Makefile
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/Makefile. By default,
|
|
||||||
# this will take the sources in this directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the SDK documents if you need to do this.
|
|
||||||
#
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := include port/include
|
COMPONENT_ADD_INCLUDEDIRS := include port/include
|
||||||
|
|
||||||
COMPONENT_SRCDIRS := library port
|
COMPONENT_SRCDIRS := library port
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
COMPONENT_ADD_INCLUDEDIRS := include
|
#
|
||||||
|
# Component Makefile
|
||||||
|
#
|
||||||
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -8,4 +8,3 @@ COMPONENT_SRCDIRS := api apps/sntp apps core/ipv4 core/ipv6 core netif port/free
|
||||||
|
|
||||||
CFLAGS += -Wno-address -Wno-unused-variable -Wno-unused-but-set-variable
|
CFLAGS += -Wno-address -Wno-unused-variable -Wno-unused-but-set-variable
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -6,4 +6,3 @@ COMPONENT_ADD_INCLUDEDIRS := port/include include
|
||||||
|
|
||||||
COMPONENT_SRCDIRS := library port
|
COMPONENT_SRCDIRS := library port
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -2,4 +2,3 @@ COMPONENT_ADD_LDFLAGS := $(COMPONENT_PATH)/lib/libc.a $(COMPONENT_PATH)/lib/libm
|
||||||
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS := include platform_include
|
COMPONENT_ADD_INCLUDEDIRS := include platform_include
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -5,5 +5,3 @@
|
||||||
COMPONENT_ADD_INCLUDEDIRS := port/include include
|
COMPONENT_ADD_INCLUDEDIRS := port/include include
|
||||||
|
|
||||||
COMPONENT_SRCDIRS := library port
|
COMPONENT_SRCDIRS := library port
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
|
@ -6,4 +6,3 @@ COMPONENT_ADD_INCLUDEDIRS := include
|
||||||
|
|
||||||
COMPONENT_SRCDIRS := src
|
COMPONENT_SRCDIRS := src
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -7,4 +7,3 @@ COMPONENT_PRIV_INCLUDEDIRS := include/internal include/platform include/openssl
|
||||||
|
|
||||||
COMPONENT_SRCDIRS := library platform
|
COMPONENT_SRCDIRS := library platform
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -5,4 +5,3 @@ ifdef IS_BOOTLOADER_BUILD
|
||||||
COMPONENT_OBJS := spi_flash_rom_patch.o
|
COMPONENT_OBJS := spi_flash_rom_patch.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Component Makefile
|
# Component Makefile
|
||||||
#
|
#
|
||||||
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
#
|
||||||
|
# Component Makefile
|
||||||
|
#
|
||||||
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,3 @@ COMPONENT_ADD_INCLUDEDIRS := include port/include
|
||||||
COMPONENT_SRCDIRS := src/crypto
|
COMPONENT_SRCDIRS := src/crypto
|
||||||
|
|
||||||
CFLAGS += -DEMBEDDED_SUPP -D__ets__ -Wno-strict-aliasing
|
CFLAGS += -DEMBEDDED_SUPP -D__ets__ -Wno-strict-aliasing
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#
|
#
|
||||||
# Component Makefile
|
# Component Makefile
|
||||||
#
|
#
|
||||||
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
#
|
#
|
||||||
# Main Makefile. This is basically the same as a component makefile.
|
# Main Makefile. This is basically the same as a component makefile.
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
# this will take the sources in the src/ directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the ESP-IDF documents if you need to do this.
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
#
|
#
|
||||||
# Main Makefile. This is basically the same as a component makefile.
|
# Main Makefile. This is basically the same as a component makefile.
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
# this will take the sources in the src/ directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the ESP-IDF documents if you need to do this.
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
#
|
#
|
||||||
# Main Makefile. This is basically the same as a component makefile.
|
# Main Makefile. This is basically the same as a component makefile.
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
# this will take the sources in the src/ directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the ESP-IDF documents if you need to do this.
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
#
|
#
|
||||||
# Main Makefile. This is basically the same as a component makefile.
|
# Main Makefile. This is basically the same as a component makefile.
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
# this will take the sources in the src/ directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the ESP-IDF documents if you need to do this.
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
#
|
#
|
||||||
# Main Makefile. This is basically the same as a component makefile.
|
# Main Makefile. This is basically the same as a component makefile.
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
# this will take the sources in the src/ directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the ESP-IDF documents if you need to do this.
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
#
|
#
|
||||||
# Main Makefile. This is basically the same as a component makefile.
|
# Main Makefile. This is basically the same as a component makefile.
|
||||||
#
|
#
|
||||||
# This Makefile should, at the very least, just include $(SDK_PATH)/make/component_common.mk. By default,
|
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||||
# this will take the sources in the src/ directory, compile them and link them into
|
|
||||||
# lib(subdirectory_name).a in the build directory. This behaviour is entirely configurable,
|
|
||||||
# please read the ESP-IDF documents if you need to do this.
|
|
||||||
#
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/component_common.mk
|
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
# Functionality common to both top-level project makefile
|
# Functionality common to both top-level project makefile (project.mk)
|
||||||
# and component makefiles
|
# and component makefiles (component_wrapper.mk)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Include project config makefile, if it exists.
|
||||||
|
#
|
||||||
|
# (Note that we only rebuild this makefile automatically for some
|
||||||
|
# targets, see project_config.mk for details.)
|
||||||
|
SDKCONFIG_MAKEFILE ?= $(abspath $(BUILD_DIR_BASE)/include/config/auto.conf)
|
||||||
|
-include $(SDKCONFIG_MAKEFILE)
|
||||||
|
export SDKCONFIG_MAKEFILE # sub-makes (like bootloader) will reuse this path
|
||||||
|
|
||||||
#Handling of V=1/VERBOSE=1 flag
|
#Handling of V=1/VERBOSE=1 flag
|
||||||
#
|
#
|
||||||
# if V=1, $(summary) does nothing and $(details) will echo extra details
|
# if V=1, $(summary) does nothing and $(details) will echo extra details
|
||||||
|
|
|
@ -1,135 +1,3 @@
|
||||||
# Component common makefile
|
$(warning Deprecated feature: It is no longer necessary to include component_common.mk.)
|
||||||
#
|
$(warning The line "include $$(IDF_PATH)/make/component_common.mk" can be removed from component.mk files.)
|
||||||
# This Makefile gets included in the Makefile of all the components to set the correct include paths etc.
|
|
||||||
# PWD is the build directory of the component and the top Makefile is the one in the
|
|
||||||
# component source dir.
|
|
||||||
#
|
|
||||||
# The way the Makefile differentiates between those two is by looking at the environment
|
|
||||||
# variable PROJECT_PATH. If this is set (to the basepath of the project), we're building a
|
|
||||||
# component and its Makefile has included this makefile. If not, we're building the entire project.
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# This Makefile requires the environment variable IDF_PATH to be set
|
|
||||||
# to the top-level directory where ESP-IDF is located (the directory
|
|
||||||
# containing this 'make' directory).
|
|
||||||
#
|
|
||||||
|
|
||||||
ifeq ("$(PROJECT_PATH)","")
|
|
||||||
$(error Make was invoked from $(CURDIR). However please do not run make from the sdk or a component directory; invoke make from the project directory. See the ESP-IDF README for details.)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Find the path to the component
|
|
||||||
COMPONENT_PATH := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
|
|
||||||
export COMPONENT_PATH
|
|
||||||
|
|
||||||
include $(IDF_PATH)/make/common.mk
|
|
||||||
|
|
||||||
#Some of these options are overridable by the component's component.mk Makefile
|
|
||||||
|
|
||||||
#Name of the component
|
|
||||||
COMPONENT_NAME ?= $(lastword $(subst /, ,$(realpath $(COMPONENT_PATH))))
|
|
||||||
|
|
||||||
#Absolute path of the .a file
|
|
||||||
COMPONENT_LIBRARY := lib$(COMPONENT_NAME).a
|
|
||||||
|
|
||||||
#Source dirs a component has. Default to root directory of component.
|
|
||||||
COMPONENT_SRCDIRS ?= .
|
|
||||||
|
|
||||||
#Object files which need to be linked into the library
|
|
||||||
#By default we take all .c/.S files in the component directory.
|
|
||||||
ifeq ("$(COMPONENT_OBJS)", "")
|
|
||||||
#Find all source files in all COMPONENT_SRCDIRS
|
|
||||||
COMPONENT_OBJS := $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.c,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.c)))
|
|
||||||
COMPONENT_OBJS += $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.cpp,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.cpp)))
|
|
||||||
COMPONENT_OBJS += $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.S,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.S)))
|
|
||||||
#Make relative by removing COMPONENT_PATH from all found object paths
|
|
||||||
COMPONENT_OBJS := $(patsubst $(COMPONENT_PATH)/%,%,$(COMPONENT_OBJS))
|
|
||||||
endif
|
|
||||||
|
|
||||||
#By default, include only the include/ dir.
|
|
||||||
COMPONENT_ADD_INCLUDEDIRS ?= include
|
|
||||||
COMPONENT_ADD_LDFLAGS ?= -l$(COMPONENT_NAME)
|
|
||||||
|
|
||||||
#If we're called to compile something, we'll get passed the COMPONENT_INCLUDES
|
|
||||||
#variable with all the include dirs from all the components in random order. This
|
|
||||||
#means we can accidentally grab a header from another component before grabbing our own.
|
|
||||||
#To make sure that does not happen, re-order the includes so ours come first.
|
|
||||||
OWN_INCLUDES:=$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS) $(COMPONENT_PRIV_INCLUDEDIRS)))
|
|
||||||
COMPONENT_INCLUDES := $(OWN_INCLUDES) $(filter-out $(OWN_INCLUDES),$(COMPONENT_INCLUDES))
|
|
||||||
|
|
||||||
# macro to generate relative paths inside component_project_vars.mk, whenever possible
|
|
||||||
# ie put literal $(IDF_PATH), $(PROJECT_PATH) and $(BUILD_DIR_BASE) into the generated
|
|
||||||
# makefiles where possible.
|
|
||||||
#
|
|
||||||
# This means if directories move (breaking absolute paths), don't need to 'make clean'
|
|
||||||
define MakeRelativePath
|
|
||||||
$(subst $(IDF_PATH),$$(IDF_PATH),$(subst $(PROJECT_PATH),$$(PROJECT_PATH),$(subst $(BUILD_DIR_BASE),\$$(BUILD_DIR_BASE),$(1))))
|
|
||||||
endef
|
|
||||||
|
|
||||||
# This target generates component_project_vars.mk for the
|
|
||||||
# component. This is used to take component.mk variables
|
|
||||||
# COMPONENT_ADD_INCLUDEDIRS, COMPONENT_ADD_LDFLAGS and
|
|
||||||
# COMPONENT_DEPENDS and inject those into the project makefile.
|
|
||||||
#
|
|
||||||
# The target here has no dependencies, as the parent target in
|
|
||||||
# project.mk evaluates dependencies before calling down to here. See
|
|
||||||
# GenerateComponentTargets macro in project.mk.
|
|
||||||
#
|
|
||||||
# If you are thinking of editing the output of this makefile for a
|
|
||||||
# component-specific feature, please don't! What you want is a
|
|
||||||
# Makefile.projbuild for your component (see docs/build-system.rst for more.)
|
|
||||||
component_project_vars.mk::
|
|
||||||
$(details) "Building component project variables list $(abspath $@)"
|
|
||||||
@echo '# Automatically generated build file. Do not edit.' > $@
|
|
||||||
@echo 'COMPONENT_INCLUDES += $(call MakeRelativePath,$(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS)))' >> $@
|
|
||||||
@echo 'COMPONENT_LDFLAGS += $(call MakeRelativePath,$(COMPONENT_ADD_LDFLAGS))' >> $@
|
|
||||||
@echo '$(COMPONENT_NAME)-build: $(addsuffix -build,$(COMPONENT_DEPENDS))' >> $@
|
|
||||||
|
|
||||||
#Targets for build/clean. Use builtin recipe if component Makefile
|
|
||||||
#hasn't defined its own.
|
|
||||||
ifeq ("$(COMPONENT_OWNBUILDTARGET)", "")
|
|
||||||
build: $(COMPONENT_LIBRARY)
|
|
||||||
@mkdir -p $(COMPONENT_SRCDIRS)
|
|
||||||
|
|
||||||
#Build the archive. We remove the archive first, otherwise ar will get confused if we update
|
|
||||||
#an archive when multiple filenames have the same name (src1/test.o and src2/test.o)
|
|
||||||
$(COMPONENT_LIBRARY): $(COMPONENT_OBJS)
|
|
||||||
$(summary) AR $@
|
|
||||||
$(Q) rm -f $@
|
|
||||||
$(Q) $(AR) cru $@ $(COMPONENT_OBJS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
CLEAN_FILES = $(COMPONENT_LIBRARY) $(COMPONENT_OBJS) $(COMPONENT_OBJS:.o=.d) $(COMPONENT_EXTRA_CLEAN) component_project_vars.mk
|
|
||||||
|
|
||||||
ifeq ("$(COMPONENT_OWNCLEANTARGET)", "")
|
|
||||||
clean:
|
|
||||||
$(summary) RM $(CLEAN_FILES)
|
|
||||||
$(Q) rm -f $(CLEAN_FILES)
|
|
||||||
endif
|
|
||||||
|
|
||||||
#Include all dependency files already generated
|
|
||||||
-include $(COMPONENT_OBJS:.o=.d)
|
|
||||||
|
|
||||||
#This pattern is generated for each COMPONENT_SRCDIR to compile the files in it.
|
|
||||||
define GenerateCompileTargets
|
|
||||||
# $(1) - directory containing source files, relative to $(COMPONENT_PATH)
|
|
||||||
$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.c | $(1)
|
|
||||||
$$(summary) CC $$@
|
|
||||||
$$(Q) $$(CC) $$(CFLAGS) $(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
|
|
||||||
|
|
||||||
$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.cpp | $(1)
|
|
||||||
$$(summary) CXX $$@
|
|
||||||
$$(Q) $$(CXX) $$(CXXFLAGS) $(CPPFLAGS) $$(addprefix -I,$$(COMPONENT_INCLUDES)) $$(addprefix -I,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
|
|
||||||
|
|
||||||
$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.S | $(1)
|
|
||||||
$$(summary) AS $$@
|
|
||||||
$$(Q) $$(CC) $$(CFLAGS) $(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
|
|
||||||
|
|
||||||
# CWD is build dir, create the build subdirectory if it doesn't exist
|
|
||||||
$(1):
|
|
||||||
@mkdir -p $(1)
|
|
||||||
endef
|
|
||||||
|
|
||||||
#Generate all the compile target recipes
|
|
||||||
$(foreach srcdir,$(COMPONENT_SRCDIRS), $(eval $(call GenerateCompileTargets,$(srcdir))))
|
|
||||||
|
|
169
make/component_wrapper.mk
Normal file
169
make/component_wrapper.mk
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
# Component wrapper makefile
|
||||||
|
#
|
||||||
|
# This makefile gets called recursively from the project make, once for each component.
|
||||||
|
# COMPONENT_MAKEFILE is set to point at the component.mk file for the component itself,
|
||||||
|
# which is included as part of this process (after default variables are defined).
|
||||||
|
#
|
||||||
|
# This makefile comprises multiple stages, marked in blocked comments below.
|
||||||
|
#
|
||||||
|
# CWD is the build directory of the component.
|
||||||
|
|
||||||
|
ifeq ("$(PROJECT_PATH)","")
|
||||||
|
$(error Make was invoked from $(CURDIR). However please do not run make from the sdk or a component directory; invoke make from the project directory. See the ESP-IDF README for details.)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# 1) Set default variables for the component build (including configuration
|
||||||
|
# loaded from sdkconfig.)
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Find the path to the component
|
||||||
|
COMPONENT_PATH := $(abspath $(dir $(COMPONENT_MAKEFILE)))
|
||||||
|
export COMPONENT_PATH
|
||||||
|
|
||||||
|
# COMPONENT_BUILD_DIR is otherwise known as CWD for the build
|
||||||
|
COMPONENT_BUILD_DIR := $(abspath .)
|
||||||
|
|
||||||
|
# include elements common to both project & component makefiles
|
||||||
|
# (includes project configuration set via menuconfig)
|
||||||
|
include $(IDF_PATH)/make/common.mk
|
||||||
|
|
||||||
|
# Some of the following defaults may be overriden by the component's component.mk makefile,
|
||||||
|
# during the next step:
|
||||||
|
|
||||||
|
# Name of the component
|
||||||
|
COMPONENT_NAME := $(lastword $(subst /, ,$(realpath $(COMPONENT_PATH))))
|
||||||
|
|
||||||
|
# Absolute path of the .a file
|
||||||
|
COMPONENT_LIBRARY = lib$(COMPONENT_NAME).a
|
||||||
|
|
||||||
|
# Source dirs a component has. Default to root directory of component.
|
||||||
|
COMPONENT_SRCDIRS = .
|
||||||
|
|
||||||
|
# By default, include only the include/ dir.
|
||||||
|
COMPONENT_ADD_INCLUDEDIRS = include
|
||||||
|
COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME)
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# 2) Include the component.mk for the specific component (COMPONENT_MAKEFILE) to
|
||||||
|
# override variables & optionally define custom targets.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
include $(COMPONENT_MAKEFILE)
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# 3) Set variables that depend on values that may changed by component.mk
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Object files which need to be linked into the library
|
||||||
|
# By default we take all .c, .cpp & .S files in COMPONENT_SRCDIRS.
|
||||||
|
ifeq ("$(COMPONENT_OBJS)", "")
|
||||||
|
# Find all source files in all COMPONENT_SRCDIRS
|
||||||
|
COMPONENT_OBJS := $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.c,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.c)))
|
||||||
|
COMPONENT_OBJS += $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.cpp,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.cpp)))
|
||||||
|
COMPONENT_OBJS += $(foreach compsrcdir,$(COMPONENT_SRCDIRS),$(patsubst %.S,%.o,$(wildcard $(COMPONENT_PATH)/$(compsrcdir)/*.S)))
|
||||||
|
# Make relative by removing COMPONENT_PATH from all found object paths
|
||||||
|
COMPONENT_OBJS := $(patsubst $(COMPONENT_PATH)/%,%,$(COMPONENT_OBJS))
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If we're called to compile something, we'll get passed the COMPONENT_INCLUDES
|
||||||
|
# variable with all the include dirs from all the components in random order. This
|
||||||
|
# means we can accidentally grab a header from another component before grabbing our own.
|
||||||
|
# To make sure that does not happen, re-order the includes so ours come first.
|
||||||
|
OWN_INCLUDES:=$(abspath $(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS) $(COMPONENT_PRIV_INCLUDEDIRS)))
|
||||||
|
COMPONENT_INCLUDES := $(OWN_INCLUDES) $(filter-out $(OWN_INCLUDES),$(COMPONENT_INCLUDES))
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# 4) Define a target to generate component_project_vars.mk Makefile which
|
||||||
|
# contains common per-component settings which are included directly in the
|
||||||
|
# top-level project make
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# macro to generate variable-relative paths inside component_project_vars.mk, whenever possible
|
||||||
|
# ie put literal $(IDF_PATH), $(PROJECT_PATH) and $(BUILD_DIR_BASE) into the generated
|
||||||
|
# makefiles where possible.
|
||||||
|
#
|
||||||
|
# This means if directories move (breaking absolute paths), don't need to 'make clean'
|
||||||
|
define MakeVariablePath
|
||||||
|
$(subst $(IDF_PATH),$$(IDF_PATH),$(subst $(PROJECT_PATH),$$(PROJECT_PATH),$(subst $(BUILD_DIR_BASE),\$$(BUILD_DIR_BASE),$(1))))
|
||||||
|
endef
|
||||||
|
|
||||||
|
# component_project_vars.mk target for the component. This is used to
|
||||||
|
# take component.mk variables COMPONENT_ADD_INCLUDEDIRS,
|
||||||
|
# COMPONENT_ADD_LDFLAGS and COMPONENT_DEPENDS and inject those into
|
||||||
|
# the project make pass.
|
||||||
|
#
|
||||||
|
# The target here has no dependencies, as the parent target in
|
||||||
|
# project.mk evaluates dependencies before calling down to here. See
|
||||||
|
# GenerateComponentTargets macro in project.mk.
|
||||||
|
#
|
||||||
|
# If you are thinking of editing the output of this target for a
|
||||||
|
# component-specific feature, please don't! What you want is a
|
||||||
|
# Makefile.projbuild for your component (see docs/build-system.rst for
|
||||||
|
# more.)
|
||||||
|
component_project_vars.mk::
|
||||||
|
$(details) "Building component project variables list $(abspath $@)"
|
||||||
|
@echo '# Automatically generated build file. Do not edit.' > $@
|
||||||
|
@echo 'COMPONENT_INCLUDES += $(call MakeVariablePath,$(addprefix $(COMPONENT_PATH)/,$(COMPONENT_ADD_INCLUDEDIRS)))' >> $@
|
||||||
|
@echo 'COMPONENT_LDFLAGS += $(call MakeVariablePath,$(COMPONENT_ADD_LDFLAGS))' >> $@
|
||||||
|
@echo '$(COMPONENT_NAME)-build: $(addsuffix -build,$(COMPONENT_DEPENDS))' >> $@
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# 5) If COMPONENT_OWNBUILDTARGET / COMPONENT_OWNCLEANTARGET is not set by component.mk,
|
||||||
|
# define default build, clean, etc. targets
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# If COMPONENT_OWNBUILDTARGET is not set, define a phony build target and
|
||||||
|
# a COMPONENT_LIBRARY link target.
|
||||||
|
ifeq ("$(COMPONENT_OWNBUILDTARGET)", "")
|
||||||
|
.PHONY: build
|
||||||
|
build: $(COMPONENT_LIBRARY)
|
||||||
|
@mkdir -p $(COMPONENT_SRCDIRS)
|
||||||
|
|
||||||
|
# Build the archive. We remove the archive first, otherwise ar will get confused if we update
|
||||||
|
# an archive when multiple filenames have the same name (src1/test.o and src2/test.o)
|
||||||
|
$(COMPONENT_LIBRARY): $(COMPONENT_OBJS)
|
||||||
|
$(summary) AR $@
|
||||||
|
$(Q) rm -f $@
|
||||||
|
$(Q) $(AR) cru $@ $(COMPONENT_OBJS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If COMPONENT_OWNCLEANTARGET is not set, define a phony clean target
|
||||||
|
ifeq ("$(COMPONENT_OWNCLEANTARGET)", "")
|
||||||
|
CLEAN_FILES = $(COMPONENT_LIBRARY) $(COMPONENT_OBJS) $(COMPONENT_OBJS:.o=.d) $(COMPONENT_EXTRA_CLEAN) component_project_vars.mk
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
$(summary) RM $(CLEAN_FILES)
|
||||||
|
$(Q) rm -f $(CLEAN_FILES)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Include all dependency files already generated
|
||||||
|
-include $(COMPONENT_OBJS:.o=.d)
|
||||||
|
|
||||||
|
# This pattern is generated for each COMPONENT_SRCDIR to compile the files in it.
|
||||||
|
define GenerateCompileTargets
|
||||||
|
# $(1) - directory containing source files, relative to $(COMPONENT_PATH)
|
||||||
|
$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.c | $(1)
|
||||||
|
$$(summary) CC $$@
|
||||||
|
$$(Q) $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
|
||||||
|
|
||||||
|
$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.cpp | $(1)
|
||||||
|
$$(summary) CXX $$@
|
||||||
|
$$(Q) $$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) $$(addprefix -I,$$(COMPONENT_INCLUDES)) $$(addprefix -I,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
|
||||||
|
|
||||||
|
$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.S | $(1)
|
||||||
|
$$(summary) AS $$@
|
||||||
|
$$(Q) $$(CC) $$(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
|
||||||
|
|
||||||
|
# CWD is build dir, create the build subdirectory if it doesn't exist
|
||||||
|
$(1):
|
||||||
|
@mkdir -p $(1)
|
||||||
|
endef
|
||||||
|
|
||||||
|
# Generate all the compile target patterns
|
||||||
|
$(foreach srcdir,$(COMPONENT_SRCDIRS), $(eval $(call GenerateCompileTargets,$(srcdir))))
|
110
make/project.mk
110
make/project.mk
|
@ -48,80 +48,73 @@ PROJECT_PATH := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
|
||||||
export PROJECT_PATH
|
export PROJECT_PATH
|
||||||
endif
|
endif
|
||||||
|
|
||||||
COMMON_MAKEFILES := $(abspath $(IDF_PATH)/make/project.mk $(IDF_PATH)/make/common.mk $(IDF_PATH)/make/component_common.mk)
|
# A list of the "common" makefiles, to use as a target dependency
|
||||||
|
COMMON_MAKEFILES := $(abspath $(IDF_PATH)/make/project.mk $(IDF_PATH)/make/common.mk $(IDF_PATH)/make/component_wrapper.mk)
|
||||||
export COMMON_MAKEFILES
|
export COMMON_MAKEFILES
|
||||||
|
|
||||||
#The directory where we put all objects/libraries/binaries. The project Makefile can
|
# The directory where we put all objects/libraries/binaries. The project Makefile can
|
||||||
#configure this if needed.
|
# configure this if needed.
|
||||||
BUILD_DIR_BASE ?= $(PROJECT_PATH)/build
|
BUILD_DIR_BASE ?= $(PROJECT_PATH)/build
|
||||||
export BUILD_DIR_BASE
|
export BUILD_DIR_BASE
|
||||||
|
|
||||||
ifndef IS_BOOTLOADER_BUILD
|
# Component directories. These directories are searched for components.
|
||||||
# Include project config file, if it exists.
|
# The project Makefile can override these component dirs, or define extra component directories.
|
||||||
# (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.
|
|
||||||
COMPONENT_DIRS ?= $(PROJECT_PATH)/components $(EXTRA_COMPONENT_DIRS) $(IDF_PATH)/components
|
COMPONENT_DIRS ?= $(PROJECT_PATH)/components $(EXTRA_COMPONENT_DIRS) $(IDF_PATH)/components
|
||||||
export COMPONENT_DIRS
|
export COMPONENT_DIRS
|
||||||
|
|
||||||
#The project Makefile can define a list of components, but if it does not do this we just take
|
# Source directories of the project itself (a special, project-specific component.) Defaults to only "main".
|
||||||
#all available components in the component dirs.
|
SRCDIRS ?= main
|
||||||
|
|
||||||
|
# The project Makefile can define a list of components, but if it does not do this we just take
|
||||||
|
# all available components in the component dirs.
|
||||||
ifeq ("$(COMPONENTS)","")
|
ifeq ("$(COMPONENTS)","")
|
||||||
#Find all component names. The component names are the same as the
|
# Find all component names. The component names are the same as the
|
||||||
#directories they're in, so /bla/components/mycomponent/ -> mycomponent. We later use
|
# directories they're in, so /bla/components/mycomponent/ -> mycomponent. We then use
|
||||||
#the COMPONENT_DIRS bit to find back the component path.
|
# COMPONENT_DIRS to build COMPONENT_PATHS with the full path to each component.
|
||||||
COMPONENTS := $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/*))
|
COMPONENTS := $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/*))
|
||||||
COMPONENTS := $(sort $(foreach comp,$(COMPONENTS),$(lastword $(subst /, ,$(comp)))))
|
COMPONENTS := $(sort $(foreach comp,$(COMPONENTS),$(lastword $(subst /, ,$(comp)))))
|
||||||
endif
|
endif
|
||||||
export COMPONENTS
|
export COMPONENTS
|
||||||
|
|
||||||
#Sources default to only "main"
|
# Resolve all of COMPONENTS into absolute paths in COMPONENT_PATHS.
|
||||||
SRCDIRS ?= main
|
#
|
||||||
|
# If a component name exists in multiple COMPONENT_DIRS, we take the first match.
|
||||||
#Here, we resolve and add all the components and source paths into absolute paths.
|
#
|
||||||
#If a component exists in multiple COMPONENT_DIRS, we take the first match.
|
# NOTE: These paths must be generated WITHOUT a trailing / so we
|
||||||
#WARNING: These directories paths must be generated WITHOUT a trailing / so we
|
# can use $(notdir x) to get the component name.
|
||||||
#can use $(notdir x) to get the component name.
|
|
||||||
COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)))))
|
COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp)))))
|
||||||
COMPONENT_PATHS += $(abspath $(SRCDIRS))
|
COMPONENT_PATHS += $(abspath $(SRCDIRS))
|
||||||
|
|
||||||
#A component is buildable if it has a component.mk makefile; we assume that a
|
# A component is buildable if it has a component.mk makefile in it
|
||||||
# 'make -C $(component dir) -f component.mk build' results in a lib$(componentname).a
|
|
||||||
COMPONENT_PATHS_BUILDABLE := $(foreach cp,$(COMPONENT_PATHS),$(if $(wildcard $(cp)/component.mk),$(cp)))
|
COMPONENT_PATHS_BUILDABLE := $(foreach cp,$(COMPONENT_PATHS),$(if $(wildcard $(cp)/component.mk),$(cp)))
|
||||||
|
|
||||||
# Assemble global list of include dirs (COMPONENT_INCLUDES), and
|
# Initialise a project-wide list of include dirs (COMPONENT_INCLUDES),
|
||||||
# LDFLAGS args (COMPONENT_LDFLAGS) supplied by each component.
|
# and LDFLAGS args (COMPONENT_LDFLAGS) supplied by each component.
|
||||||
|
#
|
||||||
|
# These variables are built up via the component_project_vars.mk
|
||||||
|
# generated makefiles (one per component).
|
||||||
COMPONENT_INCLUDES :=
|
COMPONENT_INCLUDES :=
|
||||||
COMPONENT_LDFLAGS :=
|
COMPONENT_LDFLAGS :=
|
||||||
|
|
||||||
# include paths for generated "component project variables" targets with
|
# COMPONENT_PROJECT_VARS is the list of component_project_vars.mk generated makefiles
|
||||||
# COMPONENT_INCLUDES, COMPONENT_LDFLAGS & dependency targets
|
# for each component.
|
||||||
#
|
#
|
||||||
# See component_project_vars.mk target in component_common.mk
|
# Including $(COMPONENT_PROJECT_VARS) builds the COMPONENT_INCLUDES,
|
||||||
|
# COMPONENT_LDFLAGS variables and also targets for any inter-component
|
||||||
|
# dependencies.
|
||||||
|
#
|
||||||
|
# See the component_project_vars.mk target in component_wrapper.mk
|
||||||
COMPONENT_PROJECT_VARS := $(addsuffix /component_project_vars.mk,$(notdir $(COMPONENT_PATHS_BUILDABLE)))
|
COMPONENT_PROJECT_VARS := $(addsuffix /component_project_vars.mk,$(notdir $(COMPONENT_PATHS_BUILDABLE)))
|
||||||
COMPONENT_PROJECT_VARS := $(addprefix $(BUILD_DIR_BASE)/,$(COMPONENT_PROJECT_VARS))
|
COMPONENT_PROJECT_VARS := $(addprefix $(BUILD_DIR_BASE)/,$(COMPONENT_PROJECT_VARS))
|
||||||
include $(COMPONENT_PROJECT_VARS)
|
include $(COMPONENT_PROJECT_VARS)
|
||||||
|
|
||||||
#Also add project include path, for top-level includes
|
# Also add top-level project include path, for top-level includes
|
||||||
COMPONENT_INCLUDES += $(abspath $(BUILD_DIR_BASE)/include/)
|
COMPONENT_INCLUDES += $(abspath $(BUILD_DIR_BASE)/include/)
|
||||||
|
|
||||||
export COMPONENT_INCLUDES
|
export COMPONENT_INCLUDES
|
||||||
export COMPONENT_LDFLAGS
|
|
||||||
|
|
||||||
#Make sure submakes can also use this.
|
# Set variables common to both project & component
|
||||||
export PROJECT_PATH
|
include $(IDF_PATH)/make/common.mk
|
||||||
|
|
||||||
#Include functionality common to both project & component
|
|
||||||
-include $(IDF_PATH)/make/common.mk
|
|
||||||
|
|
||||||
# Set default LDFLAGS
|
# Set default LDFLAGS
|
||||||
|
|
||||||
|
@ -198,15 +191,15 @@ CXXFLAGS := $(strip \
|
||||||
|
|
||||||
export CFLAGS CPPFLAGS CXXFLAGS
|
export CFLAGS CPPFLAGS CXXFLAGS
|
||||||
|
|
||||||
#Set host compiler and binutils
|
# Set host compiler and binutils
|
||||||
HOSTCC := $(CC)
|
HOSTCC := $(CC)
|
||||||
HOSTLD := $(LD)
|
HOSTLD := $(LD)
|
||||||
HOSTAR := $(AR)
|
HOSTAR := $(AR)
|
||||||
HOSTOBJCOPY := $(OBJCOPY)
|
HOSTOBJCOPY := $(OBJCOPY)
|
||||||
export HOSTCC HOSTLD HOSTAR HOSTOBJCOPY
|
export HOSTCC HOSTLD HOSTAR HOSTOBJCOPY
|
||||||
|
|
||||||
#Set target compiler. Defaults to whatever the user has
|
# Set target compiler. Defaults to whatever the user has
|
||||||
#configured as prefix + yer olde gcc commands
|
# configured as prefix + ye olde gcc commands
|
||||||
CC := $(call dequote,$(CONFIG_TOOLPREFIX))gcc
|
CC := $(call dequote,$(CONFIG_TOOLPREFIX))gcc
|
||||||
CXX := $(call dequote,$(CONFIG_TOOLPREFIX))c++
|
CXX := $(call dequote,$(CONFIG_TOOLPREFIX))c++
|
||||||
LD := $(call dequote,$(CONFIG_TOOLPREFIX))ld
|
LD := $(call dequote,$(CONFIG_TOOLPREFIX))ld
|
||||||
|
@ -230,10 +223,10 @@ COMPONENT_PATH := $(1)
|
||||||
endef
|
endef
|
||||||
$(foreach componentpath,$(COMPONENT_PATHS),$(eval $(call includeProjBuildMakefile,$(componentpath))))
|
$(foreach componentpath,$(COMPONENT_PATHS),$(eval $(call includeProjBuildMakefile,$(componentpath))))
|
||||||
|
|
||||||
ifndef IS_BOOTLOADER_BUILD
|
|
||||||
# once we know component paths, we can include the config generation targets
|
# once we know component paths, we can include the config generation targets
|
||||||
#
|
#
|
||||||
# (bootloader build doesn't need this, config is exported from top-level)
|
# (bootloader build doesn't need this, config is exported from top-level)
|
||||||
|
ifndef IS_BOOTLOADER_BUILD
|
||||||
include $(IDF_PATH)/make/project_config.mk
|
include $(IDF_PATH)/make/project_config.mk
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -265,12 +258,14 @@ $(BUILD_DIR_BASE):
|
||||||
#
|
#
|
||||||
# Is recursively expanded by the GenerateComponentTargets macro
|
# Is recursively expanded by the GenerateComponentTargets macro
|
||||||
define ComponentMake
|
define ComponentMake
|
||||||
$(Q) +$(MAKE) -C $(BUILD_DIR_BASE)/$(2) -f $(1)/component.mk COMPONENT_PATH=$(1) COMPONENT_BUILD_DIR=$(BUILD_DIR_BASE)/$(2)
|
$(Q) +$(MAKE) -C $(BUILD_DIR_BASE)/$(2) -f $(IDF_PATH)/make/component_wrapper.mk COMPONENT_MAKEFILE=$(1)/component.mk
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define GenerateComponentTargets
|
# Generate top-level component-specific targets for each component
|
||||||
# $(1) - path to component dir
|
# $(1) - path to component dir
|
||||||
# $(2) - name of component
|
# $(2) - name of component
|
||||||
|
#
|
||||||
|
define GenerateComponentTargets
|
||||||
.PHONY: $(2)-build $(2)-clean
|
.PHONY: $(2)-build $(2)-clean
|
||||||
|
|
||||||
$(2)-build:
|
$(2)-build:
|
||||||
|
@ -289,10 +284,19 @@ $(BUILD_DIR_BASE)/$(2):
|
||||||
$(BUILD_DIR_BASE)/$(2)/lib$(2).a: $(2)-build
|
$(BUILD_DIR_BASE)/$(2)/lib$(2).a: $(2)-build
|
||||||
$(details) "Target '$$^' responsible for '$$@'" # echo which build target built this file
|
$(details) "Target '$$^' responsible for '$$@'" # echo which build target built this file
|
||||||
|
|
||||||
# add a target to generate the component_project_vars.mk files
|
# add a target to generate the component_project_vars.mk files that
|
||||||
# that are used to inject variables into project make pass (see
|
# are used to inject variables into project make pass (see matching
|
||||||
# component_project_vars.mk target in component_common.mk).
|
# component_project_vars.mk target in component_wrapper.mk).
|
||||||
$(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(SDKCONFIG) | $(BUILD_DIR_BASE)/$(2)
|
#
|
||||||
|
# If any component_project_vars.mk file is out of date, the make
|
||||||
|
# process will call this target to rebuild it and then restart.
|
||||||
|
#
|
||||||
|
# Note: $(SDKCONFIG) is a normal prereq as we need to rebuild these
|
||||||
|
# files whenever the config changes. $(SDKCONFIG_MAKEFILE) is an
|
||||||
|
# order-only prereq because if it hasn't been rebuilt, we need to
|
||||||
|
# build it first - but including it as a normal prereq can lead to
|
||||||
|
# infinite restarts as the conf process will keep updating it.
|
||||||
|
$(BUILD_DIR_BASE)/$(2)/component_project_vars.mk: $(1)/component.mk $(COMMON_MAKEFILES) $(SDKCONFIG) | $(BUILD_DIR_BASE)/$(2) $(SDKCONFIG_MAKEFILE)
|
||||||
$(call ComponentMake,$(1),$(2)) component_project_vars.mk
|
$(call ComponentMake,$(1),$(2)) component_project_vars.mk
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ defconfig: $(KCONFIG_TOOL_DIR)/mconf $(IDF_PATH)/Kconfig $(BUILD_DIR_BASE)
|
||||||
# Work out of whether we have to build the Kconfig makefile
|
# 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
|
# (auto.conf), or if we're in a situation where we don't need it
|
||||||
NON_CONFIG_TARGETS := clean %-clean help menuconfig defconfig
|
NON_CONFIG_TARGETS := clean %-clean help menuconfig defconfig
|
||||||
AUTO_CONF_REGEN_TARGET := $(BUILD_DIR_BASE)/include/config/auto.conf
|
AUTO_CONF_REGEN_TARGET := $(SDKCONFIG_MAKEFILE)
|
||||||
|
|
||||||
# disable AUTO_CONF_REGEN_TARGET if all targets are non-config targets
|
# disable AUTO_CONF_REGEN_TARGET if all targets are non-config targets
|
||||||
# (and not building default target)
|
# (and not building default target)
|
||||||
|
@ -50,7 +50,7 @@ ifneq ("$(MAKECMDGOALS)","")
|
||||||
ifeq ($(filter $(NON_CONFIG_TARGETS), $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
ifeq ($(filter $(NON_CONFIG_TARGETS), $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
||||||
AUTO_CONF_REGEN_TARGET :=
|
AUTO_CONF_REGEN_TARGET :=
|
||||||
# dummy target
|
# dummy target
|
||||||
$(BUILD_DIR_BASE)/include/config/auto.conf:
|
$(SDKCONFIG_MAKEFILE):
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue