From 3b1c3dab4b7b40fe805b39bd572da38540cf8441 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 1 Sep 2016 09:19:06 +1000 Subject: [PATCH] Name component makefiles component.mk instead of Makefile Fixes problems with Eclipse trying to build in directories it shouldn't. This is a breaking change for existing repositories, they need to rename any component Makefiles to component.mk and rename their references to $(IDF_PATH)/make/component.mk to $(IDF_PATH)/make/component_common.mk --- README.buildenv | 14 ++++++------ .../src/main/{Makefile => component.mk} | 4 ++-- components/esp32/{Makefile => component.mk} | 4 ++-- .../freertos/{Makefile => component.mk} | 2 +- components/lwip/{Makefile => component.mk} | 2 +- components/newlib/{Makefile => component.mk} | 2 +- .../nvs_flash/{Makefile => component.mk} | 2 +- components/spi_flash/Makefile | 3 --- components/spi_flash/component.mk | 3 +++ .../tcpip_adapter/{Makefile => component.mk} | 2 +- make/{component.mk => component_common.mk} | 0 make/project.mk | 22 +++++++++---------- 12 files changed, 30 insertions(+), 30 deletions(-) rename components/bootloader/src/main/{Makefile => component.mk} (86%) rename components/esp32/{Makefile => component.mk} (96%) rename components/freertos/{Makefile => component.mk} (80%) rename components/lwip/{Makefile => component.mk} (84%) rename components/newlib/{Makefile => component.mk} (77%) rename components/nvs_flash/{Makefile => component.mk} (66%) delete mode 100755 components/spi_flash/Makefile create mode 100755 components/spi_flash/component.mk rename components/tcpip_adapter/{Makefile => component.mk} (56%) rename make/{component.mk => component_common.mk} (100%) diff --git a/README.buildenv b/README.buildenv index fd68300055..0fc007e0ca 100644 --- a/README.buildenv +++ b/README.buildenv @@ -127,7 +127,7 @@ all components and make the elf target depend on this. The targets invoke Make on the makefiles of the components in a subshell: this way the components have full freedom to do whatever is necessary to build the library without influencing other components. By default, the -component includes the utility makefile $(IDF_PATH)/make/component.mk. +component includes the utility makefile $(IDF_PATH)/make/component_common.mk. This provides default targets and configurations that will work out-of-the-box for most projects. @@ -158,7 +158,7 @@ minimum, it will just include the ESP-IDF component makefile, which adds component functionality: ----8<---- -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk ---->8---- This will take all the .c and .S files in the component root and compile @@ -169,7 +169,7 @@ system by setting COMPONENT_SRCDIRS: ----8<---- COMPONENT_SRCDIRS := src1 src2 -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk ---->8---- This will compile all source files in the src1/ and src2/ subdirectories @@ -183,7 +183,7 @@ objects that need to be generated: ----8<---- COMPONENT_OBJS := file1.o file2.o thing/filea.o thing/fileb.o anotherthing/main.o -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk ---->8---- This can also be used in order to conditionally compile some files @@ -200,7 +200,7 @@ config FOO_ENABLE_BAR Makefile: ----8<---- COMPONENT_OBJS := foo_a.o foo_b.o $(if $(CONFIG_FOO_ENABLE_BAR),foo_bar.o foo_bar_interface.o) -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk ---->8---- Some components will have a situation where a source file isn't supplied @@ -217,7 +217,7 @@ graphics_lib.o: logo.h logo.h: $(COMPONENT_PATH)/logo.bmp bmp2h -i $^ -o $@ -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk ---->8---- In this example, graphics_lib.o and logo.h will be generated in the @@ -242,7 +242,7 @@ logo.h: $(COMPONENT_PATH)/logo.bmp $(summary) BMP2H $@ $(Q) bmp2h -i $^ -o $@ -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk ---->8---- Obviously, there are cases where all these recipes are insufficient for a diff --git a/components/bootloader/src/main/Makefile b/components/bootloader/src/main/component.mk similarity index 86% rename from components/bootloader/src/main/Makefile rename to components/bootloader/src/main/component.mk index 2bb773b9c6..1671095f1b 100644 --- a/components/bootloader/src/main/Makefile +++ b/components/bootloader/src/main/component.mk @@ -1,7 +1,7 @@ # # Main Makefile. This is basically the same as a component makefile. # -# This Makefile should, at the very least, just include $(IDF_PATH)/make/component.mk. By default, +# This Makefile should, at the very least, just include $(IDF_PATH)/make/component_common.mk. By default, # 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 build system document if you need to do this. @@ -10,4 +10,4 @@ COMPONENT_ADD_LDFLAGS := -L $(abspath .) -lmain -T esp32.bootloader.ld -T $(IDF_PATH)/components/esp32/ld/esp32.rom.ld COMPONENT_EXTRA_INCLUDES := $(IDF_PATH)/components/esp32/include -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk diff --git a/components/esp32/Makefile b/components/esp32/component.mk similarity index 96% rename from components/esp32/Makefile rename to components/esp32/component.mk index 1d55d0ff63..1699a238c6 100644 --- a/components/esp32/Makefile +++ b/components/esp32/component.mk @@ -1,7 +1,7 @@ # # Component Makefile # -# This Makefile should, at the very least, just include $(IDF_PATH)/make/component.mk. By default, +# 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. @@ -33,7 +33,7 @@ COMPONENT_ADD_LDFLAGS := -lesp32 \ -L $(abspath ld) \ $(LINKER_SCRIPTS) -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk ALL_LIB_FILES := $(patsubst %,$(COMPONENT_PATH)/lib/lib%.a,$(LIBS)) diff --git a/components/freertos/Makefile b/components/freertos/component.mk similarity index 80% rename from components/freertos/Makefile rename to components/freertos/component.mk index e4003eb146..6702d1b95c 100644 --- a/components/freertos/Makefile +++ b/components/freertos/component.mk @@ -6,4 +6,4 @@ COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME) -Wl,--undefined=uxTopUsedPriority COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_PRIV_INCLUDEDIRS := include/freertos -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk diff --git a/components/lwip/Makefile b/components/lwip/component.mk similarity index 84% rename from components/lwip/Makefile rename to components/lwip/component.mk index e159c25c2d..23c9fc160e 100644 --- a/components/lwip/Makefile +++ b/components/lwip/component.mk @@ -8,4 +8,4 @@ COMPONENT_SRCDIRS := api apps/sntp apps core/ipv4 core/ipv6 core netif port/free EXTRA_CFLAGS := -Wno-error=address -Waddress -DLWIP_ESP8266 -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk diff --git a/components/newlib/Makefile b/components/newlib/component.mk similarity index 77% rename from components/newlib/Makefile rename to components/newlib/component.mk index 970461698a..7c8c74debe 100644 --- a/components/newlib/Makefile +++ b/components/newlib/component.mk @@ -5,4 +5,4 @@ define COMPONENT_BUILDRECIPE #Nothing to do; this does not generate a library. endef -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk diff --git a/components/nvs_flash/Makefile b/components/nvs_flash/component.mk similarity index 66% rename from components/nvs_flash/Makefile rename to components/nvs_flash/component.mk index 58232cc89b..02ff8cf038 100755 --- a/components/nvs_flash/Makefile +++ b/components/nvs_flash/component.mk @@ -6,4 +6,4 @@ COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_SRCDIRS := src -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk diff --git a/components/spi_flash/Makefile b/components/spi_flash/Makefile deleted file mode 100755 index fc41e5f430..0000000000 --- a/components/spi_flash/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -COMPONENT_ADD_INCLUDEDIRS := include - -include $(IDF_PATH)/make/component.mk diff --git a/components/spi_flash/component.mk b/components/spi_flash/component.mk new file mode 100755 index 0000000000..ef497a7ecb --- /dev/null +++ b/components/spi_flash/component.mk @@ -0,0 +1,3 @@ +COMPONENT_ADD_INCLUDEDIRS := include + +include $(IDF_PATH)/make/component_common.mk diff --git a/components/tcpip_adapter/Makefile b/components/tcpip_adapter/component.mk similarity index 56% rename from components/tcpip_adapter/Makefile rename to components/tcpip_adapter/component.mk index 4028caf4a3..cb863d1b7d 100755 --- a/components/tcpip_adapter/Makefile +++ b/components/tcpip_adapter/component.mk @@ -4,4 +4,4 @@ EXTRA_CFLAGS := -DLWIP_ESP8266 -include $(IDF_PATH)/make/component.mk +include $(IDF_PATH)/make/component_common.mk diff --git a/make/component.mk b/make/component_common.mk similarity index 100% rename from make/component.mk rename to make/component_common.mk diff --git a/make/project.mk b/make/project.mk index ac2b3e59d3..ca80697cb6 100644 --- a/make/project.mk +++ b/make/project.mk @@ -1,13 +1,13 @@ # # Main Project Makefile -# This Makefile is included directly from the user project Makefile in order to call the Makefiles of all the -# components (in a separate make process) to build all the libraries, then links them together -# into the final file. If so, PWD is the project dir (we assume). +# This Makefile is included directly from the user project Makefile in order to call the component.mk +# makefiles of all components (in a separate make process) to build all the libraries, then links them +# together into the final file. If so, PWD is the project dir (we assume). # # -# This Makefile requires the environment variable IDF_PATH to be set to the directory where this -# Makefile is located. +# This makefile requires the environment variable IDF_PATH to be set to the top-level esp-idf directory +# where this file is located. # .PHONY: build-components menuconfig defconfig all build clean all_binaries @@ -77,9 +77,9 @@ SRCDIRS ?= main COMPONENT_PATHS := $(foreach comp,$(COMPONENTS),$(firstword $(foreach dir,$(COMPONENT_DIRS),$(wildcard $(dir)/$(comp))))) COMPONENT_PATHS += $(abspath $(SRCDIRS)) -#A component is buildable if it has a Makefile; we assume that a 'make -C $(component dir) build' results in a -#lib$(componentname).a. -COMPONENT_PATHS_BUILDABLE := $(foreach cp,$(COMPONENT_PATHS),$(if $(wildcard $(cp)/Makefile),$(cp))) +#A component is buildable if it has a component.mk makefile; we assume that a +# '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))) # Assemble global list of include dirs (COMPONENT_INCLUDES), and # LDFLAGS args (COMPONENT_LDFLAGS) supplied by each component. @@ -98,7 +98,7 @@ COMPONENT_LDFLAGS := # # Debugging this? Replace $(shell with $(error and you'll see the full command as-run. define GetVariable -$(shell "$(MAKE)" -s --no-print-directory -C $(1) get_variable PROJECT_PATH=$(PROJECT_PATH) GET_VARIABLE=$(2) | sed -En "s/^$(2)=(.+)/\1/p" ) +$(shell "$(MAKE)" -s --no-print-directory -C $(1) -f component.mk get_variable PROJECT_PATH=$(PROJECT_PATH) GET_VARIABLE=$(2) | sed -En "s/^$(2)=(.+)/\1/p" ) endef COMPONENT_INCLUDES := $(abspath $(foreach comp,$(COMPONENT_PATHS_BUILDABLE),$(addprefix $(comp)/, \ @@ -193,7 +193,7 @@ define GenerateComponentPhonyTarget # $(2) - target to generate (build, clean) .PHONY: $(notdir $(1))-$(2) $(notdir $(1))-$(2): | $(BUILD_DIR_BASE)/$(notdir $(1)) - @+$(MAKE) -C $(BUILD_DIR_BASE)/$(notdir $(1)) -f $(1)/Makefile COMPONENT_BUILD_DIR=$(BUILD_DIR_BASE)/$(notdir $(1)) $(2) + @+$(MAKE) -C $(BUILD_DIR_BASE)/$(notdir $(1)) -f $(1)/component.mk COMPONENT_BUILD_DIR=$(BUILD_DIR_BASE)/$(notdir $(1)) $(2) endef define GenerateComponentTargets @@ -206,7 +206,7 @@ $(BUILD_DIR_BASE)/$(notdir $(1)): # only invoked for the targets whose libraries appear in COMPONENT_LIBRARIES and hence the # APP_ELF dependencies.) $(BUILD_DIR_BASE)/$(notdir $(1))/lib$(notdir $(1)).a: $(notdir $(1))-build - $(details) echo "$$^ responsible for $$@" # echo which build target built this file + $(details) "Target '$$^' responsible for '$$@'" # echo which build target built this file endef $(foreach component,$(COMPONENT_PATHS_BUILDABLE),$(eval $(call GenerateComponentTargets,$(component)))) -- 2.40.0