AlanRosenthal commented on a change in pull request #5055:
URL: https://github.com/apache/incubator-nuttx/pull/5055#discussion_r773461904



##########
File path: tools/Makefile.unix
##########
@@ -336,11 +334,39 @@ dirlinks: include/arch include/arch/board 
include/arch/chip $(ARCH_SRC)/board $(
 # the config.h and version.h header files in the include/nuttx directory and
 # the establishment of symbolic links to configured directories.
 
-context: include/nuttx/config.h include/nuttx/version.h include/math.h 
include/float.h include/stdarg.h include/setjmp.h dirlinks
-       $(Q) mkdir -p staging
-       $(Q) for dir in $(CONTEXTDIRS) ; do \
-               $(MAKE) -C $$dir context || exit; \
-       done
+# Generate a pattern to make Directories.mk context
+CONTEXTDIRS_DEPS = $(patsubst %,%/.context,$(CONTEXTDIRS))
+
+context: include/nuttx/config.h include/nuttx/version.h include/setjmp.h 
dirlinks $(CONTEXTDIRS_DEPS) | staging
+
+
+staging:
+       $(Q) mkdir -p $@
+
+# Pattern rule for $(CONTEXTDIRS_DEPS)
+%.context:
+       $(MAKE) -C $(patsubst %.context,%,$@) TOPDIR="$(TOPDIR)" context;
+       touch $@
+
+# Pattern rule for $(CONTEXTDIRS_CLEAN_DEPS)
+%.clean_context:
+       $(MAKE) -C $(patsubst %.clean_context,%,$@) TOPDIR="$(TOPDIR)" 
clean_context;
+
+ifeq ($(NEED_MATH_H),y)
+context: include/math.h
+endif
+
+ifeq ($(CONFIG_ARCH_FLOAT_H),y)
+context: include/float.h
+endif
+
+ifeq ($(CONFIG_ARCH_STDARG_H),y)
+context: include/stdarg.h
+endif
+
+ifeq ($(CONFIG_ARCH_SETJMP_H),y)
+context: include/setjmp.h
+endif

Review comment:
       Since these `context` targets don't define a recipe they can use the 
single colon without raising a warning.
   From 
https://www.gnu.org/software/make/manual/html_node/Multiple-Rules.html#Multiple-Rules:
   
   > One file can be the target of several rules. All the prerequisites 
mentioned in all the rules are merged into one list of prerequisites for the 
target. If the target is older than any prerequisite from any rule, the recipe 
is executed.
   > 
   > There can only be one recipe to be executed for a file. If more than one 
rule gives a recipe for the same file, make uses the last one given and prints 
an error message. (As a special case, if the file’s name begins with a dot, no 
error message is printed. This odd behavior is only for compatibility with 
other implementations of make… you should avoid using it). Occasionally it is 
useful to have the same target invoke multiple recipes which are defined in 
different parts of your makefile; you can use double-colon rules (see 
Double-Colon) for this.

##########
File path: tools/Makefile.unix
##########
@@ -336,11 +334,39 @@ dirlinks: include/arch include/arch/board 
include/arch/chip $(ARCH_SRC)/board $(
 # the config.h and version.h header files in the include/nuttx directory and
 # the establishment of symbolic links to configured directories.
 
-context: include/nuttx/config.h include/nuttx/version.h include/math.h 
include/float.h include/stdarg.h include/setjmp.h dirlinks
-       $(Q) mkdir -p staging
-       $(Q) for dir in $(CONTEXTDIRS) ; do \
-               $(MAKE) -C $$dir context || exit; \
-       done
+# Generate a pattern to make Directories.mk context
+CONTEXTDIRS_DEPS = $(patsubst %,%/.context,$(CONTEXTDIRS))
+
+context: include/nuttx/config.h include/nuttx/version.h include/setjmp.h 
dirlinks $(CONTEXTDIRS_DEPS) | staging

Review comment:
       yes, thank you




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to