]> granicus.if.org Git - esp-idf/commitdiff
build system: Fix bug where component src subdirs needed listing before parent source...
authorAngus Gratton <angus@espressif.com>
Mon, 22 May 2017 01:44:41 +0000 (11:44 +1000)
committerAngus Gratton <gus@projectgus.com>
Mon, 22 May 2017 01:45:55 +0000 (11:45 +1000)
Triggered on make 3.81, happens sometimes on Linux and always(?) on macOS. May depend on the order the OS' filesystem
resolves wildcards in.

Includes a revert to the LWIP component to verify this is properly fixed.

See also https://github.com/espressif/esp-idf/issues/632

components/lwip/component.mk
make/component_wrapper.mk

index 6473b021a6e302acae4db935978f7bba969b2965..204e94fa72f178e0088a8f251a5755c81fa47f43 100644 (file)
@@ -14,8 +14,8 @@ endif
 
 COMPONENT_SRCDIRS := \
        api \
-       apps/sntp apps/ping apps \
-       core/ipv4 core/ipv6 core \
+       apps apps/sntp apps/ping \
+       core core/ipv4 core/ipv6 \
        $(LWIP_PPP_DIRS) netif \
        port/freertos port/netif port/debug port
 
index 87c05479add2cfa039eeeec3c286a40454442835..55a92cf4213d2ed5a67c288def9b5c1b69aa7e88 100644 (file)
@@ -154,22 +154,30 @@ endif
 
 # 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 $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(1)
+# $(1) - directory containing source files, relative to $(COMPONENT_PATH) - one of $(COMPONENT_SRCDIRS)
+#
+$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.c $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(COMPONENT_SRCDIRS)
        $$(summary) CC $$@
        $$(CC) $$(CFLAGS) $$(CPPFLAGS) $$(addprefix -I ,$$(COMPONENT_INCLUDES)) $$(addprefix -I ,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
 
-$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.cpp $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(1)
+$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.cpp $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(COMPONENT_SRCDIRS)
        $$(summary) CXX $$@
        $$(CXX) $$(CXXFLAGS) $$(CPPFLAGS) $$(addprefix -I,$$(COMPONENT_INCLUDES)) $$(addprefix -I,$$(COMPONENT_EXTRA_INCLUDES)) -I$(1) -c $$< -o $$@
 
-$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.S $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(1)
+$(1)/%.o: $$(COMPONENT_PATH)/$(1)/%.S $(COMMON_MAKEFILES) $(COMPONENT_MAKEFILE) | $(COMPONENT_SRCDIRS)
        $$(summary) AS $$@
        $$(CC) $$(CPPFLAGS) $$(DEBUG_FLAGS) $$(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
+#
+# (NB: Each .o file depends on all relative component build dirs $(COMPONENT_SRCDIRS), rather than just $(1), to work
+# around a behaviour make 3.81 where the first pattern (randomly) seems to be matched rather than the best fit. ie if
+# you have objects a/y.o and a/b/c.o then c.o can be matched with $(1)=a & %=b/c, meaning that subdir 'a/b' needs to be
+# created but wouldn't be created if $(1)=a. Make 4.x doesn't have this problem, it seems to preferentially
+# choose the better match ie $(1)=a/b and %=c )
+#
 $(1):
-       @mkdir -p $(1)
+       mkdir -p $(1)
 endef
 
 # Generate all the compile target patterns